@@ -58,5 +58,5 @@ |
||
58 | 58 | * |
59 | 59 | * @return callable|array{class-string, non-empty-string}|null |
60 | 60 | */ |
61 | - public function getCallable(): callable|array|null; |
|
61 | + public function getCallable(): callable | array | null; |
|
62 | 62 | } |
@@ -31,7 +31,8 @@ |
||
31 | 31 | public function withInterceptors(CoreInterceptorInterface|InterceptorInterface ...$interceptors): static |
32 | 32 | { |
33 | 33 | $clone = clone $this; |
34 | - foreach ($interceptors as $interceptor) { |
|
34 | + foreach ($interceptors as $interceptor) |
|
35 | + { |
|
35 | 36 | $clone->pipeline->addInterceptor($interceptor); |
36 | 37 | } |
37 | 38 |
@@ -23,17 +23,17 @@ |
||
23 | 23 | $this->pipeline = new InterceptorPipeline($dispatcher); |
24 | 24 | } |
25 | 25 | |
26 | - public function withInterceptors(CoreInterceptorInterface|InterceptorInterface ...$interceptors): static |
|
26 | + public function withInterceptors(CoreInterceptorInterface | InterceptorInterface ...$interceptors): static |
|
27 | 27 | { |
28 | 28 | $clone = clone $this; |
29 | - foreach ($interceptors as $interceptor) { |
|
29 | + foreach ($interceptors as $interceptor){ |
|
30 | 30 | $clone->pipeline->addInterceptor($interceptor); |
31 | 31 | } |
32 | 32 | |
33 | 33 | return $clone; |
34 | 34 | } |
35 | 35 | |
36 | - public function build(HandlerInterface|CoreInterface $handler): InterceptorPipeline |
|
36 | + public function build(HandlerInterface | CoreInterface $handler): InterceptorPipeline |
|
37 | 37 | { |
38 | 38 | /** @psalm-suppress InvalidArgument */ |
39 | 39 | return $handler instanceof HandlerInterface |
@@ -7,7 +7,7 @@ |
||
7 | 7 | // Load the original class to make an alias |
8 | 8 | use Spiral\Interceptors\Exception\TargetCallException; |
9 | 9 | |
10 | -if (!\class_exists(TargetCallException::class)) { |
|
10 | +if (!\class_exists(TargetCallException::class)){ |
|
11 | 11 | /** |
12 | 12 | * Unable to perform user action or find controller. |
13 | 13 | * |
@@ -7,7 +7,8 @@ |
||
7 | 7 | // Load the original class to make an alias |
8 | 8 | use Spiral\Interceptors\Exception\TargetCallException; |
9 | 9 | |
10 | -if (!\class_exists(TargetCallException::class)) { |
|
10 | +if (!\class_exists(TargetCallException::class)) |
|
11 | +{ |
|
11 | 12 | /** |
12 | 13 | * Unable to perform user action or find controller. |
13 | 14 | * |
@@ -5,7 +5,8 @@ |
||
5 | 5 | namespace Spiral\Core\Exception; |
6 | 6 | |
7 | 7 | // Load the original class to make an alias |
8 | -if (!\class_exists(\Spiral\Interceptors\Exception\InterceptorException::class)) { |
|
8 | +if (!\class_exists(\Spiral\Interceptors\Exception\InterceptorException::class)) |
|
9 | +{ |
|
9 | 10 | /** |
10 | 11 | * @deprecated will be removed in Spiral v4.0 |
11 | 12 | * Use {@see \Spiral\Interceptors\Exception\InterceptorException} instead. |
@@ -5,10 +5,10 @@ |
||
5 | 5 | namespace Spiral\Core\Exception; |
6 | 6 | |
7 | 7 | // Load the original class to make an alias |
8 | -if (!\class_exists(\Spiral\Interceptors\Exception\InterceptorException::class)) { |
|
8 | +if (!\class_exists(\Spiral\Interceptors\Exception\InterceptorException::class)){ |
|
9 | 9 | /** |
10 | 10 | * @deprecated will be removed in Spiral v4.0 |
11 | 11 | * Use {@see \Spiral\Interceptors\Exception\InterceptorException} instead. |
12 | 12 | */ |
13 | - class InterceptorException extends \RuntimeException {} |
|
13 | + class InterceptorException extends \RuntimeException{} |
|
14 | 14 | } |
@@ -65,7 +65,8 @@ discard block |
||
65 | 65 | |
66 | 66 | protected function resolveArguments(\ReflectionMethod $method, array $parameters): array |
67 | 67 | { |
68 | - foreach ($method->getParameters() as $parameter) { |
|
68 | + foreach ($method->getParameters() as $parameter) |
|
69 | + { |
|
69 | 70 | $name = $parameter->getName(); |
70 | 71 | if ( |
71 | 72 | \array_key_exists($name, $parameters) && |
@@ -86,9 +87,12 @@ discard block |
||
86 | 87 | */ |
87 | 88 | private function invoke(?object $object, string $class, \ReflectionMethod $method, array $arguments): mixed |
88 | 89 | { |
89 | - try { |
|
90 | + try |
|
91 | + { |
|
90 | 92 | $args = $this->resolveArguments($method, $arguments); |
91 | - } catch (ArgumentResolvingException | InvalidArgumentException $e) { |
|
93 | + } |
|
94 | + catch (ArgumentResolvingException | InvalidArgumentException $e) |
|
95 | + { |
|
92 | 96 | throw new ControllerException( |
93 | 97 | \sprintf( |
94 | 98 | 'Missing/invalid parameter %s of `%s`->`%s`', |
@@ -99,7 +103,9 @@ discard block |
||
99 | 103 | ControllerException::BAD_ARGUMENT, |
100 | 104 | $e, |
101 | 105 | ); |
102 | - } catch (ContainerExceptionInterface $e) { |
|
106 | + } |
|
107 | + catch (ContainerExceptionInterface $e) |
|
108 | + { |
|
103 | 109 | throw new ControllerException( |
104 | 110 | $e->getMessage(), |
105 | 111 | ControllerException::ERROR, |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | public function __construct( |
30 | 30 | /** @internal */ |
31 | 31 | #[Proxy] protected ContainerInterface $container, |
32 | - ) { |
|
32 | + ){ |
|
33 | 33 | // TODO: can we simplify this? |
34 | 34 | // resolver is usually the container itself |
35 | 35 | /** @psalm-suppress MixedAssignment */ |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | ? $container |
38 | 38 | : $container |
39 | 39 | ->get(InvokerInterface::class) |
40 | - ->invoke(static fn(#[Proxy] ResolverInterface $resolver): ResolverInterface => $resolver); |
|
40 | + ->invoke(static fn(#[Proxy] ResolverInterface $resolver) : ResolverInterface => $resolver); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -65,13 +65,13 @@ discard block |
||
65 | 65 | |
66 | 66 | protected function resolveArguments(\ReflectionMethod $method, array $parameters): array |
67 | 67 | { |
68 | - foreach ($method->getParameters() as $parameter) { |
|
68 | + foreach ($method->getParameters() as $parameter){ |
|
69 | 69 | $name = $parameter->getName(); |
70 | 70 | if ( |
71 | 71 | \array_key_exists($name, $parameters) && |
72 | 72 | $parameters[$name] === null && |
73 | 73 | $parameter->isDefaultValueAvailable() |
74 | - ) { |
|
74 | + ){ |
|
75 | 75 | /** @psalm-suppress MixedAssignment */ |
76 | 76 | $parameters[$name] = $parameter->getDefaultValue(); |
77 | 77 | } |
@@ -86,9 +86,9 @@ discard block |
||
86 | 86 | */ |
87 | 87 | private function invoke(?object $object, string $class, \ReflectionMethod $method, array $arguments): mixed |
88 | 88 | { |
89 | - try { |
|
89 | + try{ |
|
90 | 90 | $args = $this->resolveArguments($method, $arguments); |
91 | - } catch (ArgumentResolvingException | InvalidArgumentException $e) { |
|
91 | + }catch (ArgumentResolvingException | InvalidArgumentException $e){ |
|
92 | 92 | throw new ControllerException( |
93 | 93 | \sprintf( |
94 | 94 | 'Missing/invalid parameter %s of `%s`->`%s`', |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | ControllerException::BAD_ARGUMENT, |
100 | 100 | $e, |
101 | 101 | ); |
102 | - } catch (ContainerExceptionInterface $e) { |
|
102 | + }catch (ContainerExceptionInterface $e){ |
|
103 | 103 | throw new ControllerException( |
104 | 104 | $e->getMessage(), |
105 | 105 | ControllerException::ERROR, |
@@ -108,7 +108,7 @@ |
||
108 | 108 | public function createHandler(array $definitions = []): AutowireHandler |
109 | 109 | { |
110 | 110 | $container = new Container(); |
111 | - foreach ($definitions as $id => $definition) { |
|
111 | + foreach ($definitions as $id => $definition){ |
|
112 | 112 | $container->bind($id, $definition); |
113 | 113 | } |
114 | 114 |
@@ -108,7 +108,8 @@ |
||
108 | 108 | public function createHandler(array $definitions = []): AutowireHandler |
109 | 109 | { |
110 | 110 | $container = new Container(); |
111 | - foreach ($definitions as $id => $definition) { |
|
111 | + foreach ($definitions as $id => $definition) |
|
112 | + { |
|
112 | 113 | $container->bind($id, $definition); |
113 | 114 | } |
114 | 115 |
@@ -28,15 +28,18 @@ discard block |
||
28 | 28 | 'namespaces' => $config->getNamespaces(), |
29 | 29 | ]); |
30 | 30 | |
31 | - foreach ($this->config->getDependencies() as $dependency) { |
|
31 | + foreach ($this->config->getDependencies() as $dependency) |
|
32 | + { |
|
32 | 33 | $this->addDependency($dependency->resolve($factory)); |
33 | 34 | } |
34 | 35 | |
35 | - foreach ($this->config->getEngines() as $engine) { |
|
36 | + foreach ($this->config->getEngines() as $engine) |
|
37 | + { |
|
36 | 38 | $this->addEngine($engine->resolve($factory)); |
37 | 39 | } |
38 | 40 | |
39 | - if ($this->config->isCacheEnabled()) { |
|
41 | + if ($this->config->isCacheEnabled()) |
|
42 | + { |
|
40 | 43 | $this->cache = new ViewCache(); |
41 | 44 | } |
42 | 45 | } |
@@ -93,7 +96,8 @@ discard block |
||
93 | 96 | |
94 | 97 | // Rotate all possible context variants and warm up cache |
95 | 98 | $generator = new ContextGenerator($this->context); |
96 | - foreach ($generator->generate() as $context) { |
|
99 | + foreach ($generator->generate() as $context) |
|
100 | + { |
|
97 | 101 | $engine->reset($path, $context); |
98 | 102 | $engine->compile($path, $context); |
99 | 103 | } |
@@ -110,7 +114,8 @@ discard block |
||
110 | 114 | |
111 | 115 | // Rotate all possible context variants and warm up cache |
112 | 116 | $generator = new ContextGenerator($this->context); |
113 | - foreach ($generator->generate() as $context) { |
|
117 | + foreach ($generator->generate() as $context) |
|
118 | + { |
|
114 | 119 | $engine->reset($path, $context); |
115 | 120 | } |
116 | 121 | } |
@@ -122,7 +127,8 @@ discard block |
||
122 | 127 | */ |
123 | 128 | public function get(string $path): ViewInterface |
124 | 129 | { |
125 | - if ($this->cache?->has($this->context, $path)) { |
|
130 | + if ($this->cache?->has($this->context, $path)) |
|
131 | + { |
|
126 | 132 | return $this->cache->get($this->context, $path); |
127 | 133 | } |
128 | 134 | |
@@ -150,8 +156,10 @@ discard block |
||
150 | 156 | */ |
151 | 157 | private function findEngine(string $path): EngineInterface |
152 | 158 | { |
153 | - foreach ($this->engines as $engine) { |
|
154 | - if ($engine->getLoader()->exists($path)) { |
|
159 | + foreach ($this->engines as $engine) |
|
160 | + { |
|
161 | + if ($engine->getLoader()->exists($path)) |
|
162 | + { |
|
155 | 163 | return $engine; |
156 | 164 | } |
157 | 165 | } |
@@ -22,21 +22,21 @@ discard block |
||
22 | 22 | private readonly GlobalVariablesInterface $globalVariables, |
23 | 23 | FactoryInterface $factory, |
24 | 24 | ?ContextInterface $context = null, |
25 | - ) { |
|
25 | + ){ |
|
26 | 26 | $this->context = $context ?? new ViewContext(); |
27 | 27 | $this->loader = $factory->make(LoaderInterface::class, [ |
28 | 28 | 'namespaces' => $config->getNamespaces(), |
29 | 29 | ]); |
30 | 30 | |
31 | - foreach ($this->config->getDependencies() as $dependency) { |
|
31 | + foreach ($this->config->getDependencies() as $dependency){ |
|
32 | 32 | $this->addDependency($dependency->resolve($factory)); |
33 | 33 | } |
34 | 34 | |
35 | - foreach ($this->config->getEngines() as $engine) { |
|
35 | + foreach ($this->config->getEngines() as $engine){ |
|
36 | 36 | $this->addEngine($engine->resolve($factory)); |
37 | 37 | } |
38 | 38 | |
39 | - if ($this->config->isCacheEnabled()) { |
|
39 | + if ($this->config->isCacheEnabled()){ |
|
40 | 40 | $this->cache = new ViewCache(); |
41 | 41 | } |
42 | 42 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | |
93 | 93 | // Rotate all possible context variants and warm up cache |
94 | 94 | $generator = new ContextGenerator($this->context); |
95 | - foreach ($generator->generate() as $context) { |
|
95 | + foreach ($generator->generate() as $context){ |
|
96 | 96 | $engine->reset($path, $context); |
97 | 97 | $engine->compile($path, $context); |
98 | 98 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | |
110 | 110 | // Rotate all possible context variants and warm up cache |
111 | 111 | $generator = new ContextGenerator($this->context); |
112 | - foreach ($generator->generate() as $context) { |
|
112 | + foreach ($generator->generate() as $context){ |
|
113 | 113 | $engine->reset($path, $context); |
114 | 114 | } |
115 | 115 | } |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public function get(string $path): ViewInterface |
123 | 123 | { |
124 | - if ($this->cache?->has($this->context, $path)) { |
|
124 | + if ($this->cache?->has($this->context, $path)){ |
|
125 | 125 | return $this->cache->get($this->context, $path); |
126 | 126 | } |
127 | 127 | |
@@ -148,8 +148,8 @@ discard block |
||
148 | 148 | */ |
149 | 149 | private function findEngine(string $path): EngineInterface |
150 | 150 | { |
151 | - foreach ($this->engines as $engine) { |
|
152 | - if ($engine->getLoader()->exists($path)) { |
|
151 | + foreach ($this->engines as $engine){ |
|
152 | + if ($engine->getLoader()->exists($path)){ |
|
153 | 153 | return $engine; |
154 | 154 | } |
155 | 155 | } |
@@ -29,7 +29,7 @@ |
||
29 | 29 | ResponseFactoryInterface $responseFactory, |
30 | 30 | BroadcastConfig $config, |
31 | 31 | ?EventDispatcherInterface $dispatcher = null, |
32 | - ): AuthorizationMiddleware => new AuthorizationMiddleware( |
|
32 | + ) : AuthorizationMiddleware => new AuthorizationMiddleware( |
|
33 | 33 | $broadcast, |
34 | 34 | $responseFactory, |
35 | 35 | $config->getAuthorizationPath(), |
@@ -257,10 +257,13 @@ |
||
257 | 257 | { |
258 | 258 | $result = []; |
259 | 259 | |
260 | - foreach ($response->getHeaders() as $header) { |
|
261 | - foreach ($header as $headerLine) { |
|
260 | + foreach ($response->getHeaders() as $header) |
|
261 | + { |
|
262 | + foreach ($header as $headerLine) |
|
263 | + { |
|
262 | 264 | $chunk = explode(';', $headerLine); |
263 | - if (mb_strpos($chunk[0], '=') === false) { |
|
265 | + if (mb_strpos($chunk[0], '=') === false) |
|
266 | + { |
|
264 | 267 | continue; |
265 | 268 | } |
266 | 269 |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | $cookies = $this->fetchCookies($response); |
38 | 38 | |
39 | 39 | self::assertArrayHasKey('csrf-token', $cookies); |
40 | - self::assertSame($cookies['csrf-token'], (string) $response->getBody()); |
|
40 | + self::assertSame($cookies['csrf-token'], (string)$response->getBody()); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | public function testLengthException(): void |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | |
94 | 94 | $response = $this->get($core, '/'); |
95 | 95 | self::assertSame(200, $response->getStatusCode()); |
96 | - self::assertSame('all good', (string) $response->getBody()); |
|
96 | + self::assertSame('all good', (string)$response->getBody()); |
|
97 | 97 | |
98 | 98 | $cookies = $this->fetchCookies($response); |
99 | 99 | |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | ); |
113 | 113 | |
114 | 114 | self::assertSame(200, $response->getStatusCode()); |
115 | - self::assertSame('all good', (string) $response->getBody()); |
|
115 | + self::assertSame('all good', (string)$response->getBody()); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | public function testHeaderOK(): void |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | |
125 | 125 | $response = $this->get($core, '/'); |
126 | 126 | self::assertSame(200, $response->getStatusCode()); |
127 | - self::assertSame('all good', (string) $response->getBody()); |
|
127 | + self::assertSame('all good', (string)$response->getBody()); |
|
128 | 128 | |
129 | 129 | $cookies = $this->fetchCookies($response); |
130 | 130 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | ); |
144 | 144 | |
145 | 145 | self::assertSame(200, $response->getStatusCode()); |
146 | - self::assertSame('all good', (string) $response->getBody()); |
|
146 | + self::assertSame('all good', (string)$response->getBody()); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | public function testHeaderOKStrict(): void |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | ); |
174 | 174 | |
175 | 175 | self::assertSame(200, $response->getStatusCode()); |
176 | - self::assertSame('all good', (string) $response->getBody()); |
|
176 | + self::assertSame('all good', (string)$response->getBody()); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | protected function setUp(): void |
@@ -257,10 +257,10 @@ discard block |
||
257 | 257 | { |
258 | 258 | $result = []; |
259 | 259 | |
260 | - foreach ($response->getHeaders() as $header) { |
|
261 | - foreach ($header as $headerLine) { |
|
260 | + foreach ($response->getHeaders() as $header){ |
|
261 | + foreach ($header as $headerLine){ |
|
262 | 262 | $chunk = explode(';', $headerLine); |
263 | - if (mb_strpos($chunk[0], '=') === false) { |
|
263 | + if (mb_strpos($chunk[0], '=') === false){ |
|
264 | 264 | continue; |
265 | 265 | } |
266 | 266 |