@@ -14,8 +14,8 @@ |
||
14 | 14 | { |
15 | 15 | public readonly string $name; |
16 | 16 | |
17 | - public function __construct(string|\BackedEnum $name) |
|
17 | + public function __construct(string | \BackedEnum $name) |
|
18 | 18 | { |
19 | - $this->name = \is_object($name) ? (string) $name->value : $name; |
|
19 | + $this->name = \is_object($name) ? (string)$name->value : $name; |
|
20 | 20 | } |
21 | 21 | } |
@@ -89,9 +89,12 @@ discard block |
||
89 | 89 | new ExceptionInterceptor(), |
90 | 90 | ], self::createMock(CoreInterface::class)); |
91 | 91 | |
92 | - try { |
|
92 | + try |
|
93 | + { |
|
93 | 94 | $pipeline->callAction('controller', 'action'); |
94 | - } catch (\RuntimeException) { |
|
95 | + } |
|
96 | + catch (\RuntimeException) |
|
97 | + { |
|
95 | 98 | // Attributes won't be lost after legacy interceptor |
96 | 99 | self::assertSame(['key' => 'value'], $state->context->getAttributes()); |
97 | 100 | } |
@@ -111,7 +114,8 @@ discard block |
||
111 | 114 | $lastHandler instanceof CoreInterface and $pipeline = $pipeline->withCore($lastHandler); |
112 | 115 | $lastHandler instanceof HandlerInterface and $pipeline = $pipeline->withHandler($lastHandler); |
113 | 116 | |
114 | - foreach ($interceptors as $interceptor) { |
|
117 | + foreach ($interceptors as $interceptor) |
|
118 | + { |
|
115 | 119 | $pipeline->addInterceptor($interceptor); |
116 | 120 | } |
117 | 121 |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | new ExceptionInterceptor(), |
92 | 92 | ], self::createMock(CoreInterface::class)); |
93 | 93 | |
94 | - try { |
|
94 | + try{ |
|
95 | 95 | $pipeline->callAction('controller', 'action'); |
96 | - } catch (\RuntimeException) { |
|
96 | + }catch (\RuntimeException){ |
|
97 | 97 | // Attributes won't be lost after legacy interceptor |
98 | 98 | self::assertSame(['key' => 'value'], $state->context->getAttributes()); |
99 | 99 | } |
@@ -124,15 +124,15 @@ discard block |
||
124 | 124 | */ |
125 | 125 | private function createPipeline( |
126 | 126 | array $interceptors = [], |
127 | - CoreInterface|HandlerInterface|null $lastHandler = null, |
|
128 | - EventDispatcherInterface|null $dispatcher = null, |
|
127 | + CoreInterface | HandlerInterface | null $lastHandler = null, |
|
128 | + EventDispatcherInterface | null $dispatcher = null, |
|
129 | 129 | ): InterceptorPipeline { |
130 | 130 | $pipeline = new InterceptorPipeline($dispatcher); |
131 | 131 | |
132 | 132 | $lastHandler instanceof CoreInterface and $pipeline = $pipeline->withCore($lastHandler); |
133 | 133 | $lastHandler instanceof HandlerInterface and $pipeline = $pipeline->withHandler($lastHandler); |
134 | 134 | |
135 | - foreach ($interceptors as $interceptor) { |
|
135 | + foreach ($interceptors as $interceptor){ |
|
136 | 136 | $pipeline->addInterceptor($interceptor); |
137 | 137 | } |
138 | 138 |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | |
24 | 24 | public function handle(Parser $parser, Assembler $asm, Token $token): void |
25 | 25 | { |
26 | - switch ($token->type) { |
|
26 | + switch ($token->type){ |
|
27 | 27 | case DynamicGrammar::TYPE_DIRECTIVE: |
28 | 28 | $this->directive = new Directive(new Parser\Context($token, $parser->getPath())); |
29 | 29 | $asm->push($this->directive); |
@@ -48,20 +48,20 @@ discard block |
||
48 | 48 | break; |
49 | 49 | |
50 | 50 | case DynamicGrammar::TYPE_KEYWORD: |
51 | - if ($this->directive !== null) { |
|
51 | + if ($this->directive !== null){ |
|
52 | 52 | $this->directive->name = $token->content; |
53 | 53 | } |
54 | 54 | break; |
55 | 55 | |
56 | 56 | case DynamicGrammar::TYPE_BODY: |
57 | - if ($this->directive !== null) { |
|
57 | + if ($this->directive !== null){ |
|
58 | 58 | $this->directive->body = $token->content; |
59 | 59 | $this->directive->values = $this->fetchValues($this->directive->body); |
60 | 60 | |
61 | 61 | $this->directive = null; |
62 | 62 | } |
63 | 63 | |
64 | - if ($this->output !== null) { |
|
64 | + if ($this->output !== null){ |
|
65 | 65 | $this->output->body = $token->content; |
66 | 66 | } |
67 | 67 | |
@@ -79,31 +79,31 @@ discard block |
||
79 | 79 | |
80 | 80 | $src = new StringStream($body); |
81 | 81 | |
82 | - while ($n = $src->peak()) { |
|
83 | - if (\in_array($n, ['"', "'"], true)) { |
|
82 | + while ($n = $src->peak()){ |
|
83 | + if (\in_array($n, ['"', "'"], true)){ |
|
84 | 84 | $values[\count($values) - 1] .= $n; |
85 | - while (($nn = $src->peak()) !== null) { |
|
85 | + while (($nn = $src->peak()) !== null){ |
|
86 | 86 | $values[\count($values) - 1] .= $nn; |
87 | - if ($nn === $n) { |
|
87 | + if ($nn === $n){ |
|
88 | 88 | break; |
89 | 89 | } |
90 | 90 | } |
91 | 91 | continue; |
92 | 92 | } |
93 | 93 | |
94 | - if ($n === ',' && $level === 0) { |
|
94 | + if ($n === ',' && $level === 0){ |
|
95 | 95 | $values[] = ''; |
96 | 96 | continue; |
97 | 97 | } |
98 | 98 | |
99 | 99 | $values[\count($values) - 1] .= $n; |
100 | 100 | |
101 | - if ($n === '(' || $n === '[' || $n === '{') { |
|
101 | + if ($n === '(' || $n === '[' || $n === '{'){ |
|
102 | 102 | $level++; |
103 | 103 | continue; |
104 | 104 | } |
105 | 105 | |
106 | - if ($n === ')' || $n === ']' || $n === '}') { |
|
106 | + if ($n === ')' || $n === ']' || $n === '}'){ |
|
107 | 107 | $level--; |
108 | 108 | } |
109 | 109 | } |
@@ -23,7 +23,8 @@ discard block |
||
23 | 23 | |
24 | 24 | public function handle(Parser $parser, Assembler $asm, Token $token): void |
25 | 25 | { |
26 | - switch ($token->type) { |
|
26 | + switch ($token->type) |
|
27 | + { |
|
27 | 28 | case DynamicGrammar::TYPE_DIRECTIVE: |
28 | 29 | $this->directive = new Directive(new Parser\Context($token, $parser->getPath())); |
29 | 30 | $asm->push($this->directive); |
@@ -48,20 +49,23 @@ discard block |
||
48 | 49 | break; |
49 | 50 | |
50 | 51 | case DynamicGrammar::TYPE_KEYWORD: |
51 | - if ($this->directive !== null) { |
|
52 | + if ($this->directive !== null) |
|
53 | + { |
|
52 | 54 | $this->directive->name = $token->content; |
53 | 55 | } |
54 | 56 | break; |
55 | 57 | |
56 | 58 | case DynamicGrammar::TYPE_BODY: |
57 | - if ($this->directive !== null) { |
|
59 | + if ($this->directive !== null) |
|
60 | + { |
|
58 | 61 | $this->directive->body = $token->content; |
59 | 62 | $this->directive->values = $this->fetchValues($this->directive->body); |
60 | 63 | |
61 | 64 | $this->directive = null; |
62 | 65 | } |
63 | 66 | |
64 | - if ($this->output !== null) { |
|
67 | + if ($this->output !== null) |
|
68 | + { |
|
65 | 69 | $this->output->body = $token->content; |
66 | 70 | } |
67 | 71 | |
@@ -79,31 +83,38 @@ discard block |
||
79 | 83 | |
80 | 84 | $src = new StringStream($body); |
81 | 85 | |
82 | - while ($n = $src->peak()) { |
|
83 | - if (\in_array($n, ['"', "'"], true)) { |
|
86 | + while ($n = $src->peak()) |
|
87 | + { |
|
88 | + if (\in_array($n, ['"', "'"], true)) |
|
89 | + { |
|
84 | 90 | $values[\count($values) - 1] .= $n; |
85 | - while (($nn = $src->peak()) !== null) { |
|
91 | + while (($nn = $src->peak()) !== null) |
|
92 | + { |
|
86 | 93 | $values[\count($values) - 1] .= $nn; |
87 | - if ($nn === $n) { |
|
94 | + if ($nn === $n) |
|
95 | + { |
|
88 | 96 | break; |
89 | 97 | } |
90 | 98 | } |
91 | 99 | continue; |
92 | 100 | } |
93 | 101 | |
94 | - if ($n === ',' && $level === 0) { |
|
102 | + if ($n === ',' && $level === 0) |
|
103 | + { |
|
95 | 104 | $values[] = ''; |
96 | 105 | continue; |
97 | 106 | } |
98 | 107 | |
99 | 108 | $values[\count($values) - 1] .= $n; |
100 | 109 | |
101 | - if ($n === '(' || $n === '[' || $n === '{') { |
|
110 | + if ($n === '(' || $n === '[' || $n === '{') |
|
111 | + { |
|
102 | 112 | $level++; |
103 | 113 | continue; |
104 | 114 | } |
105 | 115 | |
106 | - if ($n === ')' || $n === ']' || $n === '}') { |
|
116 | + if ($n === ')' || $n === ']' || $n === '}') |
|
117 | + { |
|
107 | 118 | $level--; |
108 | 119 | } |
109 | 120 | } |
@@ -21,8 +21,8 @@ |
||
21 | 21 | private readonly bool $isLegacy; |
22 | 22 | |
23 | 23 | public function __construct( |
24 | - private readonly CoreInterface|InterceptorHandler $core, |
|
25 | - ) { |
|
24 | + private readonly CoreInterface | InterceptorHandler $core, |
|
25 | + ){ |
|
26 | 26 | $this->isLegacy = !$core instanceof HandlerInterface; |
27 | 27 | } |
28 | 28 |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | ?string $comment = null, |
24 | 24 | ?string $namespace = null, |
25 | 25 | private readonly bool $isDomain = false, |
26 | - ) { |
|
26 | + ){ |
|
27 | 27 | parent::__construct($config, $name, $comment, $namespace); |
28 | 28 | } |
29 | 29 | |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | $this->class->addConstant('SINGLETONS', [])->setProtected(); |
44 | 44 | $this->class->addConstant('DEPENDENCIES', [])->setProtected(); |
45 | 45 | |
46 | - if ($this->isDomain) { |
|
46 | + if ($this->isDomain){ |
|
47 | 47 | $this->class->addConstant('INTERCEPTORS', [])->setProtected(); |
48 | 48 | $this->namespace->addUse(HandlerInterface::class); |
49 | 49 | $this->class->getConstant('SINGLETONS')->setValue([ |
@@ -43,7 +43,8 @@ |
||
43 | 43 | $this->class->addConstant('SINGLETONS', [])->setProtected(); |
44 | 44 | $this->class->addConstant('DEPENDENCIES', [])->setProtected(); |
45 | 45 | |
46 | - if ($this->isDomain) { |
|
46 | + if ($this->isDomain) |
|
47 | + { |
|
47 | 48 | $this->class->addConstant('INTERCEPTORS', [])->setProtected(); |
48 | 49 | $this->namespace->addUse(HandlerInterface::class); |
49 | 50 | $this->class->getConstant('SINGLETONS')->setValue([ |
@@ -28,7 +28,7 @@ |
||
28 | 28 | |
29 | 29 | public function defineDirectories(string $root): array |
30 | 30 | { |
31 | - return \array_merge(parent::defineDirectories($root), ['app' => $root . '/App']); |
|
31 | + return \array_merge(parent::defineDirectories($root), ['app' => $root.'/App']); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | protected function tearDown(): void |
@@ -28,8 +28,10 @@ discard block |
||
28 | 28 | { |
29 | 29 | $grid = $this->table(['Name:', 'Verbs:', 'Pattern:', 'Target:', 'Group:']); |
30 | 30 | |
31 | - foreach ($router->getRoutes() as $name => $route) { |
|
32 | - if ($route instanceof RouteInterface) { |
|
31 | + foreach ($router->getRoutes() as $name => $route) |
|
32 | + { |
|
33 | + if ($route instanceof RouteInterface) |
|
34 | + { |
|
33 | 35 | $grid->addRow( |
34 | 36 | [ |
35 | 37 | $name, |
@@ -53,8 +55,10 @@ discard block |
||
53 | 55 | private function getRouteGroups(GroupRegistry $registry, string $routeName): array |
54 | 56 | { |
55 | 57 | $groups = []; |
56 | - foreach ($registry as $groupName => $group) { |
|
57 | - if ($group->hasRoute($routeName)) { |
|
58 | + foreach ($registry as $groupName => $group) |
|
59 | + { |
|
60 | + if ($group->hasRoute($routeName)) |
|
61 | + { |
|
58 | 62 | $groups[] = $groupName; |
59 | 63 | } |
60 | 64 | } |
@@ -64,12 +68,14 @@ discard block |
||
64 | 68 | |
65 | 69 | private function getVerbs(RouteInterface $route): string |
66 | 70 | { |
67 | - if ($route->getVerbs() === RouteInterface::VERBS) { |
|
71 | + if ($route->getVerbs() === RouteInterface::VERBS) |
|
72 | + { |
|
68 | 73 | return '*'; |
69 | 74 | } |
70 | 75 | |
71 | 76 | $result = []; |
72 | - foreach ($route->getVerbs() as $verb) { |
|
77 | + foreach ($route->getVerbs() as $verb) |
|
78 | + { |
|
73 | 79 | $result[] = match (\strtolower($verb)) { |
74 | 80 | 'get' => '<fg=green>GET</>', |
75 | 81 | 'head' => '<fg=bright-green>HEAD</>', |
@@ -111,7 +117,8 @@ discard block |
||
111 | 117 | private function getTarget(RouteInterface $route, KernelInterface $kernel): string |
112 | 118 | { |
113 | 119 | $target = $this->getValue($route, 'target'); |
114 | - switch (true) { |
|
120 | + switch (true) |
|
121 | + { |
|
115 | 122 | case $target instanceof \Closure: |
116 | 123 | $reflection = new \ReflectionFunction($target); |
117 | 124 | |
@@ -136,7 +143,8 @@ discard block |
||
136 | 143 | |
137 | 144 | case $target instanceof Group: |
138 | 145 | $result = []; |
139 | - foreach ($this->getValue($target, 'controllers') as $alias => $class) { |
|
146 | + foreach ($this->getValue($target, 'controllers') as $alias => $class) |
|
147 | + { |
|
140 | 148 | $result[] = \sprintf('%s => %s', $alias, $this->relativeClass($class, $kernel)); |
141 | 149 | } |
142 | 150 | |
@@ -155,10 +163,13 @@ discard block |
||
155 | 163 | |
156 | 164 | private function getValue(object $object, string $property): mixed |
157 | 165 | { |
158 | - try { |
|
166 | + try |
|
167 | + { |
|
159 | 168 | $r = new \ReflectionObject($object); |
160 | 169 | $prop = $r->getProperty($property); |
161 | - } catch (\Throwable $e) { |
|
170 | + } |
|
171 | + catch (\Throwable $e) |
|
172 | + { |
|
162 | 173 | return $e->getMessage(); |
163 | 174 | } |
164 | 175 | |
@@ -169,7 +180,8 @@ discard block |
||
169 | 180 | { |
170 | 181 | $r = new \ReflectionObject($kernel); |
171 | 182 | |
172 | - if (\str_starts_with($class, $r->getNamespaceName())) { |
|
183 | + if (\str_starts_with($class, $r->getNamespaceName())) |
|
184 | + { |
|
173 | 185 | return \substr($class, \strlen($r->getNamespaceName()) + 1); |
174 | 186 | } |
175 | 187 |
@@ -28,8 +28,8 @@ discard block |
||
28 | 28 | { |
29 | 29 | $grid = $this->table(['Name:', 'Verbs:', 'Pattern:', 'Target:', 'Group:']); |
30 | 30 | |
31 | - foreach ($router->getRoutes() as $name => $route) { |
|
32 | - if ($route instanceof RouteInterface) { |
|
31 | + foreach ($router->getRoutes() as $name => $route){ |
|
32 | + if ($route instanceof RouteInterface){ |
|
33 | 33 | $grid->addRow( |
34 | 34 | [ |
35 | 35 | $name, |
@@ -53,8 +53,8 @@ discard block |
||
53 | 53 | private function getRouteGroups(GroupRegistry $registry, string $routeName): array |
54 | 54 | { |
55 | 55 | $groups = []; |
56 | - foreach ($registry as $groupName => $group) { |
|
57 | - if ($group->hasRoute($routeName)) { |
|
56 | + foreach ($registry as $groupName => $group){ |
|
57 | + if ($group->hasRoute($routeName)){ |
|
58 | 58 | $groups[] = $groupName; |
59 | 59 | } |
60 | 60 | } |
@@ -64,12 +64,12 @@ discard block |
||
64 | 64 | |
65 | 65 | private function getVerbs(RouteInterface $route): string |
66 | 66 | { |
67 | - if ($route->getVerbs() === RouteInterface::VERBS) { |
|
67 | + if ($route->getVerbs() === RouteInterface::VERBS){ |
|
68 | 68 | return '*'; |
69 | 69 | } |
70 | 70 | |
71 | 71 | $result = []; |
72 | - foreach ($route->getVerbs() as $verb) { |
|
72 | + foreach ($route->getVerbs() as $verb){ |
|
73 | 73 | $result[] = match (\strtolower($verb)) { |
74 | 74 | 'get' => '<fg=green>GET</>', |
75 | 75 | 'head' => '<fg=bright-green>HEAD</>', |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | $pattern = \preg_replace_callback( |
99 | 99 | '/<([^>]*)>/', |
100 | 100 | static fn($m) => \sprintf('<fg=magenta>%s</>', $m[0]), |
101 | - !empty($prefix) ? $prefix . '/' . \trim($pattern, '/') : $pattern, |
|
101 | + !empty($prefix) ? $prefix.'/'.\trim($pattern, '/') : $pattern, |
|
102 | 102 | ); |
103 | 103 | |
104 | 104 | return $pattern; |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | private function getTarget(RouteInterface $route, KernelInterface $kernel): string |
111 | 111 | { |
112 | 112 | $target = $this->getValue($route, 'target'); |
113 | - switch (true) { |
|
113 | + switch (true){ |
|
114 | 114 | case $target instanceof \Closure: |
115 | 115 | $reflection = new \ReflectionFunction($target); |
116 | 116 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | return \sprintf( |
125 | 125 | '%s->%s', |
126 | 126 | $this->relativeClass($this->getValue($target, 'controller'), $kernel), |
127 | - \implode('|', (array) $this->getValue($target, 'action')), |
|
127 | + \implode('|', (array)$this->getValue($target, 'action')), |
|
128 | 128 | ); |
129 | 129 | |
130 | 130 | case $target instanceof Controller: |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | |
136 | 136 | case $target instanceof Group: |
137 | 137 | $result = []; |
138 | - foreach ($this->getValue($target, 'controllers') as $alias => $class) { |
|
138 | + foreach ($this->getValue($target, 'controllers') as $alias => $class){ |
|
139 | 139 | $result[] = \sprintf('%s => %s', $alias, $this->relativeClass($class, $kernel)); |
140 | 140 | } |
141 | 141 | |
@@ -154,10 +154,10 @@ discard block |
||
154 | 154 | |
155 | 155 | private function getValue(object $object, string $property): mixed |
156 | 156 | { |
157 | - try { |
|
157 | + try{ |
|
158 | 158 | $r = new \ReflectionObject($object); |
159 | 159 | $prop = $r->getProperty($property); |
160 | - } catch (\Throwable $e) { |
|
160 | + }catch (\Throwable $e){ |
|
161 | 161 | return $e->getMessage(); |
162 | 162 | } |
163 | 163 | |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | { |
169 | 169 | $r = new \ReflectionObject($kernel); |
170 | 170 | |
171 | - if (\str_starts_with($class, $r->getNamespaceName())) { |
|
171 | + if (\str_starts_with($class, $r->getNamespaceName())){ |
|
172 | 172 | return \substr($class, \strlen($r->getNamespaceName()) + 1); |
173 | 173 | } |
174 | 174 |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | private readonly bool $useAnnotations = false, |
30 | 30 | private readonly bool $namedArguments = true, |
31 | 31 | private readonly bool $scanParents = false, |
32 | - ) { |
|
32 | + ){ |
|
33 | 33 | parent::__construct($scope); |
34 | 34 | } |
35 | 35 | |
@@ -45,25 +45,25 @@ discard block |
||
45 | 45 | ? (new Factory())->create() |
46 | 46 | : new AttributeReader($this->namedArguments ? new NamedArgumentsInstantiator() : null); |
47 | 47 | |
48 | - if ($attribute === null) { |
|
48 | + if ($attribute === null){ |
|
49 | 49 | return; |
50 | 50 | } |
51 | 51 | |
52 | 52 | $attribute = $attribute->newInstance(); |
53 | 53 | |
54 | - foreach ($classes as $class) { |
|
54 | + foreach ($classes as $class){ |
|
55 | 55 | // If attribute is defined on class level and class has target attribute |
56 | 56 | // then we can add it to the list of classes |
57 | - if ($attribute->flags & \Attribute::TARGET_CLASS) { |
|
58 | - if ($reader->firstClassMetadata($class, $target->getName())) { |
|
57 | + if ($attribute->flags & \Attribute::TARGET_CLASS){ |
|
58 | + if ($reader->firstClassMetadata($class, $target->getName())){ |
|
59 | 59 | yield $class->getName(); |
60 | 60 | continue; |
61 | 61 | } |
62 | 62 | |
63 | - if ($this->scanParents) { |
|
63 | + if ($this->scanParents){ |
|
64 | 64 | // Interfaces |
65 | - foreach ($class->getInterfaces() as $interface) { |
|
66 | - if ($reader->firstClassMetadata($interface, $target->getName())) { |
|
65 | + foreach ($class->getInterfaces() as $interface){ |
|
66 | + if ($reader->firstClassMetadata($interface, $target->getName())){ |
|
67 | 67 | yield $class->getName(); |
68 | 68 | continue 2; |
69 | 69 | } |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | |
72 | 72 | // Parents |
73 | 73 | $parent = $class->getParentClass(); |
74 | - while ($parent !== false) { |
|
75 | - if ($reader->firstClassMetadata($parent, $target->getName())) { |
|
74 | + while ($parent !== false){ |
|
75 | + if ($reader->firstClassMetadata($parent, $target->getName())){ |
|
76 | 76 | yield $class->getName(); |
77 | 77 | continue 2; |
78 | 78 | } |
@@ -83,9 +83,9 @@ discard block |
||
83 | 83 | |
84 | 84 | // If attribute is defined on method level and class methods has target attribute |
85 | 85 | // then we can add it to the list of classes |
86 | - if ($attribute->flags & \Attribute::TARGET_METHOD) { |
|
87 | - foreach ($class->getMethods() as $method) { |
|
88 | - if ($reader->firstFunctionMetadata($method, $target->getName())) { |
|
86 | + if ($attribute->flags & \Attribute::TARGET_METHOD){ |
|
87 | + foreach ($class->getMethods() as $method){ |
|
88 | + if ($reader->firstFunctionMetadata($method, $target->getName())){ |
|
89 | 89 | yield $class->getName(); |
90 | 90 | continue 2; |
91 | 91 | } |
@@ -94,9 +94,9 @@ discard block |
||
94 | 94 | |
95 | 95 | // If attribute is defined on property level and class properties has target attribute |
96 | 96 | // then we can add it to the list of classes |
97 | - if ($attribute->flags & \Attribute::TARGET_PROPERTY) { |
|
98 | - foreach ($class->getProperties() as $property) { |
|
99 | - if ($reader->firstPropertyMetadata($property, $target->getName())) { |
|
97 | + if ($attribute->flags & \Attribute::TARGET_PROPERTY){ |
|
98 | + foreach ($class->getProperties() as $property){ |
|
99 | + if ($reader->firstPropertyMetadata($property, $target->getName())){ |
|
100 | 100 | yield $class->getName(); |
101 | 101 | continue 2; |
102 | 102 | } |
@@ -106,9 +106,9 @@ discard block |
||
106 | 106 | |
107 | 107 | // If attribute is defined on constant level and class constants has target attribute |
108 | 108 | // then we can add it to the list of classes |
109 | - if ($attribute->flags & \Attribute::TARGET_CLASS_CONSTANT) { |
|
110 | - foreach ($class->getReflectionConstants() as $constant) { |
|
111 | - if ($reader->firstConstantMetadata($constant, $target->getName())) { |
|
109 | + if ($attribute->flags & \Attribute::TARGET_CLASS_CONSTANT){ |
|
110 | + foreach ($class->getReflectionConstants() as $constant){ |
|
111 | + if ($reader->firstConstantMetadata($constant, $target->getName())){ |
|
112 | 112 | yield $class->getName(); |
113 | 113 | continue 2; |
114 | 114 | } |
@@ -118,10 +118,10 @@ discard block |
||
118 | 118 | |
119 | 119 | // If attribute is defined on method parameters level and class method parameter has target attribute |
120 | 120 | // then we can add it to the list of classes |
121 | - if ($attribute->flags & \Attribute::TARGET_PARAMETER) { |
|
122 | - foreach ($class->getMethods() as $method) { |
|
123 | - foreach ($method->getParameters() as $parameter) { |
|
124 | - if ($reader->firstParameterMetadata($parameter, $target->getName())) { |
|
121 | + if ($attribute->flags & \Attribute::TARGET_PARAMETER){ |
|
122 | + foreach ($class->getMethods() as $method){ |
|
123 | + foreach ($method->getParameters() as $parameter){ |
|
124 | + if ($reader->firstParameterMetadata($parameter, $target->getName())){ |
|
125 | 125 | yield $class->getName(); |
126 | 126 | continue 3; |
127 | 127 | } |
@@ -45,25 +45,32 @@ discard block |
||
45 | 45 | ? (new Factory())->create() |
46 | 46 | : new AttributeReader($this->namedArguments ? new NamedArgumentsInstantiator() : null); |
47 | 47 | |
48 | - if ($attribute === null) { |
|
48 | + if ($attribute === null) |
|
49 | + { |
|
49 | 50 | return; |
50 | 51 | } |
51 | 52 | |
52 | 53 | $attribute = $attribute->newInstance(); |
53 | 54 | |
54 | - foreach ($classes as $class) { |
|
55 | + foreach ($classes as $class) |
|
56 | + { |
|
55 | 57 | // If attribute is defined on class level and class has target attribute |
56 | 58 | // then we can add it to the list of classes |
57 | - if ($attribute->flags & \Attribute::TARGET_CLASS) { |
|
58 | - if ($reader->firstClassMetadata($class, $target->getName())) { |
|
59 | + if ($attribute->flags & \Attribute::TARGET_CLASS) |
|
60 | + { |
|
61 | + if ($reader->firstClassMetadata($class, $target->getName())) |
|
62 | + { |
|
59 | 63 | yield $class->getName(); |
60 | 64 | continue; |
61 | 65 | } |
62 | 66 | |
63 | - if ($this->scanParents) { |
|
67 | + if ($this->scanParents) |
|
68 | + { |
|
64 | 69 | // Interfaces |
65 | - foreach ($class->getInterfaces() as $interface) { |
|
66 | - if ($reader->firstClassMetadata($interface, $target->getName())) { |
|
70 | + foreach ($class->getInterfaces() as $interface) |
|
71 | + { |
|
72 | + if ($reader->firstClassMetadata($interface, $target->getName())) |
|
73 | + { |
|
67 | 74 | yield $class->getName(); |
68 | 75 | continue 2; |
69 | 76 | } |
@@ -71,8 +78,10 @@ discard block |
||
71 | 78 | |
72 | 79 | // Parents |
73 | 80 | $parent = $class->getParentClass(); |
74 | - while ($parent !== false) { |
|
75 | - if ($reader->firstClassMetadata($parent, $target->getName())) { |
|
81 | + while ($parent !== false) |
|
82 | + { |
|
83 | + if ($reader->firstClassMetadata($parent, $target->getName())) |
|
84 | + { |
|
76 | 85 | yield $class->getName(); |
77 | 86 | continue 2; |
78 | 87 | } |
@@ -83,9 +92,12 @@ discard block |
||
83 | 92 | |
84 | 93 | // If attribute is defined on method level and class methods has target attribute |
85 | 94 | // then we can add it to the list of classes |
86 | - if ($attribute->flags & \Attribute::TARGET_METHOD) { |
|
87 | - foreach ($class->getMethods() as $method) { |
|
88 | - if ($reader->firstFunctionMetadata($method, $target->getName())) { |
|
95 | + if ($attribute->flags & \Attribute::TARGET_METHOD) |
|
96 | + { |
|
97 | + foreach ($class->getMethods() as $method) |
|
98 | + { |
|
99 | + if ($reader->firstFunctionMetadata($method, $target->getName())) |
|
100 | + { |
|
89 | 101 | yield $class->getName(); |
90 | 102 | continue 2; |
91 | 103 | } |
@@ -94,9 +106,12 @@ discard block |
||
94 | 106 | |
95 | 107 | // If attribute is defined on property level and class properties has target attribute |
96 | 108 | // then we can add it to the list of classes |
97 | - if ($attribute->flags & \Attribute::TARGET_PROPERTY) { |
|
98 | - foreach ($class->getProperties() as $property) { |
|
99 | - if ($reader->firstPropertyMetadata($property, $target->getName())) { |
|
109 | + if ($attribute->flags & \Attribute::TARGET_PROPERTY) |
|
110 | + { |
|
111 | + foreach ($class->getProperties() as $property) |
|
112 | + { |
|
113 | + if ($reader->firstPropertyMetadata($property, $target->getName())) |
|
114 | + { |
|
100 | 115 | yield $class->getName(); |
101 | 116 | continue 2; |
102 | 117 | } |
@@ -106,9 +121,12 @@ discard block |
||
106 | 121 | |
107 | 122 | // If attribute is defined on constant level and class constants has target attribute |
108 | 123 | // then we can add it to the list of classes |
109 | - if ($attribute->flags & \Attribute::TARGET_CLASS_CONSTANT) { |
|
110 | - foreach ($class->getReflectionConstants() as $constant) { |
|
111 | - if ($reader->firstConstantMetadata($constant, $target->getName())) { |
|
124 | + if ($attribute->flags & \Attribute::TARGET_CLASS_CONSTANT) |
|
125 | + { |
|
126 | + foreach ($class->getReflectionConstants() as $constant) |
|
127 | + { |
|
128 | + if ($reader->firstConstantMetadata($constant, $target->getName())) |
|
129 | + { |
|
112 | 130 | yield $class->getName(); |
113 | 131 | continue 2; |
114 | 132 | } |
@@ -118,10 +136,14 @@ discard block |
||
118 | 136 | |
119 | 137 | // If attribute is defined on method parameters level and class method parameter has target attribute |
120 | 138 | // then we can add it to the list of classes |
121 | - if ($attribute->flags & \Attribute::TARGET_PARAMETER) { |
|
122 | - foreach ($class->getMethods() as $method) { |
|
123 | - foreach ($method->getParameters() as $parameter) { |
|
124 | - if ($reader->firstParameterMetadata($parameter, $target->getName())) { |
|
139 | + if ($attribute->flags & \Attribute::TARGET_PARAMETER) |
|
140 | + { |
|
141 | + foreach ($class->getMethods() as $method) |
|
142 | + { |
|
143 | + foreach ($method->getParameters() as $parameter) |
|
144 | + { |
|
145 | + if ($reader->firstParameterMetadata($parameter, $target->getName())) |
|
146 | + { |
|
125 | 147 | yield $class->getName(); |
126 | 148 | continue 3; |
127 | 149 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | private readonly FactoryInterface $factory, |
27 | 27 | ?EventDispatcherInterface $dispatcher = null, |
28 | 28 | ?PipelineBuilderInterface $builder = null, |
29 | - ) { |
|
29 | + ){ |
|
30 | 30 | $this->builder = $builder ?? new CompatiblePipelineBuilder($dispatcher); |
31 | 31 | } |
32 | 32 | |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | // Replaces alias with real pipeline name |
37 | 37 | $name = $this->config->getAliases()[$name] ?? $name; |
38 | 38 | |
39 | - if (!isset($this->pipelines[$name])) { |
|
39 | + if (!isset($this->pipelines[$name])){ |
|
40 | 40 | $this->pipelines[$name] = $this->resolveConnection($name); |
41 | 41 | } |
42 | 42 | |
@@ -51,18 +51,18 @@ discard block |
||
51 | 51 | { |
52 | 52 | $config = $this->config->getConnection($name); |
53 | 53 | |
54 | - try { |
|
54 | + try{ |
|
55 | 55 | $driver = $this->factory->make($config['driver'], $config); |
56 | 56 | |
57 | 57 | $list = []; |
58 | - foreach ($this->config->getPushInterceptors() as $interceptor) { |
|
58 | + foreach ($this->config->getPushInterceptors() as $interceptor){ |
|
59 | 59 | $list[] = \is_string($interceptor) || $interceptor instanceof Autowire |
60 | 60 | ? $this->container->get($interceptor) |
61 | 61 | : $interceptor; |
62 | 62 | } |
63 | 63 | |
64 | 64 | return new Queue($this->builder->withInterceptors(...$list)->build(new PushCore($driver))); |
65 | - } catch (ContainerException $e) { |
|
65 | + }catch (ContainerException $e){ |
|
66 | 66 | throw new Exception\NotSupportedDriverException( |
67 | 67 | \sprintf( |
68 | 68 | 'Driver `%s` is not supported. Connection `%s` cannot be created. Reason: `%s`', |
@@ -36,7 +36,8 @@ discard block |
||
36 | 36 | // Replaces alias with real pipeline name |
37 | 37 | $name = $this->config->getAliases()[$name] ?? $name; |
38 | 38 | |
39 | - if (!isset($this->pipelines[$name])) { |
|
39 | + if (!isset($this->pipelines[$name])) |
|
40 | + { |
|
40 | 41 | $this->pipelines[$name] = $this->resolveConnection($name); |
41 | 42 | } |
42 | 43 | |
@@ -51,18 +52,22 @@ discard block |
||
51 | 52 | { |
52 | 53 | $config = $this->config->getConnection($name); |
53 | 54 | |
54 | - try { |
|
55 | + try |
|
56 | + { |
|
55 | 57 | $driver = $this->factory->make($config['driver'], $config); |
56 | 58 | |
57 | 59 | $list = []; |
58 | - foreach ($this->config->getPushInterceptors() as $interceptor) { |
|
60 | + foreach ($this->config->getPushInterceptors() as $interceptor) |
|
61 | + { |
|
59 | 62 | $list[] = \is_string($interceptor) || $interceptor instanceof Autowire |
60 | 63 | ? $this->container->get($interceptor) |
61 | 64 | : $interceptor; |
62 | 65 | } |
63 | 66 | |
64 | 67 | return new Queue($this->builder->withInterceptors(...$list)->build(new PushCore($driver))); |
65 | - } catch (ContainerException $e) { |
|
68 | + } |
|
69 | + catch (ContainerException $e) |
|
70 | + { |
|
66 | 71 | throw new Exception\NotSupportedDriverException( |
67 | 72 | \sprintf( |
68 | 73 | 'Driver `%s` is not supported. Connection `%s` cannot be created. Reason: `%s`', |