@@ -13,11 +13,11 @@ |
||
13 | 13 | public function __construct( |
14 | 14 | public readonly string $alias, |
15 | 15 | public readonly ?string $bindingScope = null, |
16 | - public readonly ?array $callingScope = null, |
|
17 | - ) { |
|
16 | + public readonly ? array $callingScope = null, |
|
17 | + ){ |
|
18 | 18 | $message = "Recursive proxy detected for `$alias`."; |
19 | 19 | $bindingScope === null or $message .= "\nBinding scope: `$bindingScope`."; |
20 | - $callingScope === null or $message .= "\nCalling scope: `" . \implode('.', $callingScope) . '`.'; |
|
20 | + $callingScope === null or $message .= "\nCalling scope: `".\implode('.', $callingScope).'`.'; |
|
21 | 21 | parent::__construct($message); |
22 | 22 | } |
23 | 23 | } |
@@ -17,8 +17,8 @@ |
||
17 | 17 | public function __construct( |
18 | 18 | protected readonly string $interface, |
19 | 19 | public readonly bool $singleton = false, |
20 | - public readonly ?\Closure $fallbackFactory = null, |
|
21 | - ) { |
|
20 | + public readonly ? \Closure $fallbackFactory = null, |
|
21 | + ){ |
|
22 | 22 | \interface_exists($interface) or throw new \InvalidArgumentException( |
23 | 23 | "Interface `{$interface}` does not exist.", |
24 | 24 | ); |
@@ -24,12 +24,15 @@ discard block |
||
24 | 24 | ): object { |
25 | 25 | $c ??= ContainerScope::getContainer() ?? throw new ContainerException('Proxy is out of scope.'); |
26 | 26 | |
27 | - try { |
|
27 | + try |
|
28 | + { |
|
28 | 29 | /** @psalm-suppress TooManyArguments */ |
29 | 30 | $result = $c->get($alias, $context) ?? throw new ContainerException( |
30 | 31 | 'Resolved `null` from the container.', |
31 | 32 | ); |
32 | - } catch (\Throwable $e) { |
|
33 | + } |
|
34 | + catch (\Throwable $e) |
|
35 | + { |
|
33 | 36 | $scope = self::getScope($c); |
34 | 37 | throw new ContainerException( |
35 | 38 | $scope === null |
@@ -39,7 +42,8 @@ discard block |
||
39 | 42 | ); |
40 | 43 | } |
41 | 44 | |
42 | - if (!Proxy::isProxy($result)) { |
|
45 | + if (!Proxy::isProxy($result)) |
|
46 | + { |
|
43 | 47 | return $result; |
44 | 48 | } |
45 | 49 | |
@@ -48,10 +52,13 @@ discard block |
||
48 | 52 | * to try to get the instance from the Proxy Fallback Factory. |
49 | 53 | * If there is no the Proxy Fallback Factory, {@see RecursiveProxyException} will be thrown. |
50 | 54 | */ |
51 | - try { |
|
55 | + try |
|
56 | + { |
|
52 | 57 | /** @psalm-suppress TooManyArguments */ |
53 | 58 | $result = $c->get($alias, new RetryContext($context)); |
54 | - } catch (RecursiveProxyException $e) { |
|
59 | + } |
|
60 | + catch (RecursiveProxyException $e) |
|
61 | + { |
|
55 | 62 | throw new RecursiveProxyException($e->alias, $e->bindingScope, self::getScope($c)); |
56 | 63 | } |
57 | 64 | |
@@ -66,8 +73,10 @@ discard block |
||
66 | 73 | */ |
67 | 74 | private static function getScope(ContainerInterface $c): ?array |
68 | 75 | { |
69 | - if (!$c instanceof Container) { |
|
70 | - if (!Proxy::isProxy($c)) { |
|
76 | + if (!$c instanceof Container) |
|
77 | + { |
|
78 | + if (!Proxy::isProxy($c)) |
|
79 | + { |
|
71 | 80 | return null; |
72 | 81 | } |
73 | 82 |
@@ -19,27 +19,27 @@ discard block |
||
19 | 19 | { |
20 | 20 | public static function resolve( |
21 | 21 | string $alias, |
22 | - \Stringable|string|null $context = null, |
|
22 | + \Stringable | string | null $context = null, |
|
23 | 23 | ?ContainerInterface $c = null, |
24 | 24 | ): object { |
25 | 25 | $c ??= ContainerScope::getContainer() ?? throw new ContainerException('Proxy is out of scope.'); |
26 | 26 | |
27 | - try { |
|
27 | + try{ |
|
28 | 28 | /** @psalm-suppress TooManyArguments */ |
29 | 29 | $result = $c->get($alias, $context) ?? throw new ContainerException( |
30 | 30 | 'Resolved `null` from the container.', |
31 | 31 | ); |
32 | - } catch (\Throwable $e) { |
|
32 | + }catch (\Throwable $e){ |
|
33 | 33 | $scope = self::getScope($c); |
34 | 34 | throw new ContainerException( |
35 | 35 | $scope === null |
36 | 36 | ? "Unable to resolve `{$alias}` in a Proxy." |
37 | 37 | : \sprintf('Unable to resolve `%s` in a Proxy in `%s` scope.', $alias, \implode('.', $scope)), |
38 | - previous: $e, |
|
38 | + previous : $e, |
|
39 | 39 | ); |
40 | 40 | } |
41 | 41 | |
42 | - if (!Proxy::isProxy($result)) { |
|
42 | + if (!Proxy::isProxy($result)){ |
|
43 | 43 | return $result; |
44 | 44 | } |
45 | 45 | |
@@ -48,10 +48,10 @@ discard block |
||
48 | 48 | * to try to get the instance from the Proxy Fallback Factory. |
49 | 49 | * If there is no the Proxy Fallback Factory, {@see RecursiveProxyException} will be thrown. |
50 | 50 | */ |
51 | - try { |
|
51 | + try{ |
|
52 | 52 | /** @psalm-suppress TooManyArguments */ |
53 | 53 | $result = $c->get($alias, new RetryContext($context)); |
54 | - } catch (RecursiveProxyException $e) { |
|
54 | + }catch (RecursiveProxyException $e){ |
|
55 | 55 | throw new RecursiveProxyException($e->alias, $e->bindingScope, self::getScope($c)); |
56 | 56 | } |
57 | 57 | |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | */ |
67 | 67 | private static function getScope(ContainerInterface $c): ?array |
68 | 68 | { |
69 | - if (!$c instanceof Container) { |
|
70 | - if (!Proxy::isProxy($c)) { |
|
69 | + if (!$c instanceof Container){ |
|
70 | + if (!Proxy::isProxy($c)){ |
|
71 | 71 | return null; |
72 | 72 | } |
73 | 73 | |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | } |
76 | 76 | |
77 | 77 | return \array_reverse(\array_map( |
78 | - static fn(?string $name): string => $name ?? 'null', |
|
78 | + static fn(?string $name) : string => $name ?? 'null', |
|
79 | 79 | Introspector::scopeNames($c), |
80 | 80 | )); |
81 | 81 | } |
@@ -19,7 +19,8 @@ discard block |
||
19 | 19 | { |
20 | 20 | public function init(HttpBootloader $http): void |
21 | 21 | { |
22 | - foreach ($this->globalMiddleware() as $middleware) { |
|
22 | + foreach ($this->globalMiddleware() as $middleware) |
|
23 | + { |
|
23 | 24 | $http->addMiddleware($middleware); |
24 | 25 | } |
25 | 26 | } |
@@ -61,7 +62,8 @@ discard block |
||
61 | 62 | |
62 | 63 | private function registerMiddlewareGroups(BinderInterface $binder, array $groups): void |
63 | 64 | { |
64 | - foreach ($groups as $group => $middleware) { |
|
65 | + foreach ($groups as $group => $middleware) |
|
66 | + { |
|
65 | 67 | $binder |
66 | 68 | ->getBinder('http') |
67 | 69 | ->bind( |
@@ -75,7 +77,8 @@ discard block |
||
75 | 77 | |
76 | 78 | private function registerMiddlewareForRouteGroups(GroupRegistry $registry, array $groups): void |
77 | 79 | { |
78 | - foreach ($groups as $group) { |
|
80 | + foreach ($groups as $group) |
|
81 | + { |
|
79 | 82 | $registry->getGroup($group)->addMiddleware('middleware:' . $group); |
80 | 83 | } |
81 | 84 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | { |
18 | 18 | public function init(HttpBootloader $http): void |
19 | 19 | { |
20 | - foreach ($this->globalMiddleware() as $middleware) { |
|
20 | + foreach ($this->globalMiddleware() as $middleware){ |
|
21 | 21 | $http->addMiddleware($middleware); |
22 | 22 | } |
23 | 23 | } |
@@ -55,11 +55,11 @@ discard block |
||
55 | 55 | |
56 | 56 | private function registerMiddlewareGroups(BinderInterface $binder, array $groups): void |
57 | 57 | { |
58 | - foreach ($groups as $group => $middleware) { |
|
58 | + foreach ($groups as $group => $middleware){ |
|
59 | 59 | $binder |
60 | 60 | ->getBinder('http') |
61 | 61 | ->bind( |
62 | - 'middleware:' . $group, |
|
62 | + 'middleware:'.$group, |
|
63 | 63 | static function (FactoryInterface $factory) use ($middleware): LazyPipeline { |
64 | 64 | return $factory->make(LazyPipeline::class)->withAddedMiddleware(...$middleware); |
65 | 65 | }, |
@@ -69,8 +69,8 @@ discard block |
||
69 | 69 | |
70 | 70 | private function registerMiddlewareForRouteGroups(GroupRegistry $registry, array $groups): void |
71 | 71 | { |
72 | - foreach ($groups as $group) { |
|
73 | - $registry->getGroup($group)->addMiddleware('middleware:' . $group); |
|
72 | + foreach ($groups as $group){ |
|
73 | + $registry->getGroup($group)->addMiddleware('middleware:'.$group); |
|
74 | 74 | } |
75 | 75 | } |
76 | 76 | } |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | { |
21 | 21 | use ContainerTrait; |
22 | 22 | |
23 | - protected Pipeline|LazyPipeline|null $pipeline = null; |
|
23 | + protected Pipeline | LazyPipeline | null $pipeline = null; |
|
24 | 24 | |
25 | 25 | /** @psalm-var array<array-key, MiddlewareType> */ |
26 | 26 | protected array $middleware = []; |
@@ -44,16 +44,16 @@ discard block |
||
44 | 44 | $route = clone $this; |
45 | 45 | |
46 | 46 | // array fallback |
47 | - if (\count($middleware) === 1 && \is_array($middleware[0])) { |
|
47 | + if (\count($middleware) === 1 && \is_array($middleware[0])){ |
|
48 | 48 | $middleware = $middleware[0]; |
49 | 49 | } |
50 | 50 | |
51 | 51 | /** @var MiddlewareType[] $middleware */ |
52 | - foreach ($middleware as $item) { |
|
52 | + foreach ($middleware as $item){ |
|
53 | 53 | $route->middleware[] = $item; |
54 | 54 | } |
55 | 55 | |
56 | - if ($route->pipeline !== null) { |
|
56 | + if ($route->pipeline !== null){ |
|
57 | 57 | $route->pipeline = $route->makeLazyPipeline(); |
58 | 58 | } |
59 | 59 | |
@@ -80,11 +80,11 @@ discard block |
||
80 | 80 | protected function makePipeline(): Pipeline |
81 | 81 | { |
82 | 82 | \assert($this->container !== null); |
83 | - try { |
|
83 | + try{ |
|
84 | 84 | return $this->container |
85 | 85 | ->get(PipelineFactory::class) |
86 | 86 | ->createWithMiddleware($this->middleware); |
87 | - } catch (ContainerExceptionInterface $e) { |
|
87 | + }catch (ContainerExceptionInterface $e){ |
|
88 | 88 | throw new RouteException($e->getMessage(), $e->getCode(), $e); |
89 | 89 | } |
90 | 90 | } |
@@ -97,11 +97,11 @@ discard block |
||
97 | 97 | protected function makeLazyPipeline(): LazyPipeline |
98 | 98 | { |
99 | 99 | \assert($this->container !== null); |
100 | - try { |
|
100 | + try{ |
|
101 | 101 | /** @var LazyPipeline $pipeline */ |
102 | 102 | $pipeline = $this->container->get(LazyPipeline::class); |
103 | 103 | return $pipeline->withMiddleware(...$this->middleware); |
104 | - } catch (ContainerExceptionInterface $e) { |
|
104 | + }catch (ContainerExceptionInterface $e){ |
|
105 | 105 | throw new RouteException($e->getMessage(), $e->getCode(), $e); |
106 | 106 | } |
107 | 107 | } |
@@ -44,16 +44,19 @@ discard block |
||
44 | 44 | $route = clone $this; |
45 | 45 | |
46 | 46 | // array fallback |
47 | - if (\count($middleware) === 1 && \is_array($middleware[0])) { |
|
47 | + if (\count($middleware) === 1 && \is_array($middleware[0])) |
|
48 | + { |
|
48 | 49 | $middleware = $middleware[0]; |
49 | 50 | } |
50 | 51 | |
51 | 52 | /** @var MiddlewareType[] $middleware */ |
52 | - foreach ($middleware as $item) { |
|
53 | + foreach ($middleware as $item) |
|
54 | + { |
|
53 | 55 | $route->middleware[] = $item; |
54 | 56 | } |
55 | 57 | |
56 | - if ($route->pipeline !== null) { |
|
58 | + if ($route->pipeline !== null) |
|
59 | + { |
|
57 | 60 | $route->pipeline = $route->makeLazyPipeline(); |
58 | 61 | } |
59 | 62 | |
@@ -80,11 +83,14 @@ discard block |
||
80 | 83 | protected function makePipeline(): Pipeline |
81 | 84 | { |
82 | 85 | \assert($this->container !== null); |
83 | - try { |
|
86 | + try |
|
87 | + { |
|
84 | 88 | return $this->container |
85 | 89 | ->get(PipelineFactory::class) |
86 | 90 | ->createWithMiddleware($this->middleware); |
87 | - } catch (ContainerExceptionInterface $e) { |
|
91 | + } |
|
92 | + catch (ContainerExceptionInterface $e) |
|
93 | + { |
|
88 | 94 | throw new RouteException($e->getMessage(), $e->getCode(), $e); |
89 | 95 | } |
90 | 96 | } |
@@ -97,11 +103,14 @@ discard block |
||
97 | 103 | protected function makeLazyPipeline(): LazyPipeline |
98 | 104 | { |
99 | 105 | \assert($this->container !== null); |
100 | - try { |
|
106 | + try |
|
107 | + { |
|
101 | 108 | /** @var LazyPipeline $pipeline */ |
102 | 109 | $pipeline = $this->container->get(LazyPipeline::class); |
103 | 110 | return $pipeline->withMiddleware(...$this->middleware); |
104 | - } catch (ContainerExceptionInterface $e) { |
|
111 | + } |
|
112 | + catch (ContainerExceptionInterface $e) |
|
113 | + { |
|
105 | 114 | throw new RouteException($e->getMessage(), $e->getCode(), $e); |
106 | 115 | } |
107 | 116 | } |
@@ -6,7 +6,7 @@ |
||
6 | 6 | |
7 | 7 | final class UserContext |
8 | 8 | { |
9 | - private function __construct() {} |
|
9 | + private function __construct(){} |
|
10 | 10 | |
11 | 11 | public static function create(): self |
12 | 12 | { |
@@ -6,7 +6,9 @@ |
||
6 | 6 | |
7 | 7 | final class UserContext |
8 | 8 | { |
9 | - private function __construct() {} |
|
9 | + private function __construct() |
|
10 | + { |
|
11 | +} |
|
10 | 12 | |
11 | 13 | public static function create(): self |
12 | 14 | { |
@@ -8,7 +8,7 @@ |
||
8 | 8 | { |
9 | 9 | public function __construct( |
10 | 10 | private readonly UserContext $scope, |
11 | - ) {} |
|
11 | + ){} |
|
12 | 12 | |
13 | 13 | public function scope(): string |
14 | 14 | { |
@@ -8,7 +8,8 @@ |
||
8 | 8 | { |
9 | 9 | public function __construct( |
10 | 10 | private readonly UserContext $scope, |
11 | - ) {} |
|
11 | + ) { |
|
12 | +} |
|
12 | 13 | |
13 | 14 | public function scope(): string |
14 | 15 | { |
@@ -7,4 +7,4 @@ |
||
7 | 7 | /** |
8 | 8 | * Triggered before cache item is deleted. |
9 | 9 | */ |
10 | -final class KeyDeleting extends CacheEvent {} |
|
10 | +final class KeyDeleting extends CacheEvent{} |
@@ -7,4 +7,6 @@ |
||
7 | 7 | /** |
8 | 8 | * Triggered before cache item is deleted. |
9 | 9 | */ |
10 | -final class KeyDeleting extends CacheEvent {} |
|
10 | +final class KeyDeleting extends CacheEvent |
|
11 | +{ |
|
12 | +} |
@@ -16,15 +16,15 @@ |
||
16 | 16 | */ |
17 | 17 | public function __construct(array $loaders = []) |
18 | 18 | { |
19 | - foreach ($loaders as $loader) { |
|
19 | + foreach ($loaders as $loader){ |
|
20 | 20 | $this->addLoader($loader); |
21 | 21 | } |
22 | 22 | } |
23 | 23 | |
24 | - public function resolve(mixed $resource, ?string $type = null): LoaderInterface|false |
|
24 | + public function resolve(mixed $resource, ?string $type = null): LoaderInterface | false |
|
25 | 25 | { |
26 | - foreach ($this->loaders as $loader) { |
|
27 | - if ($loader->supports($resource, $type)) { |
|
26 | + foreach ($this->loaders as $loader){ |
|
27 | + if ($loader->supports($resource, $type)){ |
|
28 | 28 | return $loader; |
29 | 29 | } |
30 | 30 | } |
@@ -16,15 +16,18 @@ |
||
16 | 16 | */ |
17 | 17 | public function __construct(array $loaders = []) |
18 | 18 | { |
19 | - foreach ($loaders as $loader) { |
|
19 | + foreach ($loaders as $loader) |
|
20 | + { |
|
20 | 21 | $this->addLoader($loader); |
21 | 22 | } |
22 | 23 | } |
23 | 24 | |
24 | 25 | public function resolve(mixed $resource, ?string $type = null): LoaderInterface|false |
25 | 26 | { |
26 | - foreach ($this->loaders as $loader) { |
|
27 | - if ($loader->supports($resource, $type)) { |
|
27 | + foreach ($this->loaders as $loader) |
|
28 | + { |
|
29 | + if ($loader->supports($resource, $type)) |
|
30 | + { |
|
28 | 31 | return $loader; |
29 | 32 | } |
30 | 33 | } |