@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | public function getDefaultDriver(): string |
| 66 | 66 | { |
| 67 | - if (!\is_string($this->config['default'])) { |
|
| 67 | + if (!\is_string($this->config['default'])){ |
|
| 68 | 68 | throw new InvalidArgumentException('Default queue connection config value must be a string'); |
| 69 | 69 | } |
| 70 | 70 | |
@@ -86,14 +86,14 @@ discard block |
||
| 86 | 86 | { |
| 87 | 87 | $connections = $this->config['connections'] ?? []; |
| 88 | 88 | |
| 89 | - if ($driver === null) { |
|
| 89 | + if ($driver === null){ |
|
| 90 | 90 | return $connections; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | $driverAliases = $this->getDriverAliases(); |
| 94 | 94 | |
| 95 | - if (isset($driverAliases[$driver])) { |
|
| 96 | - if (!\is_string($this->config['driverAliases'][$driver])) { |
|
| 95 | + if (isset($driverAliases[$driver])){ |
|
| 96 | + if (!\is_string($this->config['driverAliases'][$driver])){ |
|
| 97 | 97 | throw new InvalidArgumentException( |
| 98 | 98 | \sprintf('Driver alias for `%s` value must be a string', $driver) |
| 99 | 99 | ); |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | return \array_filter($connections, static function (array $connection) use ($driverAliases, $driver): bool { |
| 106 | - if (empty($connection['driver'])) { |
|
| 106 | + if (empty($connection['driver'])){ |
|
| 107 | 107 | return false; |
| 108 | 108 | } |
| 109 | 109 | |
@@ -121,28 +121,28 @@ discard block |
||
| 121 | 121 | { |
| 122 | 122 | $connections = $this->getConnections(); |
| 123 | 123 | |
| 124 | - if (!isset($connections[$name])) { |
|
| 124 | + if (!isset($connections[$name])){ |
|
| 125 | 125 | throw new InvalidArgumentException(sprintf('Queue connection with given name `%s` is not defined.', $name)); |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - if (!isset($connections[$name]['driver'])) { |
|
| 128 | + if (!isset($connections[$name]['driver'])){ |
|
| 129 | 129 | throw new InvalidArgumentException(\sprintf('Driver for queue connection `%s` is not defined.', $name)); |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | $connection = $connections[$name]; |
| 133 | 133 | $driver = $connection['driver']; |
| 134 | 134 | |
| 135 | - if (!\is_string($driver)) { |
|
| 135 | + if (!\is_string($driver)){ |
|
| 136 | 136 | throw new InvalidArgumentException( |
| 137 | 137 | \sprintf('Driver for queue connection `%s` value must be a string', $name) |
| 138 | 138 | ); |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - if (isset($this->config['driverAliases'][$driver])) { |
|
| 141 | + if (isset($this->config['driverAliases'][$driver])){ |
|
| 142 | 142 | $connection['driver'] = $this->config['driverAliases'][$driver]; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - if (!\is_string($connection['driver'])) { |
|
| 145 | + if (!\is_string($connection['driver'])){ |
|
| 146 | 146 | throw new InvalidArgumentException( |
| 147 | 147 | \sprintf('Driver alias for queue connection `%s` value must be a string', $name) |
| 148 | 148 | ); |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | /** |
| 168 | 168 | * @psalm-return SerializerInterface|class-string|Autowire|null |
| 169 | 169 | */ |
| 170 | - public function getDefaultSerializer(): SerializerInterface|string|Autowire|null |
|
| 170 | + public function getDefaultSerializer(): SerializerInterface | string | Autowire | null |
|
| 171 | 171 | { |
| 172 | 172 | return $this->config['defaultSerializer'] ?? null; |
| 173 | 173 | } |
@@ -64,7 +64,8 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | public function getDefaultDriver(): string |
| 66 | 66 | { |
| 67 | - if (!\is_string($this->config['default'])) { |
|
| 67 | + if (!\is_string($this->config['default'])) |
|
| 68 | + { |
|
| 68 | 69 | throw new InvalidArgumentException('Default queue connection config value must be a string'); |
| 69 | 70 | } |
| 70 | 71 | |
@@ -86,14 +87,17 @@ discard block |
||
| 86 | 87 | { |
| 87 | 88 | $connections = $this->config['connections'] ?? []; |
| 88 | 89 | |
| 89 | - if ($driver === null) { |
|
| 90 | + if ($driver === null) |
|
| 91 | + { |
|
| 90 | 92 | return $connections; |
| 91 | 93 | } |
| 92 | 94 | |
| 93 | 95 | $driverAliases = $this->getDriverAliases(); |
| 94 | 96 | |
| 95 | - if (isset($driverAliases[$driver])) { |
|
| 96 | - if (!\is_string($this->config['driverAliases'][$driver])) { |
|
| 97 | + if (isset($driverAliases[$driver])) |
|
| 98 | + { |
|
| 99 | + if (!\is_string($this->config['driverAliases'][$driver])) |
|
| 100 | + { |
|
| 97 | 101 | throw new InvalidArgumentException( |
| 98 | 102 | \sprintf('Driver alias for `%s` value must be a string', $driver) |
| 99 | 103 | ); |
@@ -103,7 +107,8 @@ discard block |
||
| 103 | 107 | } |
| 104 | 108 | |
| 105 | 109 | return \array_filter($connections, static function (array $connection) use ($driverAliases, $driver): bool { |
| 106 | - if (empty($connection['driver'])) { |
|
| 110 | + if (empty($connection['driver'])) |
|
| 111 | + { |
|
| 107 | 112 | return false; |
| 108 | 113 | } |
| 109 | 114 | |
@@ -121,28 +126,33 @@ discard block |
||
| 121 | 126 | { |
| 122 | 127 | $connections = $this->getConnections(); |
| 123 | 128 | |
| 124 | - if (!isset($connections[$name])) { |
|
| 129 | + if (!isset($connections[$name])) |
|
| 130 | + { |
|
| 125 | 131 | throw new InvalidArgumentException(sprintf('Queue connection with given name `%s` is not defined.', $name)); |
| 126 | 132 | } |
| 127 | 133 | |
| 128 | - if (!isset($connections[$name]['driver'])) { |
|
| 134 | + if (!isset($connections[$name]['driver'])) |
|
| 135 | + { |
|
| 129 | 136 | throw new InvalidArgumentException(\sprintf('Driver for queue connection `%s` is not defined.', $name)); |
| 130 | 137 | } |
| 131 | 138 | |
| 132 | 139 | $connection = $connections[$name]; |
| 133 | 140 | $driver = $connection['driver']; |
| 134 | 141 | |
| 135 | - if (!\is_string($driver)) { |
|
| 142 | + if (!\is_string($driver)) |
|
| 143 | + { |
|
| 136 | 144 | throw new InvalidArgumentException( |
| 137 | 145 | \sprintf('Driver for queue connection `%s` value must be a string', $name) |
| 138 | 146 | ); |
| 139 | 147 | } |
| 140 | 148 | |
| 141 | - if (isset($this->config['driverAliases'][$driver])) { |
|
| 149 | + if (isset($this->config['driverAliases'][$driver])) |
|
| 150 | + { |
|
| 142 | 151 | $connection['driver'] = $this->config['driverAliases'][$driver]; |
| 143 | 152 | } |
| 144 | 153 | |
| 145 | - if (!\is_string($connection['driver'])) { |
|
| 154 | + if (!\is_string($connection['driver'])) |
|
| 155 | + { |
|
| 146 | 156 | throw new InvalidArgumentException( |
| 147 | 157 | \sprintf('Driver alias for queue connection `%s` value must be a string', $name) |
| 148 | 158 | ); |
@@ -26,13 +26,13 @@ discard block |
||
| 26 | 26 | private readonly ContainerInterface $container, |
| 27 | 27 | private readonly FactoryInterface $factory, |
| 28 | 28 | private readonly HandlerRegistryInterface $fallbackHandlers |
| 29 | - ) { |
|
| 29 | + ){ |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /** |
| 33 | 33 | * Associate specific job type with handler class or object |
| 34 | 34 | */ |
| 35 | - public function setHandler(string $jobType, HandlerInterface|string $handler): void |
|
| 35 | + public function setHandler(string $jobType, HandlerInterface | string $handler): void |
|
| 36 | 36 | { |
| 37 | 37 | $this->handlers[$jobType] = $handler; |
| 38 | 38 | } |
@@ -43,8 +43,8 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | public function getHandler(string $jobType): HandlerInterface |
| 45 | 45 | { |
| 46 | - if (isset($this->handlers[$jobType])) { |
|
| 47 | - if ($this->handlers[$jobType] instanceof HandlerInterface) { |
|
| 46 | + if (isset($this->handlers[$jobType])){ |
|
| 47 | + if ($this->handlers[$jobType] instanceof HandlerInterface){ |
|
| 48 | 48 | return $this->handlers[$jobType]; |
| 49 | 49 | } |
| 50 | 50 | |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | * |
| 62 | 62 | * @throws InvalidArgumentException |
| 63 | 63 | */ |
| 64 | - public function setSerializer(string $jobType, SerializerInterface|string|Autowire $serializer): void |
|
| 64 | + public function setSerializer(string $jobType, SerializerInterface | string | Autowire $serializer): void |
|
| 65 | 65 | { |
| 66 | 66 | $this->serializers[$jobType] = $this->resolveSerializer($serializer); |
| 67 | 67 | } |
@@ -71,15 +71,14 @@ discard block |
||
| 71 | 71 | */ |
| 72 | 72 | public function getSerializer(?string $jobType = null): SerializerInterface |
| 73 | 73 | { |
| 74 | - if ($jobType && $this->hasSerializer($jobType)) { |
|
| 74 | + if ($jobType && $this->hasSerializer($jobType)){ |
|
| 75 | 75 | return $this->serializers[$jobType]; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | $config = $this->container->get(QueueConfig::class); |
| 79 | 79 | |
| 80 | 80 | return $config->getDefaultSerializer() === null ? |
| 81 | - $this->container->get(SerializerManager::class)->getSerializer() : |
|
| 82 | - $this->resolveSerializer($config->getDefaultSerializer()); |
|
| 81 | + $this->container->get(SerializerManager::class)->getSerializer() : $this->resolveSerializer($config->getDefaultSerializer()); |
|
| 83 | 82 | } |
| 84 | 83 | |
| 85 | 84 | public function hasSerializer(string $jobType): bool |
@@ -92,22 +91,21 @@ discard block |
||
| 92 | 91 | * |
| 93 | 92 | * @throws InvalidArgumentException |
| 94 | 93 | */ |
| 95 | - private function resolveSerializer(SerializerInterface|string|Autowire $serializer): SerializerInterface |
|
| 94 | + private function resolveSerializer(SerializerInterface | string | Autowire $serializer): SerializerInterface |
|
| 96 | 95 | { |
| 97 | - if ($serializer instanceof Autowire) { |
|
| 96 | + if ($serializer instanceof Autowire){ |
|
| 98 | 97 | $serializer = $serializer->resolve($this->factory); |
| 99 | 98 | } |
| 100 | 99 | |
| 101 | - if (\is_string($serializer)) { |
|
| 100 | + if (\is_string($serializer)){ |
|
| 102 | 101 | $registry = $this->container->get(SerializerRegistryInterface::class); |
| 103 | 102 | \assert($registry instanceof SerializerRegistryInterface); |
| 104 | 103 | |
| 105 | 104 | $serializer = $registry->has($serializer) ? |
| 106 | - $registry->get($serializer) : |
|
| 107 | - $this->container->get($serializer); |
|
| 105 | + $registry->get($serializer) : $this->container->get($serializer); |
|
| 108 | 106 | } |
| 109 | 107 | |
| 110 | - if (!$serializer instanceof SerializerInterface) { |
|
| 108 | + if (!$serializer instanceof SerializerInterface){ |
|
| 111 | 109 | throw new InvalidArgumentException(\sprintf( |
| 112 | 110 | 'Serializer must be an instance of `SerializerInterface` but `%s` given.', |
| 113 | 111 | \get_debug_type($serializer) |
@@ -43,8 +43,10 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | public function getHandler(string $jobType): HandlerInterface |
| 45 | 45 | { |
| 46 | - if (isset($this->handlers[$jobType])) { |
|
| 47 | - if ($this->handlers[$jobType] instanceof HandlerInterface) { |
|
| 46 | + if (isset($this->handlers[$jobType])) |
|
| 47 | + { |
|
| 48 | + if ($this->handlers[$jobType] instanceof HandlerInterface) |
|
| 49 | + { |
|
| 48 | 50 | return $this->handlers[$jobType]; |
| 49 | 51 | } |
| 50 | 52 | |
@@ -71,7 +73,8 @@ discard block |
||
| 71 | 73 | */ |
| 72 | 74 | public function getSerializer(?string $jobType = null): SerializerInterface |
| 73 | 75 | { |
| 74 | - if ($jobType && $this->hasSerializer($jobType)) { |
|
| 76 | + if ($jobType && $this->hasSerializer($jobType)) |
|
| 77 | + { |
|
| 75 | 78 | return $this->serializers[$jobType]; |
| 76 | 79 | } |
| 77 | 80 | |
@@ -94,11 +97,13 @@ discard block |
||
| 94 | 97 | */ |
| 95 | 98 | private function resolveSerializer(SerializerInterface|string|Autowire $serializer): SerializerInterface |
| 96 | 99 | { |
| 97 | - if ($serializer instanceof Autowire) { |
|
| 100 | + if ($serializer instanceof Autowire) |
|
| 101 | + { |
|
| 98 | 102 | $serializer = $serializer->resolve($this->factory); |
| 99 | 103 | } |
| 100 | 104 | |
| 101 | - if (\is_string($serializer)) { |
|
| 105 | + if (\is_string($serializer)) |
|
| 106 | + { |
|
| 102 | 107 | $registry = $this->container->get(SerializerRegistryInterface::class); |
| 103 | 108 | \assert($registry instanceof SerializerRegistryInterface); |
| 104 | 109 | |
@@ -107,7 +112,8 @@ discard block |
||
| 107 | 112 | $this->container->get($serializer); |
| 108 | 113 | } |
| 109 | 114 | |
| 110 | - if (!$serializer instanceof SerializerInterface) { |
|
| 115 | + if (!$serializer instanceof SerializerInterface) |
|
| 116 | + { |
|
| 111 | 117 | throw new InvalidArgumentException(\sprintf( |
| 112 | 118 | 'Serializer must be an instance of `SerializerInterface` but `%s` given.', |
| 113 | 119 | \get_debug_type($serializer) |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | public function __construct( |
| 12 | 12 | string $reason = '', |
| 13 | 13 | private ?OptionsInterface $options = null |
| 14 | - ) { |
|
| 14 | + ){ |
|
| 15 | 15 | parent::__construct($reason); |
| 16 | 16 | } |
| 17 | 17 | |
@@ -16,19 +16,19 @@ |
||
| 16 | 16 | |
| 17 | 17 | public function __construct( |
| 18 | 18 | private readonly ContainerInterface $container |
| 19 | - ) { |
|
| 19 | + ){ |
|
| 20 | 20 | $this->inflector = (new InflectorFactory())->build(); |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | public function getHandler(string $jobType): HandlerInterface |
| 24 | 24 | { |
| 25 | - try { |
|
| 25 | + try{ |
|
| 26 | 26 | $handler = $this->container->get($this->className($jobType)); |
| 27 | - } catch (ContainerException $e) { |
|
| 27 | + }catch (ContainerException $e){ |
|
| 28 | 28 | throw new JobException($e->getMessage(), $e->getCode(), $e); |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - if (!$handler instanceof HandlerInterface) { |
|
| 31 | + if (!$handler instanceof HandlerInterface){ |
|
| 32 | 32 | throw new JobException(\sprintf('Unable to resolve job handler for `%s`', $jobType)); |
| 33 | 33 | } |
| 34 | 34 | |
@@ -22,13 +22,17 @@ |
||
| 22 | 22 | |
| 23 | 23 | public function getHandler(string $jobType): HandlerInterface |
| 24 | 24 | { |
| 25 | - try { |
|
| 25 | + try |
|
| 26 | + { |
|
| 26 | 27 | $handler = $this->container->get($this->className($jobType)); |
| 27 | - } catch (ContainerException $e) { |
|
| 28 | + } |
|
| 29 | + catch (ContainerException $e) |
|
| 30 | + { |
|
| 28 | 31 | throw new JobException($e->getMessage(), $e->getCode(), $e); |
| 29 | 32 | } |
| 30 | 33 | |
| 31 | - if (!$handler instanceof HandlerInterface) { |
|
| 34 | + if (!$handler instanceof HandlerInterface) |
|
| 35 | + { |
|
| 32 | 36 | throw new JobException(\sprintf('Unable to resolve job handler for `%s`', $jobType)); |
| 33 | 37 | } |
| 34 | 38 | |
@@ -23,7 +23,7 @@ |
||
| 23 | 23 | public function __construct( |
| 24 | 24 | private readonly HandlerRegistryInterface $registry, |
| 25 | 25 | private readonly ?EventDispatcherInterface $dispatcher = null |
| 26 | - ) { |
|
| 26 | + ){ |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | /** |
@@ -13,16 +13,16 @@ |
||
| 13 | 13 | { |
| 14 | 14 | public function __construct( |
| 15 | 15 | private readonly FailedJobHandlerInterface $handler |
| 16 | - ) { |
|
| 16 | + ){ |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | /** @psalm-suppress ParamNameMismatch */ |
| 20 | 20 | public function process(string $name, string $action, array $parameters, CoreInterface $core): mixed |
| 21 | 21 | { |
| 22 | - try { |
|
| 22 | + try{ |
|
| 23 | 23 | return $core->callAction($name, $action, $parameters); |
| 24 | - } catch (\Throwable $e) { |
|
| 25 | - if (!$e instanceof StateException) { |
|
| 24 | + }catch (\Throwable $e){ |
|
| 25 | + if (!$e instanceof StateException){ |
|
| 26 | 26 | $this->handler->handle( |
| 27 | 27 | $parameters['driver'], |
| 28 | 28 | $parameters['queue'], |
@@ -19,10 +19,14 @@ |
||
| 19 | 19 | /** @psalm-suppress ParamNameMismatch */ |
| 20 | 20 | public function process(string $name, string $action, array $parameters, CoreInterface $core): mixed |
| 21 | 21 | { |
| 22 | - try { |
|
| 22 | + try |
|
| 23 | + { |
|
| 23 | 24 | return $core->callAction($name, $action, $parameters); |
| 24 | - } catch (\Throwable $e) { |
|
| 25 | - if (!$e instanceof StateException) { |
|
| 25 | + } |
|
| 26 | + catch (\Throwable $e) |
|
| 27 | + { |
|
| 28 | + if (!$e instanceof StateException) |
|
| 29 | + { |
|
| 26 | 30 | $this->handler->handle( |
| 27 | 31 | $parameters['driver'], |
| 28 | 32 | $parameters['queue'], |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | { |
| 12 | 12 | public function __construct( |
| 13 | 13 | private readonly ScopedClassesInterface $classes |
| 14 | - ) { |
|
| 14 | + ){ |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | /** |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | private readonly ConflictResolver\Names $namesResolver, |
| 26 | 26 | private readonly ConflictResolver\Namespaces $namespacesResolver, |
| 27 | 27 | Parser $parser = null |
| 28 | - ) { |
|
| 28 | + ){ |
|
| 29 | 29 | $this->parser = $parser ?? (new ParserFactory())->create(ParserFactory::ONLY_PHP7); |
| 30 | 30 | } |
| 31 | 31 | |
@@ -58,11 +58,11 @@ discard block |
||
| 58 | 58 | $declarator = new DeclareClass(); |
| 59 | 59 | $this->traverse($filename, $declarator); |
| 60 | 60 | |
| 61 | - if (empty($declarator->getClass())) { |
|
| 61 | + if (empty($declarator->getClass())){ |
|
| 62 | 62 | throw new ClassNotDeclaredException($filename); |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - if ($declarator->getNamespace()) { |
|
| 65 | + if ($declarator->getNamespace()){ |
|
| 66 | 66 | return ClassNode::createWithNamespace($declarator->getClass(), $declarator->getNamespace()); |
| 67 | 67 | } |
| 68 | 68 | |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | { |
| 74 | 74 | $tr = new NodeTraverser(); |
| 75 | 75 | |
| 76 | - foreach ($visitors as $visitor) { |
|
| 76 | + foreach ($visitors as $visitor){ |
|
| 77 | 77 | $tr->addVisitor($visitor); |
| 78 | 78 | } |
| 79 | 79 | |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | private function fillStmts(ClassNode $definition, array $imports): void |
| 84 | 84 | { |
| 85 | - foreach ($imports as $import) { |
|
| 85 | + foreach ($imports as $import){ |
|
| 86 | 86 | $definition->addImportUsage($import['name'], $import['alias']); |
| 87 | 87 | } |
| 88 | 88 | } |
@@ -95,10 +95,10 @@ discard block |
||
| 95 | 95 | $reflection = new \ReflectionClass(\sprintf('%s\%s', $definition->namespace, $definition->class)); |
| 96 | 96 | |
| 97 | 97 | $constructor = $reflection->getConstructor(); |
| 98 | - if ($constructor !== null) { |
|
| 98 | + if ($constructor !== null){ |
|
| 99 | 99 | $definition->hasConstructor = $constructor->getDeclaringClass()->getName() === $reflection->getName(); |
| 100 | 100 | |
| 101 | - foreach ($reflection->getConstructor()->getParameters() as $parameter) { |
|
| 101 | + foreach ($reflection->getConstructor()->getParameters() as $parameter){ |
|
| 102 | 102 | $definition->addParam($parameter); |
| 103 | 103 | } |
| 104 | 104 | } |
@@ -110,8 +110,8 @@ discard block |
||
| 110 | 110 | */ |
| 111 | 111 | private function fillConstructorVars(array $vars, ClassNode $definition): void |
| 112 | 112 | { |
| 113 | - foreach ($vars as $k => $var) { |
|
| 114 | - if (isset($definition->constructorParams[$var])) { |
|
| 113 | + foreach ($vars as $k => $var){ |
|
| 114 | + if (isset($definition->constructorParams[$var])){ |
|
| 115 | 115 | unset($vars[$k]); |
| 116 | 116 | } |
| 117 | 117 | } |
@@ -58,11 +58,13 @@ discard block |
||
| 58 | 58 | $declarator = new DeclareClass(); |
| 59 | 59 | $this->traverse($filename, $declarator); |
| 60 | 60 | |
| 61 | - if (empty($declarator->getClass())) { |
|
| 61 | + if (empty($declarator->getClass())) |
|
| 62 | + { |
|
| 62 | 63 | throw new ClassNotDeclaredException($filename); |
| 63 | 64 | } |
| 64 | 65 | |
| 65 | - if ($declarator->getNamespace()) { |
|
| 66 | + if ($declarator->getNamespace()) |
|
| 67 | + { |
|
| 66 | 68 | return ClassNode::createWithNamespace($declarator->getClass(), $declarator->getNamespace()); |
| 67 | 69 | } |
| 68 | 70 | |
@@ -73,7 +75,8 @@ discard block |
||
| 73 | 75 | { |
| 74 | 76 | $tr = new NodeTraverser(); |
| 75 | 77 | |
| 76 | - foreach ($visitors as $visitor) { |
|
| 78 | + foreach ($visitors as $visitor) |
|
| 79 | + { |
|
| 77 | 80 | $tr->addVisitor($visitor); |
| 78 | 81 | } |
| 79 | 82 | |
@@ -82,7 +85,8 @@ discard block |
||
| 82 | 85 | |
| 83 | 86 | private function fillStmts(ClassNode $definition, array $imports): void |
| 84 | 87 | { |
| 85 | - foreach ($imports as $import) { |
|
| 88 | + foreach ($imports as $import) |
|
| 89 | + { |
|
| 86 | 90 | $definition->addImportUsage($import['name'], $import['alias']); |
| 87 | 91 | } |
| 88 | 92 | } |
@@ -95,10 +99,12 @@ discard block |
||
| 95 | 99 | $reflection = new \ReflectionClass(\sprintf('%s\%s', $definition->namespace, $definition->class)); |
| 96 | 100 | |
| 97 | 101 | $constructor = $reflection->getConstructor(); |
| 98 | - if ($constructor !== null) { |
|
| 102 | + if ($constructor !== null) |
|
| 103 | + { |
|
| 99 | 104 | $definition->hasConstructor = $constructor->getDeclaringClass()->getName() === $reflection->getName(); |
| 100 | 105 | |
| 101 | - foreach ($reflection->getConstructor()->getParameters() as $parameter) { |
|
| 106 | + foreach ($reflection->getConstructor()->getParameters() as $parameter) |
|
| 107 | + { |
|
| 102 | 108 | $definition->addParam($parameter); |
| 103 | 109 | } |
| 104 | 110 | } |
@@ -110,8 +116,10 @@ discard block |
||
| 110 | 116 | */ |
| 111 | 117 | private function fillConstructorVars(array $vars, ClassNode $definition): void |
| 112 | 118 | { |
| 113 | - foreach ($vars as $k => $var) { |
|
| 114 | - if (isset($definition->constructorParams[$var])) { |
|
| 119 | + foreach ($vars as $k => $var) |
|
| 120 | + { |
|
| 121 | + if (isset($definition->constructorParams[$var])) |
|
| 122 | + { |
|
| 115 | 123 | unset($vars[$k]); |
| 116 | 124 | } |
| 117 | 125 | } |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | public static function shortName(string $name): string |
| 21 | 21 | { |
| 22 | 22 | $pos = \mb_strrpos($name, '\\'); |
| 23 | - if ($pos === false) { |
|
| 23 | + if ($pos === false){ |
|
| 24 | 24 | return $name; |
| 25 | 25 | } |
| 26 | 26 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | public static function trimTrailingDigits(string $name, int $number): string |
| 45 | 45 | { |
| 46 | 46 | $pos = \mb_strripos($name, (string)$number); |
| 47 | - if ($pos === false) { |
|
| 47 | + if ($pos === false){ |
|
| 48 | 48 | return $name; |
| 49 | 49 | } |
| 50 | 50 | |
@@ -20,7 +20,8 @@ discard block |
||
| 20 | 20 | public static function shortName(string $name): string |
| 21 | 21 | { |
| 22 | 22 | $pos = \mb_strrpos($name, '\\'); |
| 23 | - if ($pos === false) { |
|
| 23 | + if ($pos === false) |
|
| 24 | + { |
|
| 24 | 25 | return $name; |
| 25 | 26 | } |
| 26 | 27 | |
@@ -44,7 +45,8 @@ discard block |
||
| 44 | 45 | public static function trimTrailingDigits(string $name, int $number): string |
| 45 | 46 | { |
| 46 | 47 | $pos = \mb_strripos($name, (string)$number); |
| 47 | - if ($pos === false) { |
|
| 48 | + if ($pos === false) |
|
| 49 | + { |
|
| 48 | 50 | return $name; |
| 49 | 51 | } |
| 50 | 52 | |