Passed
Pull Request — master (#1104)
by Aleksei
26:20
created
src/Hmvc/src/Interceptors/Handler/InterceptorPipeline.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 
28 28
     public function __construct(
29 29
         private readonly ?EventDispatcherInterface $dispatcher = null
30
-    ) {
30
+    ){
31 31
     }
32 32
 
33 33
     public function addInterceptor(InterceptorInterface $interceptor): void
@@ -47,11 +47,11 @@  discard block
 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
             throw new InterceptorException('Unable to invoke pipeline without last handler.');
52 52
         }
53 53
 
54
-        if (isset($this->interceptors[$this->position])) {
54
+        if (isset($this->interceptors[$this->position])){
55 55
             $interceptor = $this->interceptors[$this->position];
56 56
 
57 57
             $this->dispatcher?->dispatch(new InterceptorCalling(context: $context, interceptor: $interceptor));
Please login to merge, or discard this 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/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.
src/Hmvc/tests/Interceptors/Unit/Handler/InterceptorPipelineTest.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  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
             public function intercept(CallContextInterface $context, HandlerInterface $handler): mixed
25 25
             {
26 26
                 return null;
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
         $pipeline = $this->createPipeline(interceptors: [$interceptor], dispatcher: $dispatcher);
40 40
 
41 41
         $pipeline->withHandler(
42
-            new class implements HandlerInterface {
42
+            new class implements HandlerInterface{
43 43
                 public function handle(CallContext $context): mixed
44 44
                 {
45 45
                     return null;
@@ -91,14 +91,14 @@  discard block
 block discarded – undo
91 91
      */
92 92
     private function createPipeline(
93 93
         array $interceptors = [],
94
-        HandlerInterface|null $lastHandler = null,
95
-        EventDispatcherInterface|null $dispatcher = null,
94
+        HandlerInterface | null $lastHandler = null,
95
+        EventDispatcherInterface | null $dispatcher = null,
96 96
     ): InterceptorPipeline {
97 97
         $pipeline = new InterceptorPipeline($dispatcher);
98 98
 
99 99
         $lastHandler instanceof HandlerInterface and $pipeline = $pipeline->withHandler($lastHandler);
100 100
 
101
-        foreach ($interceptors as $interceptor) {
101
+        foreach ($interceptors as $interceptor){
102 102
             $pipeline->addInterceptor($interceptor);
103 103
         }
104 104
 
Please login to merge, or discard this 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 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,13 +14,13 @@
 block discarded – undo
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
 
Please login to merge, or discard this 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/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.