@@ -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`', |
@@ -32,7 +32,7 @@ |
||
32 | 32 | $builder = new CompatiblePipelineBuilder($dispatcher); |
33 | 33 | |
34 | 34 | $list = []; |
35 | - foreach (static::defineInterceptors() as $interceptor) { |
|
35 | + foreach (static::defineInterceptors() as $interceptor){ |
|
36 | 36 | $list[] = $interceptor instanceof CoreInterceptorInterface || $interceptor instanceof InterceptorInterface |
37 | 37 | ? $interceptor |
38 | 38 | : $container->get($interceptor); |
@@ -32,7 +32,8 @@ |
||
32 | 32 | $builder = new CompatiblePipelineBuilder($dispatcher); |
33 | 33 | |
34 | 34 | $list = []; |
35 | - foreach (static::defineInterceptors() as $interceptor) { |
|
35 | + foreach (static::defineInterceptors() as $interceptor) |
|
36 | + { |
|
36 | 37 | $list[] = $interceptor instanceof CoreInterceptorInterface || $interceptor instanceof InterceptorInterface |
37 | 38 | ? $interceptor |
38 | 39 | : $container->get($interceptor); |
@@ -13,13 +13,13 @@ |
||
13 | 13 | /** |
14 | 14 | * @throws ClassNotFoundException |
15 | 15 | */ |
16 | - public function canInitialize(BootloaderInterface|string $bootloader, ?BootloadConfig $config = null): bool |
|
16 | + public function canInitialize(BootloaderInterface | string $bootloader, ?BootloadConfig $config = null): bool |
|
17 | 17 | { |
18 | - if (!\is_string($bootloader)) { |
|
18 | + if (!\is_string($bootloader)){ |
|
19 | 19 | return true; |
20 | 20 | } |
21 | 21 | |
22 | - if (!\class_exists($bootloader)) { |
|
22 | + if (!\class_exists($bootloader)){ |
|
23 | 23 | throw new ClassNotFoundException(\sprintf('Bootloader class `%s` does not exist.', $bootloader)); |
24 | 24 | } |
25 | 25 |
@@ -15,11 +15,13 @@ |
||
15 | 15 | */ |
16 | 16 | public function canInitialize(BootloaderInterface|string $bootloader, ?BootloadConfig $config = null): bool |
17 | 17 | { |
18 | - if (!\is_string($bootloader)) { |
|
18 | + if (!\is_string($bootloader)) |
|
19 | + { |
|
19 | 20 | return true; |
20 | 21 | } |
21 | 22 | |
22 | - if (!\class_exists($bootloader)) { |
|
23 | + if (!\class_exists($bootloader)) |
|
24 | + { |
|
23 | 25 | throw new ClassNotFoundException(\sprintf('Bootloader class `%s` does not exist.', $bootloader)); |
24 | 26 | } |
25 | 27 |
@@ -124,7 +124,8 @@ |
||
124 | 124 | $reflection = $target->getReflection(); |
125 | 125 | self::assertSame($hasReflection, $reflection !== null); |
126 | 126 | self::assertNull($target->getObject()); |
127 | - if ($hasReflection) { |
|
127 | + if ($hasReflection) |
|
128 | + { |
|
128 | 129 | self::assertInstanceOf(\ReflectionMethod::class, $reflection); |
129 | 130 | self::assertSame($action, $reflection->getName()); |
130 | 131 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | $target = Target::fromReflectionFunction($reflection, ['print_r-path']); |
37 | 37 | |
38 | 38 | self::assertSame($reflection, $target->getReflection()); |
39 | - self::assertSame('print_r-path', (string) $target); |
|
39 | + self::assertSame('print_r-path', (string)$target); |
|
40 | 40 | self::assertNull($target->getObject()); |
41 | 41 | } |
42 | 42 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | $target = Target::fromClosure(\print_r(...), ['print_r-path']); |
46 | 46 | |
47 | 47 | self::assertNotNull($target->getReflection()); |
48 | - self::assertSame('print_r-path', (string) $target); |
|
48 | + self::assertSame('print_r-path', (string)$target); |
|
49 | 49 | self::assertNull($target->getObject()); |
50 | 50 | } |
51 | 51 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | $target = Target::fromClosure($this->{__FUNCTION__}(...), ['print_r-path']); |
55 | 55 | |
56 | 56 | self::assertNotNull($target->getReflection()); |
57 | - self::assertSame('print_r-path', (string) $target); |
|
57 | + self::assertSame('print_r-path', (string)$target); |
|
58 | 58 | self::assertNull($target->getObject()); |
59 | 59 | } |
60 | 60 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | $target = Target::fromReflectionMethod($reflection, self::class); |
66 | 66 | |
67 | 67 | self::assertSame($reflection, $target->getReflection()); |
68 | - self::assertSame(self::class . '->' . __FUNCTION__, (string) $target); |
|
68 | + self::assertSame(self::class.'->'.__FUNCTION__, (string)$target); |
|
69 | 69 | self::assertNull($target->getObject()); |
70 | 70 | } |
71 | 71 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | $target = Target::fromReflectionMethod($reflection, $this); |
77 | 77 | |
78 | 78 | self::assertSame($reflection, $target->getReflection()); |
79 | - self::assertSame(self::class . '->' . __FUNCTION__, (string) $target); |
|
79 | + self::assertSame(self::class.'->'.__FUNCTION__, (string)$target); |
|
80 | 80 | self::assertNotNull($target->getObject()); |
81 | 81 | } |
82 | 82 | |
@@ -89,10 +89,10 @@ discard block |
||
89 | 89 | // Immutability |
90 | 90 | self::assertNotSame($target, $target2); |
91 | 91 | self::assertSame(['bar', 'baz'], $target2->getPath()); |
92 | - self::assertSame('bar.baz', (string) $target2); |
|
92 | + self::assertSame('bar.baz', (string)$target2); |
|
93 | 93 | // First target is not changed |
94 | 94 | self::assertSame(['foo', 'bar', 'baz'], $target->getPath()); |
95 | - self::assertSame($str, (string) $target); |
|
95 | + self::assertSame($str, (string)$target); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | #[DataProvider('providePathChunks')] |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $target = Target::fromPathString($str, $separator); |
103 | 103 | |
104 | 104 | self::assertSame($chunks, $target->getPath()); |
105 | - self::assertSame($str, (string) $target); |
|
105 | + self::assertSame($str, (string)$target); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | #[DataProvider('providePathChunks')] |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | $target = Target::fromPathArray($chunks, $separator); |
113 | 113 | |
114 | 114 | self::assertSame($chunks, $target->getPath()); |
115 | - self::assertSame($str, (string) $target); |
|
115 | + self::assertSame($str, (string)$target); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | #[DataProvider('providePairs')] |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | $reflection = $target->getReflection(); |
125 | 125 | self::assertSame($hasReflection, $reflection !== null); |
126 | 126 | self::assertNull($target->getObject()); |
127 | - if ($hasReflection) { |
|
127 | + if ($hasReflection){ |
|
128 | 128 | self::assertInstanceOf(\ReflectionMethod::class, $reflection); |
129 | 129 | self::assertSame($action, $reflection->getName()); |
130 | 130 | } |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | $target = Target::fromPathString($str); |
149 | 149 | |
150 | 150 | self::assertSame(['foo', 'bar', 'baz'], $target->getPath()); |
151 | - self::assertSame($str, (string) $target); |
|
151 | + self::assertSame($str, (string)$target); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | public function testPrivateConstructor(): void |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | public function testInterceptorCallingEventShouldBeDispatched(): void |
21 | 21 | { |
22 | 22 | $context = $this->createPathContext(['test', 'test2']); |
23 | - $interceptor = new class implements InterceptorInterface { |
|
23 | + $interceptor = new class implements InterceptorInterface{ |
|
24 | 24 | public function intercept(CallContextInterface $context, HandlerInterface $handler): mixed |
25 | 25 | { |
26 | 26 | return null; |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | $pipeline = $this->createPipeline(interceptors: [$interceptor], dispatcher: $dispatcher); |
40 | 40 | |
41 | 41 | $pipeline->withHandler( |
42 | - new class implements HandlerInterface { |
|
42 | + new class implements HandlerInterface{ |
|
43 | 43 | public function handle(CallContextInterface $context): mixed |
44 | 44 | { |
45 | 45 | return null; |
@@ -125,8 +125,8 @@ discard block |
||
125 | 125 | */ |
126 | 126 | private function createPipeline( |
127 | 127 | array $interceptors = [], |
128 | - HandlerInterface|null $lastHandler = null, |
|
129 | - EventDispatcherInterface|null $dispatcher = null, |
|
128 | + HandlerInterface | null $lastHandler = null, |
|
129 | + EventDispatcherInterface | null $dispatcher = null, |
|
130 | 130 | ): InterceptorPipeline { |
131 | 131 | $pipeline = new InterceptorPipeline($dispatcher); |
132 | 132 |
@@ -20,7 +20,8 @@ discard block |
||
20 | 20 | public function testInterceptorCallingEventShouldBeDispatched(): void |
21 | 21 | { |
22 | 22 | $context = $this->createPathContext(['test', 'test2']); |
23 | - $interceptor = new class implements InterceptorInterface { |
|
23 | + $interceptor = new class implements InterceptorInterface |
|
24 | + { |
|
24 | 25 | public function intercept(CallContextInterface $context, HandlerInterface $handler): mixed |
25 | 26 | { |
26 | 27 | return null; |
@@ -39,7 +40,8 @@ discard block |
||
39 | 40 | $pipeline = $this->createPipeline(interceptors: [$interceptor], dispatcher: $dispatcher); |
40 | 41 | |
41 | 42 | $pipeline->withHandler( |
42 | - new class implements HandlerInterface { |
|
43 | + new class implements HandlerInterface |
|
44 | + { |
|
43 | 45 | public function handle(CallContextInterface $context): mixed |
44 | 46 | { |
45 | 47 | return null; |
@@ -19,10 +19,10 @@ discard block |
||
19 | 19 | */ |
20 | 20 | public static function pathToReflection(string $controller, string $action): \ReflectionMethod |
21 | 21 | { |
22 | - try { |
|
22 | + try{ |
|
23 | 23 | /** @psalm-suppress ArgumentTypeCoercion */ |
24 | 24 | $method = new \ReflectionMethod($controller, $action); |
25 | - } catch (\ReflectionException $e) { |
|
25 | + }catch (\ReflectionException $e){ |
|
26 | 26 | throw new TargetCallException( |
27 | 27 | \sprintf('Invalid action `%s`->`%s`', $controller, $action), |
28 | 28 | TargetCallException::BAD_ACTION, |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public static function validateControllerMethod(\ReflectionMethod $method, mixed $controller = null): void |
41 | 41 | { |
42 | - if ($method->isStatic() || !$method->isPublic()) { |
|
42 | + if ($method->isStatic() || !$method->isPublic()){ |
|
43 | 43 | throw new TargetCallException( |
44 | 44 | \sprintf( |
45 | 45 | 'Invalid action `%s`->`%s`', |
@@ -50,11 +50,11 @@ discard block |
||
50 | 50 | ); |
51 | 51 | } |
52 | 52 | |
53 | - if ($controller === null) { |
|
53 | + if ($controller === null){ |
|
54 | 54 | return; |
55 | 55 | } |
56 | 56 | |
57 | - if (!\is_object($controller) || !$method->getDeclaringClass()->isInstance($controller)) { |
|
57 | + if (!\is_object($controller) || !$method->getDeclaringClass()->isInstance($controller)){ |
|
58 | 58 | throw new TargetCallException( |
59 | 59 | \sprintf( |
60 | 60 | 'Invalid controller. Expected instance of `%s`, got `%s`.', |
@@ -19,10 +19,13 @@ discard block |
||
19 | 19 | */ |
20 | 20 | public static function pathToReflection(string $controller, string $action): \ReflectionMethod |
21 | 21 | { |
22 | - try { |
|
22 | + try |
|
23 | + { |
|
23 | 24 | /** @psalm-suppress ArgumentTypeCoercion */ |
24 | 25 | $method = new \ReflectionMethod($controller, $action); |
25 | - } catch (\ReflectionException $e) { |
|
26 | + } |
|
27 | + catch (\ReflectionException $e) |
|
28 | + { |
|
26 | 29 | throw new TargetCallException( |
27 | 30 | \sprintf('Invalid action `%s`->`%s`', $controller, $action), |
28 | 31 | TargetCallException::BAD_ACTION, |
@@ -39,7 +42,8 @@ discard block |
||
39 | 42 | */ |
40 | 43 | public static function validateControllerMethod(\ReflectionMethod $method, mixed $controller = null): void |
41 | 44 | { |
42 | - if ($method->isStatic() || !$method->isPublic()) { |
|
45 | + if ($method->isStatic() || !$method->isPublic()) |
|
46 | + { |
|
43 | 47 | throw new TargetCallException( |
44 | 48 | \sprintf( |
45 | 49 | 'Invalid action `%s`->`%s`', |
@@ -50,11 +54,13 @@ discard block |
||
50 | 54 | ); |
51 | 55 | } |
52 | 56 | |
53 | - if ($controller === null) { |
|
57 | + if ($controller === null) |
|
58 | + { |
|
54 | 59 | return; |
55 | 60 | } |
56 | 61 | |
57 | - if (!\is_object($controller) || !$method->getDeclaringClass()->isInstance($controller)) { |
|
62 | + if (!\is_object($controller) || !$method->getDeclaringClass()->isInstance($controller)) |
|
63 | + { |
|
58 | 64 | throw new TargetCallException( |
59 | 65 | \sprintf( |
60 | 66 | 'Invalid controller. Expected instance of `%s`, got `%s`.', |