@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | $this->assertNull($this->app->getEnvironment()->get('FIRED')); |
44 | 44 | |
45 | 45 | $w->shouldReceive('receive')->once()->with( |
46 | - \Mockery::on(function (&$context) { |
|
46 | + \Mockery::on(function (&$context){ |
|
47 | 47 | $context = $this->arrayToContextString(TestJob::class); |
48 | 48 | |
49 | 49 | return true; |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $this->app->getContainer()->bind(Worker::class, $w); |
69 | 69 | |
70 | 70 | $w->shouldReceive('receive')->once()->with( |
71 | - \Mockery::on(function (&$context) { |
|
71 | + \Mockery::on(function (&$context){ |
|
72 | 72 | $context = $this->arrayToContextString(ErrorJob::class); |
73 | 73 | |
74 | 74 | return true; |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | $w->shouldReceive('receive')->once()->andReturn(null); |
82 | 82 | |
83 | 83 | $files = $this->app->get(FilesInterface::class)->getFiles( |
84 | - $this->app->get(DirectoriesInterface::class)->get('runtime') . '/snapshots/' |
|
84 | + $this->app->get(DirectoriesInterface::class)->get('runtime').'/snapshots/' |
|
85 | 85 | ); |
86 | 86 | |
87 | 87 | $this->assertCount(0, $files); |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | $this->app->get(JobDispatcher::class)->serve(); |
90 | 90 | |
91 | 91 | $files = $this->app->get(FilesInterface::class)->getFiles( |
92 | - $this->app->get(DirectoriesInterface::class)->get('runtime') . '/snapshots/' |
|
92 | + $this->app->get(DirectoriesInterface::class)->get('runtime').'/snapshots/' |
|
93 | 93 | ); |
94 | 94 | |
95 | 95 | $this->assertCount(1, $files); |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | |
108 | 108 | return \json_encode([ |
109 | 109 | 'id' => (string)$id, |
110 | - 'job' => \strtolower(\implode('.', $signature)) . '.' . $class |
|
110 | + 'job' => \strtolower(\implode('.', $signature)).'.'.$class |
|
111 | 111 | ]); |
112 | 112 | } |
113 | 113 | } |
@@ -20,6 +20,6 @@ |
||
20 | 20 | bool $bool, |
21 | 21 | array $array = [], |
22 | 22 | string $pong = null |
23 | - ) { |
|
23 | + ){ |
|
24 | 24 | } |
25 | 25 | } |
@@ -41,7 +41,7 @@ |
||
41 | 41 | $container = new Container(); |
42 | 42 | $this->assertInstanceOf(FactoryInterface::class, $container); |
43 | 43 | |
44 | - $container->bind(Bucket::class, function ($data) { |
|
44 | + $container->bind(Bucket::class, function ($data){ |
|
45 | 45 | return new Bucket('via-closure', $data); |
46 | 46 | }); |
47 | 47 |
@@ -40,11 +40,11 @@ discard block |
||
40 | 40 | |
41 | 41 | $this->assertNull(ContainerScope::getContainer()); |
42 | 42 | |
43 | - try { |
|
43 | + try{ |
|
44 | 44 | $this->assertTrue(ContainerScope::runScope($container, function () use ($container): void { |
45 | 45 | throw new RuntimeException('exception'); |
46 | 46 | })); |
47 | - } catch (\Throwable $e) { |
|
47 | + }catch (\Throwable $e){ |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | $this->assertInstanceOf(RuntimeException::class, $e); |
@@ -91,14 +91,14 @@ discard block |
||
91 | 91 | return $c->get('bucket')->getName() == 'b' && $c->has('other'); |
92 | 92 | })); |
93 | 93 | |
94 | - try { |
|
94 | + try{ |
|
95 | 95 | $this->assertTrue($c->runScope([ |
96 | 96 | 'bucket' => new Bucket('b'), |
97 | 97 | 'other' => new SampleClass() |
98 | 98 | ], function () use ($c): void { |
99 | 99 | throw new RuntimeException('exception'); |
100 | 100 | })); |
101 | - } catch (\Throwable $e) { |
|
101 | + }catch (\Throwable $e){ |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | $this->assertSame('a', $c->get('bucket')->getName()); |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | { |
72 | 72 | $container = new Container(); |
73 | 73 | |
74 | - $container->bindSingleton('sampleClass', function () { |
|
74 | + $container->bindSingleton('sampleClass', function (){ |
|
75 | 75 | return new SampleClass(); |
76 | 76 | }); |
77 | 77 | |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | $container = new Container(); |
99 | 99 | $container->bindSingleton('singleton', 'sampleClass'); |
100 | 100 | |
101 | - $container->bind('sampleClass', function () { |
|
101 | + $container->bind('sampleClass', function (){ |
|
102 | 102 | return new SampleClass(); |
103 | 103 | }); |
104 | 104 |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | |
37 | 37 | public function testInvalidInjector(): void |
38 | 38 | { |
39 | - $excepted = "Class 'Spiral\Tests\Core\Fixtures\InvalidInjector' must be an " . |
|
39 | + $excepted = "Class 'Spiral\Tests\Core\Fixtures\InvalidInjector' must be an ". |
|
40 | 40 | "instance of InjectorInterface for 'Spiral\Tests\Core\Fixtures\TestConfig'"; |
41 | 41 | $this->expectException(InjectionException::class); |
42 | 42 | $this->expectExceptionMessage($excepted); |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | |
61 | 61 | public function testInvalidRuntimeInjector(): void |
62 | 62 | { |
63 | - $excepted = "Class 'Spiral\Tests\Core\Fixtures\InvalidInjector' must be an " . |
|
63 | + $excepted = "Class 'Spiral\Tests\Core\Fixtures\InvalidInjector' must be an ". |
|
64 | 64 | "instance of InjectorInterface for 'Spiral\Tests\Core\Fixtures\TestConfig'"; |
65 | 65 | $this->expectException(InjectionException::class); |
66 | 66 | $this->expectExceptionMessage($excepted); |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | $container->bind(ConfigsInterface::class, $configurator); |
126 | 126 | |
127 | 127 | $configurator->shouldReceive('createInjection') |
128 | - ->with(m::on(static function (ReflectionClass $r) { |
|
128 | + ->with(m::on(static function (ReflectionClass $r){ |
|
129 | 129 | return $r->getName() === TestConfig::class; |
130 | 130 | }), null) |
131 | 131 | ->andReturn($expected) |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | $container->bind(ConfigsInterface::class, $configurator); |
144 | 144 | |
145 | 145 | $configurator->shouldReceive('createInjection') |
146 | - ->with(m::on(static function (ReflectionClass $r) { |
|
146 | + ->with(m::on(static function (ReflectionClass $r){ |
|
147 | 147 | return $r->getName() === TestConfig::class; |
148 | 148 | }), 'context') |
149 | 149 | ->andReturn($expected) |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | $container->bind(ConfigsInterface::class, $configurator); |
162 | 162 | |
163 | 163 | $configurator->shouldReceive('createInjection') |
164 | - ->with(m::on(static function (ReflectionClass $r) { |
|
164 | + ->with(m::on(static function (ReflectionClass $r){ |
|
165 | 165 | return $r->getName() === TestConfig::class; |
166 | 166 | }), 'contextArgument') |
167 | 167 | ->andReturn($expected) |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | $this->assertFalse($container->has('abc')); |
27 | 27 | |
28 | - $container->bind('abc', function () { |
|
28 | + $container->bind('abc', function (){ |
|
29 | 29 | return 'hello'; |
30 | 30 | }); |
31 | 31 | |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | $container = new Container(); |
39 | 39 | |
40 | 40 | $this->assertFalse($container->has('abc')); |
41 | - $container->bind('abc', function () { |
|
41 | + $container->bind('abc', function (){ |
|
42 | 42 | return 'hello'; |
43 | 43 | }); |
44 | 44 |
@@ -46,11 +46,11 @@ |
||
46 | 46 | { |
47 | 47 | [$previous, self::$container] = [self::$container, $container]; |
48 | 48 | |
49 | - try { |
|
49 | + try{ |
|
50 | 50 | return $scope(); |
51 | - } catch (Throwable $e) { |
|
51 | + }catch (Throwable $e){ |
|
52 | 52 | throw $e; |
53 | - } finally { |
|
53 | + }finally{ |
|
54 | 54 | self::$container = $previous; |
55 | 55 | } |
56 | 56 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public function get($alias, string $context = null) |
128 | 128 | { |
129 | - if ($alias instanceof Autowire) { |
|
129 | + if ($alias instanceof Autowire){ |
|
130 | 130 | return $alias->resolve($this); |
131 | 131 | } |
132 | 132 | |
@@ -142,34 +142,34 @@ discard block |
||
142 | 142 | */ |
143 | 143 | public function make(string $alias, array $parameters = [], string $context = null) |
144 | 144 | { |
145 | - if (!isset($this->bindings[$alias])) { |
|
145 | + if (!isset($this->bindings[$alias])){ |
|
146 | 146 | //No direct instructions how to construct class, make is automatically |
147 | 147 | return $this->autowire($alias, $parameters, $context); |
148 | 148 | } |
149 | 149 | |
150 | 150 | $binding = $this->bindings[$alias]; |
151 | - if (is_object($binding)) { |
|
151 | + if (is_object($binding)){ |
|
152 | 152 | //When binding is instance, assuming singleton |
153 | 153 | return $binding; |
154 | 154 | } |
155 | 155 | |
156 | - if (is_string($binding)) { |
|
156 | + if (is_string($binding)){ |
|
157 | 157 | //Binding is pointing to something else |
158 | 158 | return $this->make($binding, $parameters, $context); |
159 | 159 | } |
160 | 160 | |
161 | 161 | unset($this->bindings[$alias]); |
162 | - try { |
|
163 | - if ($binding[0] === $alias) { |
|
162 | + try{ |
|
163 | + if ($binding[0] === $alias){ |
|
164 | 164 | $instance = $this->autowire($alias, $parameters, $context); |
165 | - } else { |
|
165 | + }else{ |
|
166 | 166 | $instance = $this->evaluateBinding($alias, $binding[0], $parameters, $context); |
167 | 167 | } |
168 | - } finally { |
|
168 | + }finally{ |
|
169 | 169 | $this->bindings[$alias] = $binding; |
170 | 170 | } |
171 | 171 | |
172 | - if ($binding[1]) { |
|
172 | + if ($binding[1]){ |
|
173 | 173 | //Indicates singleton |
174 | 174 | $this->bindings[$alias] = $instance; |
175 | 175 | } |
@@ -190,30 +190,30 @@ discard block |
||
190 | 190 | string $context = null |
191 | 191 | ): array { |
192 | 192 | $arguments = []; |
193 | - foreach ($reflection->getParameters() as $parameter) { |
|
194 | - try { |
|
193 | + foreach ($reflection->getParameters() as $parameter){ |
|
194 | + try{ |
|
195 | 195 | //Information we need to know about argument in order to resolve it's value |
196 | 196 | $name = $parameter->getName(); |
197 | 197 | $class = $parameter->getClass(); |
198 | - } catch (Throwable $e) { |
|
198 | + }catch (Throwable $e){ |
|
199 | 199 | //Possibly invalid class definition or syntax error |
200 | 200 | $location = $reflection->getName(); |
201 | - if ($reflection instanceof ReflectionMethod) { |
|
201 | + if ($reflection instanceof ReflectionMethod){ |
|
202 | 202 | $location = "{$reflection->getDeclaringClass()->getName()}->{$location}"; |
203 | 203 | } |
204 | 204 | //Possibly invalid class definition or syntax error |
205 | 205 | throw new ContainerException( |
206 | - "Unable to resolve `{$parameter->getName()}` in {$location}: " . $e->getMessage(), |
|
206 | + "Unable to resolve `{$parameter->getName()}` in {$location}: ".$e->getMessage(), |
|
207 | 207 | $e->getCode(), |
208 | 208 | $e |
209 | 209 | ); |
210 | 210 | } |
211 | 211 | |
212 | - if (isset($parameters[$name]) && is_object($parameters[$name])) { |
|
213 | - if ($parameters[$name] instanceof Autowire) { |
|
212 | + if (isset($parameters[$name]) && is_object($parameters[$name])){ |
|
213 | + if ($parameters[$name] instanceof Autowire){ |
|
214 | 214 | //Supplied by user as late dependency |
215 | 215 | $arguments[] = $parameters[$name]->resolve($this); |
216 | - } else { |
|
216 | + }else{ |
|
217 | 217 | //Supplied by user as object |
218 | 218 | $arguments[] = $parameters[$name]; |
219 | 219 | } |
@@ -221,16 +221,16 @@ discard block |
||
221 | 221 | } |
222 | 222 | |
223 | 223 | // no declared type or scalar type or array |
224 | - if (!isset($class)) { |
|
224 | + if (!isset($class)){ |
|
225 | 225 | //Provided from outside |
226 | - if (array_key_exists($name, $parameters)) { |
|
226 | + if (array_key_exists($name, $parameters)){ |
|
227 | 227 | //Make sure it's properly typed |
228 | 228 | $this->assertType($parameter, $reflection, $parameters[$name]); |
229 | 229 | $arguments[] = $parameters[$name]; |
230 | 230 | continue; |
231 | 231 | } |
232 | 232 | |
233 | - if ($parameter->isDefaultValueAvailable()) { |
|
233 | + if ($parameter->isDefaultValueAvailable()){ |
|
234 | 234 | //Default value |
235 | 235 | $arguments[] = $parameter->getDefaultValue(); |
236 | 236 | continue; |
@@ -240,12 +240,12 @@ discard block |
||
240 | 240 | throw new ArgumentException($parameter, $reflection); |
241 | 241 | } |
242 | 242 | |
243 | - try { |
|
243 | + try{ |
|
244 | 244 | //Requesting for contextual dependency |
245 | 245 | $arguments[] = $this->get($class->getName(), $name); |
246 | 246 | continue; |
247 | - } catch (AutowireException $e) { |
|
248 | - if ($parameter->isOptional()) { |
|
247 | + }catch (AutowireException $e){ |
|
248 | + if ($parameter->isOptional()){ |
|
249 | 249 | //This is optional dependency, skip |
250 | 250 | $arguments[] = null; |
251 | 251 | continue; |
@@ -264,28 +264,28 @@ discard block |
||
264 | 264 | public function runScope(array $bindings, callable $scope) |
265 | 265 | { |
266 | 266 | $cleanup = $previous = []; |
267 | - foreach ($bindings as $alias => $resolver) { |
|
268 | - if (isset($this->bindings[$alias])) { |
|
267 | + foreach ($bindings as $alias => $resolver){ |
|
268 | + if (isset($this->bindings[$alias])){ |
|
269 | 269 | $previous[$alias] = $this->bindings[$alias]; |
270 | - } else { |
|
270 | + }else{ |
|
271 | 271 | $cleanup[] = $alias; |
272 | 272 | } |
273 | 273 | |
274 | 274 | $this->bind($alias, $resolver); |
275 | 275 | } |
276 | 276 | |
277 | - try { |
|
278 | - if (ContainerScope::getContainer() !== $this) { |
|
277 | + try{ |
|
278 | + if (ContainerScope::getContainer() !== $this){ |
|
279 | 279 | return ContainerScope::runScope($this, $scope); |
280 | 280 | } |
281 | 281 | |
282 | 282 | return $scope(); |
283 | - } finally { |
|
284 | - foreach (array_reverse($previous) as $alias => $resolver) { |
|
283 | + }finally{ |
|
284 | + foreach (array_reverse($previous) as $alias => $resolver){ |
|
285 | 285 | $this->bindings[$alias] = $resolver; |
286 | 286 | } |
287 | 287 | |
288 | - foreach ($cleanup as $alias) { |
|
288 | + foreach ($cleanup as $alias){ |
|
289 | 289 | unset($this->bindings[$alias]); |
290 | 290 | } |
291 | 291 | } |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | */ |
302 | 302 | public function bind(string $alias, $resolver): void |
303 | 303 | { |
304 | - if (is_array($resolver) || $resolver instanceof Closure || $resolver instanceof Autowire) { |
|
304 | + if (is_array($resolver) || $resolver instanceof Closure || $resolver instanceof Autowire){ |
|
305 | 305 | // array means = execute me, false = not singleton |
306 | 306 | $this->bindings[$alias] = [$resolver, false]; |
307 | 307 | return; |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | */ |
320 | 320 | public function bindSingleton(string $alias, $resolver): void |
321 | 321 | { |
322 | - if (is_object($resolver) && !$resolver instanceof Closure && !$resolver instanceof Autowire) { |
|
322 | + if (is_object($resolver) && !$resolver instanceof Closure && !$resolver instanceof Autowire){ |
|
323 | 323 | // direct binding to an instance |
324 | 324 | $this->bindings[$alias] = $resolver; |
325 | 325 | return; |
@@ -336,11 +336,11 @@ discard block |
||
336 | 336 | */ |
337 | 337 | public function hasInstance(string $alias): bool |
338 | 338 | { |
339 | - if (!$this->has($alias)) { |
|
339 | + if (!$this->has($alias)){ |
|
340 | 340 | return false; |
341 | 341 | } |
342 | 342 | |
343 | - while (isset($this->bindings[$alias]) && is_string($this->bindings[$alias])) { |
|
343 | + while (isset($this->bindings[$alias]) && is_string($this->bindings[$alias])){ |
|
344 | 344 | //Checking alias tree |
345 | 345 | $alias = $this->bindings[$alias]; |
346 | 346 | } |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | */ |
415 | 415 | protected function autowire(string $class, array $parameters, string $context = null) |
416 | 416 | { |
417 | - if (!class_exists($class)) { |
|
417 | + if (!class_exists($class)){ |
|
418 | 418 | throw new NotFoundException(sprintf("Undefined class or binding '%s'", $class)); |
419 | 419 | } |
420 | 420 | |
@@ -436,9 +436,9 @@ discard block |
||
436 | 436 | private function registerInstance($instance, array $parameters) |
437 | 437 | { |
438 | 438 | //Declarative singletons (only when class received via direct get) |
439 | - if ($parameters === [] && $instance instanceof SingletonInterface) { |
|
439 | + if ($parameters === [] && $instance instanceof SingletonInterface){ |
|
440 | 440 | $alias = get_class($instance); |
441 | - if (!isset($this->bindings[$alias])) { |
|
441 | + if (!isset($this->bindings[$alias])){ |
|
442 | 442 | $this->bindings[$alias] = $instance; |
443 | 443 | } |
444 | 444 | } |
@@ -462,20 +462,20 @@ discard block |
||
462 | 462 | $target, |
463 | 463 | array $parameters, |
464 | 464 | string $context = null |
465 | - ) { |
|
466 | - if (is_string($target)) { |
|
465 | + ){ |
|
466 | + if (is_string($target)){ |
|
467 | 467 | //Reference |
468 | 468 | return $this->make($target, $parameters, $context); |
469 | 469 | } |
470 | 470 | |
471 | - if ($target instanceof Autowire) { |
|
471 | + if ($target instanceof Autowire){ |
|
472 | 472 | return $target->resolve($this, $parameters); |
473 | 473 | } |
474 | 474 | |
475 | - if ($target instanceof Closure) { |
|
476 | - try { |
|
475 | + if ($target instanceof Closure){ |
|
476 | + try{ |
|
477 | 477 | $reflection = new ReflectionFunction($target); |
478 | - } catch (ReflectionException $e) { |
|
478 | + }catch (ReflectionException $e){ |
|
479 | 479 | throw new ContainerException($e->getMessage(), $e->getCode(), $e); |
480 | 480 | } |
481 | 481 | |
@@ -485,16 +485,16 @@ discard block |
||
485 | 485 | ); |
486 | 486 | } |
487 | 487 | |
488 | - if (is_array($target) && isset($target[1])) { |
|
488 | + if (is_array($target) && isset($target[1])){ |
|
489 | 489 | //In a form of resolver and method |
490 | 490 | [$resolver, $method] = $target; |
491 | 491 | |
492 | 492 | //Resolver instance (i.e. [ClassName::class, 'method']) |
493 | 493 | $resolver = $this->get($resolver); |
494 | 494 | |
495 | - try { |
|
495 | + try{ |
|
496 | 496 | $method = new ReflectionMethod($resolver, $method); |
497 | - } catch (ReflectionException $e) { |
|
497 | + }catch (ReflectionException $e){ |
|
498 | 498 | throw new ContainerException($e->getMessage(), $e->getCode(), $e); |
499 | 499 | } |
500 | 500 | |
@@ -523,22 +523,22 @@ discard block |
||
523 | 523 | */ |
524 | 524 | private function createInstance(string $class, array $parameters, string $context = null) |
525 | 525 | { |
526 | - try { |
|
526 | + try{ |
|
527 | 527 | $reflection = new ReflectionClass($class); |
528 | - } catch (ReflectionException $e) { |
|
528 | + }catch (ReflectionException $e){ |
|
529 | 529 | throw new ContainerException($e->getMessage(), $e->getCode(), $e); |
530 | 530 | } |
531 | 531 | |
532 | 532 | //We have to construct class using external injector when we know exact context |
533 | - if ($parameters === [] && $this->checkInjector($reflection)) { |
|
533 | + if ($parameters === [] && $this->checkInjector($reflection)){ |
|
534 | 534 | $injector = $this->injectors[$reflection->getName()]; |
535 | 535 | |
536 | 536 | $instance = null; |
537 | - try { |
|
537 | + try{ |
|
538 | 538 | /** @var InjectorInterface $injectorInstance */ |
539 | 539 | $injectorInstance = $this->get($injector); |
540 | 540 | |
541 | - if (!$injectorInstance instanceof InjectorInterface) { |
|
541 | + if (!$injectorInstance instanceof InjectorInterface){ |
|
542 | 542 | throw new InjectionException( |
543 | 543 | sprintf( |
544 | 544 | "Class '%s' must be an instance of InjectorInterface for '%s'", |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | } |
550 | 550 | |
551 | 551 | $instance = $injectorInstance->createInjection($reflection, $context); |
552 | - if (!$reflection->isInstance($instance)) { |
|
552 | + if (!$reflection->isInstance($instance)){ |
|
553 | 553 | throw new InjectionException( |
554 | 554 | sprintf( |
555 | 555 | "Invalid injection response for '%s'", |
@@ -557,23 +557,23 @@ discard block |
||
557 | 557 | ) |
558 | 558 | ); |
559 | 559 | } |
560 | - } finally { |
|
560 | + }finally{ |
|
561 | 561 | $this->injectors[$reflection->getName()] = $injector; |
562 | 562 | } |
563 | 563 | |
564 | 564 | return $instance; |
565 | 565 | } |
566 | 566 | |
567 | - if (!$reflection->isInstantiable()) { |
|
567 | + if (!$reflection->isInstantiable()){ |
|
568 | 568 | throw new ContainerException(sprintf("Class '%s' can not be constructed", $class)); |
569 | 569 | } |
570 | 570 | |
571 | 571 | $constructor = $reflection->getConstructor(); |
572 | 572 | |
573 | - if ($constructor !== null) { |
|
573 | + if ($constructor !== null){ |
|
574 | 574 | // Using constructor with resolved arguments |
575 | 575 | $instance = $reflection->newInstanceArgs($this->resolveArguments($constructor, $parameters)); |
576 | - } else { |
|
576 | + }else{ |
|
577 | 577 | // No constructor specified |
578 | 578 | $instance = $reflection->newInstance(); |
579 | 579 | } |
@@ -590,27 +590,27 @@ discard block |
||
590 | 590 | private function checkInjector(ReflectionClass $reflection): bool |
591 | 591 | { |
592 | 592 | $class = $reflection->getName(); |
593 | - if (array_key_exists($class, $this->injectors)) { |
|
593 | + if (array_key_exists($class, $this->injectors)){ |
|
594 | 594 | return $this->injectors[$class] !== null; |
595 | 595 | } |
596 | 596 | |
597 | 597 | if ( |
598 | 598 | $reflection->implementsInterface(InjectableInterface::class) |
599 | 599 | && $reflection->hasConstant('INJECTOR') |
600 | - ) { |
|
600 | + ){ |
|
601 | 601 | $this->injectors[$class] = $reflection->getConstant('INJECTOR'); |
602 | 602 | return true; |
603 | 603 | } |
604 | 604 | |
605 | - if (!isset($this->injectorsCache[$class])) { |
|
605 | + if (!isset($this->injectorsCache[$class])){ |
|
606 | 606 | $this->injectorsCache[$class] = null; |
607 | 607 | |
608 | 608 | // check interfaces |
609 | - foreach ($this->injectors as $target => $injector) { |
|
609 | + foreach ($this->injectors as $target => $injector){ |
|
610 | 610 | if ( |
611 | 611 | class_exists($target, true) |
612 | 612 | && $reflection->isSubclassOf($target) |
613 | - ) { |
|
613 | + ){ |
|
614 | 614 | $this->injectors[$class] = $injector; |
615 | 615 | return true; |
616 | 616 | } |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | if ( |
619 | 619 | interface_exists($target, true) |
620 | 620 | && $reflection->implementsInterface($target) |
621 | - ) { |
|
621 | + ){ |
|
622 | 622 | $this->injectors[$class] = $injector; |
623 | 623 | return true; |
624 | 624 | } |
@@ -640,11 +640,11 @@ discard block |
||
640 | 640 | */ |
641 | 641 | private function assertType(ReflectionParameter $parameter, ContextFunction $context, $value): void |
642 | 642 | { |
643 | - if ($value === null) { |
|
643 | + if ($value === null){ |
|
644 | 644 | if ( |
645 | 645 | !$parameter->isOptional() && |
646 | 646 | !($parameter->isDefaultValueAvailable() && $parameter->getDefaultValue() === null) |
647 | - ) { |
|
647 | + ){ |
|
648 | 648 | throw new ArgumentException($parameter, $context); |
649 | 649 | } |
650 | 650 | |
@@ -652,20 +652,20 @@ discard block |
||
652 | 652 | } |
653 | 653 | |
654 | 654 | $type = $parameter->getType(); |
655 | - if ($type === null) { |
|
655 | + if ($type === null){ |
|
656 | 656 | return; |
657 | 657 | } |
658 | 658 | |
659 | 659 | $typeName = $type->getName(); |
660 | - if ($typeName === 'array' && !is_array($value)) { |
|
660 | + if ($typeName === 'array' && !is_array($value)){ |
|
661 | 661 | throw new ArgumentException($parameter, $context); |
662 | 662 | } |
663 | 663 | |
664 | - if (($typeName === 'int' || $typeName === 'float') && !is_numeric($value)) { |
|
664 | + if (($typeName === 'int' || $typeName === 'float') && !is_numeric($value)){ |
|
665 | 665 | throw new ArgumentException($parameter, $context); |
666 | 666 | } |
667 | 667 | |
668 | - if ($typeName === 'bool' && !is_bool($value) && !is_numeric($value)) { |
|
668 | + if ($typeName === 'bool' && !is_bool($value) && !is_numeric($value)){ |
|
669 | 669 | throw new ArgumentException($parameter, $context); |
670 | 670 | } |
671 | 671 | } |