Passed
Pull Request — master (#1190)
by Aleksei
20:19 queued 07:41
created
src/Interceptors/src/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.
src/Interceptors/src/Context/CallContext.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
         private TargetInterface $target,
16 16
         private array $arguments = [],
17 17
         array $attributes = [],
18
-    ) {
18
+    ){
19 19
         $this->attributes = $attributes;
20 20
     }
21 21
 
Please login to merge, or discard this patch.
src/Interceptors/src/Context/TargetInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -58,5 +58,5 @@
 block discarded – undo
58 58
      *
59 59
      * @return callable|array{class-string, non-empty-string}|null
60 60
      */
61
-    public function getCallable(): callable|array|null;
61
+    public function getCallable(): callable | array | null;
62 62
 }
Please login to merge, or discard this patch.
src/Hmvc/src/CompatiblePipelineBuilder.php 2 patches
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,8 @@
 block discarded – undo
31 31
     public function withInterceptors(CoreInterceptorInterface|InterceptorInterface ...$interceptors): static
32 32
     {
33 33
         $clone = clone $this;
34
-        foreach ($interceptors as $interceptor) {
34
+        foreach ($interceptors as $interceptor)
35
+        {
35 36
             $clone->pipeline->addInterceptor($interceptor);
36 37
         }
37 38
 
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -23,17 +23,17 @@
 block discarded – undo
23 23
         $this->pipeline = new InterceptorPipeline($dispatcher);
24 24
     }
25 25
 
26
-    public function withInterceptors(CoreInterceptorInterface|InterceptorInterface ...$interceptors): static
26
+    public function withInterceptors(CoreInterceptorInterface | InterceptorInterface ...$interceptors): static
27 27
     {
28 28
         $clone = clone $this;
29
-        foreach ($interceptors as $interceptor) {
29
+        foreach ($interceptors as $interceptor){
30 30
             $clone->pipeline->addInterceptor($interceptor);
31 31
         }
32 32
 
33 33
         return $clone;
34 34
     }
35 35
 
36
-    public function build(HandlerInterface|CoreInterface $handler): InterceptorPipeline
36
+    public function build(HandlerInterface | CoreInterface $handler): InterceptorPipeline
37 37
     {
38 38
         /** @psalm-suppress InvalidArgument */
39 39
         return $handler instanceof HandlerInterface
Please login to merge, or discard this patch.
src/Hmvc/src/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/Exception/InterceptorException.php 2 patches
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.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -5,10 +5,10 @@
 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.
12 12
      */
13
-    class InterceptorException extends \RuntimeException {}
13
+    class InterceptorException extends \RuntimeException{}
14 14
 }
Please login to merge, or discard this patch.
src/Hmvc/src/AbstractCore.php 2 patches
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -65,7 +65,8 @@  discard block
 block discarded – undo
65 65
 
66 66
     protected function resolveArguments(\ReflectionMethod $method, array $parameters): array
67 67
     {
68
-        foreach ($method->getParameters() as $parameter) {
68
+        foreach ($method->getParameters() as $parameter)
69
+        {
69 70
             $name = $parameter->getName();
70 71
             if (
71 72
                 \array_key_exists($name, $parameters) &&
@@ -86,9 +87,12 @@  discard block
 block discarded – undo
86 87
      */
87 88
     private function invoke(?object $object, string $class, \ReflectionMethod $method, array $arguments): mixed
88 89
     {
89
-        try {
90
+        try
91
+        {
90 92
             $args = $this->resolveArguments($method, $arguments);
91
-        } catch (ArgumentResolvingException | InvalidArgumentException $e) {
93
+        }
94
+        catch (ArgumentResolvingException | InvalidArgumentException $e)
95
+        {
92 96
             throw new ControllerException(
93 97
                 \sprintf(
94 98
                     'Missing/invalid parameter %s of `%s`->`%s`',
@@ -99,7 +103,9 @@  discard block
 block discarded – undo
99 103
                 ControllerException::BAD_ARGUMENT,
100 104
                 $e,
101 105
             );
102
-        } catch (ContainerExceptionInterface $e) {
106
+        }
107
+        catch (ContainerExceptionInterface $e)
108
+        {
103 109
             throw new ControllerException(
104 110
                 $e->getMessage(),
105 111
                 ControllerException::ERROR,
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
     public function __construct(
30 30
         /** @internal */
31 31
         #[Proxy] protected ContainerInterface $container,
32
-    ) {
32
+    ){
33 33
         // TODO: can we simplify this?
34 34
         // resolver is usually the container itself
35 35
         /** @psalm-suppress MixedAssignment */
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
             ? $container
38 38
             : $container
39 39
                 ->get(InvokerInterface::class)
40
-                ->invoke(static fn(#[Proxy] ResolverInterface $resolver): ResolverInterface => $resolver);
40
+                ->invoke(static fn(#[Proxy] ResolverInterface $resolver) : ResolverInterface => $resolver);
41 41
     }
42 42
 
43 43
     /**
@@ -65,13 +65,13 @@  discard block
 block discarded – undo
65 65
 
66 66
     protected function resolveArguments(\ReflectionMethod $method, array $parameters): array
67 67
     {
68
-        foreach ($method->getParameters() as $parameter) {
68
+        foreach ($method->getParameters() as $parameter){
69 69
             $name = $parameter->getName();
70 70
             if (
71 71
                 \array_key_exists($name, $parameters) &&
72 72
                 $parameters[$name] === null &&
73 73
                 $parameter->isDefaultValueAvailable()
74
-            ) {
74
+            ){
75 75
                 /** @psalm-suppress MixedAssignment */
76 76
                 $parameters[$name] = $parameter->getDefaultValue();
77 77
             }
@@ -86,9 +86,9 @@  discard block
 block discarded – undo
86 86
      */
87 87
     private function invoke(?object $object, string $class, \ReflectionMethod $method, array $arguments): mixed
88 88
     {
89
-        try {
89
+        try{
90 90
             $args = $this->resolveArguments($method, $arguments);
91
-        } catch (ArgumentResolvingException | InvalidArgumentException $e) {
91
+        }catch (ArgumentResolvingException | InvalidArgumentException $e){
92 92
             throw new ControllerException(
93 93
                 \sprintf(
94 94
                     'Missing/invalid parameter %s of `%s`->`%s`',
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
                 ControllerException::BAD_ARGUMENT,
100 100
                 $e,
101 101
             );
102
-        } catch (ContainerExceptionInterface $e) {
102
+        }catch (ContainerExceptionInterface $e){
103 103
             throw new ControllerException(
104 104
                 $e->getMessage(),
105 105
                 ControllerException::ERROR,
Please login to merge, or discard this patch.
src/Interceptors/tests/Unit/Handler/AutowireHandlerTest.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -108,7 +108,7 @@
 block discarded – undo
108 108
     public function createHandler(array $definitions = []): AutowireHandler
109 109
     {
110 110
         $container = new Container();
111
-        foreach ($definitions as $id => $definition) {
111
+        foreach ($definitions as $id => $definition){
112 112
             $container->bind($id, $definition);
113 113
         }
114 114
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -108,7 +108,8 @@
 block discarded – undo
108 108
     public function createHandler(array $definitions = []): AutowireHandler
109 109
     {
110 110
         $container = new Container();
111
-        foreach ($definitions as $id => $definition) {
111
+        foreach ($definitions as $id => $definition)
112
+        {
112 113
             $container->bind($id, $definition);
113 114
         }
114 115
 
Please login to merge, or discard this patch.
src/Views/src/ViewManager.php 2 patches
Braces   +16 added lines, -8 removed lines patch added patch discarded remove patch
@@ -28,15 +28,18 @@  discard block
 block discarded – undo
28 28
             'namespaces' => $config->getNamespaces(),
29 29
         ]);
30 30
 
31
-        foreach ($this->config->getDependencies() as $dependency) {
31
+        foreach ($this->config->getDependencies() as $dependency)
32
+        {
32 33
             $this->addDependency($dependency->resolve($factory));
33 34
         }
34 35
 
35
-        foreach ($this->config->getEngines() as $engine) {
36
+        foreach ($this->config->getEngines() as $engine)
37
+        {
36 38
             $this->addEngine($engine->resolve($factory));
37 39
         }
38 40
 
39
-        if ($this->config->isCacheEnabled()) {
41
+        if ($this->config->isCacheEnabled())
42
+        {
40 43
             $this->cache = new ViewCache();
41 44
         }
42 45
     }
@@ -93,7 +96,8 @@  discard block
 block discarded – undo
93 96
 
94 97
         // Rotate all possible context variants and warm up cache
95 98
         $generator = new ContextGenerator($this->context);
96
-        foreach ($generator->generate() as $context) {
99
+        foreach ($generator->generate() as $context)
100
+        {
97 101
             $engine->reset($path, $context);
98 102
             $engine->compile($path, $context);
99 103
         }
@@ -110,7 +114,8 @@  discard block
 block discarded – undo
110 114
 
111 115
         // Rotate all possible context variants and warm up cache
112 116
         $generator = new ContextGenerator($this->context);
113
-        foreach ($generator->generate() as $context) {
117
+        foreach ($generator->generate() as $context)
118
+        {
114 119
             $engine->reset($path, $context);
115 120
         }
116 121
     }
@@ -122,7 +127,8 @@  discard block
 block discarded – undo
122 127
      */
123 128
     public function get(string $path): ViewInterface
124 129
     {
125
-        if ($this->cache?->has($this->context, $path)) {
130
+        if ($this->cache?->has($this->context, $path))
131
+        {
126 132
             return $this->cache->get($this->context, $path);
127 133
         }
128 134
 
@@ -150,8 +156,10 @@  discard block
 block discarded – undo
150 156
      */
151 157
     private function findEngine(string $path): EngineInterface
152 158
     {
153
-        foreach ($this->engines as $engine) {
154
-            if ($engine->getLoader()->exists($path)) {
159
+        foreach ($this->engines as $engine)
160
+        {
161
+            if ($engine->getLoader()->exists($path))
162
+            {
155 163
                 return $engine;
156 164
             }
157 165
         }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -22,21 +22,21 @@  discard block
 block discarded – undo
22 22
         private readonly GlobalVariablesInterface $globalVariables,
23 23
         FactoryInterface $factory,
24 24
         ?ContextInterface $context = null,
25
-    ) {
25
+    ){
26 26
         $this->context = $context ?? new ViewContext();
27 27
         $this->loader = $factory->make(LoaderInterface::class, [
28 28
             'namespaces' => $config->getNamespaces(),
29 29
         ]);
30 30
 
31
-        foreach ($this->config->getDependencies() as $dependency) {
31
+        foreach ($this->config->getDependencies() as $dependency){
32 32
             $this->addDependency($dependency->resolve($factory));
33 33
         }
34 34
 
35
-        foreach ($this->config->getEngines() as $engine) {
35
+        foreach ($this->config->getEngines() as $engine){
36 36
             $this->addEngine($engine->resolve($factory));
37 37
         }
38 38
 
39
-        if ($this->config->isCacheEnabled()) {
39
+        if ($this->config->isCacheEnabled()){
40 40
             $this->cache = new ViewCache();
41 41
         }
42 42
     }
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 
93 93
         // Rotate all possible context variants and warm up cache
94 94
         $generator = new ContextGenerator($this->context);
95
-        foreach ($generator->generate() as $context) {
95
+        foreach ($generator->generate() as $context){
96 96
             $engine->reset($path, $context);
97 97
             $engine->compile($path, $context);
98 98
         }
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 
110 110
         // Rotate all possible context variants and warm up cache
111 111
         $generator = new ContextGenerator($this->context);
112
-        foreach ($generator->generate() as $context) {
112
+        foreach ($generator->generate() as $context){
113 113
             $engine->reset($path, $context);
114 114
         }
115 115
     }
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
      */
122 122
     public function get(string $path): ViewInterface
123 123
     {
124
-        if ($this->cache?->has($this->context, $path)) {
124
+        if ($this->cache?->has($this->context, $path)){
125 125
             return $this->cache->get($this->context, $path);
126 126
         }
127 127
 
@@ -148,8 +148,8 @@  discard block
 block discarded – undo
148 148
      */
149 149
     private function findEngine(string $path): EngineInterface
150 150
     {
151
-        foreach ($this->engines as $engine) {
152
-            if ($engine->getLoader()->exists($path)) {
151
+        foreach ($this->engines as $engine){
152
+            if ($engine->getLoader()->exists($path)){
153 153
                 return $engine;
154 154
             }
155 155
         }
Please login to merge, or discard this patch.