Passed
Push — master ( 347780...7c17cc )
by butschster
07:14
created
src/Core/src/Internal/DestructorTrait.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -12,14 +12,14 @@
 block discarded – undo
12 12
     public function destruct(): void
13 13
     {
14 14
         $class = new \ReflectionClass($this);
15
-        foreach ($class->getProperties() as $property) {
15
+        foreach ($class->getProperties() as $property){
16 16
             $name = $property->getName();
17
-            if (!isset($this->$name)) {
17
+            if (!isset($this->$name)){
18 18
                 continue;
19 19
             }
20 20
             $value = $this->$name;
21 21
             unset($this->$name);
22
-            if (\is_object($value) && \method_exists($value, 'destruct')) {
22
+            if (\is_object($value) && \method_exists($value, 'destruct')){
23 23
                 $value->destruct();
24 24
             }
25 25
         }
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -12,14 +12,17 @@
 block discarded – undo
12 12
     public function destruct(): void
13 13
     {
14 14
         $class = new \ReflectionClass($this);
15
-        foreach ($class->getProperties() as $property) {
15
+        foreach ($class->getProperties() as $property)
16
+        {
16 17
             $name = $property->getName();
17
-            if (!isset($this->$name)) {
18
+            if (!isset($this->$name))
19
+            {
18 20
                 continue;
19 21
             }
20 22
             $value = $this->$name;
21 23
             unset($this->$name);
22
-            if (\is_object($value) && \method_exists($value, 'destruct')) {
24
+            if (\is_object($value) && \method_exists($value, 'destruct'))
25
+            {
23 26
                 $value->destruct();
24 27
             }
25 28
         }
Please login to merge, or discard this patch.
src/Core/src/Internal/Registry.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
     public function __construct(
18 18
         private Config $config,
19 19
         private array $objects = [],
20
-    ) {
20
+    ){
21 21
     }
22 22
 
23 23
     public function set(string $name, object $value): void
Please login to merge, or discard this patch.
src/Core/src/Internal/ResolvingState.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -23,15 +23,15 @@  discard block
 block discarded – undo
23 23
     public function __construct(
24 24
         public readonly ReflectionFunctionAbstract $reflection,
25 25
         private array $arguments,
26
-    ) {
26
+    ){
27 27
         $this->modeNamed = $this->isNamedMode();
28 28
     }
29 29
 
30 30
     public function addResolvedValue(mixed &$value, string $key = null): void
31 31
     {
32
-        if ($key === null) {
32
+        if ($key === null){
33 33
             $this->resolvedValues[] = &$value;
34
-        } else {
34
+        }else{
35 35
             $this->resolvedValues[$key] = &$value;
36 36
         }
37 37
     }
@@ -42,25 +42,25 @@  discard block
 block discarded – undo
42 42
             ? $parameter->getName()
43 43
             : $parameter->getPosition();
44 44
 
45
-        if (!\array_key_exists($key, $this->arguments)) {
45
+        if (!\array_key_exists($key, $this->arguments)){
46 46
             return [];
47 47
         }
48 48
         $_val = &$this->arguments[$key];
49 49
 
50
-        if ($variadic && \is_array($_val)) {
50
+        if ($variadic && \is_array($_val)){
51 51
             // Save keys is possible
52 52
             $positional = true;
53 53
             $result = [];
54
-            foreach ($_val as $key => &$item) {
55
-                if (!$positional && \is_int($key)) {
54
+            foreach ($_val as $key => &$item){
55
+                if (!$positional && \is_int($key)){
56 56
                     throw new ResolvingException(
57 57
                         'Cannot use positional argument after named argument during unpacking named variadic argument.'
58 58
                     );
59 59
                 }
60 60
                 $positional = $positional && \is_int($key);
61
-                if ($positional) {
61
+                if ($positional){
62 62
                     $result[] = &$item;
63
-                } else {
63
+                }else{
64 64
                     $result[$key] = &$item;
65 65
                 }
66 66
             }
@@ -78,10 +78,10 @@  discard block
 block discarded – undo
78 78
     {
79 79
         $nums = 0;
80 80
         $strings = 0;
81
-        foreach ($this->arguments as $key => $_) {
82
-            if (\is_int($key)) {
81
+        foreach ($this->arguments as $key => $_){
82
+            if (\is_int($key)){
83 83
                 ++$nums;
84
-            } else {
84
+            }else{
85 85
                 ++$strings;
86 86
             }
87 87
         }
Please login to merge, or discard this patch.
Braces   +25 added lines, -11 removed lines patch added patch discarded remove patch
@@ -29,9 +29,12 @@  discard block
 block discarded – undo
29 29
 
30 30
     public function addResolvedValue(mixed &$value, string $key = null): void
31 31
     {
32
-        if ($key === null) {
32
+        if ($key === null)
33
+        {
33 34
             $this->resolvedValues[] = &$value;
34
-        } else {
35
+        }
36
+        else
37
+        {
35 38
             $this->resolvedValues[$key] = &$value;
36 39
         }
37 40
     }
@@ -42,25 +45,32 @@  discard block
 block discarded – undo
42 45
             ? $parameter->getName()
43 46
             : $parameter->getPosition();
44 47
 
45
-        if (!\array_key_exists($key, $this->arguments)) {
48
+        if (!\array_key_exists($key, $this->arguments))
49
+        {
46 50
             return [];
47 51
         }
48 52
         $_val = &$this->arguments[$key];
49 53
 
50
-        if ($variadic && \is_array($_val)) {
54
+        if ($variadic && \is_array($_val))
55
+        {
51 56
             // Save keys is possible
52 57
             $positional = true;
53 58
             $result = [];
54
-            foreach ($_val as $key => &$item) {
55
-                if (!$positional && \is_int($key)) {
59
+            foreach ($_val as $key => &$item)
60
+            {
61
+                if (!$positional && \is_int($key))
62
+                {
56 63
                     throw new ResolvingException(
57 64
                         'Cannot use positional argument after named argument during unpacking named variadic argument.'
58 65
                     );
59 66
                 }
60 67
                 $positional = $positional && \is_int($key);
61
-                if ($positional) {
68
+                if ($positional)
69
+                {
62 70
                     $result[] = &$item;
63
-                } else {
71
+                }
72
+                else
73
+                {
64 74
                     $result[$key] = &$item;
65 75
                 }
66 76
             }
@@ -78,10 +88,14 @@  discard block
 block discarded – undo
78 88
     {
79 89
         $nums = 0;
80 90
         $strings = 0;
81
-        foreach ($this->arguments as $key => $_) {
82
-            if (\is_int($key)) {
91
+        foreach ($this->arguments as $key => $_)
92
+        {
93
+            if (\is_int($key))
94
+            {
83 95
                 ++$nums;
84
-            } else {
96
+            }
97
+            else
98
+            {
85 99
                 ++$strings;
86 100
             }
87 101
         }
Please login to merge, or discard this patch.
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/Internal/Container.php 2 patches
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,8 @@
 block discarded – undo
50 50
      */
51 51
     public function get(string|Autowire $id, string $context = null): mixed
52 52
     {
53
-        if ($id instanceof Autowire) {
53
+        if ($id instanceof Autowire)
54
+        {
54 55
             return $id->resolve($this->factory);
55 56
         }
56 57
 
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
     use DestructorTrait;
18 18
 
19 19
     private State $state;
20
-    private FactoryInterface|Factory $factory;
20
+    private FactoryInterface | Factory $factory;
21 21
 
22 22
     public function __construct(Registry $constructor)
23 23
     {
@@ -46,9 +46,9 @@  discard block
 block discarded – undo
46 46
      * @throws ContainerException
47 47
      * @throws \Throwable
48 48
      */
49
-    public function get(string|Autowire $id, string $context = null): mixed
49
+    public function get(string | Autowire $id, string $context = null): mixed
50 50
     {
51
-        if ($id instanceof Autowire) {
51
+        if ($id instanceof Autowire){
52 52
             return $id->resolve($this->factory);
53 53
         }
54 54
 
Please login to merge, or discard this patch.
src/Core/src/Internal/Resolver.php 2 patches
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
     ): array {
50 50
         $state = new ResolvingState($reflection, $parameters);
51 51
 
52
-        foreach ($reflection->getParameters() as $parameter) {
52
+        foreach ($reflection->getParameters() as $parameter){
53 53
             $this->resolveParameter($parameter, $state, $validate)
54 54
             or
55 55
             throw new ArgumentResolvingException($reflection, $parameter->getName());
@@ -63,46 +63,46 @@  discard block
 block discarded – undo
63 63
         $positional = true;
64 64
         $variadic = false;
65 65
         $parameters = $reflection->getParameters();
66
-        if (\count($parameters) === 0) {
66
+        if (\count($parameters) === 0){
67 67
             return;
68 68
         }
69 69
 
70 70
         $parameter = null;
71
-        while (\count($parameters) > 0 || \count($arguments) > 0) {
71
+        while (\count($parameters) > 0 || \count($arguments) > 0){
72 72
             // get related argument value
73 73
             $key = \key($arguments);
74 74
 
75 75
             // For a variadic parameter it's no sense - named or positional argument will be sent
76 76
             // But you can't send positional argument after named in any case
77
-            if (\is_int($key) && !$positional) {
77
+            if (\is_int($key) && !$positional){
78 78
                 throw new PositionalArgumentException($reflection, $key);
79 79
             }
80 80
 
81 81
             $positional = $positional && \is_int($key);
82 82
 
83
-            if (!$variadic) {
83
+            if (!$variadic){
84 84
                 $parameter = \array_shift($parameters);
85 85
                 $variadic = $parameter?->isVariadic() ?? false;
86 86
             }
87 87
 
88
-            if ($parameter === null) {
88
+            if ($parameter === null){
89 89
                 throw new UnknownParameterException($reflection, $key);
90 90
             }
91 91
             $name = $parameter->getName();
92 92
 
93
-            if (($positional || $variadic) && $key !== null) {
93
+            if (($positional || $variadic) && $key !== null){
94 94
                 $value = \array_shift($arguments);
95
-            } elseif ($key === null || !\array_key_exists($name, $arguments)) {
96
-                if ($parameter->isOptional()) {
95
+            } elseif ($key === null || !\array_key_exists($name, $arguments)){
96
+                if ($parameter->isOptional()){
97 97
                     continue;
98 98
                 }
99 99
                 throw new MissingRequiredArgumentException($reflection, $name);
100
-            } else {
100
+            }else{
101 101
                 $value = &$arguments[$name];
102 102
                 unset($arguments[$name]);
103 103
             }
104 104
 
105
-            if (!$this->validateValueToParameter($parameter, $value)) {
105
+            if (!$this->validateValueToParameter($parameter, $value)){
106 106
                 throw new InvalidArgumentException($reflection, $name);
107 107
             }
108 108
         }
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 
111 111
     private function validateValueToParameter(ReflectionParameter $parameter, mixed $value): bool
112 112
     {
113
-        if (!$parameter->hasType() || ($parameter->allowsNull() && $value === null)) {
113
+        if (!$parameter->hasType() || ($parameter->allowsNull() && $value === null)){
114 114
             return true;
115 115
         }
116 116
         $type = $parameter->getType();
@@ -121,17 +121,17 @@  discard block
 block discarded – undo
121 121
             $type instanceof ReflectionIntersectionType => [false, $type->getTypes()],
122 122
         };
123 123
 
124
-        foreach ($types as $t) {
124
+        foreach ($types as $t){
125 125
             \assert($t instanceof ReflectionNamedType);
126
-            if (!$this->validateValueNamedType($t, $value)) {
126
+            if (!$this->validateValueNamedType($t, $value)){
127 127
                 // If it is TypeIntersection
128
-                if ($or) {
128
+                if ($or){
129 129
                     continue;
130 130
                 }
131 131
                 return false;
132 132
             }
133 133
             // If it is not type intersection then we can skip that value after first successful check
134
-            if ($or) {
134
+            if ($or){
135 135
                 return true;
136 136
             }
137 137
         }
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
     {
147 147
         $name = $type->getName();
148 148
 
149
-        if ($type->isBuiltin()) {
149
+        if ($type->isBuiltin()){
150 150
             return match ($name) {
151 151
                 'mixed' => true,
152 152
                 'string' => \is_string($value),
@@ -179,13 +179,13 @@  discard block
 block discarded – undo
179 179
 
180 180
         // Try to resolve parameter by name
181 181
         $res = $state->resolveParameterByNameOrPosition($parameter, $isVariadic);
182
-        if ($res !== [] || $isVariadic) {
182
+        if ($res !== [] || $isVariadic){
183 183
             // validate
184
-            if ($isVariadic) {
185
-                foreach ($res as $k => &$v) {
186
-                    $this->processArgument($state, $v, validateWith: $validate ? $parameter : null, key: $k);
184
+            if ($isVariadic){
185
+                foreach ($res as $k => &$v){
186
+                    $this->processArgument($state, $v, validateWith: $validate ? $parameter : null, key : $k);
187 187
                 }
188
-            } else {
188
+            }else{
189 189
                 $this->processArgument($state, $res[0], validateWith: $validate ? $parameter : null);
190 190
             }
191 191
 
@@ -193,39 +193,39 @@  discard block
 block discarded – undo
193 193
         }
194 194
 
195 195
         $error = null;
196
-        if ($hasType) {
196
+        if ($hasType){
197 197
             /** @var ReflectionIntersectionType|ReflectionUnionType|ReflectionNamedType $reflectionType */
198 198
             $reflectionType = $parameter->getType();
199 199
 
200
-            if ($reflectionType instanceof ReflectionIntersectionType) {
200
+            if ($reflectionType instanceof ReflectionIntersectionType){
201 201
                 throw new UnsupportedTypeException($parameter->getDeclaringFunction(), $parameter->getName());
202 202
             }
203 203
 
204 204
             $types = $reflectionType instanceof ReflectionNamedType ? [$reflectionType] : $reflectionType->getTypes();
205
-            foreach ($types as $namedType) {
206
-                try {
207
-                    if ($this->resolveNamedType($state, $parameter, $namedType, $validate)) {
205
+            foreach ($types as $namedType){
206
+                try{
207
+                    if ($this->resolveNamedType($state, $parameter, $namedType, $validate)){
208 208
                         return true;
209 209
                     }
210
-                } catch (Throwable $e) {
210
+                }catch (Throwable $e){
211 211
                     $error = $e;
212 212
                 }
213 213
             }
214 214
         }
215 215
 
216
-        if ($parameter->isDefaultValueAvailable()) {
216
+        if ($parameter->isDefaultValueAvailable()){
217 217
             $argument = $parameter->getDefaultValue();
218 218
             $this->processArgument($state, $argument);
219 219
             return true;
220 220
         }
221 221
 
222
-        if ($hasType && $parameter->allowsNull()) {
222
+        if ($hasType && $parameter->allowsNull()){
223 223
             $argument = null;
224 224
             $this->processArgument($state, $argument);
225 225
             return true;
226 226
         }
227 227
 
228
-        if ($error === null) {
228
+        if ($error === null){
229 229
             return false;
230 230
         }
231 231
 
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
         ReflectionParameter $parameter,
247 247
         ReflectionNamedType $typeRef,
248 248
         bool $validate
249
-    ) {
249
+    ){
250 250
         return !$typeRef->isBuiltin() && $this->resolveObjectParameter(
251 251
             $state,
252 252
             $typeRef->getName(),
@@ -289,15 +289,15 @@  discard block
 block discarded – undo
289 289
         ResolvingState $state,
290 290
         mixed &$value,
291 291
         ReflectionParameter $validateWith = null,
292
-        int|string $key = null
292
+        int | string $key = null
293 293
     ): void {
294 294
         // Resolve Autowire objects
295
-        if ($value instanceof Autowire) {
295
+        if ($value instanceof Autowire){
296 296
             $value = $value->resolve($this->factory);
297 297
         }
298 298
 
299 299
         // Validation
300
-        if ($validateWith !== null && !$this->validateValueToParameter($validateWith, $value)) {
300
+        if ($validateWith !== null && !$this->validateValueToParameter($validateWith, $value)){
301 301
             throw new InvalidArgumentException(
302 302
                 $validateWith->getDeclaringFunction(),
303 303
                 $validateWith->getName()
Please login to merge, or discard this patch.
Braces   +68 added lines, -32 removed lines patch added patch discarded remove patch
@@ -49,7 +49,8 @@  discard block
 block discarded – undo
49 49
     ): array {
50 50
         $state = new ResolvingState($reflection, $parameters);
51 51
 
52
-        foreach ($reflection->getParameters() as $parameter) {
52
+        foreach ($reflection->getParameters() as $parameter)
53
+        {
53 54
             $this->resolveParameter($parameter, $state, $validate)
54 55
             or
55 56
             throw new ArgumentResolvingException($reflection, $parameter->getName());
@@ -63,46 +64,58 @@  discard block
 block discarded – undo
63 64
         $positional = true;
64 65
         $variadic = false;
65 66
         $parameters = $reflection->getParameters();
66
-        if (\count($parameters) === 0) {
67
+        if (\count($parameters) === 0)
68
+        {
67 69
             return;
68 70
         }
69 71
 
70 72
         $parameter = null;
71
-        while (\count($parameters) > 0 || \count($arguments) > 0) {
73
+        while (\count($parameters) > 0 || \count($arguments) > 0)
74
+        {
72 75
             // get related argument value
73 76
             $key = \key($arguments);
74 77
 
75 78
             // For a variadic parameter it's no sense - named or positional argument will be sent
76 79
             // But you can't send positional argument after named in any case
77
-            if (\is_int($key) && !$positional) {
80
+            if (\is_int($key) && !$positional)
81
+            {
78 82
                 throw new PositionalArgumentException($reflection, $key);
79 83
             }
80 84
 
81 85
             $positional = $positional && \is_int($key);
82 86
 
83
-            if (!$variadic) {
87
+            if (!$variadic)
88
+            {
84 89
                 $parameter = \array_shift($parameters);
85 90
                 $variadic = $parameter?->isVariadic() ?? false;
86 91
             }
87 92
 
88
-            if ($parameter === null) {
93
+            if ($parameter === null)
94
+            {
89 95
                 throw new UnknownParameterException($reflection, $key);
90 96
             }
91 97
             $name = $parameter->getName();
92 98
 
93
-            if (($positional || $variadic) && $key !== null) {
99
+            if (($positional || $variadic) && $key !== null)
100
+            {
94 101
                 $value = \array_shift($arguments);
95
-            } elseif ($key === null || !\array_key_exists($name, $arguments)) {
96
-                if ($parameter->isOptional()) {
102
+            }
103
+            elseif ($key === null || !\array_key_exists($name, $arguments))
104
+            {
105
+                if ($parameter->isOptional())
106
+                {
97 107
                     continue;
98 108
                 }
99 109
                 throw new MissingRequiredArgumentException($reflection, $name);
100
-            } else {
110
+            }
111
+            else
112
+            {
101 113
                 $value = &$arguments[$name];
102 114
                 unset($arguments[$name]);
103 115
             }
104 116
 
105
-            if (!$this->validateValueToParameter($parameter, $value)) {
117
+            if (!$this->validateValueToParameter($parameter, $value))
118
+            {
106 119
                 throw new InvalidArgumentException($reflection, $name);
107 120
             }
108 121
         }
@@ -110,7 +123,8 @@  discard block
 block discarded – undo
110 123
 
111 124
     private function validateValueToParameter(ReflectionParameter $parameter, mixed $value): bool
112 125
     {
113
-        if (!$parameter->hasType() || ($parameter->allowsNull() && $value === null)) {
126
+        if (!$parameter->hasType() || ($parameter->allowsNull() && $value === null))
127
+        {
114 128
             return true;
115 129
         }
116 130
         $type = $parameter->getType();
@@ -121,17 +135,21 @@  discard block
 block discarded – undo
121 135
             $type instanceof ReflectionIntersectionType => [false, $type->getTypes()],
122 136
         };
123 137
 
124
-        foreach ($types as $t) {
138
+        foreach ($types as $t)
139
+        {
125 140
             \assert($t instanceof ReflectionNamedType);
126
-            if (!$this->validateValueNamedType($t, $value)) {
141
+            if (!$this->validateValueNamedType($t, $value))
142
+            {
127 143
                 // If it is TypeIntersection
128
-                if ($or) {
144
+                if ($or)
145
+                {
129 146
                     continue;
130 147
                 }
131 148
                 return false;
132 149
             }
133 150
             // If it is not type intersection then we can skip that value after first successful check
134
-            if ($or) {
151
+            if ($or)
152
+            {
135 153
                 return true;
136 154
             }
137 155
         }
@@ -146,7 +164,8 @@  discard block
 block discarded – undo
146 164
     {
147 165
         $name = $type->getName();
148 166
 
149
-        if ($type->isBuiltin()) {
167
+        if ($type->isBuiltin())
168
+        {
150 169
             return match ($name) {
151 170
                 'mixed' => true,
152 171
                 'string' => \is_string($value),
@@ -179,13 +198,18 @@  discard block
 block discarded – undo
179 198
 
180 199
         // Try to resolve parameter by name
181 200
         $res = $state->resolveParameterByNameOrPosition($parameter, $isVariadic);
182
-        if ($res !== [] || $isVariadic) {
201
+        if ($res !== [] || $isVariadic)
202
+        {
183 203
             // validate
184
-            if ($isVariadic) {
185
-                foreach ($res as $k => &$v) {
204
+            if ($isVariadic)
205
+            {
206
+                foreach ($res as $k => &$v)
207
+                {
186 208
                     $this->processArgument($state, $v, validateWith: $validate ? $parameter : null, key: $k);
187 209
                 }
188
-            } else {
210
+            }
211
+            else
212
+            {
189 213
                 $this->processArgument($state, $res[0], validateWith: $validate ? $parameter : null);
190 214
             }
191 215
 
@@ -193,39 +217,49 @@  discard block
 block discarded – undo
193 217
         }
194 218
 
195 219
         $error = null;
196
-        if ($hasType) {
220
+        if ($hasType)
221
+        {
197 222
             /** @var ReflectionIntersectionType|ReflectionUnionType|ReflectionNamedType $reflectionType */
198 223
             $reflectionType = $parameter->getType();
199 224
 
200
-            if ($reflectionType instanceof ReflectionIntersectionType) {
225
+            if ($reflectionType instanceof ReflectionIntersectionType)
226
+            {
201 227
                 throw new UnsupportedTypeException($parameter->getDeclaringFunction(), $parameter->getName());
202 228
             }
203 229
 
204 230
             $types = $reflectionType instanceof ReflectionNamedType ? [$reflectionType] : $reflectionType->getTypes();
205
-            foreach ($types as $namedType) {
206
-                try {
207
-                    if ($this->resolveNamedType($state, $parameter, $namedType, $validate)) {
231
+            foreach ($types as $namedType)
232
+            {
233
+                try
234
+                {
235
+                    if ($this->resolveNamedType($state, $parameter, $namedType, $validate))
236
+                    {
208 237
                         return true;
209 238
                     }
210
-                } catch (Throwable $e) {
239
+                }
240
+                catch (Throwable $e)
241
+                {
211 242
                     $error = $e;
212 243
                 }
213 244
             }
214 245
         }
215 246
 
216
-        if ($parameter->isDefaultValueAvailable()) {
247
+        if ($parameter->isDefaultValueAvailable())
248
+        {
217 249
             $argument = $parameter->getDefaultValue();
218 250
             $this->processArgument($state, $argument);
219 251
             return true;
220 252
         }
221 253
 
222
-        if ($hasType && $parameter->allowsNull()) {
254
+        if ($hasType && $parameter->allowsNull())
255
+        {
223 256
             $argument = null;
224 257
             $this->processArgument($state, $argument);
225 258
             return true;
226 259
         }
227 260
 
228
-        if ($error === null) {
261
+        if ($error === null)
262
+        {
229 263
             return false;
230 264
         }
231 265
 
@@ -292,12 +326,14 @@  discard block
 block discarded – undo
292 326
         int|string $key = null
293 327
     ): void {
294 328
         // Resolve Autowire objects
295
-        if ($value instanceof Autowire) {
329
+        if ($value instanceof Autowire)
330
+        {
296 331
             $value = $value->resolve($this->factory);
297 332
         }
298 333
 
299 334
         // Validation
300
-        if ($validateWith !== null && !$this->validateValueToParameter($validateWith, $value)) {
335
+        if ($validateWith !== null && !$this->validateValueToParameter($validateWith, $value))
336
+        {
301 337
             throw new InvalidArgumentException(
302 338
                 $validateWith->getDeclaringFunction(),
303 339
                 $validateWith->getName()
Please login to merge, or discard this patch.
src/Core/src/Container/Autowire.php 2 patches
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
         private readonly string $alias,
28 28
         private 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.
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.
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.