Passed
Pull Request — master (#1183)
by Aleksei
10:35
created
src/Core/src/Internal/Invoker.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -35,18 +35,18 @@  discard block
 block discarded – undo
35 35
      */
36 36
     public function invoke(mixed $target, array $parameters = []): mixed
37 37
     {
38
-        if (\is_array($target) && isset($target[1])) {
38
+        if (\is_array($target) && isset($target[1])){
39 39
             // In a form of resolver and method
40 40
             [$resolver, $method] = $target;
41 41
 
42 42
             // Resolver instance (i.e. [ClassName::class, 'method'])
43
-            if (\is_string($resolver)) {
43
+            if (\is_string($resolver)){
44 44
                 $resolver = $this->container->get($resolver);
45 45
             }
46 46
 
47
-            try {
47
+            try{
48 48
                 $method = new \ReflectionMethod($resolver, $method);
49
-            } catch (\ReflectionException $e) {
49
+            }catch (\ReflectionException $e){
50 50
                 throw new ContainerException($e->getMessage(), $e->getCode(), $e);
51 51
             }
52 52
 
@@ -57,14 +57,14 @@  discard block
 block discarded – undo
57 57
             );
58 58
         }
59 59
 
60
-        if (\is_string($target) && \is_callable($target)) {
60
+        if (\is_string($target) && \is_callable($target)){
61 61
             $target = $target(...);
62 62
         }
63 63
 
64
-        if ($target instanceof \Closure) {
65
-            try {
64
+        if ($target instanceof \Closure){
65
+            try{
66 66
                 $reflection = new \ReflectionFunction($target);
67
-            } catch (\ReflectionException $e) {
67
+            }catch (\ReflectionException $e){
68 68
                 throw new ContainerException($e->getMessage(), $e->getCode(), $e);
69 69
             }
70 70
 
Please login to merge, or discard this patch.
Braces   +18 added lines, -8 removed lines patch added patch discarded remove patch
@@ -35,18 +35,23 @@  discard block
 block discarded – undo
35 35
      */
36 36
     public function invoke(mixed $target, array $parameters = []): mixed
37 37
     {
38
-        if (\is_array($target) && isset($target[1])) {
38
+        if (\is_array($target) && isset($target[1]))
39
+        {
39 40
             // In a form of resolver and method
40 41
             [$resolver, $method] = $target;
41 42
 
42 43
             // Resolver instance (i.e. [ClassName::class, 'method'])
43
-            if (\is_string($resolver)) {
44
+            if (\is_string($resolver))
45
+            {
44 46
                 $resolver = $this->container->get($resolver);
45 47
             }
46 48
 
47
-            try {
49
+            try
50
+            {
48 51
                 $method = new \ReflectionMethod($resolver, $method);
49
-            } catch (\ReflectionException $e) {
52
+            }
53
+            catch (\ReflectionException $e)
54
+            {
50 55
                 throw new ContainerException($e->getMessage(), $e->getCode(), $e);
51 56
             }
52 57
 
@@ -57,14 +62,19 @@  discard block
 block discarded – undo
57 62
             );
58 63
         }
59 64
 
60
-        if (\is_string($target) && \is_callable($target)) {
65
+        if (\is_string($target) && \is_callable($target))
66
+        {
61 67
             $target = $target(...);
62 68
         }
63 69
 
64
-        if ($target instanceof \Closure) {
65
-            try {
70
+        if ($target instanceof \Closure)
71
+        {
72
+            try
73
+            {
66 74
                 $reflection = new \ReflectionFunction($target);
67
-            } catch (\ReflectionException $e) {
75
+            }
76
+            catch (\ReflectionException $e)
77
+            {
68 78
                 throw new ContainerException($e->getMessage(), $e->getCode(), $e);
69 79
             }
70 80
 
Please login to merge, or discard this patch.
src/Core/src/Container/Autowire.php 2 patches
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -41,22 +41,26 @@
 block discarded – undo
41 41
      */
42 42
     public static function wire(mixed $definition): Autowire
43 43
     {
44
-        if ($definition instanceof self) {
44
+        if ($definition instanceof self)
45
+        {
45 46
             return $definition;
46 47
         }
47 48
 
48
-        if (\is_string($definition)) {
49
+        if (\is_string($definition))
50
+        {
49 51
             return new self($definition);
50 52
         }
51 53
 
52
-        if (\is_array($definition) && isset($definition['class'])) {
54
+        if (\is_array($definition) && isset($definition['class']))
55
+        {
53 56
             return new self(
54 57
                 $definition['class'],
55 58
                 $definition['options'] ?? $definition['params'] ?? []
56 59
             );
57 60
         }
58 61
 
59
-        if (\is_object($definition)) {
62
+        if (\is_object($definition))
63
+        {
60 64
             $autowire = new self($definition::class, []);
61 65
             $autowire->target = $definition;
62 66
             return $autowire;
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
     public function __construct(
27 27
         public readonly string $alias,
28 28
         public readonly array $parameters = []
29
-    ) {
29
+    ){
30 30
     }
31 31
 
32 32
     public static function __set_state(array $anArray): static
@@ -41,22 +41,22 @@  discard block
 block discarded – undo
41 41
      */
42 42
     public static function wire(mixed $definition): Autowire
43 43
     {
44
-        if ($definition instanceof self) {
44
+        if ($definition instanceof self){
45 45
             return $definition;
46 46
         }
47 47
 
48
-        if (\is_string($definition)) {
48
+        if (\is_string($definition)){
49 49
             return new self($definition);
50 50
         }
51 51
 
52
-        if (\is_array($definition) && isset($definition['class'])) {
52
+        if (\is_array($definition) && isset($definition['class'])){
53 53
             return new self(
54 54
                 $definition['class'],
55 55
                 $definition['options'] ?? $definition['params'] ?? []
56 56
             );
57 57
         }
58 58
 
59
-        if (\is_object($definition)) {
59
+        if (\is_object($definition)){
60 60
             $autowire = new self($definition::class, []);
61 61
             $autowire->target = $definition;
62 62
             return $autowire;
Please login to merge, or discard this patch.
src/Core/src/Exception/Container/ArgumentException.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -16,10 +16,10 @@
 block discarded – undo
16 16
     public function __construct(
17 17
         protected \ReflectionParameter $parameter,
18 18
         protected \ReflectionFunctionAbstract $context
19
-    ) {
19
+    ){
20 20
         $name = $context->getName();
21
-        if ($context instanceof \ReflectionMethod) {
22
-            $name = $context->class . '::' . $name;
21
+        if ($context instanceof \ReflectionMethod){
22
+            $name = $context->class.'::'.$name;
23 23
         }
24 24
 
25 25
         parent::__construct(\sprintf("Unable to resolve '%s' argument in '%s'", $parameter->name, $name));
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,8 @@
 block discarded – undo
18 18
         protected \ReflectionFunctionAbstract $context
19 19
     ) {
20 20
         $name = $context->getName();
21
-        if ($context instanceof \ReflectionMethod) {
21
+        if ($context instanceof \ReflectionMethod)
22
+        {
22 23
             $name = $context->class . '::' . $name;
23 24
         }
24 25
 
Please login to merge, or discard this patch.
src/Core/src/Exception/Resolver/UnknownParameterException.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
         \ReflectionFunctionAbstract $reflection,
15 15
         private readonly string $parameter
16
-    ) {
16
+    ){
17 17
         $pattern = "Unknown named parameter `{$parameter}` `%s` %s.";
18 18
         parent::__construct($this->renderFunctionAndParameter($reflection, $pattern));
19 19
     }
Please login to merge, or discard this patch.
src/Core/src/Exception/Resolver/ArgumentResolvingException.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
         \ReflectionFunctionAbstract $reflection,
15 15
         private readonly string $parameter
16
-    ) {
16
+    ){
17 17
         $pattern = "Unable to resolve required argument `{$parameter}` when resolving `%s` %s.";
18 18
         parent::__construct($this->renderFunctionAndParameter($reflection, $pattern));
19 19
     }
Please login to merge, or discard this patch.
src/Core/src/Exception/Resolver/PositionalArgumentException.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,13 +13,13 @@
 block discarded – undo
13 13
     public function __construct(
14 14
         \ReflectionFunctionAbstract $reflection,
15 15
         private readonly int $position
16
-    ) {
16
+    ){
17 17
         $pattern = 'Cannot use positional argument after named argument `%s` %s.';
18 18
         parent::__construct($this->renderFunctionAndParameter($reflection, $pattern));
19 19
     }
20 20
 
21 21
     public function getParameter(): string
22 22
     {
23
-        return '#' . $this->position;
23
+        return '#'.$this->position;
24 24
     }
25 25
 }
Please login to merge, or discard this patch.
src/Core/src/Exception/Resolver/WrongTypeException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
     {
13 13
         $message = 'An argument resolved with wrong type: ';
14 14
         parent::__construct(
15
-            $message . $error->getMessage(),
15
+            $message.$error->getMessage(),
16 16
             $error->getCode(),
17 17
             $error
18 18
         );
Please login to merge, or discard this patch.
src/Core/src/Exception/Resolver/MissingRequiredArgumentException.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
         \ReflectionFunctionAbstract $reflection,
15 15
         private readonly string $parameter
16
-    ) {
16
+    ){
17 17
         $pattern = "Missing required argument for the `{$parameter}` parameter for `%s` %s.";
18 18
         parent::__construct($this->renderFunctionAndParameter($reflection, $pattern));
19 19
     }
Please login to merge, or discard this patch.
src/Core/src/Exception/Traits/ClosureRendererTrait.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
         $line = $reflection->getStartLine();
32 32
 
33 33
         $fileAndLine = '';
34
-        if (!empty($fileName)) {
34
+        if (!empty($fileName)){
35 35
             $fileAndLine = "in \"$fileName\" at line $line";
36 36
         }
37 37
 
@@ -42,23 +42,23 @@  discard block
 block discarded – undo
42 42
     {
43 43
         $closureParameters = [];
44 44
 
45
-        foreach ($reflection->getParameters() as $parameter) {
45
+        foreach ($reflection->getParameters() as $parameter){
46 46
             /** @var ReflectionNamedType|ReflectionUnionType|null $type */
47 47
             $type = $parameter->getType();
48 48
             $parameterString = \sprintf(
49 49
                 '%s %s%s$%s',
50 50
                 // type
51
-                (string) $type,
51
+                (string)$type,
52 52
                 // reference
53 53
                 $parameter->isPassedByReference() ? '&' : '',
54 54
                 // variadic
55 55
                 $parameter->isVariadic() ? '...' : '',
56 56
                 $parameter->getName(),
57 57
             );
58
-            if ($parameter->isDefaultValueAvailable()) {
58
+            if ($parameter->isDefaultValueAvailable()){
59 59
                 $default = $parameter->getDefaultValue();
60
-                $parameterString .= ' = ' . match (true) {
61
-                    \is_object($default) => 'new ' . $default::class . '(...)',
60
+                $parameterString .= ' = '.match (true) {
61
+                    \is_object($default) => 'new '.$default::class.'(...)',
62 62
                     $parameter->isDefaultValueConstant() => $parameter->getDefaultValueConstantName(),
63 63
                     default => \var_export($default, true),
64 64
                 };
@@ -66,6 +66,6 @@  discard block
 block discarded – undo
66 66
             $closureParameters[] = \ltrim($parameterString);
67 67
         }
68 68
         $static = $reflection->isStatic() ? 'static ' : '';
69
-        return "{$static}function (" . \implode(', ', $closureParameters) . ')';
69
+        return "{$static}function (".\implode(', ', $closureParameters).')';
70 70
     }
71 71
 }
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -31,7 +31,8 @@  discard block
 block discarded – undo
31 31
         $line = $reflection->getStartLine();
32 32
 
33 33
         $fileAndLine = '';
34
-        if (!empty($fileName)) {
34
+        if (!empty($fileName))
35
+        {
35 36
             $fileAndLine = "in \"$fileName\" at line $line";
36 37
         }
37 38
 
@@ -42,7 +43,8 @@  discard block
 block discarded – undo
42 43
     {
43 44
         $closureParameters = [];
44 45
 
45
-        foreach ($reflection->getParameters() as $parameter) {
46
+        foreach ($reflection->getParameters() as $parameter)
47
+        {
46 48
             /** @var ReflectionNamedType|ReflectionUnionType|null $type */
47 49
             $type = $parameter->getType();
48 50
             $parameterString = \sprintf(
@@ -55,7 +57,8 @@  discard block
 block discarded – undo
55 57
                 $parameter->isVariadic() ? '...' : '',
56 58
                 $parameter->getName(),
57 59
             );
58
-            if ($parameter->isDefaultValueAvailable()) {
60
+            if ($parameter->isDefaultValueAvailable())
61
+            {
59 62
                 $default = $parameter->getDefaultValue();
60 63
                 $parameterString .= ' = ' . match (true) {
61 64
                     \is_object($default) => 'new ' . $default::class . '(...)',
Please login to merge, or discard this patch.