@@ -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 |
@@ -58,7 +58,8 @@ discard block |
||
58 | 58 | |
59 | 59 | $instance = new SampleClass(); |
60 | 60 | |
61 | - $container->bindSingleton('sampleClass', function () use ($instance) { |
|
61 | + $container->bindSingleton('sampleClass', function () use ($instance) |
|
62 | + { |
|
62 | 63 | return $instance; |
63 | 64 | }); |
64 | 65 | |
@@ -69,7 +70,8 @@ discard block |
||
69 | 70 | { |
70 | 71 | $container = new Container(); |
71 | 72 | |
72 | - $container->bindSingleton('sampleClass', function () { |
|
73 | + $container->bindSingleton('sampleClass', function () |
|
74 | + { |
|
73 | 75 | return new SampleClass(); |
74 | 76 | }); |
75 | 77 | |
@@ -143,7 +145,8 @@ discard block |
||
143 | 145 | $container = new Container(); |
144 | 146 | $container->bindSingleton('singleton', 'sampleClass'); |
145 | 147 | |
146 | - $container->bind('sampleClass', function () { |
|
148 | + $container->bind('sampleClass', function () |
|
149 | + { |
|
147 | 150 | return new SampleClass(); |
148 | 151 | }); |
149 | 152 | |
@@ -187,7 +190,9 @@ discard block |
||
187 | 190 | public function testHasShouldReturnTrueWhenSingletonIsAlreadyConstructed(): void |
188 | 191 | { |
189 | 192 | $container = new Container(); |
190 | - $class = new #[Singleton] class {}; |
|
193 | + $class = new #[Singleton] class |
|
194 | + { |
|
195 | +}; |
|
191 | 196 | |
192 | 197 | $this->assertFalse($container->has($class::class)); |
193 | 198 | |
@@ -200,7 +205,8 @@ discard block |
||
200 | 205 | { |
201 | 206 | return new |
202 | 207 | #[Singleton] |
203 | - class { |
|
208 | + class |
|
209 | + { |
|
204 | 210 | public string $baz = 'baz'; |
205 | 211 | }; |
206 | 212 | } |
@@ -46,7 +46,9 @@ |
||
46 | 46 | $binder = $this->constructor->get('binder', BinderInterface::class); |
47 | 47 | $factory = $this->constructor->get('factory', FactoryInterface::class); |
48 | 48 | |
49 | - $this->bindSingleton('test', new #[Singleton] class {}); |
|
49 | + $this->bindSingleton('test', new #[Singleton] class |
|
50 | + { |
|
51 | +}); |
|
50 | 52 | $factory->make('test'); |
51 | 53 | |
52 | 54 | $this->assertTrue($binder->hasInstance('test')); |
@@ -34,11 +34,11 @@ discard block |
||
34 | 34 | |
35 | 35 | $this->assertNull(ContainerScope::getContainer()); |
36 | 36 | |
37 | - try { |
|
37 | + try{ |
|
38 | 38 | $this->assertTrue(ContainerScope::runScope($container, function () use ($container): void { |
39 | 39 | throw new RuntimeException('exception'); |
40 | 40 | })); |
41 | - } catch (\Throwable $e) { |
|
41 | + }catch (\Throwable $e){ |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | $this->assertInstanceOf(RuntimeException::class, $e); |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | $this->assertTrue($c->runScope([ |
57 | 57 | 'bucket' => new Bucket('b'), |
58 | 58 | 'other' => new SampleClass() |
59 | - ], function ($c) { |
|
59 | + ], function ($c){ |
|
60 | 60 | $this->assertSame('b', $c->get('bucket')->getName()); |
61 | 61 | $this->assertTrue($c->has('other')); |
62 | 62 | |
@@ -78,21 +78,21 @@ discard block |
||
78 | 78 | $this->assertTrue($c->runScope([ |
79 | 79 | 'bucket' => new Bucket('b'), |
80 | 80 | 'other' => new SampleClass() |
81 | - ], function ($c) { |
|
81 | + ], function ($c){ |
|
82 | 82 | $this->assertSame('b', $c->get('bucket')->getName()); |
83 | 83 | $this->assertTrue($c->has('other')); |
84 | 84 | |
85 | 85 | return $c->get('bucket')->getName() == 'b' && $c->has('other'); |
86 | 86 | })); |
87 | 87 | |
88 | - try { |
|
88 | + try{ |
|
89 | 89 | $this->assertTrue($c->runScope([ |
90 | 90 | 'bucket' => new Bucket('b'), |
91 | 91 | 'other' => new SampleClass() |
92 | 92 | ], function () use ($c): void { |
93 | 93 | throw new RuntimeException('exception'); |
94 | 94 | })); |
95 | - } catch (\Throwable $e) { |
|
95 | + }catch (\Throwable $e){ |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | $this->assertSame('a', $c->get('bucket')->getName()); |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | ContainerScope::runScope($container, static fn (ContainerInterface $container) => $container) |
109 | 109 | ); |
110 | 110 | |
111 | - $result = ContainerScope::runScope($container, static function (Container $container) { |
|
111 | + $result = ContainerScope::runScope($container, static function (Container $container){ |
|
112 | 112 | return $container->runScope([], static fn (Container $container) => $container); |
113 | 113 | }); |
114 | 114 | |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | $container->bindSingleton('test', new #[Singleton] class {}); |
140 | 140 | $container->make('test'); |
141 | 141 | |
142 | - $container->runScoped(function (Container $container) { |
|
142 | + $container->runScoped(function (Container $container){ |
|
143 | 143 | $this->assertTrue($container->hasInstance('test')); |
144 | 144 | }); |
145 | 145 | } |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | $container->bindSingleton('test', SampleClass::class); |
151 | 151 | $container->make('test'); |
152 | 152 | |
153 | - $container->runScoped(function (Container $container) { |
|
153 | + $container->runScoped(function (Container $container){ |
|
154 | 154 | $this->assertTrue($container->hasInstance('test')); |
155 | 155 | }); |
156 | 156 | } |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | $container->bindSingleton('bar', 'foo'); |
166 | 166 | $container->make('bar'); |
167 | 167 | |
168 | - $container->runScoped(function (Container $container) { |
|
168 | + $container->runScoped(function (Container $container){ |
|
169 | 169 | $this->assertTrue($container->hasInstance('bar')); |
170 | 170 | }); |
171 | 171 | } |
@@ -21,7 +21,8 @@ discard block |
||
21 | 21 | |
22 | 22 | $this->assertNull(ContainerScope::getContainer()); |
23 | 23 | |
24 | - $this->assertTrue(ContainerScope::runScope($container, function () use ($container) { |
|
24 | + $this->assertTrue(ContainerScope::runScope($container, function () use ($container) |
|
25 | + { |
|
25 | 26 | return $container === ContainerScope::getContainer(); |
26 | 27 | })); |
27 | 28 | |
@@ -34,11 +35,14 @@ discard block |
||
34 | 35 | |
35 | 36 | $this->assertNull(ContainerScope::getContainer()); |
36 | 37 | |
37 | - try { |
|
38 | + try |
|
39 | + { |
|
38 | 40 | $this->assertTrue(ContainerScope::runScope($container, function () use ($container): void { |
39 | 41 | throw new RuntimeException('exception'); |
40 | 42 | })); |
41 | - } catch (\Throwable $e) { |
|
43 | + } |
|
44 | + catch (\Throwable $e) |
|
45 | + { |
|
42 | 46 | } |
43 | 47 | |
44 | 48 | $this->assertInstanceOf(RuntimeException::class, $e); |
@@ -56,7 +60,8 @@ discard block |
||
56 | 60 | $this->assertTrue($c->runScope([ |
57 | 61 | 'bucket' => new Bucket('b'), |
58 | 62 | 'other' => new SampleClass() |
59 | - ], function ($c) { |
|
63 | + ], function ($c) |
|
64 | + { |
|
60 | 65 | $this->assertSame('b', $c->get('bucket')->getName()); |
61 | 66 | $this->assertTrue($c->has('other')); |
62 | 67 | |
@@ -78,21 +83,25 @@ discard block |
||
78 | 83 | $this->assertTrue($c->runScope([ |
79 | 84 | 'bucket' => new Bucket('b'), |
80 | 85 | 'other' => new SampleClass() |
81 | - ], function ($c) { |
|
86 | + ], function ($c) |
|
87 | + { |
|
82 | 88 | $this->assertSame('b', $c->get('bucket')->getName()); |
83 | 89 | $this->assertTrue($c->has('other')); |
84 | 90 | |
85 | 91 | return $c->get('bucket')->getName() == 'b' && $c->has('other'); |
86 | 92 | })); |
87 | 93 | |
88 | - try { |
|
94 | + try |
|
95 | + { |
|
89 | 96 | $this->assertTrue($c->runScope([ |
90 | 97 | 'bucket' => new Bucket('b'), |
91 | 98 | 'other' => new SampleClass() |
92 | 99 | ], function () use ($c): void { |
93 | 100 | throw new RuntimeException('exception'); |
94 | 101 | })); |
95 | - } catch (\Throwable $e) { |
|
102 | + } |
|
103 | + catch (\Throwable $e) |
|
104 | + { |
|
96 | 105 | } |
97 | 106 | |
98 | 107 | $this->assertSame('a', $c->get('bucket')->getName()); |
@@ -108,7 +117,8 @@ discard block |
||
108 | 117 | ContainerScope::runScope($container, static fn (ContainerInterface $container) => $container) |
109 | 118 | ); |
110 | 119 | |
111 | - $result = ContainerScope::runScope($container, static function (Container $container) { |
|
120 | + $result = ContainerScope::runScope($container, static function (Container $container) |
|
121 | + { |
|
112 | 122 | return $container->runScope([], static fn (Container $container) => $container); |
113 | 123 | }); |
114 | 124 | |
@@ -136,10 +146,13 @@ discard block |
||
136 | 146 | public function testHasInstanceAfterMakeWithoutAliasInScope(): void |
137 | 147 | { |
138 | 148 | $container = new Container(); |
139 | - $container->bindSingleton('test', new #[Singleton] class {}); |
|
149 | + $container->bindSingleton('test', new #[Singleton] class |
|
150 | + { |
|
151 | +}); |
|
140 | 152 | $container->make('test'); |
141 | 153 | |
142 | - $container->runScoped(function (Container $container) { |
|
154 | + $container->runScoped(function (Container $container) |
|
155 | + { |
|
143 | 156 | $this->assertTrue($container->hasInstance('test')); |
144 | 157 | }); |
145 | 158 | } |
@@ -150,7 +163,8 @@ discard block |
||
150 | 163 | $container->bindSingleton('test', SampleClass::class); |
151 | 164 | $container->make('test'); |
152 | 165 | |
153 | - $container->runScoped(function (Container $container) { |
|
166 | + $container->runScoped(function (Container $container) |
|
167 | + { |
|
154 | 168 | $this->assertTrue($container->hasInstance('test')); |
155 | 169 | }); |
156 | 170 | } |
@@ -165,7 +179,8 @@ discard block |
||
165 | 179 | $container->bindSingleton('bar', 'foo'); |
166 | 180 | $container->make('bar'); |
167 | 181 | |
168 | - $container->runScoped(function (Container $container) { |
|
182 | + $container->runScoped(function (Container $container) |
|
183 | + { |
|
169 | 184 | $this->assertTrue($container->hasInstance('bar')); |
170 | 185 | }); |
171 | 186 | } |