@@ -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 | } |
@@ -12,6 +12,6 @@ |
||
12 | 12 | public function __construct( |
13 | 13 | public readonly CallContextInterface $context, |
14 | 14 | public readonly InterceptorInterface $interceptor, |
15 | - ) { |
|
15 | + ){ |
|
16 | 16 | } |
17 | 17 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | |
28 | 28 | public function __construct( |
29 | 29 | private readonly ?EventDispatcherInterface $dispatcher = null |
30 | - ) { |
|
30 | + ){ |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | public function withInterceptors(InterceptorInterface ...$interceptors): self |
37 | 37 | { |
38 | 38 | $clone = clone $this; |
39 | - foreach ($interceptors as $interceptor) { |
|
39 | + foreach ($interceptors as $interceptor){ |
|
40 | 40 | $clone->interceptors[] = $interceptor; |
41 | 41 | } |
42 | 42 | |
@@ -55,11 +55,11 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public function handle(CallContextInterface $context): mixed |
57 | 57 | { |
58 | - if ($this->handler === null) { |
|
58 | + if ($this->handler === null){ |
|
59 | 59 | throw new InterceptorException('Unable to invoke pipeline without last handler.'); |
60 | 60 | } |
61 | 61 | |
62 | - if (isset($this->interceptors[$this->position])) { |
|
62 | + if (isset($this->interceptors[$this->position])){ |
|
63 | 63 | $interceptor = $this->interceptors[$this->position]; |
64 | 64 | |
65 | 65 | $this->dispatcher?->dispatch(new InterceptorCalling(context: $context, interceptor: $interceptor)); |
@@ -36,7 +36,8 @@ discard block |
||
36 | 36 | public function withInterceptors(InterceptorInterface ...$interceptors): self |
37 | 37 | { |
38 | 38 | $clone = clone $this; |
39 | - foreach ($interceptors as $interceptor) { |
|
39 | + foreach ($interceptors as $interceptor) |
|
40 | + { |
|
40 | 41 | $clone->interceptors[] = $interceptor; |
41 | 42 | } |
42 | 43 | |
@@ -55,11 +56,13 @@ discard block |
||
55 | 56 | */ |
56 | 57 | public function handle(CallContextInterface $context): mixed |
57 | 58 | { |
58 | - if ($this->handler === null) { |
|
59 | + if ($this->handler === null) |
|
60 | + { |
|
59 | 61 | throw new InterceptorException('Unable to invoke pipeline without last handler.'); |
60 | 62 | } |
61 | 63 | |
62 | - if (isset($this->interceptors[$this->position])) { |
|
64 | + if (isset($this->interceptors[$this->position])) |
|
65 | + { |
|
63 | 66 | $interceptor = $this->interceptors[$this->position]; |
64 | 67 | |
65 | 68 | $this->dispatcher?->dispatch(new InterceptorCalling(context: $context, interceptor: $interceptor)); |
@@ -14,13 +14,13 @@ |
||
14 | 14 | |
15 | 15 | public function __construct( |
16 | 16 | private readonly int $counter, |
17 | - ) { |
|
17 | + ){ |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | public function intercept(CallContextInterface $context, HandlerInterface $handler): mixed |
21 | 21 | { |
22 | 22 | $this->result = []; |
23 | - for ($i = 0; $i < $this->counter; ++$i) { |
|
23 | + for ($i = 0; $i < $this->counter; ++$i){ |
|
24 | 24 | $this->result[] = $handler->handle($context); |
25 | 25 | } |
26 | 26 |
@@ -20,7 +20,8 @@ |
||
20 | 20 | public function intercept(CallContextInterface $context, HandlerInterface $handler): mixed |
21 | 21 | { |
22 | 22 | $this->result = []; |
23 | - for ($i = 0; $i < $this->counter; ++$i) { |
|
23 | + for ($i = 0; $i < $this->counter; ++$i) |
|
24 | + { |
|
24 | 25 | $this->result[] = $handler->handle($context); |
25 | 26 | } |
26 | 27 |
@@ -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 |
@@ -28,17 +28,17 @@ |
||
28 | 28 | $this->pipeline = clone $this->pipeline; |
29 | 29 | } |
30 | 30 | |
31 | - public function withInterceptors(CoreInterceptorInterface|InterceptorInterface ...$interceptors): static |
|
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 | $clone->pipeline->addInterceptor($interceptor); |
36 | 36 | } |
37 | 37 | |
38 | 38 | return $clone; |
39 | 39 | } |
40 | 40 | |
41 | - public function build(HandlerInterface|CoreInterface $handler): InterceptorPipeline |
|
41 | + public function build(HandlerInterface | CoreInterface $handler): InterceptorPipeline |
|
42 | 42 | { |
43 | 43 | /** @psalm-suppress InvalidArgument */ |
44 | 44 | 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,7 @@ |
||
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. |
@@ -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. |
@@ -31,10 +31,10 @@ discard block |
||
31 | 31 | |
32 | 32 | public function __construct( |
33 | 33 | private readonly ?EventDispatcherInterface $dispatcher = null |
34 | - ) { |
|
34 | + ){ |
|
35 | 35 | } |
36 | 36 | |
37 | - public function addInterceptor(CoreInterceptorInterface|InterceptorInterface $interceptor): void |
|
37 | + public function addInterceptor(CoreInterceptorInterface | InterceptorInterface $interceptor): void |
|
38 | 38 | { |
39 | 39 | $this->interceptors[] = $interceptor; |
40 | 40 | } |
@@ -66,13 +66,13 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function callAction(string $controller, string $action, array $parameters = []): mixed |
68 | 68 | { |
69 | - if ($this->context === null) { |
|
69 | + if ($this->context === null){ |
|
70 | 70 | return $this->handle( |
71 | 71 | new CallContext(Target::fromPathArray([$controller, $action]), $parameters), |
72 | 72 | ); |
73 | 73 | } |
74 | 74 | |
75 | - if ($this->context->getTarget()->getPath() === [$controller, $action]) { |
|
75 | + if ($this->context->getTarget()->getPath() === [$controller, $action]){ |
|
76 | 76 | return $this->handle($this->context->withArguments($parameters)); |
77 | 77 | } |
78 | 78 | |
@@ -88,13 +88,13 @@ discard block |
||
88 | 88 | */ |
89 | 89 | public function handle(CallContextInterface $context): mixed |
90 | 90 | { |
91 | - if ($this->core === null && $this->handler === null) { |
|
91 | + if ($this->core === null && $this->handler === null){ |
|
92 | 92 | throw new InterceptorException('Unable to invoke pipeline without last handler.'); |
93 | 93 | } |
94 | 94 | |
95 | 95 | $path = $context->getTarget()->getPath(); |
96 | 96 | |
97 | - if (isset($this->interceptors[$this->position])) { |
|
97 | + if (isset($this->interceptors[$this->position])){ |
|
98 | 98 | $interceptor = $this->interceptors[$this->position]; |
99 | 99 | $handler = $this->nextWithContext($context); |
100 | 100 |
@@ -66,13 +66,15 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function callAction(string $controller, string $action, array $parameters = []): mixed |
68 | 68 | { |
69 | - if ($this->context === null) { |
|
69 | + if ($this->context === null) |
|
70 | + { |
|
70 | 71 | return $this->handle( |
71 | 72 | new CallContext(Target::fromPathArray([$controller, $action]), $parameters), |
72 | 73 | ); |
73 | 74 | } |
74 | 75 | |
75 | - if ($this->context->getTarget()->getPath() === [$controller, $action]) { |
|
76 | + if ($this->context->getTarget()->getPath() === [$controller, $action]) |
|
77 | + { |
|
76 | 78 | return $this->handle($this->context->withArguments($parameters)); |
77 | 79 | } |
78 | 80 | |
@@ -88,13 +90,15 @@ discard block |
||
88 | 90 | */ |
89 | 91 | public function handle(CallContextInterface $context): mixed |
90 | 92 | { |
91 | - if ($this->core === null && $this->handler === null) { |
|
93 | + if ($this->core === null && $this->handler === null) |
|
94 | + { |
|
92 | 95 | throw new InterceptorException('Unable to invoke pipeline without last handler.'); |
93 | 96 | } |
94 | 97 | |
95 | 98 | $path = $context->getTarget()->getPath(); |
96 | 99 | |
97 | - if (isset($this->interceptors[$this->position])) { |
|
100 | + if (isset($this->interceptors[$this->position])) |
|
101 | + { |
|
98 | 102 | $interceptor = $this->interceptors[$this->position]; |
99 | 103 | $handler = $this->nextWithContext($context); |
100 | 104 |
@@ -21,11 +21,11 @@ |
||
21 | 21 | public function __construct( |
22 | 22 | private readonly CoreInterface $core, |
23 | 23 | ?EventDispatcherInterface $dispatcher = null |
24 | - ) { |
|
24 | + ){ |
|
25 | 25 | $this->pipeline = new InterceptorPipeline($dispatcher); |
26 | 26 | } |
27 | 27 | |
28 | - public function addInterceptor(CoreInterceptorInterface|InterceptorInterface $interceptor): void |
|
28 | + public function addInterceptor(CoreInterceptorInterface | InterceptorInterface $interceptor): void |
|
29 | 29 | { |
30 | 30 | $this->pipeline->addInterceptor($interceptor); |
31 | 31 | } |