@@ -10,7 +10,7 @@ |
||
10 | 10 | { |
11 | 11 | public function __construct( |
12 | 12 | protected ContainerInterface $container, |
13 | - ) { |
|
13 | + ){ |
|
14 | 14 | } |
15 | 15 | |
16 | 16 | public function make(string $key): mixed |
@@ -8,6 +8,6 @@ |
||
8 | 8 | { |
9 | 9 | public function __construct( |
10 | 10 | public LoggerInterface $logger, |
11 | - ) { |
|
11 | + ){ |
|
12 | 12 | } |
13 | 13 | } |
@@ -18,11 +18,11 @@ discard block |
||
18 | 18 | |
19 | 19 | $container = new Container(); |
20 | 20 | |
21 | - $container->scope(static function (Container $c1) { |
|
22 | - try { |
|
21 | + $container->scope(static function (Container $c1){ |
|
22 | + try{ |
|
23 | 23 | $c1->get(ExceptionConstructor::class); |
24 | 24 | self::fail('Exception should be thrown'); |
25 | - } catch (\Throwable $e) { |
|
25 | + }catch (\Throwable $e){ |
|
26 | 26 | // self::assertInstanceOf(\InvalidArgumentException::class, $e); |
27 | 27 | throw $e; |
28 | 28 | } |
@@ -36,11 +36,11 @@ discard block |
||
36 | 36 | |
37 | 37 | $container = new Container(); |
38 | 38 | |
39 | - $container->scope(static function (Container $c1) { |
|
40 | - try { |
|
39 | + $container->scope(static function (Container $c1){ |
|
40 | + try{ |
|
41 | 41 | $c1->get(ExceptionConstructor::class); |
42 | 42 | self::fail('Exception should be thrown'); |
43 | - } catch (\Throwable $e) { |
|
43 | + }catch (\Throwable $e){ |
|
44 | 44 | // self::assertInstanceOf(\InvalidArgumentException::class, $e); |
45 | 45 | throw $e; |
46 | 46 | } |
@@ -54,11 +54,11 @@ discard block |
||
54 | 54 | |
55 | 55 | $container = new Container(); |
56 | 56 | |
57 | - $container->scope(static function (Container $c1) { |
|
58 | - try { |
|
57 | + $container->scope(static function (Container $c1){ |
|
58 | + try{ |
|
59 | 59 | $c1->get(DatetimeCarrier::class); |
60 | 60 | self::fail('Exception should be thrown'); |
61 | - } catch (\Throwable $e) { |
|
61 | + }catch (\Throwable $e){ |
|
62 | 62 | self::assertInstanceOf(NotFoundException::class, $e); |
63 | 63 | self::assertInstanceOf(NotFoundException::class, $e->getPrevious()); |
64 | 64 | self::assertStringContainsString( |
@@ -18,11 +18,15 @@ discard block |
||
18 | 18 | |
19 | 19 | $container = new Container(); |
20 | 20 | |
21 | - $container->scope(static function (Container $c1) { |
|
22 | - try { |
|
21 | + $container->scope(static function (Container $c1) |
|
22 | + { |
|
23 | + try |
|
24 | + { |
|
23 | 25 | $c1->get(ExceptionConstructor::class); |
24 | 26 | self::fail('Exception should be thrown'); |
25 | - } catch (\Throwable $e) { |
|
27 | + } |
|
28 | + catch (\Throwable $e) |
|
29 | + { |
|
26 | 30 | // self::assertInstanceOf(\InvalidArgumentException::class, $e); |
27 | 31 | throw $e; |
28 | 32 | } |
@@ -36,11 +40,15 @@ discard block |
||
36 | 40 | |
37 | 41 | $container = new Container(); |
38 | 42 | |
39 | - $container->scope(static function (Container $c1) { |
|
40 | - try { |
|
43 | + $container->scope(static function (Container $c1) |
|
44 | + { |
|
45 | + try |
|
46 | + { |
|
41 | 47 | $c1->get(ExceptionConstructor::class); |
42 | 48 | self::fail('Exception should be thrown'); |
43 | - } catch (\Throwable $e) { |
|
49 | + } |
|
50 | + catch (\Throwable $e) |
|
51 | + { |
|
44 | 52 | // self::assertInstanceOf(\InvalidArgumentException::class, $e); |
45 | 53 | throw $e; |
46 | 54 | } |
@@ -54,11 +62,15 @@ discard block |
||
54 | 62 | |
55 | 63 | $container = new Container(); |
56 | 64 | |
57 | - $container->scope(static function (Container $c1) { |
|
58 | - try { |
|
65 | + $container->scope(static function (Container $c1) |
|
66 | + { |
|
67 | + try |
|
68 | + { |
|
59 | 69 | $c1->get(DatetimeCarrier::class); |
60 | 70 | self::fail('Exception should be thrown'); |
61 | - } catch (\Throwable $e) { |
|
71 | + } |
|
72 | + catch (\Throwable $e) |
|
73 | + { |
|
62 | 74 | self::assertInstanceOf(NotFoundException::class, $e); |
63 | 75 | self::assertInstanceOf(NotFoundException::class, $e->getPrevious()); |
64 | 76 | self::assertStringContainsString( |
@@ -22,10 +22,10 @@ discard block |
||
22 | 22 | $root = new Container(); |
23 | 23 | $root->bind(LoggerInterface::class, KVLogger::class); |
24 | 24 | |
25 | - $root->scope(static function (Container $c1) { |
|
25 | + $root->scope(static function (Container $c1){ |
|
26 | 26 | $c1->bind(LoggerInterface::class, FileLogger::class); |
27 | 27 | |
28 | - $c1->scope(static function (LoggerCarrier $carrier, LoggerInterface $logger) { |
|
28 | + $c1->scope(static function (LoggerCarrier $carrier, LoggerInterface $logger){ |
|
29 | 29 | // from the $root container |
30 | 30 | self::assertInstanceOf(KVLogger::class, $carrier->logger); |
31 | 31 | // from the $c1 container |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | $root = new Container(); |
40 | 40 | $root->bind(LoggerInterface::class, KVLogger::class); |
41 | 41 | |
42 | - $root->scope(static function (Container $c1) { |
|
42 | + $root->scope(static function (Container $c1){ |
|
43 | 43 | $c1->bind(LoggerInterface::class, FileLogger::class); |
44 | 44 | |
45 | 45 | self::assertInstanceOf( |
@@ -22,10 +22,12 @@ discard block |
||
22 | 22 | $root = new Container(); |
23 | 23 | $root->bind(LoggerInterface::class, KVLogger::class); |
24 | 24 | |
25 | - $root->scope(static function (Container $c1) { |
|
25 | + $root->scope(static function (Container $c1) |
|
26 | + { |
|
26 | 27 | $c1->bind(LoggerInterface::class, FileLogger::class); |
27 | 28 | |
28 | - $c1->scope(static function (LoggerCarrier $carrier, LoggerInterface $logger) { |
|
29 | + $c1->scope(static function (LoggerCarrier $carrier, LoggerInterface $logger) |
|
30 | + { |
|
29 | 31 | // from the $root container |
30 | 32 | self::assertInstanceOf(KVLogger::class, $carrier->logger); |
31 | 33 | // from the $c1 container |
@@ -39,7 +41,8 @@ discard block |
||
39 | 41 | $root = new Container(); |
40 | 42 | $root->bind(LoggerInterface::class, KVLogger::class); |
41 | 43 | |
42 | - $root->scope(static function (Container $c1) { |
|
44 | + $root->scope(static function (Container $c1) |
|
45 | + { |
|
43 | 46 | $c1->bind(LoggerInterface::class, FileLogger::class); |
44 | 47 | |
45 | 48 | self::assertInstanceOf( |
@@ -19,8 +19,8 @@ discard block |
||
19 | 19 | { |
20 | 20 | $root = new Container(); |
21 | 21 | |
22 | - $obj = $root->scope(static function (Container $c1) { |
|
23 | - $obj = $c1->scope(static function (Container $c2) { |
|
22 | + $obj = $root->scope(static function (Container $c1){ |
|
23 | + $obj = $c1->scope(static function (Container $c2){ |
|
24 | 24 | $obj = $c2->get(AttrScopeFooFinalize::class); |
25 | 25 | |
26 | 26 | self::assertFalse($obj->finalized); |
@@ -73,12 +73,12 @@ discard block |
||
73 | 73 | self::expectException(FinalizersException::class); |
74 | 74 | self::expectExceptionMessage('An exception has been thrown during finalization of the scope `foo`'); |
75 | 75 | |
76 | - try { |
|
77 | - $root->scope(static function (Container $c1) { |
|
76 | + try{ |
|
77 | + $root->scope(static function (Container $c1){ |
|
78 | 78 | $obj = $c1->get(AttrScopeFooFinalize::class); |
79 | 79 | $obj->throwException = true; |
80 | 80 | }, name: 'foo'); |
81 | - } catch (FinalizersException $e) { |
|
81 | + }catch (FinalizersException $e){ |
|
82 | 82 | self::assertSame('foo', $e->getScope()); |
83 | 83 | self::assertCount(1, $e->getExceptions()); |
84 | 84 | // Contains the message from the inner exception. |
@@ -101,13 +101,13 @@ discard block |
||
101 | 101 | self::expectException(FinalizersException::class); |
102 | 102 | self::expectExceptionMessage('3 exceptions have been thrown during finalization of the scope `foo`'); |
103 | 103 | |
104 | - try { |
|
105 | - $root->scope(static function (Container $c1) { |
|
104 | + try{ |
|
105 | + $root->scope(static function (Container $c1){ |
|
106 | 106 | $c1->get(AttrScopeFooFinalize::class)->throwException = true; |
107 | 107 | $c1->get(AttrScopeFooFinalize::class)->throwException = true; |
108 | 108 | $c1->get(AttrScopeFooFinalize::class)->throwException = true; |
109 | 109 | }, name: 'foo'); |
110 | - } catch (FinalizersException $e) { |
|
110 | + }catch (FinalizersException $e){ |
|
111 | 111 | self::assertSame('foo', $e->getScope()); |
112 | 112 | self::assertCount(3, $e->getExceptions()); |
113 | 113 | // Contains the message from the inner exception. |
@@ -20,8 +20,10 @@ discard block |
||
20 | 20 | { |
21 | 21 | $root = new Container(); |
22 | 22 | |
23 | - $obj = $root->scope(static function (Container $c1) { |
|
24 | - $obj = $c1->scope(static function (Container $c2) { |
|
23 | + $obj = $root->scope(static function (Container $c1) |
|
24 | + { |
|
25 | + $obj = $c1->scope(static function (Container $c2) |
|
26 | + { |
|
25 | 27 | $obj = $c2->get(AttrScopeFooFinalize::class); |
26 | 28 | |
27 | 29 | self::assertFalse($obj->finalized); |
@@ -45,8 +47,10 @@ discard block |
||
45 | 47 | $root->bindSingleton(LoggerInterface::class, FileLogger::class); |
46 | 48 | |
47 | 49 | $obj2 = null; |
48 | - $obj = $root->scope(static function (Container $c1) use (&$obj2) { |
|
49 | - $obj = $c1->scope(static function (Container $c2) use (&$obj2) { |
|
50 | + $obj = $root->scope(static function (Container $c1) use (&$obj2) |
|
51 | + { |
|
52 | + $obj = $c1->scope(static function (Container $c2) use (&$obj2) |
|
53 | + { |
|
50 | 54 | $obj = $c2->get(AttrScopeFooFinalize::class); |
51 | 55 | $obj2 = $c2->get(AttrScopeFooFinalize::class); |
52 | 56 | |
@@ -76,8 +80,10 @@ discard block |
||
76 | 80 | $root->bindSingleton(LoggerInterface::class, FileLogger::class); |
77 | 81 | |
78 | 82 | $obj2 = null; |
79 | - $obj = $root->scope(static function (Container $c1) use (&$obj2) { |
|
80 | - $obj = $c1->scope(static function (Container $c2) use (&$obj2) { |
|
83 | + $obj = $root->scope(static function (Container $c1) use (&$obj2) |
|
84 | + { |
|
85 | + $obj = $c1->scope(static function (Container $c2) use (&$obj2) |
|
86 | + { |
|
81 | 87 | $obj = $c2->get(AttrFinalize::class); |
82 | 88 | $obj2 = $c2->get(AttrFinalize::class); |
83 | 89 | |
@@ -122,12 +128,16 @@ discard block |
||
122 | 128 | self::expectException(FinalizersException::class); |
123 | 129 | self::expectExceptionMessage('An exception has been thrown during finalization of the scope `foo`'); |
124 | 130 | |
125 | - try { |
|
126 | - $root->scope(static function (Container $c1) { |
|
131 | + try |
|
132 | + { |
|
133 | + $root->scope(static function (Container $c1) |
|
134 | + { |
|
127 | 135 | $obj = $c1->get(AttrScopeFooFinalize::class); |
128 | 136 | $obj->throwException = true; |
129 | 137 | }, name: 'foo'); |
130 | - } catch (FinalizersException $e) { |
|
138 | + } |
|
139 | + catch (FinalizersException $e) |
|
140 | + { |
|
131 | 141 | self::assertSame('foo', $e->getScope()); |
132 | 142 | self::assertCount(1, $e->getExceptions()); |
133 | 143 | // Contains the message from the inner exception. |
@@ -150,13 +160,17 @@ discard block |
||
150 | 160 | self::expectException(FinalizersException::class); |
151 | 161 | self::expectExceptionMessage('3 exceptions have been thrown during finalization of the scope `foo`'); |
152 | 162 | |
153 | - try { |
|
154 | - $root->scope(static function (Container $c1) { |
|
163 | + try |
|
164 | + { |
|
165 | + $root->scope(static function (Container $c1) |
|
166 | + { |
|
155 | 167 | $c1->get(AttrScopeFooFinalize::class)->throwException = true; |
156 | 168 | $c1->get(AttrScopeFooFinalize::class)->throwException = true; |
157 | 169 | $c1->get(AttrScopeFooFinalize::class)->throwException = true; |
158 | 170 | }, name: 'foo'); |
159 | - } catch (FinalizersException $e) { |
|
171 | + } |
|
172 | + catch (FinalizersException $e) |
|
173 | + { |
|
160 | 174 | self::assertSame('foo', $e->getScope()); |
161 | 175 | self::assertCount(3, $e->getExceptions()); |
162 | 176 | // Contains the message from the inner exception. |
@@ -56,7 +56,8 @@ discard block |
||
56 | 56 | |
57 | 57 | $instance = new SampleClass(); |
58 | 58 | |
59 | - $container->bindSingleton('sampleClass', function () use ($instance) { |
|
59 | + $container->bindSingleton('sampleClass', function () use ($instance) |
|
60 | + { |
|
60 | 61 | return $instance; |
61 | 62 | }); |
62 | 63 | |
@@ -67,7 +68,8 @@ discard block |
||
67 | 68 | { |
68 | 69 | $container = new Container(); |
69 | 70 | |
70 | - $container->bindSingleton('sampleClass', function () { |
|
71 | + $container->bindSingleton('sampleClass', function () |
|
72 | + { |
|
71 | 73 | return new SampleClass(); |
72 | 74 | }); |
73 | 75 | |
@@ -130,7 +132,8 @@ discard block |
||
130 | 132 | $container = new Container(); |
131 | 133 | $container->bindSingleton('singleton', 'sampleClass'); |
132 | 134 | |
133 | - $container->bind('sampleClass', function () { |
|
135 | + $container->bind('sampleClass', function () |
|
136 | + { |
|
134 | 137 | return new SampleClass(); |
135 | 138 | }); |
136 | 139 | |
@@ -175,7 +178,8 @@ discard block |
||
175 | 178 | { |
176 | 179 | return new |
177 | 180 | #[Singleton] |
178 | - class { |
|
181 | + class |
|
182 | + { |
|
179 | 183 | public string $baz = 'baz'; |
180 | 184 | }; |
181 | 185 | } |
@@ -33,11 +33,11 @@ discard block |
||
33 | 33 | |
34 | 34 | $this->assertNull(ContainerScope::getContainer()); |
35 | 35 | |
36 | - try { |
|
36 | + try{ |
|
37 | 37 | $this->assertTrue(ContainerScope::runScope($container, function () use ($container): void { |
38 | 38 | throw new RuntimeException('exception'); |
39 | 39 | })); |
40 | - } catch (\Throwable $e) { |
|
40 | + }catch (\Throwable $e){ |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | $this->assertInstanceOf(RuntimeException::class, $e); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | $this->assertTrue($c->runScope([ |
56 | 56 | 'bucket' => new Bucket('b'), |
57 | 57 | 'other' => new SampleClass() |
58 | - ], function ($c) { |
|
58 | + ], function ($c){ |
|
59 | 59 | $this->assertSame('b', $c->get('bucket')->getName()); |
60 | 60 | $this->assertTrue($c->has('other')); |
61 | 61 | |
@@ -77,21 +77,21 @@ discard block |
||
77 | 77 | $this->assertTrue($c->runScope([ |
78 | 78 | 'bucket' => new Bucket('b'), |
79 | 79 | 'other' => new SampleClass() |
80 | - ], function ($c) { |
|
80 | + ], function ($c){ |
|
81 | 81 | $this->assertSame('b', $c->get('bucket')->getName()); |
82 | 82 | $this->assertTrue($c->has('other')); |
83 | 83 | |
84 | 84 | return $c->get('bucket')->getName() == 'b' && $c->has('other'); |
85 | 85 | })); |
86 | 86 | |
87 | - try { |
|
87 | + try{ |
|
88 | 88 | $this->assertTrue($c->runScope([ |
89 | 89 | 'bucket' => new Bucket('b'), |
90 | 90 | 'other' => new SampleClass() |
91 | 91 | ], function () use ($c): void { |
92 | 92 | throw new RuntimeException('exception'); |
93 | 93 | })); |
94 | - } catch (\Throwable $e) { |
|
94 | + }catch (\Throwable $e){ |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | $this->assertSame('a', $c->get('bucket')->getName()); |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | ContainerScope::runScope($container, static fn (ContainerInterface $container) => $container) |
125 | 125 | ); |
126 | 126 | |
127 | - $result = ContainerScope::runScope($container, static function (Container $container) { |
|
127 | + $result = ContainerScope::runScope($container, static function (Container $container){ |
|
128 | 128 | return $container->runScope([], static fn (Container $container) => $container); |
129 | 129 | }); |
130 | 130 |
@@ -20,7 +20,8 @@ discard block |
||
20 | 20 | |
21 | 21 | $this->assertNull(ContainerScope::getContainer()); |
22 | 22 | |
23 | - $this->assertTrue(ContainerScope::runScope($container, function () use ($container) { |
|
23 | + $this->assertTrue(ContainerScope::runScope($container, function () use ($container) |
|
24 | + { |
|
24 | 25 | return $container === ContainerScope::getContainer(); |
25 | 26 | })); |
26 | 27 | |
@@ -33,11 +34,14 @@ discard block |
||
33 | 34 | |
34 | 35 | $this->assertNull(ContainerScope::getContainer()); |
35 | 36 | |
36 | - try { |
|
37 | + try |
|
38 | + { |
|
37 | 39 | $this->assertTrue(ContainerScope::runScope($container, function () use ($container): void { |
38 | 40 | throw new RuntimeException('exception'); |
39 | 41 | })); |
40 | - } catch (\Throwable $e) { |
|
42 | + } |
|
43 | + catch (\Throwable $e) |
|
44 | + { |
|
41 | 45 | } |
42 | 46 | |
43 | 47 | $this->assertInstanceOf(RuntimeException::class, $e); |
@@ -55,7 +59,8 @@ discard block |
||
55 | 59 | $this->assertTrue($c->runScope([ |
56 | 60 | 'bucket' => new Bucket('b'), |
57 | 61 | 'other' => new SampleClass() |
58 | - ], function ($c) { |
|
62 | + ], function ($c) |
|
63 | + { |
|
59 | 64 | $this->assertSame('b', $c->get('bucket')->getName()); |
60 | 65 | $this->assertTrue($c->has('other')); |
61 | 66 | |
@@ -77,21 +82,25 @@ discard block |
||
77 | 82 | $this->assertTrue($c->runScope([ |
78 | 83 | 'bucket' => new Bucket('b'), |
79 | 84 | 'other' => new SampleClass() |
80 | - ], function ($c) { |
|
85 | + ], function ($c) |
|
86 | + { |
|
81 | 87 | $this->assertSame('b', $c->get('bucket')->getName()); |
82 | 88 | $this->assertTrue($c->has('other')); |
83 | 89 | |
84 | 90 | return $c->get('bucket')->getName() == 'b' && $c->has('other'); |
85 | 91 | })); |
86 | 92 | |
87 | - try { |
|
93 | + try |
|
94 | + { |
|
88 | 95 | $this->assertTrue($c->runScope([ |
89 | 96 | 'bucket' => new Bucket('b'), |
90 | 97 | 'other' => new SampleClass() |
91 | 98 | ], function () use ($c): void { |
92 | 99 | throw new RuntimeException('exception'); |
93 | 100 | })); |
94 | - } catch (\Throwable $e) { |
|
101 | + } |
|
102 | + catch (\Throwable $e) |
|
103 | + { |
|
95 | 104 | } |
96 | 105 | |
97 | 106 | $this->assertSame('a', $c->get('bucket')->getName()); |
@@ -124,7 +133,8 @@ discard block |
||
124 | 133 | ContainerScope::runScope($container, static fn (ContainerInterface $container) => $container) |
125 | 134 | ); |
126 | 135 | |
127 | - $result = ContainerScope::runScope($container, static function (Container $container) { |
|
136 | + $result = ContainerScope::runScope($container, static function (Container $container) |
|
137 | + { |
|
128 | 138 | return $container->runScope([], static fn (Container $container) => $container); |
129 | 139 | }); |
130 | 140 |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | { |
22 | 22 | $root = new Container(); |
23 | 23 | |
24 | - $root->scope(static function (Container $c1) { |
|
24 | + $root->scope(static function (Container $c1){ |
|
25 | 25 | $c1->scope(static function (Container $c2) use ($c1) { |
26 | 26 | $obj1 = $c1->get(AttrScopeFooSingleton::class); |
27 | 27 | $obj2 = $c2->get(AttrScopeFooSingleton::class); |
@@ -43,8 +43,8 @@ discard block |
||
43 | 43 | $root = new Container(); |
44 | 44 | $root->bind('foo', self::makeFooScopeObject(...)); |
45 | 45 | |
46 | - $root->scope(static function (Container $c1) { |
|
47 | - $c1->scope(static function (Container $c2) { |
|
46 | + $root->scope(static function (Container $c1){ |
|
47 | + $c1->scope(static function (Container $c2){ |
|
48 | 48 | $c2->get('foo'); |
49 | 49 | }, name: 'foo'); |
50 | 50 | }); |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | $root = new Container(); |
62 | 62 | $root->bind('foo', self::makeFooScopeObject(...)); |
63 | 63 | |
64 | - $root->scope(static function (Container $c1) { |
|
65 | - $c1->scope(static function (Container $c2) { |
|
64 | + $root->scope(static function (Container $c1){ |
|
65 | + $c1->scope(static function (Container $c2){ |
|
66 | 66 | $c2->get('foo'); |
67 | 67 | }); |
68 | 68 | }); |
@@ -79,15 +79,15 @@ discard block |
||
79 | 79 | |
80 | 80 | $root = new Container(); |
81 | 81 | |
82 | - try { |
|
83 | - $root->scope(static function (Container $c1) { |
|
84 | - $c1->scope(static function (Container $c2) { |
|
85 | - $c2->scope(static function (Container $c3) { |
|
82 | + try{ |
|
83 | + $root->scope(static function (Container $c1){ |
|
84 | + $c1->scope(static function (Container $c2){ |
|
85 | + $c2->scope(static function (Container $c3){ |
|
86 | 86 | // do nothing |
87 | 87 | }, name: 'root'); |
88 | 88 | }); |
89 | 89 | }); |
90 | - } catch (NamedScopeDuplicationException $e) { |
|
90 | + }catch (NamedScopeDuplicationException $e){ |
|
91 | 91 | self::assertSame('root', $e->getScope()); |
92 | 92 | throw $e; |
93 | 93 | } |
@@ -101,14 +101,14 @@ discard block |
||
101 | 101 | { |
102 | 102 | self::expectException(BadScopeException::class); |
103 | 103 | |
104 | - try { |
|
104 | + try{ |
|
105 | 105 | $root = new Container(); |
106 | - $root->scope(static function (Container $c1) { |
|
107 | - $c1->scope(static function (Container $c2) { |
|
106 | + $root->scope(static function (Container $c1){ |
|
107 | + $c1->scope(static function (Container $c2){ |
|
108 | 108 | $c2->get(AttrScopeFoo::class); |
109 | 109 | }); |
110 | 110 | }, name: 'bar'); |
111 | - } catch (BadScopeException $e) { |
|
111 | + }catch (BadScopeException $e){ |
|
112 | 112 | self::assertSame('foo', $e->getScope()); |
113 | 113 | throw $e; |
114 | 114 | } |
@@ -21,8 +21,10 @@ discard block |
||
21 | 21 | { |
22 | 22 | $root = new Container(); |
23 | 23 | |
24 | - $root->scope(static function (Container $c1) { |
|
25 | - $c1->scope(static function (Container $c2) use ($c1) { |
|
24 | + $root->scope(static function (Container $c1) |
|
25 | + { |
|
26 | + $c1->scope(static function (Container $c2) use ($c1) |
|
27 | + { |
|
26 | 28 | $obj1 = $c1->get(AttrScopeFooSingleton::class); |
27 | 29 | $obj2 = $c2->get(AttrScopeFooSingleton::class); |
28 | 30 | |
@@ -43,8 +45,10 @@ discard block |
||
43 | 45 | $root = new Container(); |
44 | 46 | $root->bind('foo', self::makeFooScopeObject(...)); |
45 | 47 | |
46 | - $root->scope(static function (Container $c1) { |
|
47 | - $c1->scope(static function (Container $c2) { |
|
48 | + $root->scope(static function (Container $c1) |
|
49 | + { |
|
50 | + $c1->scope(static function (Container $c2) |
|
51 | + { |
|
48 | 52 | $c2->get('foo'); |
49 | 53 | }, name: 'foo'); |
50 | 54 | }); |
@@ -61,8 +65,10 @@ discard block |
||
61 | 65 | $root = new Container(); |
62 | 66 | $root->bind('foo', self::makeFooScopeObject(...)); |
63 | 67 | |
64 | - $root->scope(static function (Container $c1) { |
|
65 | - $c1->scope(static function (Container $c2) { |
|
68 | + $root->scope(static function (Container $c1) |
|
69 | + { |
|
70 | + $c1->scope(static function (Container $c2) |
|
71 | + { |
|
66 | 72 | $c2->get('foo'); |
67 | 73 | }); |
68 | 74 | }); |
@@ -79,15 +85,21 @@ discard block |
||
79 | 85 | |
80 | 86 | $root = new Container(); |
81 | 87 | |
82 | - try { |
|
83 | - $root->scope(static function (Container $c1) { |
|
84 | - $c1->scope(static function (Container $c2) { |
|
85 | - $c2->scope(static function (Container $c3) { |
|
88 | + try |
|
89 | + { |
|
90 | + $root->scope(static function (Container $c1) |
|
91 | + { |
|
92 | + $c1->scope(static function (Container $c2) |
|
93 | + { |
|
94 | + $c2->scope(static function (Container $c3) |
|
95 | + { |
|
86 | 96 | // do nothing |
87 | 97 | }, name: 'root'); |
88 | 98 | }); |
89 | 99 | }); |
90 | - } catch (NamedScopeDuplicationException $e) { |
|
100 | + } |
|
101 | + catch (NamedScopeDuplicationException $e) |
|
102 | + { |
|
91 | 103 | self::assertSame('root', $e->getScope()); |
92 | 104 | throw $e; |
93 | 105 | } |
@@ -101,14 +113,19 @@ discard block |
||
101 | 113 | { |
102 | 114 | self::expectException(BadScopeException::class); |
103 | 115 | |
104 | - try { |
|
116 | + try |
|
117 | + { |
|
105 | 118 | $root = new Container(); |
106 | - $root->scope(static function (Container $c1) { |
|
107 | - $c1->scope(static function (Container $c2) { |
|
119 | + $root->scope(static function (Container $c1) |
|
120 | + { |
|
121 | + $c1->scope(static function (Container $c2) |
|
122 | + { |
|
108 | 123 | $c2->get(AttrScopeFoo::class); |
109 | 124 | }); |
110 | 125 | }, name: 'bar'); |
111 | - } catch (BadScopeException $e) { |
|
126 | + } |
|
127 | + catch (BadScopeException $e) |
|
128 | + { |
|
112 | 129 | self::assertSame('foo', $e->getScope()); |
113 | 130 | throw $e; |
114 | 131 | } |
@@ -21,7 +21,7 @@ |
||
21 | 21 | $root = new Container(); |
22 | 22 | $root->bind('foo', SampleClass::class); |
23 | 23 | |
24 | - $root->scope(function (ContainerInterface $c1) { |
|
24 | + $root->scope(function (ContainerInterface $c1){ |
|
25 | 25 | $c1->get('foo'); |
26 | 26 | }, bindings: ['foo' => SampleClass::class]); |
27 | 27 |
@@ -21,7 +21,8 @@ discard block |
||
21 | 21 | $root = new Container(); |
22 | 22 | $root->bind('foo', SampleClass::class); |
23 | 23 | |
24 | - $root->scope(function (ContainerInterface $c1) { |
|
24 | + $root->scope(function (ContainerInterface $c1) |
|
25 | + { |
|
25 | 26 | $c1->get('foo'); |
26 | 27 | }, bindings: ['foo' => SampleClass::class]); |
27 | 28 | |
@@ -53,7 +54,8 @@ discard block |
||
53 | 54 | { |
54 | 55 | $root = new Container(); |
55 | 56 | |
56 | - $root->scope(function (ContainerInterface $c1) use ($theSame, $alias) { |
|
57 | + $root->scope(function (ContainerInterface $c1) use ($theSame, $alias) |
|
58 | + { |
|
57 | 59 | $obj1 = $c1->get($alias); |
58 | 60 | $obj2 = $c1->get($alias); |
59 | 61 | |
@@ -77,14 +79,16 @@ discard block |
||
77 | 79 | { |
78 | 80 | $root = new Container(); |
79 | 81 | |
80 | - $root->scope(function (ContainerInterface $c1) use ($root) { |
|
82 | + $root->scope(function (ContainerInterface $c1) use ($root) |
|
83 | + { |
|
81 | 84 | $obj1 = $c1->get('foo'); |
82 | 85 | $this->weakMap->offsetSet($obj1, true); |
83 | 86 | |
84 | 87 | self::assertNotSame($root, $c1); |
85 | 88 | self::assertInstanceOf(stdClass::class, $obj1); |
86 | 89 | |
87 | - $c1->scope(function (ContainerInterface $c2) use ($root, $c1, $obj1) { |
|
90 | + $c1->scope(function (ContainerInterface $c2) use ($root, $c1, $obj1) |
|
91 | + { |
|
88 | 92 | $obj2 = $c2->get('foo'); |
89 | 93 | $this->weakMap->offsetSet($obj2, true); |
90 | 94 | |
@@ -113,14 +117,16 @@ discard block |
||
113 | 117 | $root->bindSingleton('bar', [self::class, 'makeStdClass']); |
114 | 118 | $root->bind(stdClass::class, new stdClass()); |
115 | 119 | |
116 | - $root->scope(function (ContainerInterface $c1) use ($root) { |
|
120 | + $root->scope(function (ContainerInterface $c1) use ($root) |
|
121 | + { |
|
117 | 122 | $obj1 = $c1->get('foo'); |
118 | 123 | $this->weakMap->offsetSet($obj1, true); |
119 | 124 | |
120 | 125 | self::assertInstanceOf(stdClass::class, $obj1); |
121 | 126 | // Singleton must be the same |
122 | 127 | self::assertSame($c1->get('bar'), $root->get('bar')); |
123 | - $c1->scope(function (ContainerInterface $c2) use ($root, $obj1) { |
|
128 | + $c1->scope(function (ContainerInterface $c2) use ($root, $obj1) |
|
129 | + { |
|
124 | 130 | $obj2 = $c2->get('foo'); |
125 | 131 | |
126 | 132 | self::assertInstanceOf(stdClass::class, $obj2); |