@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | { |
40 | 40 | $handler = $this->createHandler(); |
41 | 41 | // Call Context |
42 | - $ctx = new CallContext(Target::fromReflection(new class extends \ReflectionFunctionAbstract { |
|
42 | + $ctx = new CallContext(Target::fromReflection(new class extends \ReflectionFunctionAbstract{ |
|
43 | 43 | /** @psalm-immutable */ |
44 | 44 | public function getName(): string |
45 | 45 | { |
@@ -123,7 +123,7 @@ discard block |
||
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 | $container->bind($id, $definition); |
128 | 128 | } |
129 | 129 |
@@ -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 |
@@ -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 |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | /** @internal */ |
23 | 23 | protected ContainerInterface $container, |
24 | 24 | protected bool $resolveFromPath = true, |
25 | - ) { |
|
25 | + ){ |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | /** |
@@ -34,14 +34,14 @@ discard block |
||
34 | 34 | { |
35 | 35 | // Resolve controller method |
36 | 36 | $method = $context->getTarget()->getReflection(); |
37 | - if ($method === null) { |
|
37 | + if ($method === null){ |
|
38 | 38 | $this->resolveFromPath or throw new TargetCallException( |
39 | 39 | "Reflection not provided for target `{$context->getTarget()}`.", |
40 | 40 | TargetCallException::NOT_FOUND, |
41 | 41 | ); |
42 | 42 | |
43 | 43 | $path = $context->getTarget()->getPath(); |
44 | - if (\count($path) !== 2) { |
|
44 | + if (\count($path) !== 2){ |
|
45 | 45 | throw new TargetCallException( |
46 | 46 | "Invalid target path to resolve reflection for `{$context->getTarget()}`." |
47 | 47 | . ' Expected two parts: class and method.', |
@@ -52,13 +52,13 @@ discard block |
||
52 | 52 | $method = ActionResolver::pathToReflection(\reset($path), \end($path)); |
53 | 53 | } |
54 | 54 | |
55 | - if ($method instanceof \ReflectionFunction) { |
|
55 | + if ($method instanceof \ReflectionFunction){ |
|
56 | 56 | return $method->invokeArgs( |
57 | 57 | $this->resolveArguments($method, $context) |
58 | 58 | ); |
59 | 59 | } |
60 | 60 | |
61 | - if (!$method instanceof \ReflectionMethod) { |
|
61 | + if (!$method instanceof \ReflectionMethod){ |
|
62 | 62 | throw new TargetCallException("Action not found for target `{$context->getTarget()}`."); |
63 | 63 | } |
64 | 64 |
@@ -34,14 +34,16 @@ discard block |
||
34 | 34 | { |
35 | 35 | // Resolve controller method |
36 | 36 | $method = $context->getTarget()->getReflection(); |
37 | - if ($method === null) { |
|
37 | + if ($method === null) |
|
38 | + { |
|
38 | 39 | $this->resolveFromPath or throw new TargetCallException( |
39 | 40 | "Reflection not provided for target `{$context->getTarget()}`.", |
40 | 41 | TargetCallException::NOT_FOUND, |
41 | 42 | ); |
42 | 43 | |
43 | 44 | $path = $context->getTarget()->getPath(); |
44 | - if (\count($path) !== 2) { |
|
45 | + if (\count($path) !== 2) |
|
46 | + { |
|
45 | 47 | throw new TargetCallException( |
46 | 48 | "Invalid target path to resolve reflection for `{$context->getTarget()}`." |
47 | 49 | . ' Expected two parts: class and method.', |
@@ -52,13 +54,15 @@ discard block |
||
52 | 54 | $method = ActionResolver::pathToReflection(\reset($path), \end($path)); |
53 | 55 | } |
54 | 56 | |
55 | - if ($method instanceof \ReflectionFunction) { |
|
57 | + if ($method instanceof \ReflectionFunction) |
|
58 | + { |
|
56 | 59 | return $method->invokeArgs( |
57 | 60 | $this->resolveArguments($method, $context) |
58 | 61 | ); |
59 | 62 | } |
60 | 63 | |
61 | - if (!$method instanceof \ReflectionMethod) { |
|
64 | + if (!$method instanceof \ReflectionMethod) |
|
65 | + { |
|
62 | 66 | throw new TargetCallException("Action not found for target `{$context->getTarget()}`."); |
63 | 67 | } |
64 | 68 |
@@ -19,10 +19,10 @@ discard block |
||
19 | 19 | */ |
20 | 20 | public static function pathToReflection(string $controller, string $action): \ReflectionMethod |
21 | 21 | { |
22 | - try { |
|
22 | + try{ |
|
23 | 23 | /** @psalm-suppress ArgumentTypeCoercion */ |
24 | 24 | $method = new \ReflectionMethod($controller, $action); |
25 | - } catch (\ReflectionException $e) { |
|
25 | + }catch (\ReflectionException $e){ |
|
26 | 26 | throw new TargetCallException( |
27 | 27 | \sprintf('Invalid action `%s`->`%s`', $controller, $action), |
28 | 28 | TargetCallException::BAD_ACTION, |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public static function validateControllerMethod(\ReflectionMethod $method, mixed $controller = null): void |
41 | 41 | { |
42 | - if ($method->isStatic() || !$method->isPublic()) { |
|
42 | + if ($method->isStatic() || !$method->isPublic()){ |
|
43 | 43 | throw new TargetCallException( |
44 | 44 | \sprintf( |
45 | 45 | 'Invalid action `%s`->`%s`', |
@@ -50,11 +50,11 @@ discard block |
||
50 | 50 | ); |
51 | 51 | } |
52 | 52 | |
53 | - if ($controller === null) { |
|
53 | + if ($controller === null){ |
|
54 | 54 | return; |
55 | 55 | } |
56 | 56 | |
57 | - if (!\is_object($controller) || !$method->getDeclaringClass()->isInstance($controller)) { |
|
57 | + if (!\is_object($controller) || !$method->getDeclaringClass()->isInstance($controller)){ |
|
58 | 58 | throw new TargetCallException( |
59 | 59 | \sprintf( |
60 | 60 | 'Invalid controller. Expected instance of `%s`, got `%s`.', |
@@ -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`.', |