@@ -83,7 +83,7 @@ |
||
83 | 83 | public function testNullableUnionDefaultScalar(): void |
84 | 84 | { |
85 | 85 | $result = $this->resolveClosure( |
86 | - static fn(null|int|string $param = 42) => $param |
|
86 | + static fn(null | int | string $param = 42) => $param |
|
87 | 87 | ); |
88 | 88 | |
89 | 89 | $this->assertSame([42], $result); |
@@ -12,13 +12,13 @@ |
||
12 | 12 | { |
13 | 13 | public function testInternalServicesDontBlockContainer(): void |
14 | 14 | { |
15 | - (static function () { |
|
15 | + (static function (){ |
|
16 | 16 | $container = new Container(); |
17 | 17 | $finalizer = new class { |
18 | 18 | public ?\Closure $closure = null; |
19 | 19 | public function __destruct() |
20 | 20 | { |
21 | - if ($this->closure !== null) { |
|
21 | + if ($this->closure !== null){ |
|
22 | 22 | ($this->closure)(); |
23 | 23 | } |
24 | 24 | } |
@@ -12,18 +12,22 @@ |
||
12 | 12 | { |
13 | 13 | public function testInternalServicesDontBlockContainer(): void |
14 | 14 | { |
15 | - (static function () { |
|
15 | + (static function () |
|
16 | + { |
|
16 | 17 | $container = new Container(); |
17 | - $finalizer = new class { |
|
18 | + $finalizer = new class |
|
19 | + { |
|
18 | 20 | public ?\Closure $closure = null; |
19 | 21 | public function __destruct() |
20 | 22 | { |
21 | - if ($this->closure !== null) { |
|
23 | + if ($this->closure !== null) |
|
24 | + { |
|
22 | 25 | ($this->closure)(); |
23 | 26 | } |
24 | 27 | } |
25 | 28 | }; |
26 | - $finalizer->closure = static function () use ($container) { |
|
29 | + $finalizer->closure = static function () use ($container) |
|
30 | + { |
|
27 | 31 | $container->hasInstance('finalizer'); |
28 | 32 | }; |
29 | 33 | $container->bind('finalizer', $finalizer); |
@@ -36,9 +36,9 @@ |
||
36 | 36 | { |
37 | 37 | $map = new WeakMap(); |
38 | 38 | |
39 | - $fn = function (WeakMap $map) { |
|
40 | - foreach ($this as $key => $value) { |
|
41 | - if (\is_object($value)) { |
|
39 | + $fn = function (WeakMap $map){ |
|
40 | + foreach ($this as $key => $value){ |
|
41 | + if (\is_object($value)){ |
|
42 | 42 | $map->offsetSet($value, $key); |
43 | 43 | } |
44 | 44 | } |
@@ -36,9 +36,12 @@ |
||
36 | 36 | { |
37 | 37 | $map = new WeakMap(); |
38 | 38 | |
39 | - $fn = function (WeakMap $map) { |
|
40 | - foreach ($this as $key => $value) { |
|
41 | - if (\is_object($value)) { |
|
39 | + $fn = function (WeakMap $map) |
|
40 | + { |
|
41 | + foreach ($this as $key => $value) |
|
42 | + { |
|
43 | + if (\is_object($value)) |
|
44 | + { |
|
42 | 45 | $map->offsetSet($value, $key); |
43 | 46 | } |
44 | 47 | } |
@@ -85,7 +85,7 @@ |
||
85 | 85 | |
86 | 86 | public function testClosureFactory(): void |
87 | 87 | { |
88 | - $this->bind(Bucket::class, function ($data) { |
|
88 | + $this->bind(Bucket::class, function ($data){ |
|
89 | 89 | return new Bucket('via-closure', $data); |
90 | 90 | }); |
91 | 91 |
@@ -88,7 +88,8 @@ discard block |
||
88 | 88 | |
89 | 89 | public function testClosureFactory(): void |
90 | 90 | { |
91 | - $this->bind(Bucket::class, function ($data) { |
|
91 | + $this->bind(Bucket::class, function ($data) |
|
92 | + { |
|
92 | 93 | return new Bucket('via-closure', $data); |
93 | 94 | }); |
94 | 95 | |
@@ -128,7 +129,8 @@ discard block |
||
128 | 129 | $sample = new SampleClass(); |
129 | 130 | |
130 | 131 | $this->bind(Bucket::class, [Factory::class, 'makeBucketWithSample']); |
131 | - $this->bind(SampleClass::class, function () use ($sample) { |
|
132 | + $this->bind(SampleClass::class, function () use ($sample) |
|
133 | + { |
|
132 | 134 | return $sample; |
133 | 135 | }); |
134 | 136 |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | public function testClassWithNamespace(): void |
94 | 94 | { |
95 | 95 | $this->assertSame( |
96 | - 'function (?' . Container::class . ' ...$v)', |
|
96 | + 'function (?'.Container::class.' ...$v)', |
|
97 | 97 | $this->renderClosureForTesting(fn (?Container ...$v) => null), |
98 | 98 | ); |
99 | 99 | } |
@@ -102,14 +102,14 @@ discard block |
||
102 | 102 | { |
103 | 103 | $this->assertSame( |
104 | 104 | 'function (self|string|int|null $v)', |
105 | - $this->renderClosureForTesting(fn (self|string|int|null $v) => null), |
|
105 | + $this->renderClosureForTesting(fn (self | string | int | null $v) => null), |
|
106 | 106 | ); |
107 | 107 | } |
108 | 108 | |
109 | 109 | public function testTypeIntersection(): void |
110 | 110 | { |
111 | 111 | $this->assertSame( |
112 | - 'function (' . ContainerInterface::class . '&' . ContainerExceptionInterface::class . ' $v)', |
|
112 | + 'function ('.ContainerInterface::class.'&'.ContainerExceptionInterface::class.' $v)', |
|
113 | 113 | $this->renderClosureForTesting(fn (ContainerInterface&ContainerExceptionInterface $v) => null), |
114 | 114 | ); |
115 | 115 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | { |
128 | 128 | $this->assertSame( |
129 | 129 | 'function (Foo|Bar $v)', |
130 | - $this->renderClosureForTesting(fn (\Foo|\Bar $v) => null), |
|
130 | + $this->renderClosureForTesting(fn (\Foo | \Bar $v) => null), |
|
131 | 131 | ); |
132 | 132 | } |
133 | 133 |
@@ -13,6 +13,6 @@ |
||
13 | 13 | public bool $bool, |
14 | 14 | public array $array = [], |
15 | 15 | public ?string $pong = null |
16 | - ) { |
|
16 | + ){ |
|
17 | 17 | } |
18 | 18 | } |
@@ -8,7 +8,7 @@ |
||
8 | 8 | { |
9 | 9 | public function __construct( |
10 | 10 | public LightEngine $engine |
11 | - ) { |
|
11 | + ){ |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | public function __call(string $name, array $arguments) |
@@ -10,6 +10,6 @@ |
||
10 | 10 | { |
11 | 11 | public function __construct( |
12 | 12 | private object $object = new stdClass() |
13 | - ) { |
|
13 | + ){ |
|
14 | 14 | } |
15 | 15 | } |
@@ -35,18 +35,18 @@ discard block |
||
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 |
||
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 |
@@ -35,18 +35,23 @@ discard block |
||
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 |
||
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 |