@@ -4,4 +4,4 @@ |
||
4 | 4 | |
5 | 5 | namespace Spiral\Tests\Core\Stub; |
6 | 6 | |
7 | -trait TestTrait {} |
|
7 | +trait TestTrait{} |
@@ -4,4 +4,6 @@ |
||
4 | 4 | |
5 | 5 | namespace Spiral\Tests\Core\Stub; |
6 | 6 | |
7 | -trait TestTrait {} |
|
7 | +trait TestTrait |
|
8 | +{ |
|
9 | +} |
@@ -8,7 +8,7 @@ |
||
8 | 8 | { |
9 | 9 | public function __construct( |
10 | 10 | public LightEngine $engine, |
11 | - ) {} |
|
11 | + ){} |
|
12 | 12 | |
13 | 13 | public function __call(string $name, array $arguments) |
14 | 14 | { |
@@ -8,7 +8,8 @@ |
||
8 | 8 | { |
9 | 9 | public function __construct( |
10 | 10 | public LightEngine $engine, |
11 | - ) {} |
|
11 | + ) { |
|
12 | +} |
|
12 | 13 | |
13 | 14 | public function __call(string $name, array $arguments) |
14 | 15 | { |
@@ -4,4 +4,4 @@ |
||
4 | 4 | |
5 | 5 | namespace Spiral\Tests\Core\Stub; |
6 | 6 | |
7 | -interface MadeInUssrInterface {} |
|
7 | +interface MadeInUssrInterface{} |
@@ -4,4 +4,6 @@ |
||
4 | 4 | |
5 | 5 | namespace Spiral\Tests\Core\Stub; |
6 | 6 | |
7 | -interface MadeInUssrInterface {} |
|
7 | +interface MadeInUssrInterface |
|
8 | +{ |
|
9 | +} |
@@ -6,5 +6,5 @@ |
||
6 | 6 | |
7 | 7 | class EnumService |
8 | 8 | { |
9 | - public function __construct(public EnumObject $enum) {} |
|
9 | + public function __construct(public EnumObject $enum){} |
|
10 | 10 | } |
@@ -6,5 +6,7 @@ |
||
6 | 6 | |
7 | 7 | class EnumService |
8 | 8 | { |
9 | - public function __construct(public EnumObject $enum) {} |
|
9 | + public function __construct(public EnumObject $enum) |
|
10 | + { |
|
11 | +} |
|
10 | 12 | } |
@@ -8,5 +8,5 @@ |
||
8 | 8 | { |
9 | 9 | public function __construct( |
10 | 10 | private object $object = new \stdClass(), |
11 | - ) {} |
|
11 | + ){} |
|
12 | 12 | } |
@@ -8,5 +8,6 @@ |
||
8 | 8 | { |
9 | 9 | public function __construct( |
10 | 10 | private object $object = new \stdClass(), |
11 | - ) {} |
|
11 | + ) { |
|
12 | +} |
|
12 | 13 | } |
@@ -4,9 +4,9 @@ |
||
4 | 4 | |
5 | 5 | namespace Spiral\Framework; |
6 | 6 | |
7 | -require_once __DIR__ . '/../vendor/autoload.php'; |
|
7 | +require_once __DIR__.'/../vendor/autoload.php'; |
|
8 | 8 | |
9 | -if (!\enum_exists(Spiral::class)) { |
|
9 | +if (!\enum_exists(Spiral::class)){ |
|
10 | 10 | enum Spiral: string |
11 | 11 | { |
12 | 12 | case HttpRequest = 'http-request'; |
@@ -6,7 +6,8 @@ |
||
6 | 6 | |
7 | 7 | require_once __DIR__ . '/../vendor/autoload.php'; |
8 | 8 | |
9 | -if (!\enum_exists(Spiral::class)) { |
|
9 | +if (!\enum_exists(Spiral::class)) |
|
10 | +{ |
|
10 | 11 | enum Spiral: string |
11 | 12 | { |
12 | 13 | case HttpRequest = 'http-request'; |
@@ -20,7 +20,7 @@ |
||
20 | 20 | } |
21 | 21 | |
22 | 22 | #[DataProvider('scopeNameDataProvider')] |
23 | - public function testScope(string|\BackedEnum $name, string $expected): void |
|
23 | + public function testScope(string | \BackedEnum $name, string $expected): void |
|
24 | 24 | { |
25 | 25 | $scope = new Scope($name); |
26 | 26 |
@@ -31,7 +31,7 @@ |
||
31 | 31 | { |
32 | 32 | public function __construct( |
33 | 33 | public PublicContainer $publicContainer, |
34 | - ) {} |
|
34 | + ){} |
|
35 | 35 | |
36 | 36 | public function __get(string $name): object |
37 | 37 | { |
@@ -31,7 +31,8 @@ |
||
31 | 31 | { |
32 | 32 | public function __construct( |
33 | 33 | public PublicContainer $publicContainer, |
34 | - ) {} |
|
34 | + ) { |
|
35 | +} |
|
35 | 36 | |
36 | 37 | public function __get(string $name): object |
37 | 38 | { |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | ): array { |
49 | 49 | $state = new ResolvingState($reflection, $parameters); |
50 | 50 | |
51 | - foreach ($reflection->getParameters() as $parameter) { |
|
51 | + foreach ($reflection->getParameters() as $parameter){ |
|
52 | 52 | $this->resolveParameter($parameter, $state, $validate) |
53 | 53 | or |
54 | 54 | throw new ArgumentResolvingException($reflection, $parameter->getName()); |
@@ -62,47 +62,47 @@ discard block |
||
62 | 62 | $positional = true; |
63 | 63 | $variadic = false; |
64 | 64 | $parameters = $reflection->getParameters(); |
65 | - if (\count($parameters) === 0) { |
|
65 | + if (\count($parameters) === 0){ |
|
66 | 66 | return; |
67 | 67 | } |
68 | 68 | |
69 | 69 | $parameter = null; |
70 | - while (\count($parameters) > 0 || \count($arguments) > 0) { |
|
70 | + while (\count($parameters) > 0 || \count($arguments) > 0){ |
|
71 | 71 | // get related argument value |
72 | 72 | $key = \key($arguments); |
73 | 73 | |
74 | 74 | // For a variadic parameter it's no sense - named or positional argument will be sent |
75 | 75 | // But you can't send positional argument after named in any case |
76 | - if (\is_int($key) && !$positional) { |
|
76 | + if (\is_int($key) && !$positional){ |
|
77 | 77 | throw new PositionalArgumentException($reflection, $key); |
78 | 78 | } |
79 | 79 | |
80 | 80 | $positional = $positional && \is_int($key); |
81 | 81 | |
82 | - if (!$variadic) { |
|
82 | + if (!$variadic){ |
|
83 | 83 | $parameter = \array_shift($parameters); |
84 | 84 | $variadic = $parameter?->isVariadic() ?? false; |
85 | 85 | } |
86 | 86 | |
87 | - if ($parameter === null) { |
|
87 | + if ($parameter === null){ |
|
88 | 88 | throw new UnknownParameterException($reflection, $key); |
89 | 89 | } |
90 | 90 | $name = $parameter->getName(); |
91 | 91 | |
92 | - if (($positional || $variadic) && $key !== null) { |
|
92 | + if (($positional || $variadic) && $key !== null){ |
|
93 | 93 | /** @psalm-suppress ReferenceReusedFromConfusingScope */ |
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 |
||
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 |
||
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 |
||
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 |
||
179 | 179 | |
180 | 180 | // Try to resolve parameter by name |
181 | 181 | $res = $state->resolveParameterByNameOrPosition($param, $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 ? $param : null, key: $k); |
|
184 | + if ($isVariadic){ |
|
185 | + foreach ($res as $k => &$v){ |
|
186 | + $this->processArgument($state, $v, validateWith: $validate ? $param : null, key : $k); |
|
187 | 187 | } |
188 | - } else { |
|
188 | + }else{ |
|
189 | 189 | $this->processArgument($state, $res[0], validateWith: $validate ? $param : null); |
190 | 190 | } |
191 | 191 | |
@@ -193,18 +193,18 @@ discard block |
||
193 | 193 | } |
194 | 194 | |
195 | 195 | $error = null; |
196 | - while ($hasType) { |
|
196 | + while ($hasType){ |
|
197 | 197 | /** @var \ReflectionIntersectionType|\ReflectionUnionType|\ReflectionNamedType $refType */ |
198 | 198 | $refType = $param->getType(); |
199 | 199 | |
200 | - if ($refType::class === \ReflectionNamedType::class) { |
|
201 | - if ($refType->isBuiltin()) { |
|
200 | + if ($refType::class === \ReflectionNamedType::class){ |
|
201 | + if ($refType->isBuiltin()){ |
|
202 | 202 | break; |
203 | 203 | } |
204 | 204 | |
205 | 205 | if (\interface_exists($refType->getName()) && !empty( |
206 | 206 | $attrs = $param->getAttributes(ProxyAttribute::class) |
207 | - )) { |
|
207 | + )){ |
|
208 | 208 | $proxy = Proxy::create( |
209 | 209 | new \ReflectionClass($refType->getName()), |
210 | 210 | $param, |
@@ -214,23 +214,23 @@ discard block |
||
214 | 214 | return true; |
215 | 215 | } |
216 | 216 | |
217 | - try { |
|
218 | - if ($this->resolveObject($state, $refType, $param, $validate)) { |
|
217 | + try{ |
|
218 | + if ($this->resolveObject($state, $refType, $param, $validate)){ |
|
219 | 219 | return true; |
220 | 220 | } |
221 | - } catch (\Throwable $e) { |
|
221 | + }catch (\Throwable $e){ |
|
222 | 222 | $error = $e; |
223 | 223 | } |
224 | 224 | break; |
225 | 225 | } |
226 | 226 | |
227 | - if ($refType::class === \ReflectionUnionType::class) { |
|
228 | - foreach ($refType->getTypes() as $namedType) { |
|
229 | - try { |
|
230 | - if (!$namedType->isBuiltin() && $this->resolveObject($state, $namedType, $param, $validate)) { |
|
227 | + if ($refType::class === \ReflectionUnionType::class){ |
|
228 | + foreach ($refType->getTypes() as $namedType){ |
|
229 | + try{ |
|
230 | + if (!$namedType->isBuiltin() && $this->resolveObject($state, $namedType, $param, $validate)){ |
|
231 | 231 | return true; |
232 | 232 | } |
233 | - } catch (\Throwable $e) { |
|
233 | + }catch (\Throwable $e){ |
|
234 | 234 | $error = $e; |
235 | 235 | } |
236 | 236 | } |
@@ -240,19 +240,19 @@ discard block |
||
240 | 240 | throw new UnsupportedTypeException($param->getDeclaringFunction(), $param->getName()); |
241 | 241 | } |
242 | 242 | |
243 | - if ($param->isDefaultValueAvailable()) { |
|
243 | + if ($param->isDefaultValueAvailable()){ |
|
244 | 244 | $argument = $param->getDefaultValue(); |
245 | 245 | $this->processArgument($state, $argument); |
246 | 246 | return true; |
247 | 247 | } |
248 | 248 | |
249 | - if ($hasType && $param->allowsNull()) { |
|
249 | + if ($hasType && $param->allowsNull()){ |
|
250 | 250 | $argument = null; |
251 | 251 | $this->processArgument($state, $argument); |
252 | 252 | return true; |
253 | 253 | } |
254 | 254 | |
255 | - if ($error === null) { |
|
255 | + if ($error === null){ |
|
256 | 256 | return false; |
257 | 257 | } |
258 | 258 | |
@@ -290,15 +290,15 @@ discard block |
||
290 | 290 | ResolvingState $state, |
291 | 291 | mixed &$value, |
292 | 292 | ?\ReflectionParameter $validateWith = null, |
293 | - int|string|null $key = null, |
|
293 | + int | string | null $key = null, |
|
294 | 294 | ): void { |
295 | 295 | // Resolve Autowire objects |
296 | - if ($value instanceof Autowire) { |
|
296 | + if ($value instanceof Autowire){ |
|
297 | 297 | $value = $value->resolve($this->factory); |
298 | 298 | } |
299 | 299 | |
300 | 300 | // Validation |
301 | - if ($validateWith !== null && !$this->validateValueToParameter($validateWith, $value)) { |
|
301 | + if ($validateWith !== null && !$this->validateValueToParameter($validateWith, $value)){ |
|
302 | 302 | throw new InvalidArgumentException( |
303 | 303 | $validateWith->getDeclaringFunction(), |
304 | 304 | $validateWith->getName(), |
@@ -48,7 +48,8 @@ discard block |
||
48 | 48 | ): array { |
49 | 49 | $state = new ResolvingState($reflection, $parameters); |
50 | 50 | |
51 | - foreach ($reflection->getParameters() as $parameter) { |
|
51 | + foreach ($reflection->getParameters() as $parameter) |
|
52 | + { |
|
52 | 53 | $this->resolveParameter($parameter, $state, $validate) |
53 | 54 | or |
54 | 55 | throw new ArgumentResolvingException($reflection, $parameter->getName()); |
@@ -62,47 +63,59 @@ discard block |
||
62 | 63 | $positional = true; |
63 | 64 | $variadic = false; |
64 | 65 | $parameters = $reflection->getParameters(); |
65 | - if (\count($parameters) === 0) { |
|
66 | + if (\count($parameters) === 0) |
|
67 | + { |
|
66 | 68 | return; |
67 | 69 | } |
68 | 70 | |
69 | 71 | $parameter = null; |
70 | - while (\count($parameters) > 0 || \count($arguments) > 0) { |
|
72 | + while (\count($parameters) > 0 || \count($arguments) > 0) |
|
73 | + { |
|
71 | 74 | // get related argument value |
72 | 75 | $key = \key($arguments); |
73 | 76 | |
74 | 77 | // For a variadic parameter it's no sense - named or positional argument will be sent |
75 | 78 | // But you can't send positional argument after named in any case |
76 | - if (\is_int($key) && !$positional) { |
|
79 | + if (\is_int($key) && !$positional) |
|
80 | + { |
|
77 | 81 | throw new PositionalArgumentException($reflection, $key); |
78 | 82 | } |
79 | 83 | |
80 | 84 | $positional = $positional && \is_int($key); |
81 | 85 | |
82 | - if (!$variadic) { |
|
86 | + if (!$variadic) |
|
87 | + { |
|
83 | 88 | $parameter = \array_shift($parameters); |
84 | 89 | $variadic = $parameter?->isVariadic() ?? false; |
85 | 90 | } |
86 | 91 | |
87 | - if ($parameter === null) { |
|
92 | + if ($parameter === null) |
|
93 | + { |
|
88 | 94 | throw new UnknownParameterException($reflection, $key); |
89 | 95 | } |
90 | 96 | $name = $parameter->getName(); |
91 | 97 | |
92 | - if (($positional || $variadic) && $key !== null) { |
|
98 | + if (($positional || $variadic) && $key !== null) |
|
99 | + { |
|
93 | 100 | /** @psalm-suppress ReferenceReusedFromConfusingScope */ |
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 |
||
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 |
||
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 |
||
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 |
||
179 | 198 | |
180 | 199 | // Try to resolve parameter by name |
181 | 200 | $res = $state->resolveParameterByNameOrPosition($param, $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 ? $param : null, key: $k); |
187 | 209 | } |
188 | - } else { |
|
210 | + } |
|
211 | + else |
|
212 | + { |
|
189 | 213 | $this->processArgument($state, $res[0], validateWith: $validate ? $param : null); |
190 | 214 | } |
191 | 215 | |
@@ -193,18 +217,22 @@ discard block |
||
193 | 217 | } |
194 | 218 | |
195 | 219 | $error = null; |
196 | - while ($hasType) { |
|
220 | + while ($hasType) |
|
221 | + { |
|
197 | 222 | /** @var \ReflectionIntersectionType|\ReflectionUnionType|\ReflectionNamedType $refType */ |
198 | 223 | $refType = $param->getType(); |
199 | 224 | |
200 | - if ($refType::class === \ReflectionNamedType::class) { |
|
201 | - if ($refType->isBuiltin()) { |
|
225 | + if ($refType::class === \ReflectionNamedType::class) |
|
226 | + { |
|
227 | + if ($refType->isBuiltin()) |
|
228 | + { |
|
202 | 229 | break; |
203 | 230 | } |
204 | 231 | |
205 | 232 | if (\interface_exists($refType->getName()) && !empty( |
206 | 233 | $attrs = $param->getAttributes(ProxyAttribute::class) |
207 | - )) { |
|
234 | + )) |
|
235 | + { |
|
208 | 236 | $proxy = Proxy::create( |
209 | 237 | new \ReflectionClass($refType->getName()), |
210 | 238 | $param, |
@@ -214,23 +242,33 @@ discard block |
||
214 | 242 | return true; |
215 | 243 | } |
216 | 244 | |
217 | - try { |
|
218 | - if ($this->resolveObject($state, $refType, $param, $validate)) { |
|
245 | + try |
|
246 | + { |
|
247 | + if ($this->resolveObject($state, $refType, $param, $validate)) |
|
248 | + { |
|
219 | 249 | return true; |
220 | 250 | } |
221 | - } catch (\Throwable $e) { |
|
251 | + } |
|
252 | + catch (\Throwable $e) |
|
253 | + { |
|
222 | 254 | $error = $e; |
223 | 255 | } |
224 | 256 | break; |
225 | 257 | } |
226 | 258 | |
227 | - if ($refType::class === \ReflectionUnionType::class) { |
|
228 | - foreach ($refType->getTypes() as $namedType) { |
|
229 | - try { |
|
230 | - if (!$namedType->isBuiltin() && $this->resolveObject($state, $namedType, $param, $validate)) { |
|
259 | + if ($refType::class === \ReflectionUnionType::class) |
|
260 | + { |
|
261 | + foreach ($refType->getTypes() as $namedType) |
|
262 | + { |
|
263 | + try |
|
264 | + { |
|
265 | + if (!$namedType->isBuiltin() && $this->resolveObject($state, $namedType, $param, $validate)) |
|
266 | + { |
|
231 | 267 | return true; |
232 | 268 | } |
233 | - } catch (\Throwable $e) { |
|
269 | + } |
|
270 | + catch (\Throwable $e) |
|
271 | + { |
|
234 | 272 | $error = $e; |
235 | 273 | } |
236 | 274 | } |
@@ -240,19 +278,22 @@ discard block |
||
240 | 278 | throw new UnsupportedTypeException($param->getDeclaringFunction(), $param->getName()); |
241 | 279 | } |
242 | 280 | |
243 | - if ($param->isDefaultValueAvailable()) { |
|
281 | + if ($param->isDefaultValueAvailable()) |
|
282 | + { |
|
244 | 283 | $argument = $param->getDefaultValue(); |
245 | 284 | $this->processArgument($state, $argument); |
246 | 285 | return true; |
247 | 286 | } |
248 | 287 | |
249 | - if ($hasType && $param->allowsNull()) { |
|
288 | + if ($hasType && $param->allowsNull()) |
|
289 | + { |
|
250 | 290 | $argument = null; |
251 | 291 | $this->processArgument($state, $argument); |
252 | 292 | return true; |
253 | 293 | } |
254 | 294 | |
255 | - if ($error === null) { |
|
295 | + if ($error === null) |
|
296 | + { |
|
256 | 297 | return false; |
257 | 298 | } |
258 | 299 | |
@@ -293,12 +334,14 @@ discard block |
||
293 | 334 | int|string|null $key = null, |
294 | 335 | ): void { |
295 | 336 | // Resolve Autowire objects |
296 | - if ($value instanceof Autowire) { |
|
337 | + if ($value instanceof Autowire) |
|
338 | + { |
|
297 | 339 | $value = $value->resolve($this->factory); |
298 | 340 | } |
299 | 341 | |
300 | 342 | // Validation |
301 | - if ($validateWith !== null && !$this->validateValueToParameter($validateWith, $value)) { |
|
343 | + if ($validateWith !== null && !$this->validateValueToParameter($validateWith, $value)) |
|
344 | + { |
|
302 | 345 | throw new InvalidArgumentException( |
303 | 346 | $validateWith->getDeclaringFunction(), |
304 | 347 | $validateWith->getName(), |