@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | { |
48 | 48 | $kernel = TestCore::create(['root' => __DIR__])->run(); |
49 | 49 | |
50 | - $d = new class() implements DispatcherInterface { |
|
50 | + $d = new class() implements DispatcherInterface{ |
|
51 | 51 | public static function canServe(EnvironmentInterface $env): bool |
52 | 52 | { |
53 | 53 | return true; |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | { |
68 | 68 | $kernel = TestCore::create(['root' => __DIR__])->run(); |
69 | 69 | |
70 | - $d = new class() implements DispatcherInterface { |
|
70 | + $d = new class() implements DispatcherInterface{ |
|
71 | 71 | public function canServe(): bool |
72 | 72 | { |
73 | 73 | return true; |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | { |
91 | 91 | $kernel = TestCore::create(['root' => __DIR__])->run(); |
92 | 92 | |
93 | - $d = new class() implements DispatcherInterface { |
|
93 | + $d = new class() implements DispatcherInterface{ |
|
94 | 94 | public static function canServe(EnvironmentInterface $env): bool |
95 | 95 | { |
96 | 96 | return true; |
@@ -124,19 +124,19 @@ discard block |
||
124 | 124 | { |
125 | 125 | $kernel = TestCore::create(['root' => __DIR__]); |
126 | 126 | |
127 | - $kernel->booting(static function (TestCore $core) { |
|
127 | + $kernel->booting(static function (TestCore $core){ |
|
128 | 128 | $core->getContainer()->bind('abc', 'foo'); |
129 | 129 | }); |
130 | 130 | |
131 | - $kernel->booting(static function (TestCore $core) { |
|
131 | + $kernel->booting(static function (TestCore $core){ |
|
132 | 132 | $core->getContainer()->bind('bcd', 'foo'); |
133 | 133 | }); |
134 | 134 | |
135 | - $kernel->booted( static function (TestCore $core) { |
|
135 | + $kernel->booted(static function (TestCore $core){ |
|
136 | 136 | $core->getContainer()->bind('cde', 'foo'); |
137 | 137 | }); |
138 | 138 | |
139 | - $kernel->booted( static function (TestCore $core) { |
|
139 | + $kernel->booted(static function (TestCore $core){ |
|
140 | 140 | $core->getContainer()->bind('def', 'foo'); |
141 | 141 | }); |
142 | 142 | |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | |
160 | 160 | public function testEventsShouldBeDispatched(): void |
161 | 161 | { |
162 | - $testDispatcher = new class implements DispatcherInterface { |
|
162 | + $testDispatcher = new class implements DispatcherInterface{ |
|
163 | 163 | public static function canServe(EnvironmentInterface $env): bool |
164 | 164 | { |
165 | 165 | return true; |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | }; |
172 | 172 | |
173 | 173 | $container = new Container(); |
174 | - $kernel = TestCore::create(directories: ['root' => __DIR__,], container: $container) |
|
174 | + $kernel = TestCore::create(directories: ['root' => __DIR__, ], container: $container) |
|
175 | 175 | ->addDispatcher($testDispatcher); |
176 | 176 | |
177 | 177 | $dispatcher = $this->createMock(EventDispatcherInterface::class); |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | public function testDispatcherNotFoundEventShouldBeDispatched(): void |
193 | 193 | { |
194 | 194 | $container = new Container(); |
195 | - $kernel = TestCore::create(directories: ['root' => __DIR__,], container: $container); |
|
195 | + $kernel = TestCore::create(directories: ['root' => __DIR__, ], container: $container); |
|
196 | 196 | |
197 | 197 | $dispatcher = $this->createMock(EventDispatcherInterface::class); |
198 | 198 | $dispatcher |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | protected readonly ExceptionHandlerInterface $exceptionHandler, |
78 | 78 | protected readonly BootloadManagerInterface $bootloader, |
79 | 79 | array $directories |
80 | - ) { |
|
80 | + ){ |
|
81 | 81 | $container->bindSingleton(ExceptionHandlerInterface::class, $exceptionHandler); |
82 | 82 | $container->bindSingleton(ExceptionRendererInterface::class, $exceptionHandler); |
83 | 83 | $container->bindSingleton(ExceptionReporterInterface::class, $exceptionHandler); |
@@ -114,35 +114,35 @@ discard block |
||
114 | 114 | final public static function create( |
115 | 115 | array $directories, |
116 | 116 | bool $handleErrors = true, |
117 | - ExceptionHandlerInterface|string|null $exceptionHandler = null, |
|
117 | + ExceptionHandlerInterface | string | null $exceptionHandler = null, |
|
118 | 118 | Container $container = new Container(), |
119 | - BootloadManagerInterface|Autowire|null $bootloadManager = null |
|
119 | + BootloadManagerInterface | Autowire | null $bootloadManager = null |
|
120 | 120 | ): static { |
121 | 121 | $exceptionHandler ??= ExceptionHandler::class; |
122 | 122 | |
123 | - if (\is_string($exceptionHandler)) { |
|
123 | + if (\is_string($exceptionHandler)){ |
|
124 | 124 | $exceptionHandler = $container->make($exceptionHandler); |
125 | 125 | } |
126 | 126 | |
127 | - if ($handleErrors) { |
|
127 | + if ($handleErrors){ |
|
128 | 128 | $exceptionHandler->register(); |
129 | 129 | } |
130 | 130 | |
131 | - if (!$container->has(InitializerInterface::class)) { |
|
131 | + if (!$container->has(InitializerInterface::class)){ |
|
132 | 132 | $container->bind(InitializerInterface::class, Initializer::class); |
133 | 133 | } |
134 | - if (!$container->has(InvokerStrategyInterface::class)) { |
|
134 | + if (!$container->has(InvokerStrategyInterface::class)){ |
|
135 | 135 | $container->bind(InvokerStrategyInterface::class, DefaultInvokerStrategy::class); |
136 | 136 | } |
137 | 137 | |
138 | - if ($bootloadManager instanceof Autowire) { |
|
138 | + if ($bootloadManager instanceof Autowire){ |
|
139 | 139 | $bootloadManager = $bootloadManager->resolve($container); |
140 | 140 | } |
141 | 141 | $bootloadManager ??= $container->make(StrategyBasedBootloadManager::class); |
142 | 142 | \assert($bootloadManager instanceof BootloadManagerInterface); |
143 | 143 | $container->bind(BootloadManagerInterface::class, $bootloadManager); |
144 | 144 | |
145 | - if (!$container->has(BootloaderRegistryInterface::class)) { |
|
145 | + if (!$container->has(BootloaderRegistryInterface::class)){ |
|
146 | 146 | $container->bindSingleton(BootloaderRegistryInterface::class, [self::class, 'initBootloaderRegistry']); |
147 | 147 | } |
148 | 148 | |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | $environment ??= new Environment(); |
172 | 172 | $this->container->bindSingleton(EnvironmentInterface::class, $environment); |
173 | 173 | |
174 | - try { |
|
174 | + try{ |
|
175 | 175 | // will protect any against env overwrite action |
176 | 176 | $this->container->runScope( |
177 | 177 | [EnvironmentInterface::class => $environment], |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | $this->fireCallbacks($this->bootstrappedCallbacks); |
189 | 189 | } |
190 | 190 | ); |
191 | - } catch (\Throwable $e) { |
|
191 | + }catch (\Throwable $e){ |
|
192 | 192 | $this->exceptionHandler->handleGlobalException($e); |
193 | 193 | |
194 | 194 | return null; |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | */ |
210 | 210 | public function running(Closure ...$callbacks): void |
211 | 211 | { |
212 | - foreach ($callbacks as $callback) { |
|
212 | + foreach ($callbacks as $callback){ |
|
213 | 213 | $this->runningCallbacks[] = $callback; |
214 | 214 | } |
215 | 215 | } |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | */ |
225 | 225 | public function booting(Closure ...$callbacks): void |
226 | 226 | { |
227 | - foreach ($callbacks as $callback) { |
|
227 | + foreach ($callbacks as $callback){ |
|
228 | 228 | $this->bootingCallbacks[] = $callback; |
229 | 229 | } |
230 | 230 | } |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | */ |
240 | 240 | public function booted(Closure ...$callbacks): void |
241 | 241 | { |
242 | - foreach ($callbacks as $callback) { |
|
242 | + foreach ($callbacks as $callback){ |
|
243 | 243 | $this->bootedCallbacks[] = $callback; |
244 | 244 | } |
245 | 245 | } |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | */ |
256 | 256 | public function bootstrapped(Closure ...$callbacks): void |
257 | 257 | { |
258 | - foreach ($callbacks as $callback) { |
|
258 | + foreach ($callbacks as $callback){ |
|
259 | 259 | $this->bootstrappedCallbacks[] = $callback; |
260 | 260 | } |
261 | 261 | } |
@@ -267,9 +267,9 @@ discard block |
||
267 | 267 | * @param class-string<DispatcherInterface>|DispatcherInterface $dispatcher The class name or instance |
268 | 268 | * of the dispatcher. Since v4.0, it will only accept the class name. |
269 | 269 | */ |
270 | - public function addDispatcher(string|DispatcherInterface $dispatcher): self |
|
270 | + public function addDispatcher(string | DispatcherInterface $dispatcher): self |
|
271 | 271 | { |
272 | - if (\is_object($dispatcher)) { |
|
272 | + if (\is_object($dispatcher)){ |
|
273 | 273 | $dispatcher = $dispatcher::class; |
274 | 274 | } |
275 | 275 | |
@@ -291,19 +291,19 @@ discard block |
||
291 | 291 | $eventDispatcher?->dispatch(new Serving()); |
292 | 292 | |
293 | 293 | $serving = $servingScope = null; |
294 | - foreach ($this->dispatchers as $dispatcher) { |
|
294 | + foreach ($this->dispatchers as $dispatcher){ |
|
295 | 295 | $reflection = new \ReflectionClass($dispatcher); |
296 | 296 | |
297 | 297 | $scope = ($reflection->getAttributes(DispatcherScope::class)[0] ?? null)?->newInstance()->scope; |
298 | 298 | $this->container->getBinder($scope)->bind($dispatcher, $dispatcher); |
299 | 299 | |
300 | - if ($serving === null && $this->canServe($reflection)) { |
|
300 | + if ($serving === null && $this->canServe($reflection)){ |
|
301 | 301 | $serving = $dispatcher; |
302 | 302 | $servingScope = $scope; |
303 | 303 | } |
304 | 304 | } |
305 | 305 | |
306 | - if ($serving === null) { |
|
306 | + if ($serving === null){ |
|
307 | 307 | $eventDispatcher?->dispatch(new DispatcherNotFound()); |
308 | 308 | throw new BootException('Unable to locate active dispatcher.'); |
309 | 309 | } |
@@ -352,13 +352,13 @@ discard block |
||
352 | 352 | */ |
353 | 353 | protected function fireCallbacks(array &$callbacks): void |
354 | 354 | { |
355 | - if ($callbacks === []) { |
|
355 | + if ($callbacks === []){ |
|
356 | 356 | return; |
357 | 357 | } |
358 | 358 | |
359 | - do { |
|
359 | + do{ |
|
360 | 360 | $this->container->invoke(\current($callbacks)); |
361 | - } while (\next($callbacks)); |
|
361 | + }while (\next($callbacks)); |
|
362 | 362 | |
363 | 363 | $callbacks = []; |
364 | 364 | } |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | */ |
399 | 399 | private function canServe(\ReflectionClass $reflection): bool |
400 | 400 | { |
401 | - if (!$reflection->hasMethod('canServe')) { |
|
401 | + if (!$reflection->hasMethod('canServe')){ |
|
402 | 402 | throw new BootException('Dispatcher must implement static `canServe` method.'); |
403 | 403 | } |
404 | 404 |
@@ -13,7 +13,7 @@ |
||
13 | 13 | final class ScopeTest extends TestCase |
14 | 14 | { |
15 | 15 | #[DataProvider('scopeNameDataProvider')] |
16 | - public function testScope(string|\BackedEnum $name, string $expected): void |
|
16 | + public function testScope(string | \BackedEnum $name, string $expected): void |
|
17 | 17 | { |
18 | 18 | $scope = new Scope($name); |
19 | 19 |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | $root = new Container(); |
35 | 35 | $root->bind('foo', SampleClass::class); |
36 | 36 | |
37 | - $root->runScoped(function (ContainerInterface $c1) { |
|
37 | + $root->runScoped(function (ContainerInterface $c1){ |
|
38 | 38 | $c1->get('foo'); |
39 | 39 | }, bindings: ['foo' => SampleClass::class]); |
40 | 40 | |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | |
322 | 322 | $root->runScope( |
323 | 323 | new Scope('foo'), |
324 | - function (ContainerInterface $c) { |
|
324 | + function (ContainerInterface $c){ |
|
325 | 325 | self::assertTrue($c->get('isFoo')); |
326 | 326 | $c->get('foo'); |
327 | 327 | } |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | $root = new Container(); |
335 | 335 | $root->getBinder($scope)->bindSingleton('foo', SampleClass::class); |
336 | 336 | |
337 | - $root->runScope(new Scope($scope), function (Container $container) { |
|
337 | + $root->runScope(new Scope($scope), function (Container $container){ |
|
338 | 338 | $this->assertTrue($container->has('foo')); |
339 | 339 | $this->assertInstanceOf(SampleClass::class, $container->get('foo')); |
340 | 340 | }); |
@@ -346,20 +346,20 @@ discard block |
||
346 | 346 | $root = new Container(); |
347 | 347 | $root->bindSingleton('sampleClass', SampleClass::class); |
348 | 348 | |
349 | - $root->runScope(new Scope('foo'), function (Container $container) { |
|
349 | + $root->runScope(new Scope('foo'), function (Container $container){ |
|
350 | 350 | $this->assertTrue($container->has('sampleClass')); |
351 | 351 | }); |
352 | 352 | |
353 | - $root->runScope(new Scope('foo'), function (Container $container) { |
|
354 | - $container->runScope(new Scope('bar'), function (Container $container) { |
|
353 | + $root->runScope(new Scope('foo'), function (Container $container){ |
|
354 | + $container->runScope(new Scope('bar'), function (Container $container){ |
|
355 | 355 | $this->assertTrue($container->has('sampleClass')); |
356 | 356 | }); |
357 | 357 | }); |
358 | 358 | |
359 | - $root->runScope(new Scope('foo'), function (Container $container) { |
|
359 | + $root->runScope(new Scope('foo'), function (Container $container){ |
|
360 | 360 | $container->bindSingleton('otherClass', SampleClass::class); |
361 | 361 | |
362 | - $container->runScope(new Scope('bar'), function (Container $container) { |
|
362 | + $container->runScope(new Scope('bar'), function (Container $container){ |
|
363 | 363 | $this->assertTrue($container->has('sampleClass')); |
364 | 364 | $this->assertTrue($container->has('otherClass')); |
365 | 365 | }); |
@@ -371,33 +371,33 @@ discard block |
||
371 | 371 | $root = new Container(); |
372 | 372 | $root->getBinder('foo')->bindSingleton('sampleClass', AttrScopeFoo::class); |
373 | 373 | |
374 | - $root->runScope(new Scope('foo'), function (Container $container) { |
|
374 | + $root->runScope(new Scope('foo'), function (Container $container){ |
|
375 | 375 | $this->assertTrue($container->has('sampleClass')); |
376 | 376 | }); |
377 | 377 | |
378 | - $root->runScope(new Scope('bar'), function (Container $container) { |
|
378 | + $root->runScope(new Scope('bar'), function (Container $container){ |
|
379 | 379 | $this->assertFalse($container->has('sampleClass')); |
380 | 380 | }); |
381 | 381 | |
382 | - $root->runScope(new Scope('foo'), function (Container $container) { |
|
383 | - $container->runScope(new Scope('bar'), function (Container $container) { |
|
382 | + $root->runScope(new Scope('foo'), function (Container $container){ |
|
383 | + $container->runScope(new Scope('bar'), function (Container $container){ |
|
384 | 384 | $this->assertTrue($container->has('sampleClass')); |
385 | 385 | }); |
386 | 386 | }); |
387 | 387 | |
388 | - $root->runScope(new Scope('foo'), function (Container $container) { |
|
388 | + $root->runScope(new Scope('foo'), function (Container $container){ |
|
389 | 389 | $container->bindSingleton('otherClass', AttrScopeFoo::class); |
390 | 390 | |
391 | - $container->runScope(new Scope('bar'), function (Container $container) { |
|
391 | + $container->runScope(new Scope('bar'), function (Container $container){ |
|
392 | 392 | $this->assertTrue($container->has('sampleClass')); |
393 | 393 | $this->assertTrue($container->has('otherClass')); |
394 | 394 | }); |
395 | 395 | }); |
396 | 396 | |
397 | - $root->runScope(new Scope('baz'), function (Container $container) { |
|
397 | + $root->runScope(new Scope('baz'), function (Container $container){ |
|
398 | 398 | $container->getBinder('foo')->bindSingleton('otherClass', AttrScopeFoo::class); |
399 | 399 | |
400 | - $container->runScope(new Scope('bar'), function (Container $container) { |
|
400 | + $container->runScope(new Scope('bar'), function (Container $container){ |
|
401 | 401 | $this->assertFalse($container->has('sampleClass')); |
402 | 402 | $this->assertFalse($container->has('otherClass')); |
403 | 403 | }); |
@@ -14,8 +14,8 @@ |
||
14 | 14 | { |
15 | 15 | public readonly string $name; |
16 | 16 | |
17 | - public function __construct(string|\BackedEnum $name) |
|
17 | + public function __construct(string | \BackedEnum $name) |
|
18 | 18 | { |
19 | - $this->name = \is_object($name) ? (string) $name->value : $name; |
|
19 | + $this->name = \is_object($name) ? (string)$name->value : $name; |
|
20 | 20 | } |
21 | 21 | } |
@@ -20,9 +20,9 @@ |
||
20 | 20 | * as the first argument. Otherwise, {@see InvokerInterface::invoke()} will be used to invoke the closure. |
21 | 21 | */ |
22 | 22 | public function __construct( |
23 | - public readonly string|\BackedEnum|null $name = null, |
|
23 | + public readonly string | \BackedEnum | null $name = null, |
|
24 | 24 | public readonly array $bindings = [], |
25 | 25 | public readonly bool $autowire = true, |
26 | - ) { |
|
26 | + ){ |
|
27 | 27 | } |
28 | 28 | } |
@@ -47,11 +47,11 @@ discard block |
||
47 | 47 | public const DEFAULT_ROOT_SCOPE_NAME = 'root'; |
48 | 48 | |
49 | 49 | private Internal\State $state; |
50 | - private ResolverInterface|Internal\Resolver $resolver; |
|
51 | - private FactoryInterface|Internal\Factory $factory; |
|
52 | - private ContainerInterface|Internal\Container $container; |
|
53 | - private BinderInterface|Internal\Binder $binder; |
|
54 | - private InvokerInterface|Internal\Invoker $invoker; |
|
50 | + private ResolverInterface | Internal\Resolver $resolver; |
|
51 | + private FactoryInterface | Internal\Factory $factory; |
|
52 | + private ContainerInterface | Internal\Container $container; |
|
53 | + private BinderInterface | Internal\Binder $binder; |
|
54 | + private InvokerInterface | Internal\Invoker $invoker; |
|
55 | 55 | private Internal\Scope $scope; |
56 | 56 | |
57 | 57 | /** |
@@ -59,11 +59,11 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function __construct( |
61 | 61 | private Config $config = new Config(), |
62 | - string|\BackedEnum|null $scopeName = self::DEFAULT_ROOT_SCOPE_NAME, |
|
62 | + string | \BackedEnum | null $scopeName = self::DEFAULT_ROOT_SCOPE_NAME, |
|
63 | 63 | private Options $options = new Options(), |
64 | - ) { |
|
65 | - if (\is_object($scopeName)) { |
|
66 | - $scopeName = (string) $scopeName->value; |
|
64 | + ){ |
|
65 | + if (\is_object($scopeName)){ |
|
66 | + $scopeName = (string)$scopeName->value; |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | $this->initServices($this, $scopeName); |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * @throws \Throwable |
118 | 118 | * @psalm-suppress TooManyArguments |
119 | 119 | */ |
120 | - public function make(string $alias, array $parameters = [], \Stringable|string|null $context = null): mixed |
|
120 | + public function make(string $alias, array $parameters = [], \Stringable | string | null $context = null): mixed |
|
121 | 121 | { |
122 | 122 | return ContainerScope::getContainer() === $this |
123 | 123 | ? $this->factory->make($alias, $parameters, $context) |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * @throws \Throwable |
144 | 144 | * @psalm-suppress TooManyArguments |
145 | 145 | */ |
146 | - public function get(string|Autowire $id, \Stringable|string|null $context = null): mixed |
|
146 | + public function get(string | Autowire $id, \Stringable | string | null $context = null): mixed |
|
147 | 147 | { |
148 | 148 | return ContainerScope::getContainer() === $this |
149 | 149 | ? $this->container->get($id, $context) |
@@ -163,9 +163,9 @@ discard block |
||
163 | 163 | * If {@see string}, the default binder for the given scope will be returned. Default bindings won't affect |
164 | 164 | * already created Container instances except the case with the root one. |
165 | 165 | */ |
166 | - public function getBinder(string|\BackedEnum|null $scope = null): BinderInterface |
|
166 | + public function getBinder(string | \BackedEnum | null $scope = null): BinderInterface |
|
167 | 167 | { |
168 | - $scope = \is_object($scope) ? (string) $scope->value : $scope; |
|
168 | + $scope = \is_object($scope) ? (string)$scope->value : $scope; |
|
169 | 169 | |
170 | 170 | return $scope === null |
171 | 171 | ? $this->binder |
@@ -175,25 +175,25 @@ discard block |
||
175 | 175 | /** |
176 | 176 | * @throws \Throwable |
177 | 177 | */ |
178 | - public function runScope(Scope|array $bindings, callable $scope): mixed |
|
178 | + public function runScope(Scope | array $bindings, callable $scope): mixed |
|
179 | 179 | { |
180 | - if (!\is_array($bindings)) { |
|
180 | + if (!\is_array($bindings)){ |
|
181 | 181 | return $this->runIsolatedScope($bindings, $scope); |
182 | 182 | } |
183 | 183 | |
184 | 184 | $binds = &$this->state->bindings; |
185 | 185 | $singletons = &$this->state->singletons; |
186 | 186 | $cleanup = $previous = $prevSin = []; |
187 | - foreach ($bindings as $alias => $resolver) { |
|
187 | + foreach ($bindings as $alias => $resolver){ |
|
188 | 188 | // Store previous bindings |
189 | - if (isset($binds[$alias])) { |
|
189 | + if (isset($binds[$alias])){ |
|
190 | 190 | $previous[$alias] = $binds[$alias]; |
191 | - } else { |
|
191 | + }else{ |
|
192 | 192 | // Store bindings to be removed |
193 | 193 | $cleanup[] = $alias; |
194 | 194 | } |
195 | 195 | // Store previous singletons |
196 | - if (isset($singletons[$alias])) { |
|
196 | + if (isset($singletons[$alias])){ |
|
197 | 197 | $prevSin[$alias] = $singletons[$alias]; |
198 | 198 | unset($singletons[$alias]); |
199 | 199 | } |
@@ -201,21 +201,21 @@ discard block |
||
201 | 201 | $this->binder->bind($alias, $resolver); |
202 | 202 | } |
203 | 203 | |
204 | - try { |
|
204 | + try{ |
|
205 | 205 | return ContainerScope::getContainer() !== $this |
206 | 206 | ? ContainerScope::runScope($this, $scope) |
207 | 207 | : $scope($this); |
208 | - } finally { |
|
208 | + }finally{ |
|
209 | 209 | // Remove new bindings |
210 | - foreach ($cleanup as $alias) { |
|
210 | + foreach ($cleanup as $alias){ |
|
211 | 211 | unset($binds[$alias], $singletons[$alias]); |
212 | 212 | } |
213 | 213 | // Restore previous bindings |
214 | - foreach ($previous as $alias => $resolver) { |
|
214 | + foreach ($previous as $alias => $resolver){ |
|
215 | 215 | $binds[$alias] = $resolver; |
216 | 216 | } |
217 | 217 | // Restore singletons |
218 | - foreach ($prevSin as $alias => $instance) { |
|
218 | + foreach ($prevSin as $alias => $instance){ |
|
219 | 219 | $singletons[$alias] = $instance; |
220 | 220 | } |
221 | 221 | } |
@@ -261,9 +261,9 @@ discard block |
||
261 | 261 | * @param bool $force If the value is false, an exception will be thrown when attempting |
262 | 262 | * to bind an already constructed singleton. |
263 | 263 | */ |
264 | - public function bindSingleton(string $alias, string|array|callable|object $resolver, bool $force = true): void |
|
264 | + public function bindSingleton(string $alias, string | array | callable | object $resolver, bool $force = true): void |
|
265 | 265 | { |
266 | - if ($force) { |
|
266 | + if ($force){ |
|
267 | 267 | $this->binder->removeBinding($alias); |
268 | 268 | } |
269 | 269 | |
@@ -334,8 +334,8 @@ discard block |
||
334 | 334 | ], $this->options); |
335 | 335 | |
336 | 336 | // Create container services |
337 | - foreach ($container->config as $property => $class) { |
|
338 | - if (\property_exists($container, $property)) { |
|
337 | + foreach ($container->config as $property => $class){ |
|
338 | + if (\property_exists($container, $property)){ |
|
339 | 339 | $container->$property = $constructor->get($property, $class); |
340 | 340 | } |
341 | 341 | } |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | private function closeScope(): void |
350 | 350 | { |
351 | 351 | /** @psalm-suppress RedundantPropertyInitializationCheck */ |
352 | - if (!isset($this->scope)) { |
|
352 | + if (!isset($this->scope)){ |
|
353 | 353 | $this->destruct(); |
354 | 354 | return; |
355 | 355 | } |
@@ -358,10 +358,10 @@ discard block |
||
358 | 358 | |
359 | 359 | // Run finalizers |
360 | 360 | $errors = []; |
361 | - foreach ($this->state->finalizers as $finalizer) { |
|
362 | - try { |
|
361 | + foreach ($this->state->finalizers as $finalizer){ |
|
362 | + try{ |
|
363 | 363 | $this->invoker->invoke($finalizer); |
364 | - } catch (\Throwable $e) { |
|
364 | + }catch (\Throwable $e){ |
|
365 | 365 | $errors[] = $e; |
366 | 366 | } |
367 | 367 | } |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | $this->destruct(); |
371 | 371 | |
372 | 372 | // Throw collected errors |
373 | - if ($errors !== []) { |
|
373 | + if ($errors !== []){ |
|
374 | 374 | throw new FinalizersException($scopeName, $errors); |
375 | 375 | } |
376 | 376 | } |
@@ -392,18 +392,18 @@ discard block |
||
392 | 392 | $container->scope->setParent($this, $this->scope, $this->factory); |
393 | 393 | |
394 | 394 | // Add specific bindings |
395 | - foreach ($config->bindings as $alias => $resolver) { |
|
395 | + foreach ($config->bindings as $alias => $resolver){ |
|
396 | 396 | $container->binder->bind($alias, $resolver); |
397 | 397 | } |
398 | 398 | |
399 | 399 | return ContainerScope::runScope( |
400 | 400 | $container, |
401 | 401 | static function (self $container) use ($config, $closure): mixed { |
402 | - try { |
|
402 | + try{ |
|
403 | 403 | return $config->autowire |
404 | 404 | ? $container->invoke($closure) |
405 | 405 | : $closure($container); |
406 | - } finally { |
|
406 | + }finally{ |
|
407 | 407 | $container->closeScope(); |
408 | 408 | } |
409 | 409 | } |
@@ -11,7 +11,7 @@ |
||
11 | 11 | final class DispatcherScope |
12 | 12 | { |
13 | 13 | public function __construct( |
14 | - public readonly string|\BackedEnum $scope |
|
15 | - ) { |
|
14 | + public readonly string | \BackedEnum $scope |
|
15 | + ){ |
|
16 | 16 | } |
17 | 17 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | private readonly FinalizerInterface $finalizer, |
30 | 30 | private readonly ContainerInterface $container, |
31 | 31 | private readonly ExceptionHandlerInterface $errorHandler, |
32 | - ) { |
|
32 | + ){ |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | public static function canServe(EnvironmentInterface $env): bool |
@@ -51,13 +51,13 @@ discard block |
||
51 | 51 | /** @var Console $console */ |
52 | 52 | $console = $this->container->get(Console::class); |
53 | 53 | |
54 | - try { |
|
54 | + try{ |
|
55 | 55 | return $console->start($input ?? new ArgvInput(), $output); |
56 | - } catch (Throwable $e) { |
|
56 | + }catch (Throwable $e){ |
|
57 | 57 | $this->handleException($e, $output); |
58 | 58 | |
59 | 59 | return 255; |
60 | - } finally { |
|
60 | + }finally{ |
|
61 | 61 | $listener->disable(); |
62 | 62 | $this->finalizer->finalize(false); |
63 | 63 | } |