@@ -47,11 +47,13 @@ |
||
47 | 47 | */ |
48 | 48 | public function handle(CallContext $context): mixed |
49 | 49 | { |
50 | - if ($this->handler === null) { |
|
50 | + if ($this->handler === null) |
|
51 | + { |
|
51 | 52 | throw new InterceptorException('Unable to invoke pipeline without last handler.'); |
52 | 53 | } |
53 | 54 | |
54 | - if (isset($this->interceptors[$this->position])) { |
|
55 | + if (isset($this->interceptors[$this->position])) |
|
56 | + { |
|
55 | 57 | $interceptor = $this->interceptors[$this->position]; |
56 | 58 | |
57 | 59 | $this->dispatcher?->dispatch(new InterceptorCalling(context: $context, interceptor: $interceptor)); |
@@ -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. |
@@ -59,13 +59,15 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function callAction(string $controller, string $action, array $parameters = []): mixed |
61 | 61 | { |
62 | - if ($this->context === null) { |
|
62 | + if ($this->context === null) |
|
63 | + { |
|
63 | 64 | return $this->handle( |
64 | 65 | new CallContext(Target::fromPathArray([$controller, $action]), $parameters), |
65 | 66 | ); |
66 | 67 | } |
67 | 68 | |
68 | - if ($this->context->getTarget()->getPath() === [$controller, $action]) { |
|
69 | + if ($this->context->getTarget()->getPath() === [$controller, $action]) |
|
70 | + { |
|
69 | 71 | return $this->handle($this->context->withArguments($parameters)); |
70 | 72 | } |
71 | 73 | |
@@ -81,13 +83,15 @@ discard block |
||
81 | 83 | */ |
82 | 84 | public function handle(CallContext $context): mixed |
83 | 85 | { |
84 | - if ($this->core === null && $this->handler === null) { |
|
86 | + if ($this->core === null && $this->handler === null) |
|
87 | + { |
|
85 | 88 | throw new InterceptorException('Unable to invoke pipeline without last handler.'); |
86 | 89 | } |
87 | 90 | |
88 | 91 | $path = $context->getTarget()->getPath(); |
89 | 92 | |
90 | - if (isset($this->interceptors[$this->position])) { |
|
93 | + if (isset($this->interceptors[$this->position])) |
|
94 | + { |
|
91 | 95 | $interceptor = $this->interceptors[$this->position]; |
92 | 96 | $handler = $this->nextWithContext($context); |
93 | 97 |
@@ -20,7 +20,8 @@ discard block |
||
20 | 20 | public function testInterceptorCallingEventShouldBeDispatched(): void |
21 | 21 | { |
22 | 22 | $context = $this->createPathContext(['test', 'test2']); |
23 | - $interceptor = new class implements InterceptorInterface { |
|
23 | + $interceptor = new class implements InterceptorInterface |
|
24 | + { |
|
24 | 25 | public function intercept(CallContextInterface $context, HandlerInterface $handler): mixed |
25 | 26 | { |
26 | 27 | return null; |
@@ -39,7 +40,8 @@ discard block |
||
39 | 40 | $pipeline = $this->createPipeline(interceptors: [$interceptor], dispatcher: $dispatcher); |
40 | 41 | |
41 | 42 | $pipeline->withHandler( |
42 | - new class implements HandlerInterface { |
|
43 | + new class implements HandlerInterface |
|
44 | + { |
|
43 | 45 | public function handle(CallContext $context): mixed |
44 | 46 | { |
45 | 47 | return null; |
@@ -98,7 +100,8 @@ discard block |
||
98 | 100 | |
99 | 101 | $lastHandler instanceof HandlerInterface and $pipeline = $pipeline->withHandler($lastHandler); |
100 | 102 | |
101 | - foreach ($interceptors as $interceptor) { |
|
103 | + foreach ($interceptors as $interceptor) |
|
104 | + { |
|
102 | 105 | $pipeline->addInterceptor($interceptor); |
103 | 106 | } |
104 | 107 |
@@ -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 |
@@ -123,7 +123,8 @@ |
||
123 | 123 | public function createHandler(array $definitions = [], bool $resolveFromPath = true): ReflectionHandler |
124 | 124 | { |
125 | 125 | $container = new Container(); |
126 | - foreach ($definitions as $id => $definition) { |
|
126 | + foreach ($definitions as $id => $definition) |
|
127 | + { |
|
127 | 128 | $container->bind($id, $definition); |
128 | 129 | } |
129 | 130 |
@@ -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 |
@@ -19,10 +19,13 @@ discard block |
||
19 | 19 | */ |
20 | 20 | public static function pathToReflection(string $controller, string $action): \ReflectionMethod |
21 | 21 | { |
22 | - try { |
|
22 | + try |
|
23 | + { |
|
23 | 24 | /** @psalm-suppress ArgumentTypeCoercion */ |
24 | 25 | $method = new \ReflectionMethod($controller, $action); |
25 | - } catch (\ReflectionException $e) { |
|
26 | + } |
|
27 | + catch (\ReflectionException $e) |
|
28 | + { |
|
26 | 29 | throw new TargetCallException( |
27 | 30 | \sprintf('Invalid action `%s`->`%s`', $controller, $action), |
28 | 31 | TargetCallException::BAD_ACTION, |
@@ -39,7 +42,8 @@ discard block |
||
39 | 42 | */ |
40 | 43 | public static function validateControllerMethod(\ReflectionMethod $method, mixed $controller = null): void |
41 | 44 | { |
42 | - if ($method->isStatic() || !$method->isPublic()) { |
|
45 | + if ($method->isStatic() || !$method->isPublic()) |
|
46 | + { |
|
43 | 47 | throw new TargetCallException( |
44 | 48 | \sprintf( |
45 | 49 | 'Invalid action `%s`->`%s`', |
@@ -50,11 +54,13 @@ discard block |
||
50 | 54 | ); |
51 | 55 | } |
52 | 56 | |
53 | - if ($controller === null) { |
|
57 | + if ($controller === null) |
|
58 | + { |
|
54 | 59 | return; |
55 | 60 | } |
56 | 61 | |
57 | - if (!\is_object($controller) || !$method->getDeclaringClass()->isInstance($controller)) { |
|
62 | + if (!\is_object($controller) || !$method->getDeclaringClass()->isInstance($controller)) |
|
63 | + { |
|
58 | 64 | throw new TargetCallException( |
59 | 65 | \sprintf( |
60 | 66 | 'Invalid controller. Expected instance of `%s`, got `%s`.', |