@@ -32,11 +32,11 @@ |
||
32 | 32 | public function hasInstance(string $alias): bool |
33 | 33 | { |
34 | 34 | $parent = $this->scope->getParent(); |
35 | - if ($parent !== null && $parent->hasInstance($alias)) { |
|
35 | + if ($parent !== null && $parent->hasInstance($alias)){ |
|
36 | 36 | return true; |
37 | 37 | } |
38 | 38 | |
39 | - if (!$this->container->has($alias)) { |
|
39 | + if (!$this->container->has($alias)){ |
|
40 | 40 | return false; |
41 | 41 | } |
42 | 42 |
@@ -32,11 +32,13 @@ |
||
32 | 32 | public function hasInstance(string $alias): bool |
33 | 33 | { |
34 | 34 | $parent = $this->scope->getParent(); |
35 | - if ($parent !== null && $parent->hasInstance($alias)) { |
|
35 | + if ($parent !== null && $parent->hasInstance($alias)) |
|
36 | + { |
|
36 | 37 | return true; |
37 | 38 | } |
38 | 39 | |
39 | - if (!$this->container->has($alias)) { |
|
40 | + if (!$this->container->has($alias)) |
|
41 | + { |
|
40 | 42 | return false; |
41 | 43 | } |
42 | 44 |
@@ -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 | |
@@ -136,10 +136,10 @@ discard block |
||
136 | 136 | public function testHasInstanceAfterMakeWithoutAliasInScope(): void |
137 | 137 | { |
138 | 138 | $container = new Container(); |
139 | - $container->bindSingleton('test', new class implements SingletonInterface {}); |
|
139 | + $container->bindSingleton('test', new class implements SingletonInterface{}); |
|
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 class implements SingletonInterface {}); |
|
149 | + $container->bindSingleton('test', new class implements SingletonInterface |
|
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 | } |