Passed
Pull Request — master (#1095)
by Aleksei
12:04
created
src/Hmvc/tests/Unit/InterceptorPipelineTest.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -89,9 +89,9 @@  discard block
 block discarded – undo
89 89
             new ExceptionInterceptor(),
90 90
         ], self::createMock(CoreInterface::class));
91 91
 
92
-        try {
92
+        try{
93 93
             $pipeline->callAction('controller', 'action');
94
-        } catch (\RuntimeException) {
94
+        }catch (\RuntimeException){
95 95
             // Attributes won't be lost after legacy interceptor
96 96
             self::assertSame(['key' => 'value'], $state->context->getAttributes());
97 97
         }
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
      */
103 103
     private function createPipeline(
104 104
         array $interceptors = [],
105
-        CoreInterface|HandlerInterface|null $lastHandler = null,
106
-        EventDispatcherInterface|null $dispatcher = null,
105
+        CoreInterface | HandlerInterface | null $lastHandler = null,
106
+        EventDispatcherInterface | null $dispatcher = null,
107 107
     ): InterceptorPipeline
108 108
     {
109 109
         $pipeline = new InterceptorPipeline($dispatcher);
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
         $lastHandler instanceof CoreInterface and $pipeline = $pipeline->withCore($lastHandler);
112 112
         $lastHandler instanceof HandlerInterface and $pipeline = $pipeline->withHandler($lastHandler);
113 113
 
114
-        foreach ($interceptors as $interceptor) {
114
+        foreach ($interceptors as $interceptor){
115 115
             $pipeline->addInterceptor($interceptor);
116 116
         }
117 117
 
Please login to merge, or discard this patch.
Braces   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -89,9 +89,12 @@  discard block
 block discarded – undo
89 89
             new ExceptionInterceptor(),
90 90
         ], self::createMock(CoreInterface::class));
91 91
 
92
-        try {
92
+        try
93
+        {
93 94
             $pipeline->callAction('controller', 'action');
94
-        } catch (\RuntimeException) {
95
+        }
96
+        catch (\RuntimeException)
97
+        {
95 98
             // Attributes won't be lost after legacy interceptor
96 99
             self::assertSame(['key' => 'value'], $state->context->getAttributes());
97 100
         }
@@ -111,7 +114,8 @@  discard block
 block discarded – undo
111 114
         $lastHandler instanceof CoreInterface and $pipeline = $pipeline->withCore($lastHandler);
112 115
         $lastHandler instanceof HandlerInterface and $pipeline = $pipeline->withHandler($lastHandler);
113 116
 
114
-        foreach ($interceptors as $interceptor) {
117
+        foreach ($interceptors as $interceptor)
118
+        {
115 119
             $pipeline->addInterceptor($interceptor);
116 120
         }
117 121
 
Please login to merge, or discard this patch.
src/Hmvc/tests/Unit/Stub/Legacy/LegacyChangerInterceptor.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,8 +12,8 @@
 block discarded – undo
12 12
     public function __construct(
13 13
         private readonly ?string $controller = null,
14 14
         private readonly ?string $action = null,
15
-        private readonly ?array $parameters = null,
16
-    ) {
15
+        private readonly ? array $parameters = null,
16
+    ){
17 17
     }
18 18
 
19 19
     public function process(string $controller, string $action, array $parameters, CoreInterface $core): mixed
Please login to merge, or discard this patch.
src/Hmvc/tests/Unit/Stub/AddAttributeInterceptor.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
     public function __construct(
14 14
         private string $attribute,
15 15
         private mixed $value,
16
-    ) {
16
+    ){
17 17
     }
18 18
 
19 19
     public function intercept(CallContextInterface $context, HandlerInterface $handler): mixed
Please login to merge, or discard this patch.
src/Hmvc/src/Interceptors/Handler/ReflectionHandler.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
             $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
 
Please login to merge, or discard this patch.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -34,14 +34,16 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
             $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
 
Please login to merge, or discard this patch.
src/Hmvc/src/Interceptors/Event/InterceptorCalling.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,6 +12,6 @@
 block discarded – undo
12 12
     public function __construct(
13 13
         public readonly CallContextInterface $context,
14 14
         public readonly InterceptorInterface $interceptor,
15
-    ) {
15
+    ){
16 16
     }
17 17
 }
Please login to merge, or discard this patch.
src/Hmvc/src/Core/Exception/ControllerException.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@
 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
      * Unable to perform user action or find controller.
13 13
      *
Please login to merge, or discard this 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 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@
 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
      * @deprecated will be removed in Spiral v4.0
11 11
      * Use {@see \Spiral\Interceptors\Exception\InterceptorException} instead.
Please login to merge, or discard this 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 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -30,10 +30,10 @@  discard block
 block discarded – undo
30 30
 
31 31
     public function __construct(
32 32
         private readonly ?EventDispatcherInterface $dispatcher = null
33
-    ) {
33
+    ){
34 34
     }
35 35
 
36
-    public function addInterceptor(CoreInterceptorInterface|InterceptorInterface $interceptor): void
36
+    public function addInterceptor(CoreInterceptorInterface | InterceptorInterface $interceptor): void
37 37
     {
38 38
         $this->interceptors[] = $interceptor;
39 39
     }
@@ -59,13 +59,13 @@  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
             return $this->handle(
64 64
                 new CallContext(Target::fromPathArray([$controller, $action]), $parameters),
65 65
             );
66 66
         }
67 67
 
68
-        if ($this->context->getTarget()->getPath() === [$controller, $action]) {
68
+        if ($this->context->getTarget()->getPath() === [$controller, $action]){
69 69
             return $this->handle($this->context->withArguments($parameters));
70 70
         }
71 71
 
@@ -81,13 +81,13 @@  discard block
 block discarded – undo
81 81
      */
82 82
     public function handle(CallContext $context): mixed
83 83
     {
84
-        if ($this->core === null && $this->handler === null) {
84
+        if ($this->core === null && $this->handler === null){
85 85
             throw new InterceptorException('Unable to invoke pipeline without last handler.');
86 86
         }
87 87
 
88 88
         $path = $context->getTarget()->getPath();
89 89
 
90
-        if (isset($this->interceptors[$this->position])) {
90
+        if (isset($this->interceptors[$this->position])){
91 91
             $interceptor = $this->interceptors[$this->position];
92 92
             $handler = $this->nextWithContext($context);
93 93
 
Please login to merge, or discard this 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/InterceptableCore.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,11 +21,11 @@
 block discarded – undo
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
     }
Please login to merge, or discard this patch.