@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | public function testCookieQueueInRequestAttribute(): void |
53 | 53 | { |
54 | 54 | $core = $this->httpCore([CookiesMiddleware::class]); |
55 | - $core->setHandler(function (ServerRequestInterface $r) { |
|
55 | + $core->setHandler(function (ServerRequestInterface $r){ |
|
56 | 56 | $this->assertInstanceOf(CookieQueue::class, $r->getAttribute(CookieQueue::ATTRIBUTE)); |
57 | 57 | return 'all good'; |
58 | 58 | }); |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | public function testSetEncryptedCookie(): void |
66 | 66 | { |
67 | 67 | $core = $this->httpCore([CookiesMiddleware::class]); |
68 | - $core->setHandler(function (ServerRequestInterface $r) { |
|
68 | + $core->setHandler(function (ServerRequestInterface $r){ |
|
69 | 69 | $r->getAttribute(CookieQueue::ATTRIBUTE)->set('name', 'value'); |
70 | 70 | |
71 | 71 | return 'all good'; |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | public function testSetNotProtectedCookie(): void |
87 | 87 | { |
88 | 88 | $core = $this->httpCore([CookiesMiddleware::class]); |
89 | - $core->setHandler(function (ServerRequestInterface $r) { |
|
89 | + $core->setHandler(function (ServerRequestInterface $r){ |
|
90 | 90 | $r->getAttribute(CookieQueue::ATTRIBUTE)->set('PHPSESSID', 'value'); |
91 | 91 | |
92 | 92 | return 'all good'; |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | $core = $this->httpCore([CookiesMiddleware::class]); |
131 | 131 | $core->setHandler(fn(ServerRequestInterface $r) => $r->getCookieParams()['name']); |
132 | 132 | |
133 | - $value = $this->container->get(EncrypterInterface::class)->encrypt('cookie-value') . 'BROKEN'; |
|
133 | + $value = $this->container->get(EncrypterInterface::class)->encrypt('cookie-value').'BROKEN'; |
|
134 | 134 | |
135 | 135 | $response = $this->get($core, '/', [], [], ['name' => $value]); |
136 | 136 | $this->assertSame(200, $response->getStatusCode()); |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | public function testDelete(): void |
141 | 141 | { |
142 | 142 | $core = $this->httpCore([CookiesMiddleware::class]); |
143 | - $core->setHandler(function (ServerRequestInterface $r) { |
|
143 | + $core->setHandler(function (ServerRequestInterface $r){ |
|
144 | 144 | $r->getAttribute(CookieQueue::ATTRIBUTE)->set('name', 'value'); |
145 | 145 | $r->getAttribute(CookieQueue::ATTRIBUTE)->delete('name'); |
146 | 146 | |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | ])); |
166 | 166 | |
167 | 167 | $core = $this->httpCore([CookiesMiddleware::class]); |
168 | - $core->setHandler(function (ServerRequestInterface $r) { |
|
168 | + $core->setHandler(function (ServerRequestInterface $r){ |
|
169 | 169 | $r->getAttribute(CookieQueue::ATTRIBUTE)->set('name', 'value'); |
170 | 170 | |
171 | 171 | return 'all good'; |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | ])); |
208 | 208 | |
209 | 209 | $core = $this->httpCore([CookiesMiddleware::class]); |
210 | - $core->setHandler(function (ServerRequestInterface $r) { |
|
210 | + $core->setHandler(function (ServerRequestInterface $r){ |
|
211 | 211 | $r->getAttribute(CookieQueue::ATTRIBUTE)->set('name', 'value'); |
212 | 212 | |
213 | 213 | return 'all good'; |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | { |
274 | 274 | $result = []; |
275 | 275 | |
276 | - foreach ($response->getHeaders() as $line) { |
|
276 | + foreach ($response->getHeaders() as $line){ |
|
277 | 277 | $cookie = explode('=', implode('', $line)); |
278 | 278 | $result[$cookie[0]] = rawurldecode(substr( |
279 | 279 | $cookie[1], |
@@ -52,7 +52,8 @@ discard block |
||
52 | 52 | public function testCookieQueueInRequestAttribute(): void |
53 | 53 | { |
54 | 54 | $core = $this->httpCore([CookiesMiddleware::class]); |
55 | - $core->setHandler(function (ServerRequestInterface $r) { |
|
55 | + $core->setHandler(function (ServerRequestInterface $r) |
|
56 | + { |
|
56 | 57 | $this->assertInstanceOf(CookieQueue::class, $r->getAttribute(CookieQueue::ATTRIBUTE)); |
57 | 58 | return 'all good'; |
58 | 59 | }); |
@@ -65,7 +66,8 @@ discard block |
||
65 | 66 | public function testSetEncryptedCookie(): void |
66 | 67 | { |
67 | 68 | $core = $this->httpCore([CookiesMiddleware::class]); |
68 | - $core->setHandler(function (ServerRequestInterface $r) { |
|
69 | + $core->setHandler(function (ServerRequestInterface $r) |
|
70 | + { |
|
69 | 71 | $r->getAttribute(CookieQueue::ATTRIBUTE)->set('name', 'value'); |
70 | 72 | |
71 | 73 | return 'all good'; |
@@ -86,7 +88,8 @@ discard block |
||
86 | 88 | public function testSetNotProtectedCookie(): void |
87 | 89 | { |
88 | 90 | $core = $this->httpCore([CookiesMiddleware::class]); |
89 | - $core->setHandler(function (ServerRequestInterface $r) { |
|
91 | + $core->setHandler(function (ServerRequestInterface $r) |
|
92 | + { |
|
90 | 93 | $r->getAttribute(CookieQueue::ATTRIBUTE)->set('PHPSESSID', 'value'); |
91 | 94 | |
92 | 95 | return 'all good'; |
@@ -140,7 +143,8 @@ discard block |
||
140 | 143 | public function testDelete(): void |
141 | 144 | { |
142 | 145 | $core = $this->httpCore([CookiesMiddleware::class]); |
143 | - $core->setHandler(function (ServerRequestInterface $r) { |
|
146 | + $core->setHandler(function (ServerRequestInterface $r) |
|
147 | + { |
|
144 | 148 | $r->getAttribute(CookieQueue::ATTRIBUTE)->set('name', 'value'); |
145 | 149 | $r->getAttribute(CookieQueue::ATTRIBUTE)->delete('name'); |
146 | 150 | |
@@ -165,7 +169,8 @@ discard block |
||
165 | 169 | ])); |
166 | 170 | |
167 | 171 | $core = $this->httpCore([CookiesMiddleware::class]); |
168 | - $core->setHandler(function (ServerRequestInterface $r) { |
|
172 | + $core->setHandler(function (ServerRequestInterface $r) |
|
173 | + { |
|
169 | 174 | $r->getAttribute(CookieQueue::ATTRIBUTE)->set('name', 'value'); |
170 | 175 | |
171 | 176 | return 'all good'; |
@@ -207,7 +212,8 @@ discard block |
||
207 | 212 | ])); |
208 | 213 | |
209 | 214 | $core = $this->httpCore([CookiesMiddleware::class]); |
210 | - $core->setHandler(function (ServerRequestInterface $r) { |
|
215 | + $core->setHandler(function (ServerRequestInterface $r) |
|
216 | + { |
|
211 | 217 | $r->getAttribute(CookieQueue::ATTRIBUTE)->set('name', 'value'); |
212 | 218 | |
213 | 219 | return 'all good'; |
@@ -273,7 +279,8 @@ discard block |
||
273 | 279 | { |
274 | 280 | $result = []; |
275 | 281 | |
276 | - foreach ($response->getHeaders() as $line) { |
|
282 | + foreach ($response->getHeaders() as $line) |
|
283 | + { |
|
277 | 284 | $cookie = explode('=', implode('', $line)); |
278 | 285 | $result[$cookie[0]] = rawurldecode(substr( |
279 | 286 | $cookie[1], |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | |
31 | 31 | FiberHelper::runInFiber( |
32 | 32 | self::functionScopedTestDataIterator(), |
33 | - static function (mixed $suspendValue) { |
|
33 | + static function (mixed $suspendValue){ |
|
34 | 34 | self::assertNull(ContainerScope::getContainer()); |
35 | 35 | self::assertTrue(\in_array($suspendValue, self::TEST_DATA, true)); |
36 | 36 | }, |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | ); |
64 | 64 | |
65 | 65 | self::assertCount(5, $result); |
66 | - foreach ($result as $suspendValue) { |
|
66 | + foreach ($result as $suspendValue){ |
|
67 | 67 | self::assertSame(self::TEST_DATA, $suspendValue); |
68 | 68 | } |
69 | 69 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | ); |
82 | 82 | |
83 | 83 | self::assertCount(2, $result); |
84 | - foreach ($result as $suspendValue) { |
|
84 | + foreach ($result as $suspendValue){ |
|
85 | 85 | self::assertSame(self::TEST_DATA, $suspendValue); |
86 | 86 | } |
87 | 87 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | $result = ''; |
98 | 98 | $result .= Fiber::suspend('foo'); |
99 | 99 | $result .= Fiber::suspend('bar'); |
100 | - return $result . Fiber::suspend('error'); |
|
100 | + return $result.Fiber::suspend('error'); |
|
101 | 101 | } |
102 | 102 | ), |
103 | 103 | static fn(string $suspendValue): string => $suspendValue !== 'error' |
@@ -114,12 +114,12 @@ discard block |
||
114 | 114 | $result = ''; |
115 | 115 | $result .= Fiber::suspend('foo'); |
116 | 116 | $result .= Fiber::suspend('bar'); |
117 | - try { |
|
117 | + try{ |
|
118 | 118 | $result .= Fiber::suspend('error'); |
119 | - } catch (\Throwable $e) { |
|
119 | + }catch (\Throwable $e){ |
|
120 | 120 | $result .= $e->getMessage(); |
121 | 121 | } |
122 | - return $result . Fiber::suspend('baz'); |
|
122 | + return $result.Fiber::suspend('baz'); |
|
123 | 123 | } |
124 | 124 | ), |
125 | 125 | static fn(string $suspendValue): string => $suspendValue !== 'error' |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | ?callable $load = null, |
143 | 143 | ?Container $container = null, |
144 | 144 | ): callable { |
145 | - return static function () use ($load, $container): array { |
|
145 | + return static function () use ($load, $container) : array { |
|
146 | 146 | // The function should be called in a fiber |
147 | 147 | self::assertNotNull(Fiber::getCurrent()); |
148 | 148 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | $resource = $c3->get('resource'); |
164 | 164 | self::assertInstanceOf(DateTimeImmutable::class, $c3->get('bar')); |
165 | 165 | self::assertInstanceOf(stdClass::class, $resource); |
166 | - foreach (self::TEST_DATA as $key => $value) { |
|
166 | + foreach (self::TEST_DATA as $key => $value){ |
|
167 | 167 | $resource->$key = $value; |
168 | 168 | $load === null or $load(); |
169 | 169 | Fiber::suspend($value); |
@@ -176,8 +176,8 @@ discard block |
||
176 | 176 | }, ['foo' => new DateTime()]); |
177 | 177 | self::assertFalse($c1->has('foo')); |
178 | 178 | |
179 | - self::assertSame(self::TEST_DATA, (array) $result); |
|
180 | - return (array) $result; |
|
179 | + self::assertSame(self::TEST_DATA, (array)$result); |
|
180 | + return (array)$result; |
|
181 | 181 | }; |
182 | 182 | } |
183 | 183 | } |
@@ -30,7 +30,8 @@ discard block |
||
30 | 30 | |
31 | 31 | FiberHelper::runInFiber( |
32 | 32 | self::functionScopedTestDataIterator(), |
33 | - static function (mixed $suspendValue) { |
|
33 | + static function (mixed $suspendValue) |
|
34 | + { |
|
34 | 35 | self::assertNull(ContainerScope::getContainer()); |
35 | 36 | self::assertTrue(\in_array($suspendValue, self::TEST_DATA, true)); |
36 | 37 | }, |
@@ -63,7 +64,8 @@ discard block |
||
63 | 64 | ); |
64 | 65 | |
65 | 66 | self::assertCount(5, $result); |
66 | - foreach ($result as $suspendValue) { |
|
67 | + foreach ($result as $suspendValue) |
|
68 | + { |
|
67 | 69 | self::assertSame(self::TEST_DATA, $suspendValue); |
68 | 70 | } |
69 | 71 | } |
@@ -81,7 +83,8 @@ discard block |
||
81 | 83 | ); |
82 | 84 | |
83 | 85 | self::assertCount(2, $result); |
84 | - foreach ($result as $suspendValue) { |
|
86 | + foreach ($result as $suspendValue) |
|
87 | + { |
|
85 | 88 | self::assertSame(self::TEST_DATA, $suspendValue); |
86 | 89 | } |
87 | 90 | } |
@@ -114,9 +117,12 @@ discard block |
||
114 | 117 | $result = ''; |
115 | 118 | $result .= Fiber::suspend('foo'); |
116 | 119 | $result .= Fiber::suspend('bar'); |
117 | - try { |
|
120 | + try |
|
121 | + { |
|
118 | 122 | $result .= Fiber::suspend('error'); |
119 | - } catch (\Throwable $e) { |
|
123 | + } |
|
124 | + catch (\Throwable $e) |
|
125 | + { |
|
120 | 126 | $result .= $e->getMessage(); |
121 | 127 | } |
122 | 128 | return $result . Fiber::suspend('baz'); |
@@ -150,20 +156,23 @@ discard block |
||
150 | 156 | $c1 = $container ?? new Container(); |
151 | 157 | $c1->bindSingleton('resource', new stdClass()); |
152 | 158 | |
153 | - $result = $c1->runScoped(static function (Container $c2) use ($load) { |
|
159 | + $result = $c1->runScoped(static function (Container $c2) use ($load) |
|
160 | + { |
|
154 | 161 | // check local binding |
155 | 162 | self::assertTrue($c2->has('foo')); |
156 | 163 | self::assertInstanceOf(DateTime::class, $c2->get('foo')); |
157 | 164 | |
158 | 165 | return $c2->runScoped( |
159 | - static function (ContainerInterface $c3) use ($load) { |
|
166 | + static function (ContainerInterface $c3) use ($load) |
|
167 | + { |
|
160 | 168 | // check local binding |
161 | 169 | self::assertTrue($c3->has('bar')); |
162 | 170 | |
163 | 171 | $resource = $c3->get('resource'); |
164 | 172 | self::assertInstanceOf(DateTimeImmutable::class, $c3->get('bar')); |
165 | 173 | self::assertInstanceOf(stdClass::class, $resource); |
166 | - foreach (self::TEST_DATA as $key => $value) { |
|
174 | + foreach (self::TEST_DATA as $key => $value) |
|
175 | + { |
|
167 | 176 | $resource->$key = $value; |
168 | 177 | $load === null or $load(); |
169 | 178 | Fiber::suspend($value); |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | |
33 | 33 | $this->assertNull(ContainerScope::getContainer()); |
34 | 34 | |
35 | - try { |
|
35 | + try{ |
|
36 | 36 | $this->assertTrue(ContainerScope::runScope($container, function () use ($container): void { |
37 | 37 | throw new RuntimeException('exception'); |
38 | 38 | })); |
39 | - } catch (\Throwable $e) { |
|
39 | + }catch (\Throwable $e){ |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | $this->assertInstanceOf(RuntimeException::class, $e); |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | $this->assertTrue($c->runScope([ |
55 | 55 | 'bucket' => new Bucket('b'), |
56 | 56 | 'other' => new SampleClass() |
57 | - ], function ($c) { |
|
57 | + ], function ($c){ |
|
58 | 58 | $this->assertSame('b', $c->get('bucket')->getName()); |
59 | 59 | $this->assertTrue($c->has('other')); |
60 | 60 | |
@@ -76,21 +76,21 @@ discard block |
||
76 | 76 | $this->assertTrue($c->runScope([ |
77 | 77 | 'bucket' => new Bucket('b'), |
78 | 78 | 'other' => new SampleClass() |
79 | - ], function ($c) { |
|
79 | + ], function ($c){ |
|
80 | 80 | $this->assertSame('b', $c->get('bucket')->getName()); |
81 | 81 | $this->assertTrue($c->has('other')); |
82 | 82 | |
83 | 83 | return $c->get('bucket')->getName() == 'b' && $c->has('other'); |
84 | 84 | })); |
85 | 85 | |
86 | - try { |
|
86 | + try{ |
|
87 | 87 | $this->assertTrue($c->runScope([ |
88 | 88 | 'bucket' => new Bucket('b'), |
89 | 89 | 'other' => new SampleClass() |
90 | 90 | ], function () use ($c): void { |
91 | 91 | throw new RuntimeException('exception'); |
92 | 92 | })); |
93 | - } catch (\Throwable $e) { |
|
93 | + }catch (\Throwable $e){ |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | $this->assertSame('a', $c->get('bucket')->getName()); |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | $container->bindSingleton('test', new #[Singleton] class {}); |
136 | 136 | $container->make('test'); |
137 | 137 | |
138 | - $container->runScoped(function (Container $container) { |
|
138 | + $container->runScoped(function (Container $container){ |
|
139 | 139 | $this->assertTrue($container->hasInstance('test')); |
140 | 140 | }); |
141 | 141 | } |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | $container->bindSingleton('test', SampleClass::class); |
147 | 147 | $container->make('test'); |
148 | 148 | |
149 | - $container->runScoped(function (Container $container) { |
|
149 | + $container->runScoped(function (Container $container){ |
|
150 | 150 | $this->assertTrue($container->hasInstance('test')); |
151 | 151 | }); |
152 | 152 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | $container->bindSingleton('bar', 'foo'); |
162 | 162 | $container->make('bar'); |
163 | 163 | |
164 | - $container->runScoped(function (Container $container) { |
|
164 | + $container->runScoped(function (Container $container){ |
|
165 | 165 | $this->assertTrue($container->hasInstance('bar')); |
166 | 166 | }); |
167 | 167 | } |
@@ -32,11 +32,14 @@ discard block |
||
32 | 32 | |
33 | 33 | $this->assertNull(ContainerScope::getContainer()); |
34 | 34 | |
35 | - try { |
|
35 | + try |
|
36 | + { |
|
36 | 37 | $this->assertTrue(ContainerScope::runScope($container, function () use ($container): void { |
37 | 38 | throw new RuntimeException('exception'); |
38 | 39 | })); |
39 | - } catch (\Throwable $e) { |
|
40 | + } |
|
41 | + catch (\Throwable $e) |
|
42 | + { |
|
40 | 43 | } |
41 | 44 | |
42 | 45 | $this->assertInstanceOf(RuntimeException::class, $e); |
@@ -54,7 +57,8 @@ discard block |
||
54 | 57 | $this->assertTrue($c->runScope([ |
55 | 58 | 'bucket' => new Bucket('b'), |
56 | 59 | 'other' => new SampleClass() |
57 | - ], function ($c) { |
|
60 | + ], function ($c) |
|
61 | + { |
|
58 | 62 | $this->assertSame('b', $c->get('bucket')->getName()); |
59 | 63 | $this->assertTrue($c->has('other')); |
60 | 64 | |
@@ -76,21 +80,25 @@ discard block |
||
76 | 80 | $this->assertTrue($c->runScope([ |
77 | 81 | 'bucket' => new Bucket('b'), |
78 | 82 | 'other' => new SampleClass() |
79 | - ], function ($c) { |
|
83 | + ], function ($c) |
|
84 | + { |
|
80 | 85 | $this->assertSame('b', $c->get('bucket')->getName()); |
81 | 86 | $this->assertTrue($c->has('other')); |
82 | 87 | |
83 | 88 | return $c->get('bucket')->getName() == 'b' && $c->has('other'); |
84 | 89 | })); |
85 | 90 | |
86 | - try { |
|
91 | + try |
|
92 | + { |
|
87 | 93 | $this->assertTrue($c->runScope([ |
88 | 94 | 'bucket' => new Bucket('b'), |
89 | 95 | 'other' => new SampleClass() |
90 | 96 | ], function () use ($c): void { |
91 | 97 | throw new RuntimeException('exception'); |
92 | 98 | })); |
93 | - } catch (\Throwable $e) { |
|
99 | + } |
|
100 | + catch (\Throwable $e) |
|
101 | + { |
|
94 | 102 | } |
95 | 103 | |
96 | 104 | $this->assertSame('a', $c->get('bucket')->getName()); |
@@ -132,10 +140,13 @@ discard block |
||
132 | 140 | public function testHasInstanceAfterMakeWithoutAliasInScope(): void |
133 | 141 | { |
134 | 142 | $container = new Container(); |
135 | - $container->bindSingleton('test', new #[Singleton] class {}); |
|
143 | + $container->bindSingleton('test', new #[Singleton] class |
|
144 | + { |
|
145 | +}); |
|
136 | 146 | $container->make('test'); |
137 | 147 | |
138 | - $container->runScoped(function (Container $container) { |
|
148 | + $container->runScoped(function (Container $container) |
|
149 | + { |
|
139 | 150 | $this->assertTrue($container->hasInstance('test')); |
140 | 151 | }); |
141 | 152 | } |
@@ -146,7 +157,8 @@ discard block |
||
146 | 157 | $container->bindSingleton('test', SampleClass::class); |
147 | 158 | $container->make('test'); |
148 | 159 | |
149 | - $container->runScoped(function (Container $container) { |
|
160 | + $container->runScoped(function (Container $container) |
|
161 | + { |
|
150 | 162 | $this->assertTrue($container->hasInstance('test')); |
151 | 163 | }); |
152 | 164 | } |
@@ -161,7 +173,8 @@ discard block |
||
161 | 173 | $container->bindSingleton('bar', 'foo'); |
162 | 174 | $container->make('bar'); |
163 | 175 | |
164 | - $container->runScoped(function (Container $container) { |
|
176 | + $container->runScoped(function (Container $container) |
|
177 | + { |
|
165 | 178 | $this->assertTrue($container->hasInstance('bar')); |
166 | 179 | }); |
167 | 180 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | { |
15 | 15 | $core = TestCore::create([ |
16 | 16 | 'root' => __DIR__, |
17 | - 'config' => __DIR__ . '/config' |
|
17 | + 'config' => __DIR__.'/config' |
|
18 | 18 | ])->run(); |
19 | 19 | |
20 | 20 | /** @var TestConfig $config */ |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | { |
28 | 28 | $core = TestCore::create([ |
29 | 29 | 'root' => __DIR__, |
30 | - 'config' => __DIR__ . '/config', |
|
30 | + 'config' => __DIR__.'/config', |
|
31 | 31 | ])->run(); |
32 | 32 | |
33 | 33 | /** @var ConfiguratorInterface $configurator */ |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | |
40 | 40 | public function testInvalidInjector(): void |
41 | 41 | { |
42 | - $excepted = "Class 'Spiral\Tests\Core\Fixtures\InvalidInjector' must be an " . |
|
42 | + $excepted = "Class 'Spiral\Tests\Core\Fixtures\InvalidInjector' must be an ". |
|
43 | 43 | "instance of InjectorInterface for 'Spiral\Tests\Core\Fixtures\TestConfig'"; |
44 | 44 | $this->expectException(InjectionException::class); |
45 | 45 | $this->expectExceptionMessage($excepted); |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | |
66 | 66 | public function testInvalidRuntimeInjector(): void |
67 | 67 | { |
68 | - $excepted = "Class 'Spiral\Tests\Core\Fixtures\InvalidInjector' must be an " . |
|
68 | + $excepted = "Class 'Spiral\Tests\Core\Fixtures\InvalidInjector' must be an ". |
|
69 | 69 | "instance of InjectorInterface for 'Spiral\Tests\Core\Fixtures\TestConfig'"; |
70 | 70 | $this->expectException(InjectionException::class); |
71 | 71 | $this->expectExceptionMessage($excepted); |
@@ -203,8 +203,8 @@ discard block |
||
203 | 203 | public function testExtendedInjectorAnonClassObjectParam(): void |
204 | 204 | { |
205 | 205 | $container = new Container(); |
206 | - $container->bind(stdClass::class, new Injectable(new class implements Container\InjectorInterface { |
|
207 | - public function createInjection(\ReflectionClass $class, object|string|null $context = null): object |
|
206 | + $container->bind(stdClass::class, new Injectable(new class implements Container\InjectorInterface{ |
|
207 | + public function createInjection(\ReflectionClass $class, object | string | null $context = null): object |
|
208 | 208 | { |
209 | 209 | return (object)['context' => $context]; |
210 | 210 | } |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | public function testExtendedInjectorAnonClassMixedParam(): void |
220 | 220 | { |
221 | 221 | $container = new Container(); |
222 | - $container->bind(stdClass::class, new Injectable(new class implements Container\InjectorInterface { |
|
222 | + $container->bind(stdClass::class, new Injectable(new class implements Container\InjectorInterface{ |
|
223 | 223 | public function createInjection(\ReflectionClass $class, mixed $context = null): object |
224 | 224 | { |
225 | 225 | return (object)['context' => $context]; |
@@ -181,7 +181,9 @@ discard block |
||
181 | 181 | public function testHasShouldReturnTrueWhenSingletonIsAlreadyConstructed(): void |
182 | 182 | { |
183 | 183 | $container = new Container(); |
184 | - $class = new #[Singleton] class {}; |
|
184 | + $class = new #[Singleton] class |
|
185 | + { |
|
186 | +}; |
|
185 | 187 | |
186 | 188 | $this->assertFalse($container->has($class::class)); |
187 | 189 | |
@@ -194,7 +196,8 @@ discard block |
||
194 | 196 | { |
195 | 197 | return new |
196 | 198 | #[Singleton] |
197 | - class { |
|
199 | + class |
|
200 | + { |
|
198 | 201 | public string $baz = 'baz'; |
199 | 202 | }; |
200 | 203 | } |
@@ -19,59 +19,59 @@ discard block |
||
19 | 19 | |
20 | 20 | return RectorConfig::configure() |
21 | 21 | ->withPaths([ |
22 | - __DIR__ . '/src/*/src', |
|
23 | - __DIR__ . '/src/*/tests', |
|
24 | - __DIR__ . '/tests', |
|
22 | + __DIR__.'/src/*/src', |
|
23 | + __DIR__.'/src/*/tests', |
|
24 | + __DIR__.'/tests', |
|
25 | 25 | ]) |
26 | 26 | ->withParallel() |
27 | 27 | ->withSkip([ |
28 | 28 | IfIssetToCoalescingRector::class, |
29 | 29 | RemoveUnusedPrivatePropertyRector::class => [ |
30 | - __DIR__ . '/src/Scaffolder/src/Command/BootloaderCommand.php', |
|
31 | - __DIR__ . '/src/Scaffolder/src/Command/CommandCommand.php', |
|
32 | - __DIR__ . '/src/Scaffolder/src/Command/ConfigCommand.php', |
|
33 | - __DIR__ . '/src/Scaffolder/src/Command/ControllerCommand.php', |
|
34 | - __DIR__ . '/src/Scaffolder/src/Command/FilterCommand.php', |
|
35 | - __DIR__ . '/src/Scaffolder/src/Command/JobHandlerCommand.php', |
|
36 | - __DIR__ . '/src/Scaffolder/src/Command/MiddlewareCommand.php', |
|
37 | - __DIR__ . '/src/Console/tests/PromptArgumentsTest.php', |
|
30 | + __DIR__.'/src/Scaffolder/src/Command/BootloaderCommand.php', |
|
31 | + __DIR__.'/src/Scaffolder/src/Command/CommandCommand.php', |
|
32 | + __DIR__.'/src/Scaffolder/src/Command/ConfigCommand.php', |
|
33 | + __DIR__.'/src/Scaffolder/src/Command/ControllerCommand.php', |
|
34 | + __DIR__.'/src/Scaffolder/src/Command/FilterCommand.php', |
|
35 | + __DIR__.'/src/Scaffolder/src/Command/JobHandlerCommand.php', |
|
36 | + __DIR__.'/src/Scaffolder/src/Command/MiddlewareCommand.php', |
|
37 | + __DIR__.'/src/Console/tests/PromptArgumentsTest.php', |
|
38 | 38 | ], |
39 | 39 | RemoveUnusedPrivateMethodRector::class => [ |
40 | - __DIR__ . '/src/Boot/src/Bootloader/ConfigurationBootloader.php', |
|
41 | - __DIR__ . '/src/Broadcasting/src/Bootloader/BroadcastingBootloader.php', |
|
42 | - __DIR__ . '/src/Cache/src/Bootloader/CacheBootloader.php', |
|
43 | - __DIR__ . '/src/Serializer/src/Bootloader/SerializerBootloader.php', |
|
44 | - __DIR__ . '/src/Validation/src/Bootloader/ValidationBootloader.php', |
|
45 | - __DIR__ . '/src/Translator/tests/IndexerTest.php', |
|
46 | - __DIR__ . '/src/Tokenizer/tests/ReflectionFileTest.php', |
|
47 | - __DIR__ . '/src/Core/tests/SingletonsTest.php', |
|
40 | + __DIR__.'/src/Boot/src/Bootloader/ConfigurationBootloader.php', |
|
41 | + __DIR__.'/src/Broadcasting/src/Bootloader/BroadcastingBootloader.php', |
|
42 | + __DIR__.'/src/Cache/src/Bootloader/CacheBootloader.php', |
|
43 | + __DIR__.'/src/Serializer/src/Bootloader/SerializerBootloader.php', |
|
44 | + __DIR__.'/src/Validation/src/Bootloader/ValidationBootloader.php', |
|
45 | + __DIR__.'/src/Translator/tests/IndexerTest.php', |
|
46 | + __DIR__.'/src/Tokenizer/tests/ReflectionFileTest.php', |
|
47 | + __DIR__.'/src/Core/tests/SingletonsTest.php', |
|
48 | 48 | ], |
49 | 49 | RemoveUselessVarTagRector::class => [ |
50 | - __DIR__ . '/src/Console/src/Traits/HelpersTrait.php', |
|
50 | + __DIR__.'/src/Console/src/Traits/HelpersTrait.php', |
|
51 | 51 | ], |
52 | 52 | RemoveAlwaysTrueIfConditionRector::class => [ |
53 | - __DIR__ . '/src/Boot/src/BootloadManager/Initializer.php', |
|
54 | - __DIR__ . '/src/Stempler/src/Traverser.php', |
|
55 | - __DIR__ . '/src/Prototype/src/NodeVisitors/LocateProperties.php', |
|
56 | - __DIR__ . '/src/Prototype/src/NodeVisitors/RemoveTrait.php', |
|
57 | - __DIR__ . '/src/Logger/src/ListenerRegistry.php', |
|
58 | - __DIR__ . '/src/Stempler/src/Transform/Merge/ExtendsParent.php', |
|
53 | + __DIR__.'/src/Boot/src/BootloadManager/Initializer.php', |
|
54 | + __DIR__.'/src/Stempler/src/Traverser.php', |
|
55 | + __DIR__.'/src/Prototype/src/NodeVisitors/LocateProperties.php', |
|
56 | + __DIR__.'/src/Prototype/src/NodeVisitors/RemoveTrait.php', |
|
57 | + __DIR__.'/src/Logger/src/ListenerRegistry.php', |
|
58 | + __DIR__.'/src/Stempler/src/Transform/Merge/ExtendsParent.php', |
|
59 | 59 | ], |
60 | 60 | RemoveExtraParametersRector::class => [ |
61 | - __DIR__ . '/src/Boot/src/BootloadManager/AbstractBootloadManager.php', |
|
61 | + __DIR__.'/src/Boot/src/BootloadManager/AbstractBootloadManager.php', |
|
62 | 62 | ], |
63 | 63 | RemoveUnusedPrivateMethodParameterRector::class => [ |
64 | - __DIR__ . '/src/Core/src/Internal/Factory.php', |
|
65 | - __DIR__ . '/src/Core/tests/InjectableTest.php', |
|
64 | + __DIR__.'/src/Core/src/Internal/Factory.php', |
|
65 | + __DIR__.'/src/Core/tests/InjectableTest.php', |
|
66 | 66 | ], |
67 | 67 | RemoveDoubleAssignRector::class => [ |
68 | - __DIR__ . '/src/Core/tests/Scope/FinalizeAttributeTest.php', |
|
68 | + __DIR__.'/src/Core/tests/Scope/FinalizeAttributeTest.php', |
|
69 | 69 | ], |
70 | 70 | RemoveUnusedVariableAssignRector::class => [ |
71 | - __DIR__ . '/src/Core/tests/ExceptionsTest.php', |
|
71 | + __DIR__.'/src/Core/tests/ExceptionsTest.php', |
|
72 | 72 | ], |
73 | 73 | RemoveDeadStmtRector::class => [ |
74 | - __DIR__ . '/src/Core/tests/ExceptionsTest.php', |
|
74 | + __DIR__.'/src/Core/tests/ExceptionsTest.php', |
|
75 | 75 | ], |
76 | 76 | |
77 | 77 | // to be enabled later for bc break 4.x |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | RemoveUnusedPromotedPropertyRector::class, |
81 | 81 | |
82 | 82 | // start with short open tag |
83 | - __DIR__ . '/src/Views/tests/fixtures/other/var.php', |
|
84 | - __DIR__ . '/tests/app/views/native.php', |
|
83 | + __DIR__.'/src/Views/tests/fixtures/other/var.php', |
|
84 | + __DIR__.'/tests/app/views/native.php', |
|
85 | 85 | |
86 | 86 | // example code for test |
87 | 87 | '*/Fixtures/*', |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | '*/Stubs/*', |
90 | 90 | '*/tests/Classes/*', |
91 | 91 | '*/tests/Internal/*', |
92 | - __DIR__ . '/src/Console/tests/Configurator', |
|
92 | + __DIR__.'/src/Console/tests/Configurator', |
|
93 | 93 | |
94 | 94 | // cache |
95 | 95 | '*/runtime/cache/*', |
@@ -20,11 +20,11 @@ discard block |
||
20 | 20 | |
21 | 21 | $container = new Container(); |
22 | 22 | |
23 | - $container->runScoped(static function (Container $c1) { |
|
24 | - try { |
|
23 | + $container->runScoped(static function (Container $c1){ |
|
24 | + try{ |
|
25 | 25 | $c1->get(ExceptionConstructor::class); |
26 | 26 | self::fail('Exception should be thrown'); |
27 | - } catch (\Throwable $e) { |
|
27 | + }catch (\Throwable $e){ |
|
28 | 28 | self::assertInstanceOf(\Exception::class, $e); |
29 | 29 | throw $e; |
30 | 30 | } |
@@ -38,11 +38,11 @@ discard block |
||
38 | 38 | |
39 | 39 | $container = new Container(); |
40 | 40 | |
41 | - $container->runScoped(static function (Container $c1) { |
|
42 | - try { |
|
41 | + $container->runScoped(static function (Container $c1){ |
|
42 | + try{ |
|
43 | 43 | $c1->get(ExceptionConstructor::class); |
44 | 44 | self::fail('Exception should be thrown'); |
45 | - } catch (\Throwable $e) { |
|
45 | + }catch (\Throwable $e){ |
|
46 | 46 | self::assertInstanceOf(\Exception::class, $e); |
47 | 47 | throw $e; |
48 | 48 | } |
@@ -56,11 +56,11 @@ discard block |
||
56 | 56 | |
57 | 57 | $container = new Container(); |
58 | 58 | |
59 | - $container->runScoped(static function (Container $c1) { |
|
60 | - try { |
|
59 | + $container->runScoped(static function (Container $c1){ |
|
60 | + try{ |
|
61 | 61 | $c1->get(DatetimeCarrier::class); |
62 | 62 | self::fail('Exception should be thrown'); |
63 | - } catch (\Throwable $e) { |
|
63 | + }catch (\Throwable $e){ |
|
64 | 64 | self::assertInstanceOf(NotFoundException::class, $e); |
65 | 65 | self::assertInstanceOf(NotFoundException::class, $e->getPrevious()); |
66 | 66 | self::assertStringContainsString( |
@@ -20,11 +20,15 @@ discard block |
||
20 | 20 | |
21 | 21 | $container = new Container(); |
22 | 22 | |
23 | - $container->runScoped(static function (Container $c1) { |
|
24 | - try { |
|
23 | + $container->runScoped(static function (Container $c1) |
|
24 | + { |
|
25 | + try |
|
26 | + { |
|
25 | 27 | $c1->get(ExceptionConstructor::class); |
26 | 28 | self::fail('Exception should be thrown'); |
27 | - } catch (\Throwable $e) { |
|
29 | + } |
|
30 | + catch (\Throwable $e) |
|
31 | + { |
|
28 | 32 | self::assertInstanceOf(\Exception::class, $e); |
29 | 33 | throw $e; |
30 | 34 | } |
@@ -38,11 +42,15 @@ discard block |
||
38 | 42 | |
39 | 43 | $container = new Container(); |
40 | 44 | |
41 | - $container->runScoped(static function (Container $c1) { |
|
42 | - try { |
|
45 | + $container->runScoped(static function (Container $c1) |
|
46 | + { |
|
47 | + try |
|
48 | + { |
|
43 | 49 | $c1->get(ExceptionConstructor::class); |
44 | 50 | self::fail('Exception should be thrown'); |
45 | - } catch (\Throwable $e) { |
|
51 | + } |
|
52 | + catch (\Throwable $e) |
|
53 | + { |
|
46 | 54 | self::assertInstanceOf(\Exception::class, $e); |
47 | 55 | throw $e; |
48 | 56 | } |
@@ -56,11 +64,15 @@ discard block |
||
56 | 64 | |
57 | 65 | $container = new Container(); |
58 | 66 | |
59 | - $container->runScoped(static function (Container $c1) { |
|
60 | - try { |
|
67 | + $container->runScoped(static function (Container $c1) |
|
68 | + { |
|
69 | + try |
|
70 | + { |
|
61 | 71 | $c1->get(DatetimeCarrier::class); |
62 | 72 | self::fail('Exception should be thrown'); |
63 | - } catch (\Throwable $e) { |
|
73 | + } |
|
74 | + catch (\Throwable $e) |
|
75 | + { |
|
64 | 76 | self::assertInstanceOf(NotFoundException::class, $e); |
65 | 77 | self::assertInstanceOf(NotFoundException::class, $e->getPrevious()); |
66 | 78 | self::assertStringContainsString( |
@@ -23,19 +23,23 @@ |
||
23 | 23 | ): object { |
24 | 24 | $c ??= ContainerScope::getContainer() ?? throw new ContainerException('Proxy is out of scope.'); |
25 | 25 | |
26 | - try { |
|
26 | + try |
|
27 | + { |
|
27 | 28 | /** @psalm-suppress TooManyArguments */ |
28 | 29 | $result = $c->get($alias, $context) ?? throw new ContainerException( |
29 | 30 | 'Resolved `null` from the container.', |
30 | 31 | ); |
31 | - } catch (\Throwable $e) { |
|
32 | + } |
|
33 | + catch (\Throwable $e) |
|
34 | + { |
|
32 | 35 | throw new ContainerException( |
33 | 36 | \sprintf('Unable to resolve `%s` in a Proxy in `%s` scope.', $alias, self::getScope($c)), |
34 | 37 | previous: $e, |
35 | 38 | ); |
36 | 39 | } |
37 | 40 | |
38 | - if (Proxy::isProxy($result)) { |
|
41 | + if (Proxy::isProxy($result)) |
|
42 | + { |
|
39 | 43 | throw new RecursiveProxyException( |
40 | 44 | \sprintf('Recursive proxy detected for `%s` in `%s` scope.', $alias, self::getScope($c)), |
41 | 45 | ); |
@@ -18,24 +18,24 @@ discard block |
||
18 | 18 | { |
19 | 19 | public static function resolve( |
20 | 20 | string $alias, |
21 | - \Stringable|string|null $context = null, |
|
21 | + \Stringable | string | null $context = null, |
|
22 | 22 | ?ContainerInterface $c = null, |
23 | 23 | ): object { |
24 | 24 | $c ??= ContainerScope::getContainer() ?? throw new ContainerException('Proxy is out of scope.'); |
25 | 25 | |
26 | - try { |
|
26 | + try{ |
|
27 | 27 | /** @psalm-suppress TooManyArguments */ |
28 | 28 | $result = $c->get($alias, $context) ?? throw new ContainerException( |
29 | 29 | 'Resolved `null` from the container.', |
30 | 30 | ); |
31 | - } catch (\Throwable $e) { |
|
31 | + }catch (\Throwable $e){ |
|
32 | 32 | throw new ContainerException( |
33 | 33 | \sprintf('Unable to resolve `%s` in a Proxy in `%s` scope.', $alias, self::getScope($c)), |
34 | 34 | previous: $e, |
35 | 35 | ); |
36 | 36 | } |
37 | 37 | |
38 | - if (Proxy::isProxy($result)) { |
|
38 | + if (Proxy::isProxy($result)){ |
|
39 | 39 | throw new RecursiveProxyException( |
40 | 40 | \sprintf('Recursive proxy detected for `%s` in `%s` scope.', $alias, self::getScope($c)), |
41 | 41 | ); |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | private static function getScope(ContainerInterface $c): string |
51 | 51 | { |
52 | 52 | return \implode('.', \array_reverse(\array_map( |
53 | - static fn (?string $name): string => $name ?? 'null', |
|
53 | + static fn (?string $name) : string => $name ?? 'null', |
|
54 | 54 | Introspector::scopeNames($c), |
55 | 55 | ))); |
56 | 56 | } |