@@ -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 | } |
@@ -20,9 +20,9 @@ |
||
20 | 20 | * as the first argument. Otherwise, {@see InvokerInterface::invoke()} will be used to invoke the closure. |
21 | 21 | */ |
22 | 22 | public function __construct( |
23 | - public readonly string|\BackedEnum|null $name = null, |
|
23 | + public readonly string | \BackedEnum | null $name = null, |
|
24 | 24 | public readonly array $bindings = [], |
25 | 25 | public readonly bool $autowire = true, |
26 | - ) { |
|
26 | + ){ |
|
27 | 27 | } |
28 | 28 | } |
@@ -62,7 +62,8 @@ discard block |
||
62 | 62 | string|\BackedEnum|null $scopeName = self::DEFAULT_ROOT_SCOPE_NAME, |
63 | 63 | private Options $options = new Options(), |
64 | 64 | ) { |
65 | - if (\is_object($scopeName)) { |
|
65 | + if (\is_object($scopeName)) |
|
66 | + { |
|
66 | 67 | $scopeName = (string) $scopeName->value; |
67 | 68 | } |
68 | 69 | |
@@ -177,23 +178,29 @@ discard block |
||
177 | 178 | */ |
178 | 179 | public function runScope(Scope|array $bindings, callable $scope): mixed |
179 | 180 | { |
180 | - if (!\is_array($bindings)) { |
|
181 | + if (!\is_array($bindings)) |
|
182 | + { |
|
181 | 183 | return $this->runIsolatedScope($bindings, $scope); |
182 | 184 | } |
183 | 185 | |
184 | 186 | $binds = &$this->state->bindings; |
185 | 187 | $singletons = &$this->state->singletons; |
186 | 188 | $cleanup = $previous = $prevSin = []; |
187 | - foreach ($bindings as $alias => $resolver) { |
|
189 | + foreach ($bindings as $alias => $resolver) |
|
190 | + { |
|
188 | 191 | // Store previous bindings |
189 | - if (isset($binds[$alias])) { |
|
192 | + if (isset($binds[$alias])) |
|
193 | + { |
|
190 | 194 | $previous[$alias] = $binds[$alias]; |
191 | - } else { |
|
195 | + } |
|
196 | + else |
|
197 | + { |
|
192 | 198 | // Store bindings to be removed |
193 | 199 | $cleanup[] = $alias; |
194 | 200 | } |
195 | 201 | // Store previous singletons |
196 | - if (isset($singletons[$alias])) { |
|
202 | + if (isset($singletons[$alias])) |
|
203 | + { |
|
197 | 204 | $prevSin[$alias] = $singletons[$alias]; |
198 | 205 | unset($singletons[$alias]); |
199 | 206 | } |
@@ -201,21 +208,27 @@ discard block |
||
201 | 208 | $this->binder->bind($alias, $resolver); |
202 | 209 | } |
203 | 210 | |
204 | - try { |
|
211 | + try |
|
212 | + { |
|
205 | 213 | return ContainerScope::getContainer() !== $this |
206 | 214 | ? ContainerScope::runScope($this, $scope) |
207 | 215 | : $scope($this); |
208 | - } finally { |
|
216 | + } |
|
217 | + finally |
|
218 | + { |
|
209 | 219 | // Remove new bindings |
210 | - foreach ($cleanup as $alias) { |
|
220 | + foreach ($cleanup as $alias) |
|
221 | + { |
|
211 | 222 | unset($binds[$alias], $singletons[$alias]); |
212 | 223 | } |
213 | 224 | // Restore previous bindings |
214 | - foreach ($previous as $alias => $resolver) { |
|
225 | + foreach ($previous as $alias => $resolver) |
|
226 | + { |
|
215 | 227 | $binds[$alias] = $resolver; |
216 | 228 | } |
217 | 229 | // Restore singletons |
218 | - foreach ($prevSin as $alias => $instance) { |
|
230 | + foreach ($prevSin as $alias => $instance) |
|
231 | + { |
|
219 | 232 | $singletons[$alias] = $instance; |
220 | 233 | } |
221 | 234 | } |
@@ -263,7 +276,8 @@ discard block |
||
263 | 276 | */ |
264 | 277 | public function bindSingleton(string $alias, string|array|callable|object $resolver, bool $force = true): void |
265 | 278 | { |
266 | - if ($force) { |
|
279 | + if ($force) |
|
280 | + { |
|
267 | 281 | $this->binder->removeBinding($alias); |
268 | 282 | } |
269 | 283 | |
@@ -334,8 +348,10 @@ discard block |
||
334 | 348 | ], $this->options); |
335 | 349 | |
336 | 350 | // Create container services |
337 | - foreach ($container->config as $property => $class) { |
|
338 | - if (\property_exists($container, $property)) { |
|
351 | + foreach ($container->config as $property => $class) |
|
352 | + { |
|
353 | + if (\property_exists($container, $property)) |
|
354 | + { |
|
339 | 355 | $container->$property = $constructor->get($property, $class); |
340 | 356 | } |
341 | 357 | } |
@@ -349,7 +365,8 @@ discard block |
||
349 | 365 | private function closeScope(): void |
350 | 366 | { |
351 | 367 | /** @psalm-suppress RedundantPropertyInitializationCheck */ |
352 | - if (!isset($this->scope)) { |
|
368 | + if (!isset($this->scope)) |
|
369 | + { |
|
353 | 370 | $this->destruct(); |
354 | 371 | return; |
355 | 372 | } |
@@ -358,10 +375,14 @@ discard block |
||
358 | 375 | |
359 | 376 | // Run finalizers |
360 | 377 | $errors = []; |
361 | - foreach ($this->state->finalizers as $finalizer) { |
|
362 | - try { |
|
378 | + foreach ($this->state->finalizers as $finalizer) |
|
379 | + { |
|
380 | + try |
|
381 | + { |
|
363 | 382 | $this->invoker->invoke($finalizer); |
364 | - } catch (\Throwable $e) { |
|
383 | + } |
|
384 | + catch (\Throwable $e) |
|
385 | + { |
|
365 | 386 | $errors[] = $e; |
366 | 387 | } |
367 | 388 | } |
@@ -370,7 +391,8 @@ discard block |
||
370 | 391 | $this->destruct(); |
371 | 392 | |
372 | 393 | // Throw collected errors |
373 | - if ($errors !== []) { |
|
394 | + if ($errors !== []) |
|
395 | + { |
|
374 | 396 | throw new FinalizersException($scopeName, $errors); |
375 | 397 | } |
376 | 398 | } |
@@ -392,18 +414,22 @@ discard block |
||
392 | 414 | $container->scope->setParent($this, $this->scope, $this->factory); |
393 | 415 | |
394 | 416 | // Add specific bindings |
395 | - foreach ($config->bindings as $alias => $resolver) { |
|
417 | + foreach ($config->bindings as $alias => $resolver) |
|
418 | + { |
|
396 | 419 | $container->binder->bind($alias, $resolver); |
397 | 420 | } |
398 | 421 | |
399 | 422 | return ContainerScope::runScope( |
400 | 423 | $container, |
401 | 424 | static function (self $container) use ($config, $closure): mixed { |
402 | - try { |
|
425 | + try |
|
426 | + { |
|
403 | 427 | return $config->autowire |
404 | 428 | ? $container->invoke($closure) |
405 | 429 | : $closure($container); |
406 | - } finally { |
|
430 | + } |
|
431 | + finally |
|
432 | + { |
|
407 | 433 | $container->closeScope(); |
408 | 434 | } |
409 | 435 | } |
@@ -47,11 +47,11 @@ discard block |
||
47 | 47 | public const DEFAULT_ROOT_SCOPE_NAME = 'root'; |
48 | 48 | |
49 | 49 | private Internal\State $state; |
50 | - private ResolverInterface|Internal\Resolver $resolver; |
|
51 | - private FactoryInterface|Internal\Factory $factory; |
|
52 | - private ContainerInterface|Internal\Container $container; |
|
53 | - private BinderInterface|Internal\Binder $binder; |
|
54 | - private InvokerInterface|Internal\Invoker $invoker; |
|
50 | + private ResolverInterface | Internal\Resolver $resolver; |
|
51 | + private FactoryInterface | Internal\Factory $factory; |
|
52 | + private ContainerInterface | Internal\Container $container; |
|
53 | + private BinderInterface | Internal\Binder $binder; |
|
54 | + private InvokerInterface | Internal\Invoker $invoker; |
|
55 | 55 | private Internal\Scope $scope; |
56 | 56 | |
57 | 57 | /** |
@@ -59,11 +59,11 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function __construct( |
61 | 61 | private Config $config = new Config(), |
62 | - string|\BackedEnum|null $scopeName = self::DEFAULT_ROOT_SCOPE_NAME, |
|
62 | + string | \BackedEnum | null $scopeName = self::DEFAULT_ROOT_SCOPE_NAME, |
|
63 | 63 | private Options $options = new Options(), |
64 | - ) { |
|
65 | - if (\is_object($scopeName)) { |
|
66 | - $scopeName = (string) $scopeName->value; |
|
64 | + ){ |
|
65 | + if (\is_object($scopeName)){ |
|
66 | + $scopeName = (string)$scopeName->value; |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | $this->initServices($this, $scopeName); |
@@ -117,11 +117,11 @@ discard block |
||
117 | 117 | * @throws \Throwable |
118 | 118 | * @psalm-suppress TooManyArguments |
119 | 119 | */ |
120 | - public function make(string $alias, array $parameters = [], \Stringable|string|null $context = null): mixed |
|
120 | + public function make(string $alias, array $parameters = [], \Stringable | string | null $context = null): mixed |
|
121 | 121 | { |
122 | 122 | return ContainerScope::getContainer() === $this |
123 | 123 | ? $this->factory->make($alias, $parameters, $context) |
124 | - : ContainerScope::runScope($this, fn (): mixed => $this->factory->make($alias, $parameters, $context)); |
|
124 | + : ContainerScope::runScope($this, fn () : mixed => $this->factory->make($alias, $parameters, $context)); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * @throws \Throwable |
144 | 144 | * @psalm-suppress TooManyArguments |
145 | 145 | */ |
146 | - public function get(string|Autowire $id, \Stringable|string|null $context = null): mixed |
|
146 | + public function get(string | Autowire $id, \Stringable | string | null $context = null): mixed |
|
147 | 147 | { |
148 | 148 | return ContainerScope::getContainer() === $this |
149 | 149 | ? $this->container->get($id, $context) |
@@ -163,9 +163,9 @@ discard block |
||
163 | 163 | * If {@see string}, the default binder for the given scope will be returned. Default bindings won't affect |
164 | 164 | * already created Container instances except the case with the root one. |
165 | 165 | */ |
166 | - public function getBinder(string|\BackedEnum|null $scope = null): BinderInterface |
|
166 | + public function getBinder(string | \BackedEnum | null $scope = null): BinderInterface |
|
167 | 167 | { |
168 | - $scope = \is_object($scope) ? (string) $scope->value : $scope; |
|
168 | + $scope = \is_object($scope) ? (string)$scope->value : $scope; |
|
169 | 169 | |
170 | 170 | return $scope === null |
171 | 171 | ? $this->binder |
@@ -175,25 +175,25 @@ discard block |
||
175 | 175 | /** |
176 | 176 | * @throws \Throwable |
177 | 177 | */ |
178 | - public function runScope(Scope|array $bindings, callable $scope): mixed |
|
178 | + public function runScope(Scope | array $bindings, callable $scope): mixed |
|
179 | 179 | { |
180 | - if (!\is_array($bindings)) { |
|
180 | + if (!\is_array($bindings)){ |
|
181 | 181 | return $this->runIsolatedScope($bindings, $scope); |
182 | 182 | } |
183 | 183 | |
184 | 184 | $binds = &$this->state->bindings; |
185 | 185 | $singletons = &$this->state->singletons; |
186 | 186 | $cleanup = $previous = $prevSin = []; |
187 | - foreach ($bindings as $alias => $resolver) { |
|
187 | + foreach ($bindings as $alias => $resolver){ |
|
188 | 188 | // Store previous bindings |
189 | - if (isset($binds[$alias])) { |
|
189 | + if (isset($binds[$alias])){ |
|
190 | 190 | $previous[$alias] = $binds[$alias]; |
191 | - } else { |
|
191 | + }else{ |
|
192 | 192 | // Store bindings to be removed |
193 | 193 | $cleanup[] = $alias; |
194 | 194 | } |
195 | 195 | // Store previous singletons |
196 | - if (isset($singletons[$alias])) { |
|
196 | + if (isset($singletons[$alias])){ |
|
197 | 197 | $prevSin[$alias] = $singletons[$alias]; |
198 | 198 | unset($singletons[$alias]); |
199 | 199 | } |
@@ -201,21 +201,21 @@ discard block |
||
201 | 201 | $this->binder->bind($alias, $resolver); |
202 | 202 | } |
203 | 203 | |
204 | - try { |
|
204 | + try{ |
|
205 | 205 | return ContainerScope::getContainer() !== $this |
206 | 206 | ? ContainerScope::runScope($this, $scope) |
207 | 207 | : $scope($this); |
208 | - } finally { |
|
208 | + }finally{ |
|
209 | 209 | // Remove new bindings |
210 | - foreach ($cleanup as $alias) { |
|
210 | + foreach ($cleanup as $alias){ |
|
211 | 211 | unset($binds[$alias], $singletons[$alias]); |
212 | 212 | } |
213 | 213 | // Restore previous bindings |
214 | - foreach ($previous as $alias => $resolver) { |
|
214 | + foreach ($previous as $alias => $resolver){ |
|
215 | 215 | $binds[$alias] = $resolver; |
216 | 216 | } |
217 | 217 | // Restore singletons |
218 | - foreach ($prevSin as $alias => $instance) { |
|
218 | + foreach ($prevSin as $alias => $instance){ |
|
219 | 219 | $singletons[$alias] = $instance; |
220 | 220 | } |
221 | 221 | } |
@@ -261,9 +261,9 @@ discard block |
||
261 | 261 | * @param bool $force If the value is false, an exception will be thrown when attempting |
262 | 262 | * to bind an already constructed singleton. |
263 | 263 | */ |
264 | - public function bindSingleton(string $alias, string|array|callable|object $resolver, bool $force = true): void |
|
264 | + public function bindSingleton(string $alias, string | array | callable | object $resolver, bool $force = true): void |
|
265 | 265 | { |
266 | - if ($force) { |
|
266 | + if ($force){ |
|
267 | 267 | $this->binder->removeBinding($alias); |
268 | 268 | } |
269 | 269 | |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | { |
291 | 291 | return ContainerScope::getContainer() === $this |
292 | 292 | ? $this->invoker->invoke($target, $parameters) |
293 | - : ContainerScope::runScope($this, fn (): mixed => $this->invoker->invoke($target, $parameters)); |
|
293 | + : ContainerScope::runScope($this, fn () : mixed => $this->invoker->invoke($target, $parameters)); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | /** |
@@ -334,8 +334,8 @@ discard block |
||
334 | 334 | ], $this->options); |
335 | 335 | |
336 | 336 | // Create container services |
337 | - foreach ($container->config as $property => $class) { |
|
338 | - if (\property_exists($container, $property)) { |
|
337 | + foreach ($container->config as $property => $class){ |
|
338 | + if (\property_exists($container, $property)){ |
|
339 | 339 | $container->$property = $constructor->get($property, $class); |
340 | 340 | } |
341 | 341 | } |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | private function closeScope(): void |
350 | 350 | { |
351 | 351 | /** @psalm-suppress RedundantPropertyInitializationCheck */ |
352 | - if (!isset($this->scope)) { |
|
352 | + if (!isset($this->scope)){ |
|
353 | 353 | $this->destruct(); |
354 | 354 | return; |
355 | 355 | } |
@@ -358,10 +358,10 @@ discard block |
||
358 | 358 | |
359 | 359 | // Run finalizers |
360 | 360 | $errors = []; |
361 | - foreach ($this->state->finalizers as $finalizer) { |
|
362 | - try { |
|
361 | + foreach ($this->state->finalizers as $finalizer){ |
|
362 | + try{ |
|
363 | 363 | $this->invoker->invoke($finalizer); |
364 | - } catch (\Throwable $e) { |
|
364 | + }catch (\Throwable $e){ |
|
365 | 365 | $errors[] = $e; |
366 | 366 | } |
367 | 367 | } |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | $this->destruct(); |
371 | 371 | |
372 | 372 | // Throw collected errors |
373 | - if ($errors !== []) { |
|
373 | + if ($errors !== []){ |
|
374 | 374 | throw new FinalizersException($scopeName, $errors); |
375 | 375 | } |
376 | 376 | } |
@@ -392,18 +392,18 @@ discard block |
||
392 | 392 | $container->scope->setParent($this, $this->scope, $this->factory); |
393 | 393 | |
394 | 394 | // Add specific bindings |
395 | - foreach ($config->bindings as $alias => $resolver) { |
|
395 | + foreach ($config->bindings as $alias => $resolver){ |
|
396 | 396 | $container->binder->bind($alias, $resolver); |
397 | 397 | } |
398 | 398 | |
399 | 399 | return ContainerScope::runScope( |
400 | 400 | $container, |
401 | 401 | static function (self $container) use ($config, $closure): mixed { |
402 | - try { |
|
402 | + try{ |
|
403 | 403 | return $config->autowire |
404 | 404 | ? $container->invoke($closure) |
405 | 405 | : $closure($container); |
406 | - } finally { |
|
406 | + }finally{ |
|
407 | 407 | $container->closeScope(); |
408 | 408 | } |
409 | 409 | } |
@@ -11,7 +11,7 @@ |
||
11 | 11 | final class DispatcherScope |
12 | 12 | { |
13 | 13 | public function __construct( |
14 | - public readonly string|\BackedEnum $scope |
|
15 | - ) { |
|
14 | + public readonly string | \BackedEnum $scope |
|
15 | + ){ |
|
16 | 16 | } |
17 | 17 | } |
@@ -93,22 +93,28 @@ |
||
93 | 93 | |
94 | 94 | public static function provideRenderMethod(): iterable |
95 | 95 | { |
96 | - $class = new class { |
|
96 | + $class = new class |
|
97 | + { |
|
97 | 98 | public const INT_CONST = 42; |
98 | 99 | |
99 | 100 | #[ExpectedAttribute('public function test1(...$variadic)')] |
100 | - public function test1(...$variadic) {} |
|
101 | + public function test1(...$variadic) |
|
102 | + { |
|
103 | +} |
|
101 | 104 | #[ExpectedAttribute('public function test2(mixed $string = self::INT_CONST): string|int')] |
102 | 105 | public function test2(string|int $string = self::INT_CONST): string|int {} |
103 | 106 | #[ExpectedAttribute('public function test3(mixed $obj = new \stdClass(new \stdClass(), new \stdClass()))')] |
104 | - public function test3(object $obj = new stdClass(new stdClass(), new stdClass())) {} |
|
107 | + public function test3(object $obj = new stdClass(new stdClass(), new stdClass())) |
|
108 | + { |
|
109 | +} |
|
105 | 110 | #[ExpectedAttribute('public function test4(): \\' . ProxyClassRendererTest::class)] |
106 | 111 | public function test4(): ProxyClassRendererTest {} |
107 | 112 | #[ExpectedAttribute('public function &test5(): string')] |
108 | 113 | public function &test5(): string {} |
109 | 114 | }; |
110 | 115 | |
111 | - foreach ((new \ReflectionClass($class))->getMethods() as $method) { |
|
116 | + foreach ((new \ReflectionClass($class))->getMethods() as $method) |
|
117 | + { |
|
112 | 118 | $expected = $method->getAttributes(ExpectedAttribute::class)[0]->newInstance(); |
113 | 119 | |
114 | 120 | yield [$method, $expected->value]; |
@@ -56,24 +56,24 @@ discard block |
||
56 | 56 | yield [$from(fn(string $string = self::STRING_CONST) => 0), 'mixed $string = self::STRING_CONST']; |
57 | 57 | yield [ |
58 | 58 | $from(fn(string $string = ProxyClassRendererTest::STRING_CONST) => 0), |
59 | - 'mixed $string = \\' . self::class . '::STRING_CONST', |
|
59 | + 'mixed $string = \\'.self::class.'::STRING_CONST', |
|
60 | 60 | ]; |
61 | - yield [$from(fn(string|int $string = self::INT_CONST) => 0), 'mixed $string = self::INT_CONST']; |
|
61 | + yield [$from(fn(string | int $string = self::INT_CONST) => 0), 'mixed $string = self::INT_CONST']; |
|
62 | 62 | yield [$from(fn(mixed $string = 42) => 0), 'mixed $string = 42']; |
63 | 63 | yield [$from(fn(int $string = 42) => 0), 'mixed $string = 42']; |
64 | 64 | yield [$from(fn(float $string = 42) => 0), 'mixed $string = 42.0']; |
65 | 65 | yield [$from(fn(?bool $string = false) => 0), 'mixed $string = false']; |
66 | - yield [$from(fn(bool|null $string = true) => 0), 'mixed $string = true']; |
|
66 | + yield [$from(fn(bool | null $string = true) => 0), 'mixed $string = true']; |
|
67 | 67 | yield [$from(fn(?object $string = null) => 0), 'mixed $string = NULL']; |
68 | 68 | yield [$from(fn(?iterable $string = null) => 0), 'mixed $string = NULL']; |
69 | 69 | yield [$from(fn(Countable&ArrayAccess $val) => 0), 'mixed $val']; |
70 | 70 | yield [$from(fn(string ...$val) => 0), 'mixed ...$val']; |
71 | - yield [$from(fn(string|int ...$val) => 0), 'mixed ...$val']; |
|
72 | - yield [$from(fn(string|int &$link) => 0), 'mixed &$link']; |
|
71 | + yield [$from(fn(string | int ...$val) => 0), 'mixed ...$val']; |
|
72 | + yield [$from(fn(string | int &$link) => 0), 'mixed &$link']; |
|
73 | 73 | yield [$from(self::withSelf(...)), 'mixed $self = new self()']; |
74 | 74 | yield [$from(fn(object $link = new \stdClass()) => 0), 'mixed $link = new \stdClass()']; |
75 | 75 | yield [ |
76 | - $from(fn(#[Proxy] float|int|\stdClass|null $string = new \stdClass(1, 2, bar: "\n'zero")) => 0), |
|
76 | + $from(fn(#[Proxy] float | int | \stdClass | null $string = new \stdClass(1, 2, bar: "\n'zero")) => 0), |
|
77 | 77 | "mixed \$string = new \stdClass(1, 2, bar: '\n\'zero')", |
78 | 78 | ]; |
79 | 79 | yield [ |
@@ -97,18 +97,18 @@ discard block |
||
97 | 97 | public const INT_CONST = 42; |
98 | 98 | |
99 | 99 | #[ExpectedAttribute('public function test1(...$variadic)')] |
100 | - public function test1(...$variadic) {} |
|
100 | + public function test1(...$variadic){} |
|
101 | 101 | #[ExpectedAttribute('public function test2(mixed $string = self::INT_CONST): string|int')] |
102 | - public function test2(string|int $string = self::INT_CONST): string|int {} |
|
102 | + public function test2(string | int $string = self::INT_CONST): string | int {} |
|
103 | 103 | #[ExpectedAttribute('public function test3(mixed $obj = new \stdClass(new \stdClass(), new \stdClass()))')] |
104 | - public function test3(object $obj = new stdClass(new stdClass(), new stdClass())) {} |
|
105 | - #[ExpectedAttribute('public function test4(): \\' . ProxyClassRendererTest::class)] |
|
104 | + public function test3(object $obj = new stdClass(new stdClass(), new stdClass())){} |
|
105 | + #[ExpectedAttribute('public function test4(): \\'.ProxyClassRendererTest::class)] |
|
106 | 106 | public function test4(): ProxyClassRendererTest {} |
107 | 107 | #[ExpectedAttribute('public function &test5(): string')] |
108 | 108 | public function &test5(): string {} |
109 | 109 | }; |
110 | 110 | |
111 | - foreach ((new \ReflectionClass($class))->getMethods() as $method) { |
|
111 | + foreach ((new \ReflectionClass($class))->getMethods() as $method){ |
|
112 | 112 | $expected = $method->getAttributes(ExpectedAttribute::class)[0]->newInstance(); |
113 | 113 | |
114 | 114 | yield [$method, $expected->value]; |
@@ -145,22 +145,22 @@ discard block |
||
145 | 145 | $from = static fn(\Closure $closure): \ReflectionParameter => new \ReflectionParameter($closure, 0); |
146 | 146 | |
147 | 147 | yield [$from(fn(string $string) => 0), 'string']; |
148 | - yield [$from(fn(string|int $string) => 0), 'string|int']; |
|
148 | + yield [$from(fn(string | int $string) => 0), 'string|int']; |
|
149 | 149 | yield [$from(fn(mixed $string) => 0), 'mixed']; |
150 | 150 | yield [$from(fn(int $string) => 0), 'int']; |
151 | 151 | yield [$from(fn(float $string) => 0), 'float']; |
152 | 152 | yield [$from(fn(?bool $string) => 0), '?bool']; |
153 | - yield [$from(fn(bool|null $string) => 0), '?bool']; |
|
153 | + yield [$from(fn(bool | null $string) => 0), '?bool']; |
|
154 | 154 | yield [$from(fn(object $string) => 0), 'object']; |
155 | 155 | yield [$from(fn(iterable $string) => 0), 'iterable']; |
156 | 156 | yield [$from(fn(Countable&ArrayAccess $val) => 0), '\Countable&\ArrayAccess']; |
157 | 157 | yield [$from(fn(string ...$val) => 0), 'string']; |
158 | - yield [$from(fn(string|int ...$val) => 0), 'string|int']; |
|
159 | - yield [$from(fn(string|int &$link) => 0), 'string|int']; |
|
160 | - yield [$from(self::withSelf(...)), '\\' . self::class]; |
|
158 | + yield [$from(fn(string | int ...$val) => 0), 'string|int']; |
|
159 | + yield [$from(fn(string | int &$link) => 0), 'string|int']; |
|
160 | + yield [$from(self::withSelf(...)), '\\'.self::class]; |
|
161 | 161 | yield [$from(fn(object $link) => 0), 'object']; |
162 | - yield [$from(fn(#[Proxy] float|int|\stdClass|null $string) => 0), '\stdClass|int|float|null']; |
|
163 | - yield [$from(fn(SimpleEnum $val) => 0), '\\' . SimpleEnum::class]; |
|
162 | + yield [$from(fn(#[Proxy] float | int | \stdClass | null $string) => 0), '\stdClass|int|float|null']; |
|
163 | + yield [$from(fn(SimpleEnum $val) => 0), '\\'.SimpleEnum::class]; |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | private static function withSelf(self $self = new self()): void |
@@ -173,6 +173,6 @@ discard block |
||
173 | 173 | { |
174 | 174 | public function __construct( |
175 | 175 | public readonly string $value, |
176 | - ) { |
|
176 | + ){ |
|
177 | 177 | } |
178 | 178 | } |
@@ -8,12 +8,12 @@ |
||
8 | 8 | { |
9 | 9 | public function __construct( |
10 | 10 | private string $name, |
11 | - ) { |
|
11 | + ){ |
|
12 | 12 | } |
13 | 13 | |
14 | - public function setName(string|\Stringable $name): void |
|
14 | + public function setName(string | \Stringable $name): void |
|
15 | 15 | { |
16 | - $this->name = (string) $name; |
|
16 | + $this->name = (string)$name; |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | public function getName(): string |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | |
48 | 48 | public function __construct( |
49 | 49 | private readonly ConfiguratorInterface $config, |
50 | - ) { |
|
50 | + ){ |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | public function init(BinderInterface $binder, DirectoriesInterface $dirs, EnvironmentInterface $env): void |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | 'migrations', |
70 | 70 | ], |
71 | 71 | 'cache' => [ |
72 | - 'directory' => $dirs->get('runtime') . 'cache/listeners', |
|
72 | + 'directory' => $dirs->get('runtime').'cache/listeners', |
|
73 | 73 | 'enabled' => \filter_var($env->get('TOKENIZER_CACHE_TARGETS', false), \FILTER_VALIDATE_BOOL), |
74 | 74 | ], |
75 | 75 | 'load' => [ |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | |
104 | 104 | $this->config->modify( |
105 | 105 | TokenizerConfig::CONFIG, |
106 | - new Append('scopes.' . $scope . '.directories', null, $directory), |
|
106 | + new Append('scopes.'.$scope.'.directories', null, $directory), |
|
107 | 107 | ); |
108 | 108 | } |
109 | 109 | |
@@ -118,20 +118,20 @@ discard block |
||
118 | 118 | |
119 | 119 | $this->config->modify( |
120 | 120 | TokenizerConfig::CONFIG, |
121 | - new Append('scopes.' . $scope . '.exclude', null, $directory), |
|
121 | + new Append('scopes.'.$scope.'.exclude', null, $directory), |
|
122 | 122 | ); |
123 | 123 | } |
124 | 124 | |
125 | 125 | private function ensureScopeExists(string $scope, string $section): void |
126 | 126 | { |
127 | - if (!isset($this->config->getConfig(TokenizerConfig::CONFIG)['scopes'])) { |
|
127 | + if (!isset($this->config->getConfig(TokenizerConfig::CONFIG)['scopes'])){ |
|
128 | 128 | $this->config->modify( |
129 | 129 | TokenizerConfig::CONFIG, |
130 | 130 | new Set('scopes', []), |
131 | 131 | ); |
132 | 132 | } |
133 | 133 | |
134 | - if (!isset($this->config->getConfig(TokenizerConfig::CONFIG)['scopes'][$scope])) { |
|
134 | + if (!isset($this->config->getConfig(TokenizerConfig::CONFIG)['scopes'][$scope])){ |
|
135 | 135 | $this->config->modify( |
136 | 136 | TokenizerConfig::CONFIG, |
137 | 137 | new Append('scopes', $scope, [$section => []]), |
@@ -124,14 +124,16 @@ |
||
124 | 124 | |
125 | 125 | private function ensureScopeExists(string $scope, string $section): void |
126 | 126 | { |
127 | - if (!isset($this->config->getConfig(TokenizerConfig::CONFIG)['scopes'])) { |
|
127 | + if (!isset($this->config->getConfig(TokenizerConfig::CONFIG)['scopes'])) |
|
128 | + { |
|
128 | 129 | $this->config->modify( |
129 | 130 | TokenizerConfig::CONFIG, |
130 | 131 | new Set('scopes', []), |
131 | 132 | ); |
132 | 133 | } |
133 | 134 | |
134 | - if (!isset($this->config->getConfig(TokenizerConfig::CONFIG)['scopes'][$scope])) { |
|
135 | + if (!isset($this->config->getConfig(TokenizerConfig::CONFIG)['scopes'][$scope])) |
|
136 | + { |
|
135 | 137 | $this->config->modify( |
136 | 138 | TokenizerConfig::CONFIG, |
137 | 139 | new Append('scopes', $scope, [$section => []]), |
@@ -89,9 +89,9 @@ discard block |
||
89 | 89 | new ExceptionInterceptor(), |
90 | 90 | ], self::createMock(CoreInterface::class)); |
91 | 91 | |
92 | - try { |
|
92 | + try{ |
|
93 | 93 | $pipeline->callAction('controller', 'action'); |
94 | - } catch (\RuntimeException) { |
|
94 | + }catch (\RuntimeException){ |
|
95 | 95 | // Attributes won't be lost after legacy interceptor |
96 | 96 | self::assertSame(['key' => 'value'], $state->context->getAttributes()); |
97 | 97 | } |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | */ |
103 | 103 | private function createPipeline( |
104 | 104 | array $interceptors = [], |
105 | - CoreInterface|HandlerInterface|null $lastHandler = null, |
|
106 | - EventDispatcherInterface|null $dispatcher = null, |
|
105 | + CoreInterface | HandlerInterface | null $lastHandler = null, |
|
106 | + EventDispatcherInterface | null $dispatcher = null, |
|
107 | 107 | ): InterceptorPipeline |
108 | 108 | { |
109 | 109 | $pipeline = new InterceptorPipeline($dispatcher); |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | $lastHandler instanceof CoreInterface and $pipeline = $pipeline->withCore($lastHandler); |
112 | 112 | $lastHandler instanceof HandlerInterface and $pipeline = $pipeline->withHandler($lastHandler); |
113 | 113 | |
114 | - foreach ($interceptors as $interceptor) { |
|
114 | + foreach ($interceptors as $interceptor){ |
|
115 | 115 | $pipeline->addInterceptor($interceptor); |
116 | 116 | } |
117 | 117 |
@@ -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 |
@@ -12,8 +12,8 @@ |
||
12 | 12 | public function __construct( |
13 | 13 | private readonly ?string $controller = null, |
14 | 14 | private readonly ?string $action = null, |
15 | - private readonly ?array $parameters = null, |
|
16 | - ) { |
|
15 | + private readonly ? array $parameters = null, |
|
16 | + ){ |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | public function process(string $controller, string $action, array $parameters, CoreInterface $core): mixed |