@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | public function __construct( |
29 | 29 | /** @internal */ |
30 | 30 | protected ContainerInterface $container |
31 | - ) { |
|
31 | + ){ |
|
32 | 32 | // resolver is usually the container itself |
33 | 33 | /** @psalm-suppress MixedAssignment */ |
34 | 34 | $this->resolver = $container->get(ResolverInterface::class); |
@@ -59,13 +59,13 @@ discard block |
||
59 | 59 | |
60 | 60 | protected function resolveArguments(\ReflectionMethod $method, array $parameters): array |
61 | 61 | { |
62 | - foreach ($method->getParameters() as $parameter) { |
|
62 | + foreach ($method->getParameters() as $parameter){ |
|
63 | 63 | $name = $parameter->getName(); |
64 | 64 | if ( |
65 | 65 | \array_key_exists($name, $parameters) && |
66 | 66 | $parameters[$name] === null && |
67 | 67 | $parameter->isDefaultValueAvailable() |
68 | - ) { |
|
68 | + ){ |
|
69 | 69 | /** @psalm-suppress MixedAssignment */ |
70 | 70 | $parameters[$name] = $parameter->getDefaultValue(); |
71 | 71 | } |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | */ |
81 | 81 | private function invoke(\ReflectionMethod $method, array $arguments): mixed |
82 | 82 | { |
83 | - try { |
|
83 | + try{ |
|
84 | 84 | $args = $this->resolveArguments($method, $arguments); |
85 | - } catch (ArgumentResolvingException | InvalidArgumentException $e) { |
|
85 | + }catch (ArgumentResolvingException | InvalidArgumentException $e){ |
|
86 | 86 | throw new ControllerException( |
87 | 87 | \sprintf( |
88 | 88 | 'Missing/invalid parameter %s of `%s`->`%s`', |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | ControllerException::BAD_ARGUMENT, |
94 | 94 | $e, |
95 | 95 | ); |
96 | - } catch (ContainerExceptionInterface $e) { |
|
96 | + }catch (ContainerExceptionInterface $e){ |
|
97 | 97 | throw new ControllerException( |
98 | 98 | $e->getMessage(), |
99 | 99 | ControllerException::ERROR, |
@@ -59,7 +59,8 @@ discard block |
||
59 | 59 | |
60 | 60 | protected function resolveArguments(\ReflectionMethod $method, array $parameters): array |
61 | 61 | { |
62 | - foreach ($method->getParameters() as $parameter) { |
|
62 | + foreach ($method->getParameters() as $parameter) |
|
63 | + { |
|
63 | 64 | $name = $parameter->getName(); |
64 | 65 | if ( |
65 | 66 | \array_key_exists($name, $parameters) && |
@@ -80,9 +81,12 @@ discard block |
||
80 | 81 | */ |
81 | 82 | private function invoke(\ReflectionMethod $method, array $arguments): mixed |
82 | 83 | { |
83 | - try { |
|
84 | + try |
|
85 | + { |
|
84 | 86 | $args = $this->resolveArguments($method, $arguments); |
85 | - } catch (ArgumentResolvingException | InvalidArgumentException $e) { |
|
87 | + } |
|
88 | + catch (ArgumentResolvingException | InvalidArgumentException $e) |
|
89 | + { |
|
86 | 90 | throw new ControllerException( |
87 | 91 | \sprintf( |
88 | 92 | 'Missing/invalid parameter %s of `%s`->`%s`', |
@@ -93,7 +97,9 @@ discard block |
||
93 | 97 | ControllerException::BAD_ARGUMENT, |
94 | 98 | $e, |
95 | 99 | ); |
96 | - } catch (ContainerExceptionInterface $e) { |
|
100 | + } |
|
101 | + catch (ContainerExceptionInterface $e) |
|
102 | + { |
|
97 | 103 | throw new ControllerException( |
98 | 104 | $e->getMessage(), |
99 | 105 | ControllerException::ERROR, |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | private bool $isLegacyPipeline; |
45 | 45 | |
46 | 46 | public function __construct( |
47 | - private readonly HandlerInterface|CoreInterface $core, |
|
47 | + private readonly HandlerInterface | CoreInterface $core, |
|
48 | 48 | private readonly ScopeInterface $scope, |
49 | 49 | private readonly ResponseFactoryInterface $responseFactory, |
50 | 50 | ?TracerInterface $tracer = null |
51 | - ) { |
|
51 | + ){ |
|
52 | 52 | $this->tracer = $tracer ?? new NullTracer($scope); |
53 | 53 | $this->isLegacyPipeline = !$core instanceof HandlerInterface; |
54 | 54 | } |
@@ -96,9 +96,9 @@ discard block |
||
96 | 96 | $output = ''; |
97 | 97 | |
98 | 98 | $response = $this->responseFactory->createResponse(200); |
99 | - try { |
|
99 | + try{ |
|
100 | 100 | $action = $this->verbActions |
101 | - ? \strtolower($request->getMethod()) . \ucfirst($this->action) |
|
101 | + ? \strtolower($request->getMethod()).\ucfirst($this->action) |
|
102 | 102 | : $this->action; |
103 | 103 | |
104 | 104 | // run the core withing PSR-7 Request/Response scope |
@@ -108,42 +108,42 @@ discard block |
||
108 | 108 | Response::class => $response, |
109 | 109 | ], |
110 | 110 | fn (): mixed => $this->tracer->trace( |
111 | - name: 'Controller [' . $controller . ':' . $action . ']', |
|
111 | + name: 'Controller ['.$controller.':'.$action.']', |
|
112 | 112 | callback: $this->isLegacyPipeline |
113 | - ? fn (): mixed => $this->core->callAction( |
|
114 | - controller: $controller, |
|
115 | - action: $action, |
|
116 | - parameters: $parameters, |
|
113 | + ? fn () : mixed => $this->core->callAction( |
|
114 | + controller : $controller, |
|
115 | + action : $action, |
|
116 | + parameters : $parameters, |
|
117 | 117 | ) |
118 | - : fn (): mixed => $this->core->handle( |
|
118 | + : fn () : mixed => $this->core->handle( |
|
119 | 119 | new CallContext( |
120 | 120 | Target::fromPair($controller, $action), |
121 | 121 | $parameters, |
122 | 122 | ), |
123 | 123 | ), |
124 | - attributes: [ |
|
124 | + attributes : [ |
|
125 | 125 | 'route.controller' => $this->controller, |
126 | 126 | 'route.action' => $action, |
127 | 127 | 'route.parameters' => \array_keys($parameters), |
128 | 128 | ] |
129 | 129 | ) |
130 | 130 | ); |
131 | - } catch (TargetCallException $e) { |
|
131 | + }catch (TargetCallException $e){ |
|
132 | 132 | \ob_get_clean(); |
133 | 133 | throw $this->mapException($e); |
134 | - } catch (\Throwable $e) { |
|
134 | + }catch (\Throwable $e){ |
|
135 | 135 | \ob_get_clean(); |
136 | 136 | throw $e; |
137 | - } finally { |
|
138 | - while (\ob_get_level() > $outputLevel + 1) { |
|
139 | - $output = \ob_get_clean() . $output; |
|
137 | + }finally{ |
|
138 | + while (\ob_get_level() > $outputLevel + 1){ |
|
139 | + $output = \ob_get_clean().$output; |
|
140 | 140 | } |
141 | 141 | } |
142 | 142 | |
143 | 143 | return $this->wrapResponse( |
144 | 144 | $response, |
145 | 145 | $result, |
146 | - \ob_get_clean() . $output, |
|
146 | + \ob_get_clean().$output, |
|
147 | 147 | ); |
148 | 148 | } |
149 | 149 | |
@@ -156,21 +156,21 @@ discard block |
||
156 | 156 | */ |
157 | 157 | private function wrapResponse(Response $response, mixed $result = null, string $output = ''): Response |
158 | 158 | { |
159 | - if ($result instanceof Response) { |
|
160 | - if ($output !== '' && $result->getBody()->isWritable()) { |
|
159 | + if ($result instanceof Response){ |
|
160 | + if ($output !== '' && $result->getBody()->isWritable()){ |
|
161 | 161 | $result->getBody()->write($output); |
162 | 162 | } |
163 | 163 | |
164 | 164 | return $result; |
165 | 165 | } |
166 | 166 | |
167 | - if ($result instanceof \Generator) { |
|
167 | + if ($result instanceof \Generator){ |
|
168 | 168 | return $response->withBody(new GeneratorStream($result)); |
169 | 169 | } |
170 | 170 | |
171 | - if (\is_array($result) || $result instanceof \JsonSerializable) { |
|
171 | + if (\is_array($result) || $result instanceof \JsonSerializable){ |
|
172 | 172 | $response = $this->writeJson($response, $result); |
173 | - } else { |
|
173 | + }else{ |
|
174 | 174 | $response->getBody()->write((string)$result); |
175 | 175 | } |
176 | 176 | |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | */ |
204 | 204 | private function checkValues(): void |
205 | 205 | { |
206 | - if ($this->controller === null) { |
|
206 | + if ($this->controller === null){ |
|
207 | 207 | throw new HandlerException('Controller and action pair are not set.'); |
208 | 208 | } |
209 | 209 | } |
@@ -96,7 +96,8 @@ discard block |
||
96 | 96 | $output = ''; |
97 | 97 | |
98 | 98 | $response = $this->responseFactory->createResponse(200); |
99 | - try { |
|
99 | + try |
|
100 | + { |
|
100 | 101 | $action = $this->verbActions |
101 | 102 | ? \strtolower($request->getMethod()) . \ucfirst($this->action) |
102 | 103 | : $this->action; |
@@ -128,14 +129,21 @@ discard block |
||
128 | 129 | ] |
129 | 130 | ) |
130 | 131 | ); |
131 | - } catch (TargetCallException $e) { |
|
132 | + } |
|
133 | + catch (TargetCallException $e) |
|
134 | + { |
|
132 | 135 | \ob_get_clean(); |
133 | 136 | throw $this->mapException($e); |
134 | - } catch (\Throwable $e) { |
|
137 | + } |
|
138 | + catch (\Throwable $e) |
|
139 | + { |
|
135 | 140 | \ob_get_clean(); |
136 | 141 | throw $e; |
137 | - } finally { |
|
138 | - while (\ob_get_level() > $outputLevel + 1) { |
|
142 | + } |
|
143 | + finally |
|
144 | + { |
|
145 | + while (\ob_get_level() > $outputLevel + 1) |
|
146 | + { |
|
139 | 147 | $output = \ob_get_clean() . $output; |
140 | 148 | } |
141 | 149 | } |
@@ -156,21 +164,27 @@ discard block |
||
156 | 164 | */ |
157 | 165 | private function wrapResponse(Response $response, mixed $result = null, string $output = ''): Response |
158 | 166 | { |
159 | - if ($result instanceof Response) { |
|
160 | - if ($output !== '' && $result->getBody()->isWritable()) { |
|
167 | + if ($result instanceof Response) |
|
168 | + { |
|
169 | + if ($output !== '' && $result->getBody()->isWritable()) |
|
170 | + { |
|
161 | 171 | $result->getBody()->write($output); |
162 | 172 | } |
163 | 173 | |
164 | 174 | return $result; |
165 | 175 | } |
166 | 176 | |
167 | - if ($result instanceof \Generator) { |
|
177 | + if ($result instanceof \Generator) |
|
178 | + { |
|
168 | 179 | return $response->withBody(new GeneratorStream($result)); |
169 | 180 | } |
170 | 181 | |
171 | - if (\is_array($result) || $result instanceof \JsonSerializable) { |
|
182 | + if (\is_array($result) || $result instanceof \JsonSerializable) |
|
183 | + { |
|
172 | 184 | $response = $this->writeJson($response, $result); |
173 | - } else { |
|
185 | + } |
|
186 | + else |
|
187 | + { |
|
174 | 188 | $response->getBody()->write((string)$result); |
175 | 189 | } |
176 | 190 | |
@@ -203,7 +217,8 @@ discard block |
||
203 | 217 | */ |
204 | 218 | private function checkValues(): void |
205 | 219 | { |
206 | - if ($this->controller === null) { |
|
220 | + if ($this->controller === null) |
|
221 | + { |
|
207 | 222 | throw new HandlerException('Controller and action pair are not set.'); |
208 | 223 | } |
209 | 224 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | private ?string $group = null; |
23 | 23 | private ?array $methods = null; |
24 | 24 | private string $prefix = ''; |
25 | - private HandlerInterface|CoreInterface|null $core = null; |
|
25 | + private HandlerInterface | CoreInterface | null $core = null; |
|
26 | 26 | private ?array $middleware = null; |
27 | 27 | |
28 | 28 | /** @var null|string|callable|RequestHandlerInterface|TargetInterface */ |
@@ -36,12 +36,12 @@ discard block |
||
36 | 36 | private readonly string $name, |
37 | 37 | private readonly string $pattern, |
38 | 38 | private readonly RouteCollection $collection |
39 | - ) { |
|
39 | + ){ |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | public function __destruct() |
43 | 43 | { |
44 | - if ($this->target === null) { |
|
44 | + if ($this->target === null){ |
|
45 | 45 | throw new TargetException( |
46 | 46 | \sprintf('The [%s] route has no defined target. Call one of: `controller`, `action`, |
47 | 47 | `namespaced`, `groupControllers`, `callable`, `handler` methods.', $this->name) |
@@ -92,21 +92,21 @@ discard block |
||
92 | 92 | return $this; |
93 | 93 | } |
94 | 94 | |
95 | - public function action(string $controller, string|array $action, int $options = 0): self |
|
95 | + public function action(string $controller, string | array $action, int $options = 0): self |
|
96 | 96 | { |
97 | 97 | $this->target = new Action($controller, $action, $options); |
98 | 98 | |
99 | 99 | return $this; |
100 | 100 | } |
101 | 101 | |
102 | - public function callable(array|\Closure $callable): self |
|
102 | + public function callable(array | \Closure $callable): self |
|
103 | 103 | { |
104 | 104 | $this->target = $callable; |
105 | 105 | |
106 | 106 | return $this; |
107 | 107 | } |
108 | 108 | |
109 | - public function handler(TargetInterface|string $target): self |
|
109 | + public function handler(TargetInterface | string $target): self |
|
110 | 110 | { |
111 | 111 | $this->target = $target; |
112 | 112 | |
@@ -134,16 +134,16 @@ discard block |
||
134 | 134 | return $this; |
135 | 135 | } |
136 | 136 | |
137 | - public function core(HandlerInterface|CoreInterface $core): self |
|
137 | + public function core(HandlerInterface | CoreInterface $core): self |
|
138 | 138 | { |
139 | 139 | $this->core = $core; |
140 | 140 | |
141 | 141 | return $this; |
142 | 142 | } |
143 | 143 | |
144 | - public function middleware(MiddlewareInterface|string|array $middleware): self |
|
144 | + public function middleware(MiddlewareInterface | string | array $middleware): self |
|
145 | 145 | { |
146 | - if (!\is_array($middleware)) { |
|
146 | + if (!\is_array($middleware)){ |
|
147 | 147 | $middleware = [$middleware]; |
148 | 148 | } |
149 | 149 | |
@@ -152,9 +152,9 @@ discard block |
||
152 | 152 | return $this; |
153 | 153 | } |
154 | 154 | |
155 | - public function methods(string|array $methods): self |
|
155 | + public function methods(string | array $methods): self |
|
156 | 156 | { |
157 | - $this->methods = (array) $methods; |
|
157 | + $this->methods = (array)$methods; |
|
158 | 158 | |
159 | 159 | return $this; |
160 | 160 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | public function __construct( |
15 | 15 | private readonly RouteCollection $parent, |
16 | 16 | private readonly RouteCollection $routes |
17 | - ) { |
|
17 | + ){ |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | public function __destruct() |
@@ -24,17 +24,17 @@ discard block |
||
24 | 24 | |
25 | 25 | public function __sleep(): array |
26 | 26 | { |
27 | - throw new \BadMethodCallException('Cannot unserialize ' . self::class); |
|
27 | + throw new \BadMethodCallException('Cannot unserialize '.self::class); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | public function __wakeup() |
31 | 31 | { |
32 | - throw new \BadMethodCallException('Cannot unserialize ' . self::class); |
|
32 | + throw new \BadMethodCallException('Cannot unserialize '.self::class); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | public function defaults(array $defaults): self |
36 | 36 | { |
37 | - foreach ($this->routes->all() as $configurator) { |
|
37 | + foreach ($this->routes->all() as $configurator){ |
|
38 | 38 | $configurator->defaults($defaults); |
39 | 39 | } |
40 | 40 | |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function group(string $group): self |
48 | 48 | { |
49 | - foreach ($this->routes->all() as $configurator) { |
|
49 | + foreach ($this->routes->all() as $configurator){ |
|
50 | 50 | $configurator->group($group); |
51 | 51 | } |
52 | 52 | |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public function prefix(string $prefix): self |
60 | 60 | { |
61 | - foreach ($this->routes->all() as $configurator) { |
|
61 | + foreach ($this->routes->all() as $configurator){ |
|
62 | 62 | $configurator->prefix($prefix); |
63 | 63 | } |
64 | 64 | |
@@ -70,26 +70,26 @@ discard block |
||
70 | 70 | */ |
71 | 71 | public function namePrefix(string $prefix): self |
72 | 72 | { |
73 | - foreach ($this->routes->all() as $name => $configurator) { |
|
74 | - $this->routes->add($prefix . $name, $configurator); |
|
73 | + foreach ($this->routes->all() as $name => $configurator){ |
|
74 | + $this->routes->add($prefix.$name, $configurator); |
|
75 | 75 | $this->routes->remove($name); |
76 | 76 | } |
77 | 77 | |
78 | 78 | return $this; |
79 | 79 | } |
80 | 80 | |
81 | - public function core(HandlerInterface|CoreInterface $core): self |
|
81 | + public function core(HandlerInterface | CoreInterface $core): self |
|
82 | 82 | { |
83 | - foreach ($this->routes->all() as $configurator) { |
|
83 | + foreach ($this->routes->all() as $configurator){ |
|
84 | 84 | $configurator->core($core); |
85 | 85 | } |
86 | 86 | |
87 | 87 | return $this; |
88 | 88 | } |
89 | 89 | |
90 | - public function middleware(MiddlewareInterface|string|array $middleware): self |
|
90 | + public function middleware(MiddlewareInterface | string | array $middleware): self |
|
91 | 91 | { |
92 | - foreach ($this->routes->all() as $configurator) { |
|
92 | + foreach ($this->routes->all() as $configurator){ |
|
93 | 93 | $configurator->middleware($middleware); |
94 | 94 | } |
95 | 95 |
@@ -34,7 +34,8 @@ discard block |
||
34 | 34 | |
35 | 35 | public function defaults(array $defaults): self |
36 | 36 | { |
37 | - foreach ($this->routes->all() as $configurator) { |
|
37 | + foreach ($this->routes->all() as $configurator) |
|
38 | + { |
|
38 | 39 | $configurator->defaults($defaults); |
39 | 40 | } |
40 | 41 | |
@@ -46,7 +47,8 @@ discard block |
||
46 | 47 | */ |
47 | 48 | public function group(string $group): self |
48 | 49 | { |
49 | - foreach ($this->routes->all() as $configurator) { |
|
50 | + foreach ($this->routes->all() as $configurator) |
|
51 | + { |
|
50 | 52 | $configurator->group($group); |
51 | 53 | } |
52 | 54 | |
@@ -58,7 +60,8 @@ discard block |
||
58 | 60 | */ |
59 | 61 | public function prefix(string $prefix): self |
60 | 62 | { |
61 | - foreach ($this->routes->all() as $configurator) { |
|
63 | + foreach ($this->routes->all() as $configurator) |
|
64 | + { |
|
62 | 65 | $configurator->prefix($prefix); |
63 | 66 | } |
64 | 67 | |
@@ -70,7 +73,8 @@ discard block |
||
70 | 73 | */ |
71 | 74 | public function namePrefix(string $prefix): self |
72 | 75 | { |
73 | - foreach ($this->routes->all() as $name => $configurator) { |
|
76 | + foreach ($this->routes->all() as $name => $configurator) |
|
77 | + { |
|
74 | 78 | $this->routes->add($prefix . $name, $configurator); |
75 | 79 | $this->routes->remove($name); |
76 | 80 | } |
@@ -80,7 +84,8 @@ discard block |
||
80 | 84 | |
81 | 85 | public function core(HandlerInterface|CoreInterface $core): self |
82 | 86 | { |
83 | - foreach ($this->routes->all() as $configurator) { |
|
87 | + foreach ($this->routes->all() as $configurator) |
|
88 | + { |
|
84 | 89 | $configurator->core($core); |
85 | 90 | } |
86 | 91 | |
@@ -89,7 +94,8 @@ discard block |
||
89 | 94 | |
90 | 95 | public function middleware(MiddlewareInterface|string|array $middleware): self |
91 | 96 | { |
92 | - foreach ($this->routes->all() as $configurator) { |
|
97 | + foreach ($this->routes->all() as $configurator) |
|
98 | + { |
|
93 | 99 | $configurator->middleware($middleware); |
94 | 100 | } |
95 | 101 |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | /** @var array<MiddlewareType> */ |
29 | 29 | private array $middleware = []; |
30 | 30 | |
31 | - private Autowire|HandlerInterface|CoreInterface|string|null $core = null; |
|
31 | + private Autowire | HandlerInterface | CoreInterface | string | null $core = null; |
|
32 | 32 | |
33 | 33 | public function __construct( |
34 | 34 | /** @deprecated since v3.3.0 */ |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | private readonly ?RouterInterface $router = null, |
38 | 38 | /** @deprecated since v3.3.0 */ |
39 | 39 | private readonly ?UriHandler $handler = null |
40 | - ) { |
|
40 | + ){ |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | return $this; |
69 | 69 | } |
70 | 70 | |
71 | - public function setCore(Autowire|CoreInterface|HandlerInterface|string $core): self |
|
71 | + public function setCore(Autowire | CoreInterface | HandlerInterface | string $core): self |
|
72 | 72 | { |
73 | 73 | $this->core = $core; |
74 | 74 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | /** |
79 | 79 | * @param MiddlewareType $middleware |
80 | 80 | */ |
81 | - public function addMiddleware(MiddlewareInterface|Autowire|string $middleware): self |
|
81 | + public function addMiddleware(MiddlewareInterface | Autowire | string $middleware): self |
|
82 | 82 | { |
83 | 83 | $this->middleware[] = $middleware; |
84 | 84 | |
@@ -92,21 +92,21 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public function register(RouterInterface $router, FactoryInterface $factory): void |
94 | 94 | { |
95 | - foreach ($this->routes as $name => $route) { |
|
96 | - if ($this->core !== null) { |
|
97 | - if (!$this->core instanceof CoreInterface && !$this->core instanceof HandlerInterface) { |
|
95 | + foreach ($this->routes as $name => $route){ |
|
96 | + if ($this->core !== null){ |
|
97 | + if (!$this->core instanceof CoreInterface && !$this->core instanceof HandlerInterface){ |
|
98 | 98 | $this->core = $factory->make($this->core); |
99 | 99 | } |
100 | 100 | |
101 | 101 | $target = $route->getTarget(); |
102 | - if ($target instanceof AbstractTarget) { |
|
102 | + if ($target instanceof AbstractTarget){ |
|
103 | 103 | $route = $route->withTarget($target->withCore($this->core)); |
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
107 | - try { |
|
107 | + try{ |
|
108 | 108 | $uriHandler = $route->getUriHandler(); |
109 | - } catch (\Throwable) { |
|
109 | + }catch (\Throwable){ |
|
110 | 110 | $uriHandler = $factory->make(UriHandler::class); |
111 | 111 | } |
112 | 112 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | { |
131 | 131 | \assert($route instanceof Route); |
132 | 132 | |
133 | - $this->routes[$this->namePrefix . $name] = $route; |
|
133 | + $this->routes[$this->namePrefix.$name] = $route; |
|
134 | 134 | |
135 | 135 | return $this; |
136 | 136 | } |
@@ -92,21 +92,28 @@ |
||
92 | 92 | */ |
93 | 93 | public function register(RouterInterface $router, FactoryInterface $factory): void |
94 | 94 | { |
95 | - foreach ($this->routes as $name => $route) { |
|
96 | - if ($this->core !== null) { |
|
97 | - if (!$this->core instanceof CoreInterface && !$this->core instanceof HandlerInterface) { |
|
95 | + foreach ($this->routes as $name => $route) |
|
96 | + { |
|
97 | + if ($this->core !== null) |
|
98 | + { |
|
99 | + if (!$this->core instanceof CoreInterface && !$this->core instanceof HandlerInterface) |
|
100 | + { |
|
98 | 101 | $this->core = $factory->make($this->core); |
99 | 102 | } |
100 | 103 | |
101 | 104 | $target = $route->getTarget(); |
102 | - if ($target instanceof AbstractTarget) { |
|
105 | + if ($target instanceof AbstractTarget) |
|
106 | + { |
|
103 | 107 | $route = $route->withTarget($target->withCore($this->core)); |
104 | 108 | } |
105 | 109 | } |
106 | 110 | |
107 | - try { |
|
111 | + try |
|
112 | + { |
|
108 | 113 | $uriHandler = $route->getUriHandler(); |
109 | - } catch (\Throwable) { |
|
114 | + } |
|
115 | + catch (\Throwable) |
|
116 | + { |
|
110 | 117 | $uriHandler = $factory->make(UriHandler::class); |
111 | 118 | } |
112 | 119 |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | // Automatically prepend HTTP verb to all action names. |
26 | 26 | public const RESTFUL = 1; |
27 | 27 | |
28 | - private HandlerInterface|CoreInterface|null $pipeline = null; |
|
28 | + private HandlerInterface | CoreInterface | null $pipeline = null; |
|
29 | 29 | private ?CoreHandler $handler = null; |
30 | 30 | private bool $verbActions; |
31 | 31 | |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | private array $constrains, |
35 | 35 | int $options = 0, |
36 | 36 | private string $defaultAction = 'index' |
37 | - ) { |
|
37 | + ){ |
|
38 | 38 | $this->verbActions = ($options & self::RESTFUL) === self::RESTFUL; |
39 | 39 | } |
40 | 40 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @mutation-free |
53 | 53 | * @deprecated Use {@see withHandler()} instead. |
54 | 54 | */ |
55 | - public function withCore(HandlerInterface|CoreInterface $core): TargetInterface |
|
55 | + public function withCore(HandlerInterface | CoreInterface $core): TargetInterface |
|
56 | 56 | { |
57 | 57 | $target = clone $this; |
58 | 58 | $target->pipeline = $core; |
@@ -84,11 +84,11 @@ discard block |
||
84 | 84 | |
85 | 85 | protected function coreHandler(ContainerInterface $container): CoreHandler |
86 | 86 | { |
87 | - if ($this->handler !== null) { |
|
87 | + if ($this->handler !== null){ |
|
88 | 88 | return $this->handler; |
89 | 89 | } |
90 | 90 | |
91 | - try { |
|
91 | + try{ |
|
92 | 92 | // construct on demand |
93 | 93 | $this->handler = new CoreHandler( |
94 | 94 | $this->pipeline ?? $container->get(HandlerInterface::class), |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | ); |
99 | 99 | |
100 | 100 | return $this->handler; |
101 | - } catch (ContainerExceptionInterface $e) { |
|
101 | + }catch (ContainerExceptionInterface $e){ |
|
102 | 102 | throw new TargetException($e->getMessage(), $e->getCode(), $e); |
103 | 103 | } |
104 | 104 | } |
@@ -84,11 +84,13 @@ discard block |
||
84 | 84 | |
85 | 85 | protected function coreHandler(ContainerInterface $container): CoreHandler |
86 | 86 | { |
87 | - if ($this->handler !== null) { |
|
87 | + if ($this->handler !== null) |
|
88 | + { |
|
88 | 89 | return $this->handler; |
89 | 90 | } |
90 | 91 | |
91 | - try { |
|
92 | + try |
|
93 | + { |
|
92 | 94 | // construct on demand |
93 | 95 | $this->handler = new CoreHandler( |
94 | 96 | $this->pipeline ?? $container->get(HandlerInterface::class), |
@@ -98,7 +100,9 @@ discard block |
||
98 | 100 | ); |
99 | 101 | |
100 | 102 | return $this->handler; |
101 | - } catch (ContainerExceptionInterface $e) { |
|
103 | + } |
|
104 | + catch (ContainerExceptionInterface $e) |
|
105 | + { |
|
102 | 106 | throw new TargetException($e->getMessage(), $e->getCode(), $e); |
103 | 107 | } |
104 | 108 | } |
@@ -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([ |
@@ -14,8 +14,8 @@ |
||
14 | 14 | { |
15 | 15 | private readonly bool $isLegacy; |
16 | 16 | public function __construct( |
17 | - private readonly HandlerInterface|CoreInterface $core |
|
18 | - ) { |
|
17 | + private readonly HandlerInterface | CoreInterface $core |
|
18 | + ){ |
|
19 | 19 | $this->isLegacy = !$core instanceof HandlerInterface; |
20 | 20 | } |
21 | 21 |
@@ -31,8 +31,8 @@ |
||
31 | 31 | ): CoreInterface&HandlerInterface { |
32 | 32 | $pipeline = (new InterceptorPipeline($dispatcher))->withCore($core); |
33 | 33 | |
34 | - foreach (static::defineInterceptors() as $interceptor) { |
|
35 | - if (!$interceptor instanceof CoreInterceptorInterface && !$interceptor instanceof InterceptorInterface) { |
|
34 | + foreach (static::defineInterceptors() as $interceptor){ |
|
35 | + if (!$interceptor instanceof CoreInterceptorInterface && !$interceptor instanceof InterceptorInterface){ |
|
36 | 36 | $interceptor = $container->get($interceptor); |
37 | 37 | } |
38 | 38 |
@@ -31,8 +31,10 @@ |
||
31 | 31 | ): CoreInterface&HandlerInterface { |
32 | 32 | $pipeline = (new InterceptorPipeline($dispatcher))->withCore($core); |
33 | 33 | |
34 | - foreach (static::defineInterceptors() as $interceptor) { |
|
35 | - if (!$interceptor instanceof CoreInterceptorInterface && !$interceptor instanceof InterceptorInterface) { |
|
34 | + foreach (static::defineInterceptors() as $interceptor) |
|
35 | + { |
|
36 | + if (!$interceptor instanceof CoreInterceptorInterface && !$interceptor instanceof InterceptorInterface) |
|
37 | + { |
|
36 | 38 | $interceptor = $container->get($interceptor); |
37 | 39 | } |
38 | 40 |