Passed
Pull Request — master (#1095)
by Aleksei
11:58 queued 42s
created
src/Hmvc/src/Interceptors/Handler/InterceptorPipeline.php 1 patch
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -47,11 +47,13 @@
 block discarded – undo
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));
Please login to merge, or discard this patch.
src/Hmvc/src/Core/Exception/ControllerException.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,8 @@
 block discarded – undo
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
      *
Please login to merge, or discard this patch.
src/Hmvc/src/Core/Exception/InterceptorException.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,8 @@
 block discarded – undo
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.
Please login to merge, or discard this patch.
src/Hmvc/src/Core/InterceptorPipeline.php 1 patch
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -59,13 +59,15 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Hmvc/src/Core/AbstractCore.php 1 patch
Braces   +12 added lines, -5 removed lines patch added patch discarded remove patch
@@ -41,7 +41,8 @@  discard block
 block discarded – undo
41 41
         $method = ActionResolver::pathToReflection($controller, $action);
42 42
 
43 43
         // Validate method
44
-        if ($method->isStatic() || !$method->isPublic()) {
44
+        if ($method->isStatic() || !$method->isPublic())
45
+        {
45 46
             throw new ControllerException(
46 47
                 \sprintf(
47 48
                     'Invalid action `%s`->`%s`',
@@ -52,15 +53,20 @@  discard block
 block discarded – undo
52 53
             );
53 54
         }
54 55
 
55
-        try {
56
+        try
57
+        {
56 58
             $args = $this->resolveArguments($method, $parameters);
57
-        } catch (ArgumentResolvingException|InvalidArgumentException $e) {
59
+        }
60
+        catch (ArgumentResolvingException|InvalidArgumentException $e)
61
+        {
58 62
             throw new ControllerException(
59 63
                 \sprintf('Missing/invalid parameter %s of `%s`->`%s`', $e->getParameter(), $controller, $action),
60 64
                 ControllerException::BAD_ARGUMENT,
61 65
                 $e,
62 66
             );
63
-        } catch (ContainerExceptionInterface $e) {
67
+        }
68
+        catch (ContainerExceptionInterface $e)
69
+        {
64 70
             throw new ControllerException(
65 71
                 $e->getMessage(),
66 72
                 ControllerException::ERROR,
@@ -78,7 +84,8 @@  discard block
 block discarded – undo
78 84
 
79 85
     protected function resolveArguments(\ReflectionMethod $method, array $parameters): array
80 86
     {
81
-        foreach ($method->getParameters() as $parameter) {
87
+        foreach ($method->getParameters() as $parameter)
88
+        {
82 89
             $name = $parameter->getName();
83 90
             if (
84 91
                 \array_key_exists($name, $parameters) &&
Please login to merge, or discard this patch.
src/Hmvc/tests/Interceptors/Unit/Handler/InterceptorPipelineTest.php 1 patch
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,7 +20,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Hmvc/tests/Interceptors/Unit/Stub/MultipleCallNextInterceptor.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,8 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Hmvc/tests/Interceptors/Unit/Handler/ReflectionHandlerTest.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -123,7 +123,8 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Hmvc/tests/Core/Unit/Stub/MultipleCallNextInterceptor.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,8 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.