@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | public function testScope(): void |
54 | 54 | { |
55 | 55 | $core = $this->httpCore([CookiesMiddleware::class]); |
56 | - $core->setHandler(function ($r) { |
|
56 | + $core->setHandler(function ($r){ |
|
57 | 57 | $this->assertInstanceOf( |
58 | 58 | CookieQueue::class, |
59 | 59 | ContainerScope::getContainer()->get(ServerRequestInterface::class) |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | public function testSetEncryptedCookie(): void |
78 | 78 | { |
79 | 79 | $core = $this->httpCore([CookiesMiddleware::class]); |
80 | - $core->setHandler(function ($r) { |
|
80 | + $core->setHandler(function ($r){ |
|
81 | 81 | ContainerScope::getContainer()->get(ServerRequestInterface::class) |
82 | 82 | ->getAttribute(CookieQueue::ATTRIBUTE)->set('name', 'value'); |
83 | 83 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | public function testSetNotProtectedCookie(): void |
100 | 100 | { |
101 | 101 | $core = $this->httpCore([CookiesMiddleware::class]); |
102 | - $core->setHandler(function ($r) { |
|
102 | + $core->setHandler(function ($r){ |
|
103 | 103 | ContainerScope::getContainer()->get(ServerRequestInterface::class) |
104 | 104 | ->getAttribute(CookieQueue::ATTRIBUTE)->set('PHPSESSID', 'value'); |
105 | 105 | |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | public function testDecrypt(): void |
119 | 119 | { |
120 | 120 | $core = $this->httpCore([CookiesMiddleware::class]); |
121 | - $core->setHandler(function ($r) { |
|
121 | + $core->setHandler(function ($r){ |
|
122 | 122 | |
123 | 123 | /** |
124 | 124 | * @var ServerRequest $r |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | public function testDecryptArray(): void |
137 | 137 | { |
138 | 138 | $core = $this->httpCore([CookiesMiddleware::class]); |
139 | - $core->setHandler(function ($r) { |
|
139 | + $core->setHandler(function ($r){ |
|
140 | 140 | |
141 | 141 | /** |
142 | 142 | * @var ServerRequest $r |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | public function testDecryptBroken(): void |
155 | 155 | { |
156 | 156 | $core = $this->httpCore([CookiesMiddleware::class]); |
157 | - $core->setHandler(function ($r) { |
|
157 | + $core->setHandler(function ($r){ |
|
158 | 158 | |
159 | 159 | /** |
160 | 160 | * @var ServerRequest $r |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | return $r->getCookieParams()['name']; |
163 | 163 | }); |
164 | 164 | |
165 | - $value = $this->container->get(EncrypterInterface::class)->encrypt('cookie-value') . 'BROKEN'; |
|
165 | + $value = $this->container->get(EncrypterInterface::class)->encrypt('cookie-value').'BROKEN'; |
|
166 | 166 | |
167 | 167 | $response = $this->get($core, '/', [], [], ['name' => $value]); |
168 | 168 | $this->assertSame(200, $response->getStatusCode()); |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | public function testDelete(): void |
173 | 173 | { |
174 | 174 | $core = $this->httpCore([CookiesMiddleware::class]); |
175 | - $core->setHandler(function ($r) { |
|
175 | + $core->setHandler(function ($r){ |
|
176 | 176 | ContainerScope::getContainer()->get(ServerRequestInterface::class) |
177 | 177 | ->getAttribute(CookieQueue::ATTRIBUTE)->set('name', 'value'); |
178 | 178 | |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | ])); |
201 | 201 | |
202 | 202 | $core = $this->httpCore([CookiesMiddleware::class]); |
203 | - $core->setHandler(function ($r) { |
|
203 | + $core->setHandler(function ($r){ |
|
204 | 204 | ContainerScope::getContainer()->get(ServerRequestInterface::class) |
205 | 205 | ->getAttribute(CookieQueue::ATTRIBUTE)->set('name', 'value'); |
206 | 206 | |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | ])); |
226 | 226 | |
227 | 227 | $core = $this->httpCore([CookiesMiddleware::class]); |
228 | - $core->setHandler(function ($r) { |
|
228 | + $core->setHandler(function ($r){ |
|
229 | 229 | |
230 | 230 | /** |
231 | 231 | * @var ServerRequest $r |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | ])); |
250 | 250 | |
251 | 251 | $core = $this->httpCore([CookiesMiddleware::class]); |
252 | - $core->setHandler(function ($r) { |
|
252 | + $core->setHandler(function ($r){ |
|
253 | 253 | ContainerScope::getContainer()->get(ServerRequestInterface::class) |
254 | 254 | ->getAttribute(CookieQueue::ATTRIBUTE)->set('name', 'value'); |
255 | 255 | |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | $cookies = $this->fetchCookies($response); |
264 | 264 | $this->assertArrayHasKey('name', $cookies); |
265 | 265 | |
266 | - $core->setHandler(function ($r) { |
|
266 | + $core->setHandler(function ($r){ |
|
267 | 267 | return $r->getCookieParams()['name']; |
268 | 268 | }); |
269 | 269 | |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | { |
319 | 319 | $result = []; |
320 | 320 | |
321 | - foreach ($response->getHeaders() as $line) { |
|
321 | + foreach ($response->getHeaders() as $line){ |
|
322 | 322 | $cookie = explode('=', implode('', $line)); |
323 | 323 | $result[$cookie[0]] = rawurldecode(substr( |
324 | 324 | (string)$cookie[1], |
@@ -53,7 +53,8 @@ discard block |
||
53 | 53 | public function testScope(): void |
54 | 54 | { |
55 | 55 | $core = $this->httpCore([CookiesMiddleware::class]); |
56 | - $core->setHandler(function ($r) { |
|
56 | + $core->setHandler(function ($r) |
|
57 | + { |
|
57 | 58 | $this->assertInstanceOf( |
58 | 59 | CookieQueue::class, |
59 | 60 | ContainerScope::getContainer()->get(ServerRequestInterface::class) |
@@ -77,7 +78,8 @@ discard block |
||
77 | 78 | public function testSetEncryptedCookie(): void |
78 | 79 | { |
79 | 80 | $core = $this->httpCore([CookiesMiddleware::class]); |
80 | - $core->setHandler(function ($r) { |
|
81 | + $core->setHandler(function ($r) |
|
82 | + { |
|
81 | 83 | ContainerScope::getContainer()->get(ServerRequestInterface::class) |
82 | 84 | ->getAttribute(CookieQueue::ATTRIBUTE)->set('name', 'value'); |
83 | 85 | |
@@ -99,7 +101,8 @@ discard block |
||
99 | 101 | public function testSetNotProtectedCookie(): void |
100 | 102 | { |
101 | 103 | $core = $this->httpCore([CookiesMiddleware::class]); |
102 | - $core->setHandler(function ($r) { |
|
104 | + $core->setHandler(function ($r) |
|
105 | + { |
|
103 | 106 | ContainerScope::getContainer()->get(ServerRequestInterface::class) |
104 | 107 | ->getAttribute(CookieQueue::ATTRIBUTE)->set('PHPSESSID', 'value'); |
105 | 108 | |
@@ -118,7 +121,8 @@ discard block |
||
118 | 121 | public function testDecrypt(): void |
119 | 122 | { |
120 | 123 | $core = $this->httpCore([CookiesMiddleware::class]); |
121 | - $core->setHandler(function ($r) { |
|
124 | + $core->setHandler(function ($r) |
|
125 | + { |
|
122 | 126 | |
123 | 127 | /** |
124 | 128 | * @var ServerRequest $r |
@@ -136,7 +140,8 @@ discard block |
||
136 | 140 | public function testDecryptArray(): void |
137 | 141 | { |
138 | 142 | $core = $this->httpCore([CookiesMiddleware::class]); |
139 | - $core->setHandler(function ($r) { |
|
143 | + $core->setHandler(function ($r) |
|
144 | + { |
|
140 | 145 | |
141 | 146 | /** |
142 | 147 | * @var ServerRequest $r |
@@ -154,7 +159,8 @@ discard block |
||
154 | 159 | public function testDecryptBroken(): void |
155 | 160 | { |
156 | 161 | $core = $this->httpCore([CookiesMiddleware::class]); |
157 | - $core->setHandler(function ($r) { |
|
162 | + $core->setHandler(function ($r) |
|
163 | + { |
|
158 | 164 | |
159 | 165 | /** |
160 | 166 | * @var ServerRequest $r |
@@ -172,7 +178,8 @@ discard block |
||
172 | 178 | public function testDelete(): void |
173 | 179 | { |
174 | 180 | $core = $this->httpCore([CookiesMiddleware::class]); |
175 | - $core->setHandler(function ($r) { |
|
181 | + $core->setHandler(function ($r) |
|
182 | + { |
|
176 | 183 | ContainerScope::getContainer()->get(ServerRequestInterface::class) |
177 | 184 | ->getAttribute(CookieQueue::ATTRIBUTE)->set('name', 'value'); |
178 | 185 | |
@@ -200,7 +207,8 @@ discard block |
||
200 | 207 | ])); |
201 | 208 | |
202 | 209 | $core = $this->httpCore([CookiesMiddleware::class]); |
203 | - $core->setHandler(function ($r) { |
|
210 | + $core->setHandler(function ($r) |
|
211 | + { |
|
204 | 212 | ContainerScope::getContainer()->get(ServerRequestInterface::class) |
205 | 213 | ->getAttribute(CookieQueue::ATTRIBUTE)->set('name', 'value'); |
206 | 214 | |
@@ -225,7 +233,8 @@ discard block |
||
225 | 233 | ])); |
226 | 234 | |
227 | 235 | $core = $this->httpCore([CookiesMiddleware::class]); |
228 | - $core->setHandler(function ($r) { |
|
236 | + $core->setHandler(function ($r) |
|
237 | + { |
|
229 | 238 | |
230 | 239 | /** |
231 | 240 | * @var ServerRequest $r |
@@ -249,7 +258,8 @@ discard block |
||
249 | 258 | ])); |
250 | 259 | |
251 | 260 | $core = $this->httpCore([CookiesMiddleware::class]); |
252 | - $core->setHandler(function ($r) { |
|
261 | + $core->setHandler(function ($r) |
|
262 | + { |
|
253 | 263 | ContainerScope::getContainer()->get(ServerRequestInterface::class) |
254 | 264 | ->getAttribute(CookieQueue::ATTRIBUTE)->set('name', 'value'); |
255 | 265 | |
@@ -263,7 +273,8 @@ discard block |
||
263 | 273 | $cookies = $this->fetchCookies($response); |
264 | 274 | $this->assertArrayHasKey('name', $cookies); |
265 | 275 | |
266 | - $core->setHandler(function ($r) { |
|
276 | + $core->setHandler(function ($r) |
|
277 | + { |
|
267 | 278 | return $r->getCookieParams()['name']; |
268 | 279 | }); |
269 | 280 | |
@@ -318,7 +329,8 @@ discard block |
||
318 | 329 | { |
319 | 330 | $result = []; |
320 | 331 | |
321 | - foreach ($response->getHeaders() as $line) { |
|
332 | + foreach ($response->getHeaders() as $line) |
|
333 | + { |
|
322 | 334 | $cookie = explode('=', implode('', $line)); |
323 | 335 | $result[$cookie[0]] = rawurldecode(substr( |
324 | 336 | (string)$cookie[1], |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | { |
46 | 46 | $core = $this->getCore(); |
47 | 47 | |
48 | - $core->setHandler(function () { |
|
48 | + $core->setHandler(function (){ |
|
49 | 49 | return 'hello world'; |
50 | 50 | }); |
51 | 51 | |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | { |
68 | 68 | $core = $this->getCore(); |
69 | 69 | $core->setHandler( |
70 | - new CallableHandler(function () { |
|
70 | + new CallableHandler(function (){ |
|
71 | 71 | return 'hello world'; |
72 | 72 | }, new ResponseFactory(new HttpConfig(['headers' => []]))) |
73 | 73 | ); |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | { |
81 | 81 | $core = $this->getCore(); |
82 | 82 | |
83 | - $core->setHandler(function ($req, $resp) { |
|
83 | + $core->setHandler(function ($req, $resp){ |
|
84 | 84 | return $resp->withAddedHeader('hello', 'value'); |
85 | 85 | }); |
86 | 86 | |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | { |
94 | 94 | $core = $this->getCore(); |
95 | 95 | |
96 | - $core->setHandler(function ($req, $resp) { |
|
96 | + $core->setHandler(function ($req, $resp){ |
|
97 | 97 | echo 'hello!'; |
98 | 98 | |
99 | 99 | return $resp->withAddedHeader('hello', 'value'); |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | { |
110 | 110 | $core = $this->getCore(); |
111 | 111 | |
112 | - $core->setHandler(function ($req, $resp) { |
|
112 | + $core->setHandler(function ($req, $resp){ |
|
113 | 113 | echo 'hello!'; |
114 | 114 | $resp->getBody()->write('world '); |
115 | 115 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | { |
127 | 127 | $core = $this->getCore(); |
128 | 128 | |
129 | - $core->setHandler(function () { |
|
129 | + $core->setHandler(function (){ |
|
130 | 130 | ob_start(); |
131 | 131 | ob_start(); |
132 | 132 | echo 'hello!'; |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | { |
148 | 148 | $core = $this->getCore(); |
149 | 149 | |
150 | - $core->setHandler(function () { |
|
150 | + $core->setHandler(function (){ |
|
151 | 151 | return [ |
152 | 152 | 'status' => 404, |
153 | 153 | 'message' => 'not found', |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | { |
164 | 164 | $core = $this->getCore(); |
165 | 165 | |
166 | - $core->setHandler(function () { |
|
166 | + $core->setHandler(function (){ |
|
167 | 167 | return new Json([ |
168 | 168 | 'status' => 404, |
169 | 169 | 'message' => 'not found', |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | { |
180 | 180 | $core = $this->getCore([HeaderMiddleware::class]); |
181 | 181 | |
182 | - $core->setHandler(function () { |
|
182 | + $core->setHandler(function (){ |
|
183 | 183 | return 'hello?'; |
184 | 184 | }); |
185 | 185 | |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | $core->getPipeline()->pushMiddleware(new Header2Middleware()); |
197 | 197 | $core->getPipeline()->riseMiddleware(new HeaderMiddleware()); |
198 | 198 | |
199 | - $core->setHandler(function () { |
|
199 | + $core->setHandler(function (){ |
|
200 | 200 | return 'hello?'; |
201 | 201 | }); |
202 | 202 | |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | $core->getPipeline()->pushMiddleware(new HeaderMiddleware()); |
214 | 214 | $core->getPipeline()->riseMiddleware(new Header2Middleware()); |
215 | 215 | |
216 | - $core->setHandler(function () { |
|
216 | + $core->setHandler(function (){ |
|
217 | 217 | return 'hello?'; |
218 | 218 | }); |
219 | 219 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | { |
228 | 228 | $core = $this->getCore(); |
229 | 229 | |
230 | - $core->setHandler(function () { |
|
230 | + $core->setHandler(function (){ |
|
231 | 231 | $this->assertTrue(ContainerScope::getContainer()->has(ServerRequestInterface::class)); |
232 | 232 | |
233 | 233 | return 'OK'; |
@@ -260,12 +260,12 @@ discard block |
||
260 | 260 | $dispatcher |
261 | 261 | ->expects(self::exactly(2)) |
262 | 262 | ->method('dispatch') |
263 | - ->with($this->callback(static fn(RequestReceived|RequestHandled $event): bool => true)); |
|
263 | + ->with($this->callback(static fn(RequestReceived | RequestHandled $event): bool => true)); |
|
264 | 264 | $this->container->bind(EventDispatcherInterface::class, $dispatcher); |
265 | 265 | |
266 | 266 | $core = $this->getCore(); |
267 | 267 | |
268 | - $core->setHandler(function () { |
|
268 | + $core->setHandler(function (){ |
|
269 | 269 | return 'hello world'; |
270 | 270 | }); |
271 | 271 | |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | $tracerFactory = m::mock(TracerFactoryInterface::class), |
287 | 287 | ); |
288 | 288 | |
289 | - $http->setHandler(function () { |
|
289 | + $http->setHandler(function (){ |
|
290 | 290 | return 'hello world'; |
291 | 291 | }); |
292 | 292 |
@@ -45,7 +45,8 @@ discard block |
||
45 | 45 | { |
46 | 46 | $core = $this->getCore(); |
47 | 47 | |
48 | - $core->setHandler(function () { |
|
48 | + $core->setHandler(function () |
|
49 | + { |
|
49 | 50 | return 'hello world'; |
50 | 51 | }); |
51 | 52 | |
@@ -67,7 +68,8 @@ discard block |
||
67 | 68 | { |
68 | 69 | $core = $this->getCore(); |
69 | 70 | $core->setHandler( |
70 | - new CallableHandler(function () { |
|
71 | + new CallableHandler(function () |
|
72 | + { |
|
71 | 73 | return 'hello world'; |
72 | 74 | }, new ResponseFactory(new HttpConfig(['headers' => []]))) |
73 | 75 | ); |
@@ -80,7 +82,8 @@ discard block |
||
80 | 82 | { |
81 | 83 | $core = $this->getCore(); |
82 | 84 | |
83 | - $core->setHandler(function ($req, $resp) { |
|
85 | + $core->setHandler(function ($req, $resp) |
|
86 | + { |
|
84 | 87 | return $resp->withAddedHeader('hello', 'value'); |
85 | 88 | }); |
86 | 89 | |
@@ -93,7 +96,8 @@ discard block |
||
93 | 96 | { |
94 | 97 | $core = $this->getCore(); |
95 | 98 | |
96 | - $core->setHandler(function ($req, $resp) { |
|
99 | + $core->setHandler(function ($req, $resp) |
|
100 | + { |
|
97 | 101 | echo 'hello!'; |
98 | 102 | |
99 | 103 | return $resp->withAddedHeader('hello', 'value'); |
@@ -109,7 +113,8 @@ discard block |
||
109 | 113 | { |
110 | 114 | $core = $this->getCore(); |
111 | 115 | |
112 | - $core->setHandler(function ($req, $resp) { |
|
116 | + $core->setHandler(function ($req, $resp) |
|
117 | + { |
|
113 | 118 | echo 'hello!'; |
114 | 119 | $resp->getBody()->write('world '); |
115 | 120 | |
@@ -126,7 +131,8 @@ discard block |
||
126 | 131 | { |
127 | 132 | $core = $this->getCore(); |
128 | 133 | |
129 | - $core->setHandler(function () { |
|
134 | + $core->setHandler(function () |
|
135 | + { |
|
130 | 136 | ob_start(); |
131 | 137 | ob_start(); |
132 | 138 | echo 'hello!'; |
@@ -147,7 +153,8 @@ discard block |
||
147 | 153 | { |
148 | 154 | $core = $this->getCore(); |
149 | 155 | |
150 | - $core->setHandler(function () { |
|
156 | + $core->setHandler(function () |
|
157 | + { |
|
151 | 158 | return [ |
152 | 159 | 'status' => 404, |
153 | 160 | 'message' => 'not found', |
@@ -163,7 +170,8 @@ discard block |
||
163 | 170 | { |
164 | 171 | $core = $this->getCore(); |
165 | 172 | |
166 | - $core->setHandler(function () { |
|
173 | + $core->setHandler(function () |
|
174 | + { |
|
167 | 175 | return new Json([ |
168 | 176 | 'status' => 404, |
169 | 177 | 'message' => 'not found', |
@@ -179,7 +187,8 @@ discard block |
||
179 | 187 | { |
180 | 188 | $core = $this->getCore([HeaderMiddleware::class]); |
181 | 189 | |
182 | - $core->setHandler(function () { |
|
190 | + $core->setHandler(function () |
|
191 | + { |
|
183 | 192 | return 'hello?'; |
184 | 193 | }); |
185 | 194 | |
@@ -196,7 +205,8 @@ discard block |
||
196 | 205 | $core->getPipeline()->pushMiddleware(new Header2Middleware()); |
197 | 206 | $core->getPipeline()->riseMiddleware(new HeaderMiddleware()); |
198 | 207 | |
199 | - $core->setHandler(function () { |
|
208 | + $core->setHandler(function () |
|
209 | + { |
|
200 | 210 | return 'hello?'; |
201 | 211 | }); |
202 | 212 | |
@@ -213,7 +223,8 @@ discard block |
||
213 | 223 | $core->getPipeline()->pushMiddleware(new HeaderMiddleware()); |
214 | 224 | $core->getPipeline()->riseMiddleware(new Header2Middleware()); |
215 | 225 | |
216 | - $core->setHandler(function () { |
|
226 | + $core->setHandler(function () |
|
227 | + { |
|
217 | 228 | return 'hello?'; |
218 | 229 | }); |
219 | 230 | |
@@ -227,7 +238,8 @@ discard block |
||
227 | 238 | { |
228 | 239 | $core = $this->getCore(); |
229 | 240 | |
230 | - $core->setHandler(function () { |
|
241 | + $core->setHandler(function () |
|
242 | + { |
|
231 | 243 | $this->assertTrue(ContainerScope::getContainer()->has(ServerRequestInterface::class)); |
232 | 244 | |
233 | 245 | return 'OK'; |
@@ -265,7 +277,8 @@ discard block |
||
265 | 277 | |
266 | 278 | $core = $this->getCore(); |
267 | 279 | |
268 | - $core->setHandler(function () { |
|
280 | + $core->setHandler(function () |
|
281 | + { |
|
269 | 282 | return 'hello world'; |
270 | 283 | }); |
271 | 284 | |
@@ -286,7 +299,8 @@ discard block |
||
286 | 299 | $tracerFactory = m::mock(TracerFactoryInterface::class), |
287 | 300 | ); |
288 | 301 | |
289 | - $http->setHandler(function () { |
|
302 | + $http->setHandler(function () |
|
303 | + { |
|
290 | 304 | return 'hello world'; |
291 | 305 | }); |
292 | 306 |
@@ -28,7 +28,7 @@ |
||
28 | 28 | |
29 | 29 | public function hasInstance(string $alias): bool |
30 | 30 | { |
31 | - if (!$this->container->has($alias)) { |
|
31 | + if (!$this->container->has($alias)){ |
|
32 | 32 | return false; |
33 | 33 | } |
34 | 34 | return parent::hasInstance($alias); |
@@ -28,7 +28,8 @@ |
||
28 | 28 | |
29 | 29 | public function hasInstance(string $alias): bool |
30 | 30 | { |
31 | - if (!$this->container->has($alias)) { |
|
31 | + if (!$this->container->has($alias)) |
|
32 | + { |
|
32 | 33 | return false; |
33 | 34 | } |
34 | 35 | return parent::hasInstance($alias); |
@@ -12,6 +12,6 @@ |
||
12 | 12 | public ?string $parameter = null, |
13 | 13 | public ?bool $singleton = null, |
14 | 14 | public ?\ReflectionClass $reflection = null, |
15 | - ) { |
|
15 | + ){ |
|
16 | 16 | } |
17 | 17 | } |
@@ -18,15 +18,15 @@ discard block |
||
18 | 18 | { |
19 | 19 | public function __construct( |
20 | 20 | protected readonly State $state, |
21 | - ) { |
|
21 | + ){ |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
25 | 25 | * @param TResolver|object $resolver |
26 | 26 | */ |
27 | - public function bind(string $alias, string|array|callable|object $resolver): void |
|
27 | + public function bind(string $alias, string | array | callable | object $resolver): void |
|
28 | 28 | { |
29 | - if (\is_array($resolver) || $resolver instanceof \Closure || $resolver instanceof Autowire) { |
|
29 | + if (\is_array($resolver) || $resolver instanceof \Closure || $resolver instanceof Autowire){ |
|
30 | 30 | // array means = execute me, false = not singleton |
31 | 31 | $this->state->bindings[$alias] = [$resolver, false]; |
32 | 32 | |
@@ -39,9 +39,9 @@ discard block |
||
39 | 39 | /** |
40 | 40 | * @param TResolver|object $resolver |
41 | 41 | */ |
42 | - public function bindSingleton(string $alias, string|array|callable|object $resolver): void |
|
42 | + public function bindSingleton(string $alias, string | array | callable | object $resolver): void |
|
43 | 43 | { |
44 | - if (\is_object($resolver) && !$resolver instanceof \Closure && !$resolver instanceof Autowire) { |
|
44 | + if (\is_object($resolver) && !$resolver instanceof \Closure && !$resolver instanceof Autowire){ |
|
45 | 45 | // direct binding to an instance |
46 | 46 | $this->state->bindings[$alias] = $resolver; |
47 | 47 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | { |
56 | 56 | $bindings = &$this->state->bindings; |
57 | 57 | |
58 | - while (\is_string($bindings[$alias] ?? null)) { |
|
58 | + while (\is_string($bindings[$alias] ?? null)){ |
|
59 | 59 | //Checking alias tree |
60 | 60 | $alias = $bindings[$alias]; |
61 | 61 | } |
@@ -80,31 +80,31 @@ discard block |
||
80 | 80 | |
81 | 81 | public function hasInjector(string $class): bool |
82 | 82 | { |
83 | - try { |
|
83 | + try{ |
|
84 | 84 | $reflection = new \ReflectionClass($class); |
85 | - } catch (\ReflectionException $e) { |
|
85 | + }catch (\ReflectionException $e){ |
|
86 | 86 | throw new ContainerException($e->getMessage(), $e->getCode(), $e); |
87 | 87 | } |
88 | 88 | |
89 | - if (\array_key_exists($class, $this->state->injectors)) { |
|
89 | + if (\array_key_exists($class, $this->state->injectors)){ |
|
90 | 90 | return $this->state->injectors[$class] !== null; |
91 | 91 | } |
92 | 92 | |
93 | 93 | if ( |
94 | 94 | $reflection->implementsInterface(InjectableInterface::class) |
95 | 95 | && $reflection->hasConstant('INJECTOR') |
96 | - ) { |
|
96 | + ){ |
|
97 | 97 | $this->state->injectors[$class] = $reflection->getConstant('INJECTOR'); |
98 | 98 | |
99 | 99 | return true; |
100 | 100 | } |
101 | 101 | |
102 | 102 | // check interfaces |
103 | - foreach ($this->state->injectors as $target => $injector) { |
|
103 | + foreach ($this->state->injectors as $target => $injector){ |
|
104 | 104 | if ( |
105 | 105 | \class_exists($target, true) |
106 | 106 | && $reflection->isSubclassOf($target) |
107 | - ) { |
|
107 | + ){ |
|
108 | 108 | $this->state->injectors[$class] = $injector; |
109 | 109 | |
110 | 110 | return true; |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | if ( |
114 | 114 | \interface_exists($target, true) |
115 | 115 | && $reflection->implementsInterface($target) |
116 | - ) { |
|
116 | + ){ |
|
117 | 117 | $this->state->injectors[$class] = $injector; |
118 | 118 | |
119 | 119 | return true; |
@@ -26,7 +26,8 @@ discard block |
||
26 | 26 | */ |
27 | 27 | public function bind(string $alias, string|array|callable|object $resolver): void |
28 | 28 | { |
29 | - if (\is_array($resolver) || $resolver instanceof \Closure || $resolver instanceof Autowire) { |
|
29 | + if (\is_array($resolver) || $resolver instanceof \Closure || $resolver instanceof Autowire) |
|
30 | + { |
|
30 | 31 | // array means = execute me, false = not singleton |
31 | 32 | $this->state->bindings[$alias] = [$resolver, false]; |
32 | 33 | |
@@ -41,7 +42,8 @@ discard block |
||
41 | 42 | */ |
42 | 43 | public function bindSingleton(string $alias, string|array|callable|object $resolver): void |
43 | 44 | { |
44 | - if (\is_object($resolver) && !$resolver instanceof \Closure && !$resolver instanceof Autowire) { |
|
45 | + if (\is_object($resolver) && !$resolver instanceof \Closure && !$resolver instanceof Autowire) |
|
46 | + { |
|
45 | 47 | // direct binding to an instance |
46 | 48 | $this->state->bindings[$alias] = $resolver; |
47 | 49 | |
@@ -55,7 +57,8 @@ discard block |
||
55 | 57 | { |
56 | 58 | $bindings = &$this->state->bindings; |
57 | 59 | |
58 | - while (\is_string($bindings[$alias] ?? null)) { |
|
60 | + while (\is_string($bindings[$alias] ?? null)) |
|
61 | + { |
|
59 | 62 | //Checking alias tree |
60 | 63 | $alias = $bindings[$alias]; |
61 | 64 | } |
@@ -80,13 +83,17 @@ discard block |
||
80 | 83 | |
81 | 84 | public function hasInjector(string $class): bool |
82 | 85 | { |
83 | - try { |
|
86 | + try |
|
87 | + { |
|
84 | 88 | $reflection = new \ReflectionClass($class); |
85 | - } catch (\ReflectionException $e) { |
|
89 | + } |
|
90 | + catch (\ReflectionException $e) |
|
91 | + { |
|
86 | 92 | throw new ContainerException($e->getMessage(), $e->getCode(), $e); |
87 | 93 | } |
88 | 94 | |
89 | - if (\array_key_exists($class, $this->state->injectors)) { |
|
95 | + if (\array_key_exists($class, $this->state->injectors)) |
|
96 | + { |
|
90 | 97 | return $this->state->injectors[$class] !== null; |
91 | 98 | } |
92 | 99 | |
@@ -100,7 +107,8 @@ discard block |
||
100 | 107 | } |
101 | 108 | |
102 | 109 | // check interfaces |
103 | - foreach ($this->state->injectors as $target => $injector) { |
|
110 | + foreach ($this->state->injectors as $target => $injector) |
|
111 | + { |
|
104 | 112 | if ( |
105 | 113 | \class_exists($target, true) |
106 | 114 | && $reflection->isSubclassOf($target) |
@@ -34,22 +34,22 @@ |
||
34 | 34 | { |
35 | 35 | [$previous, self::$container] = [self::$container, $container]; |
36 | 36 | |
37 | - try { |
|
38 | - if (Fiber::getCurrent() === null) { |
|
37 | + try{ |
|
38 | + if (Fiber::getCurrent() === null){ |
|
39 | 39 | return $scope(self::$container); |
40 | 40 | } |
41 | 41 | |
42 | 42 | // Wrap scope into fiber |
43 | 43 | $fiber = new Fiber(static fn () => $scope(self::$container)); |
44 | 44 | $value = $fiber->start(); |
45 | - while (!$fiber->isTerminated()) { |
|
45 | + while (!$fiber->isTerminated()){ |
|
46 | 46 | self::$container = $previous; |
47 | 47 | $resume = Fiber::suspend($value); |
48 | 48 | self::$container = $container; |
49 | 49 | $value = $fiber->resume($resume); |
50 | 50 | } |
51 | 51 | return $fiber->getReturn(); |
52 | - } finally { |
|
52 | + }finally{ |
|
53 | 53 | self::$container = $previous; |
54 | 54 | } |
55 | 55 | } |
@@ -34,22 +34,27 @@ |
||
34 | 34 | { |
35 | 35 | [$previous, self::$container] = [self::$container, $container]; |
36 | 36 | |
37 | - try { |
|
38 | - if (Fiber::getCurrent() === null) { |
|
37 | + try |
|
38 | + { |
|
39 | + if (Fiber::getCurrent() === null) |
|
40 | + { |
|
39 | 41 | return $scope(self::$container); |
40 | 42 | } |
41 | 43 | |
42 | 44 | // Wrap scope into fiber |
43 | 45 | $fiber = new Fiber(static fn () => $scope(self::$container)); |
44 | 46 | $value = $fiber->start(); |
45 | - while (!$fiber->isTerminated()) { |
|
47 | + while (!$fiber->isTerminated()) |
|
48 | + { |
|
46 | 49 | self::$container = $previous; |
47 | 50 | $resume = Fiber::suspend($value); |
48 | 51 | self::$container = $container; |
49 | 52 | $value = $fiber->resume($resume); |
50 | 53 | } |
51 | 54 | return $fiber->getReturn(); |
52 | - } finally { |
|
55 | + } |
|
56 | + finally |
|
57 | + { |
|
53 | 58 | self::$container = $previous; |
54 | 59 | } |
55 | 60 | } |
@@ -12,6 +12,6 @@ |
||
12 | 12 | { |
13 | 13 | public function __construct( |
14 | 14 | public string $method, |
15 | - ) { |
|
15 | + ){ |
|
16 | 16 | } |
17 | 17 | } |
@@ -12,6 +12,6 @@ |
||
12 | 12 | { |
13 | 13 | public function __construct( |
14 | 14 | public string $name, |
15 | - ) { |
|
15 | + ){ |
|
16 | 16 | } |
17 | 17 | } |
@@ -10,6 +10,6 @@ |
||
10 | 10 | { |
11 | 11 | public function __construct( |
12 | 12 | public DateTimeInterface $logger, |
13 | - ) { |
|
13 | + ){ |
|
14 | 14 | } |
15 | 15 | } |