Passed
Pull Request — master (#1095)
by Aleksei
11:58 queued 42s
created
src/Hmvc/tests/Interceptors/Unit/Handler/ReflectionHandlerTest.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
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
 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
             $container->bind($id, $definition);
128 128
         }
129 129
 
Please login to merge, or discard this 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 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/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
             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
 
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
             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
 
Please login to merge, or discard this patch.
src/Hmvc/src/Interceptors/Internal/ActionResolver.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -19,10 +19,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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`.',
Please login to merge, or discard this patch.
Braces   +11 added lines, -5 removed lines patch added patch discarded remove patch
@@ -19,10 +19,13 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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`.',
Please login to merge, or discard this patch.