Passed
Push — master ( 9f2c4f...e942df )
by Aleksei
17:57 queued 05:15
created
src/Core/src/Config/Shared.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,10 +12,10 @@
 block discarded – undo
12 12
     public function __construct(
13 13
         public readonly object $value,
14 14
         public readonly bool $singleton = false,
15
-    ) {}
15
+    ){}
16 16
 
17 17
     public function __toString(): string
18 18
     {
19
-        return 'Shared object of class ' . $this->value::class;
19
+        return 'Shared object of class '.$this->value::class;
20 20
     }
21 21
 }
Please login to merge, or discard this patch.
src/Core/src/Internal/Factory.php 1 patch
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -68,19 +68,19 @@  discard block
 block discarded – undo
68 68
      *
69 69
      * @throws \Throwable
70 70
      */
71
-    public function make(string $alias, array $parameters = [], Stringable|string|null $context = null): mixed
71
+    public function make(string $alias, array $parameters = [], Stringable | string | null $context = null): mixed
72 72
     {
73
-        if ($parameters === [] && \array_key_exists($alias, $this->state->singletons)) {
73
+        if ($parameters === [] && \array_key_exists($alias, $this->state->singletons)){
74 74
             return $this->state->singletons[$alias];
75 75
         }
76 76
 
77 77
         $binding = $this->state->bindings[$alias] ?? null;
78 78
 
79
-        if ($binding === null) {
79
+        if ($binding === null){
80 80
             return $this->resolveWithoutBinding($alias, $parameters, $context);
81 81
         }
82 82
 
83
-        try {
83
+        try{
84 84
             $this->tracer->push(
85 85
                 false,
86 86
                 action: 'resolve from binding',
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
                     ->resolveWeakReference($binding, $alias, $context, $parameters),
111 111
                 default => $binding,
112 112
             };
113
-        } finally {
113
+        }finally{
114 114
             $this->state->bindings[$alias] ??= $binding;
115 115
             $this->tracer->pop(true);
116 116
             $this->tracer->pop(false);
@@ -124,18 +124,18 @@  discard block
 block discarded – undo
124 124
     private function resolveInjector(Config\Injectable $binding, Ctx $ctx, array $arguments)
125 125
     {
126 126
         $context = $ctx->context;
127
-        try {
127
+        try{
128 128
             $reflection = $ctx->reflection ??= new \ReflectionClass($ctx->class);
129
-        } catch (\ReflectionException $e) {
129
+        }catch (\ReflectionException $e){
130 130
             throw new ContainerException($e->getMessage(), $e->getCode(), $e);
131 131
         }
132 132
 
133 133
         $injector = $binding->injector;
134 134
 
135
-        try {
135
+        try{
136 136
             $injectorInstance = \is_object($injector) ? $injector : $this->container->get($injector);
137 137
 
138
-            if (!$injectorInstance instanceof InjectorInterface) {
138
+            if (!$injectorInstance instanceof InjectorInterface){
139 139
                 throw new InjectionException(
140 140
                     \sprintf(
141 141
                         "Class '%s' must be an instance of InjectorInterface for '%s'.",
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
                 default => (string)$context,
163 163
             });
164 164
 
165
-            if (!$reflection->isInstance($instance)) {
165
+            if (!$reflection->isInstance($instance)){
166 166
                 throw new InjectionException(
167 167
                     \sprintf(
168 168
                         "Invalid injection response for '%s'.",
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
             }
173 173
 
174 174
             return $instance;
175
-        } finally {
175
+        }finally{
176 176
             $this->state->bindings[$ctx->class] ??= $binding;
177 177
         }
178 178
     }
@@ -180,27 +180,27 @@  discard block
 block discarded – undo
180 180
     private function resolveAlias(
181 181
         Config\Alias $binding,
182 182
         string $alias,
183
-        Stringable|string|null $context,
183
+        Stringable | string | null $context,
184 184
         array $arguments,
185 185
     ): mixed {
186 186
         $result = $binding->alias === $alias
187 187
             ? $this->autowire(
188
-                new Ctx(alias: $alias, class: $binding->alias, context: $context, singleton: $binding->singleton),
188
+                new Ctx(alias : $alias, class : $binding->alias, context : $context, singleton : $binding->singleton),
189 189
                 $arguments,
190 190
             )
191 191
             //Binding is pointing to something else
192 192
             : $this->make($binding->alias, $arguments, $context);
193 193
 
194
-        if ($binding->singleton && $arguments === []) {
194
+        if ($binding->singleton && $arguments === []){
195 195
             $this->state->singletons[$alias] = $result;
196 196
         }
197 197
 
198 198
         return $result;
199 199
     }
200 200
 
201
-    private function resolveProxy(Config\Proxy $binding, string $alias, Stringable|string|null $context): mixed
201
+    private function resolveProxy(Config\Proxy $binding, string $alias, Stringable | string | null $context): mixed
202 202
     {
203
-        if ($context instanceof RetryContext) {
203
+        if ($context instanceof RetryContext){
204 204
             return $binding->fallbackFactory === null
205 205
                 ? throw new RecursiveProxyException(
206 206
                     $alias,
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 
212 212
         $result = Proxy::create(new \ReflectionClass($binding->getInterface()), $context, new Attribute\Proxy());
213 213
 
214
-        if ($binding->singleton) {
214
+        if ($binding->singleton){
215 215
             $this->state->singletons[$alias] = $result;
216 216
         }
217 217
 
@@ -221,19 +221,19 @@  discard block
 block discarded – undo
221 221
     private function resolveShared(
222 222
         Config\Shared $binding,
223 223
         string $alias,
224
-        Stringable|string|null $context,
224
+        Stringable | string | null $context,
225 225
         array $arguments,
226 226
     ): object {
227 227
         $avoidCache = $arguments !== [];
228 228
 
229
-        if ($avoidCache) {
229
+        if ($avoidCache){
230 230
             return $this->createInstance(
231 231
                 new Ctx(alias: $alias, class: $binding->value::class, context: $context),
232 232
                 $arguments,
233 233
             );
234 234
         }
235 235
 
236
-        if ($binding->singleton) {
236
+        if ($binding->singleton){
237 237
             $this->state->singletons[$alias] = $binding->value;
238 238
         }
239 239
 
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
     private function resolveAutowire(
244 244
         Config\Autowire $binding,
245 245
         string $alias,
246
-        Stringable|string|null $context,
246
+        Stringable | string | null $context,
247 247
         array $arguments,
248 248
     ): mixed {
249 249
         $target = $binding->autowire->alias;
@@ -257,17 +257,17 @@  discard block
 block discarded – undo
257 257
     }
258 258
 
259 259
     private function resolveFactory(
260
-        Config\Factory|Config\DeferredFactory $binding,
260
+        Config\Factory | Config\DeferredFactory $binding,
261 261
         string $alias,
262
-        Stringable|string|null $context,
262
+        Stringable | string | null $context,
263 263
         array $arguments,
264 264
     ): mixed {
265 265
         $ctx = new Ctx(alias: $alias, class: $alias, context: $context, singleton: $binding->singleton);
266
-        try {
266
+        try{
267 267
             $instance = $binding::class === Config\Factory::class && $binding->getParametersCount() === 0
268 268
                 ? ($binding->factory)()
269 269
                 : $this->invoker->invoke($binding->factory, $arguments);
270
-        } catch (NotCallableException $e) {
270
+        }catch (NotCallableException $e){
271 271
             throw new ContainerException(
272 272
                 $this->tracer->combineTraceMessage(\sprintf('Invalid binding for `%s`.', $ctx->alias)),
273 273
                 $e->getCode(),
@@ -281,24 +281,24 @@  discard block
 block discarded – undo
281 281
     private function resolveWeakReference(
282 282
         Config\WeakReference $binding,
283 283
         string $alias,
284
-        Stringable|string|null $context,
284
+        Stringable | string | null $context,
285 285
         array $arguments,
286 286
     ): ?object {
287 287
         $avoidCache = $arguments !== [];
288 288
 
289
-        if (($avoidCache || $binding->reference->get() === null) && \class_exists($alias)) {
290
-            try {
289
+        if (($avoidCache || $binding->reference->get() === null) && \class_exists($alias)){
290
+            try{
291 291
                 $this->tracer->push(false, alias: $alias, source: WeakReference::class, context: $context);
292 292
 
293 293
                 $object = $this->createInstance(
294 294
                     new Ctx(alias: $alias, class: $alias, context: $context),
295 295
                     $arguments,
296 296
                 );
297
-                if ($avoidCache) {
297
+                if ($avoidCache){
298 298
                     return $object;
299 299
                 }
300 300
                 $binding->reference = WeakReference::create($object);
301
-            } catch (\Throwable) {
301
+            }catch (\Throwable){
302 302
                 throw new ContainerException(
303 303
                     $this->tracer->combineTraceMessage(
304 304
                         \sprintf(
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
                         )
309 309
                     )
310 310
                 );
311
-            } finally {
311
+            }finally{
312 312
                 $this->tracer->pop();
313 313
             }
314 314
         }
@@ -319,23 +319,23 @@  discard block
 block discarded – undo
319 319
     private function resolveWithoutBinding(
320 320
         string $alias,
321 321
         array $parameters = [],
322
-        Stringable|string|null $context = null
322
+        Stringable | string | null $context = null
323 323
     ): mixed {
324 324
         $parent = $this->scope->getParentFactory();
325 325
 
326
-        if ($parent !== null) {
327
-            try {
326
+        if ($parent !== null){
327
+            try{
328 328
                 $this->tracer->push(false, ...[
329 329
                     'current scope' => $this->scope->getScopeName(),
330 330
                     'jump to parent scope' => $this->scope->getParentScope()->getScopeName(),
331 331
                 ]);
332 332
                 /** @psalm-suppress TooManyArguments */
333 333
                 return $parent->make($alias, $parameters, $context);
334
-            } catch (BadScopeException $e) {
335
-                if ($this->scope->getScopeName() !== $e->getScope()) {
334
+            }catch (BadScopeException $e){
335
+                if ($this->scope->getScopeName() !== $e->getScope()){
336 336
                     throw $e;
337 337
                 }
338
-            } catch (ContainerExceptionInterface $e) {
338
+            }catch (ContainerExceptionInterface $e){
339 339
                 $className = match (true) {
340 340
                     $e instanceof NotFoundException => NotFoundException::class,
341 341
                     $e instanceof RecursiveProxyException => throw $e,
@@ -345,19 +345,19 @@  discard block
 block discarded – undo
345 345
                     'Can\'t resolve `%s`.',
346 346
                     $alias,
347 347
                 )), previous: $e);
348
-            } finally {
348
+            }finally{
349 349
                 $this->tracer->pop(false);
350 350
             }
351 351
         }
352 352
 
353 353
         $this->tracer->push(false, action: 'autowire', alias: $alias, context: $context);
354
-        try {
354
+        try{
355 355
             //No direct instructions how to construct class, make is automatically
356 356
             return $this->autowire(
357 357
                 new Ctx(alias: $alias, class: $alias, context: $context),
358 358
                 $parameters,
359 359
             );
360
-        } finally {
360
+        }finally{
361 361
             $this->tracer->pop(false);
362 362
         }
363 363
     }
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
                 &&
379 379
                 (isset($this->state->injectors[$ctx->class]) || $this->binder->hasInjector($ctx->class))
380 380
         ))
381
-        ) {
381
+        ){
382 382
             throw new NotFoundException($this->tracer->combineTraceMessage(\sprintf(
383 383
                 'Can\'t resolve `%s`: undefined class or binding `%s`.',
384 384
                 $this->tracer->getRootAlias(),
@@ -404,13 +404,13 @@  discard block
 block discarded – undo
404 404
         Ctx $ctx,
405 405
         array $arguments,
406 406
     ): object {
407
-        if ($this->options->checkScope) {
407
+        if ($this->options->checkScope){
408 408
             // Check scope name
409 409
             $ctx->reflection = new \ReflectionClass($instance);
410 410
             $scopeName = ($ctx->reflection->getAttributes(Attribute\Scope::class)[0] ?? null)?->newInstance()->name;
411
-            if ($scopeName !== null) {
411
+            if ($scopeName !== null){
412 412
                 $scope = $this->scope;
413
-                while ($scope->getScopeName() !== $scopeName) {
413
+                while ($scope->getScopeName() !== $scopeName){
414 414
                     $scope = $scope->getParentScope() ?? throw new BadScopeException($scopeName, $instance::class);
415 415
                 }
416 416
             }
@@ -439,26 +439,26 @@  discard block
 block discarded – undo
439 439
         array $arguments,
440 440
     ): object {
441 441
         $class = $ctx->class;
442
-        try {
442
+        try{
443 443
             $ctx->reflection = $reflection = new \ReflectionClass($class);
444
-        } catch (\ReflectionException $e) {
444
+        }catch (\ReflectionException $e){
445 445
             throw new ContainerException($e->getMessage(), $e->getCode(), $e);
446 446
         }
447 447
 
448 448
         // Check scope name
449
-        if ($this->options->checkScope) {
449
+        if ($this->options->checkScope){
450 450
             $scope = ($reflection->getAttributes(Attribute\Scope::class)[0] ?? null)?->newInstance()->name;
451
-            if ($scope !== null && $scope !== $this->scope->getScopeName()) {
451
+            if ($scope !== null && $scope !== $this->scope->getScopeName()){
452 452
                 throw new BadScopeException($scope, $class);
453 453
             }
454 454
         }
455 455
 
456 456
         // We have to construct class using external injector when we know the exact context
457
-        if ($arguments === [] && $this->binder->hasInjector($class)) {
457
+        if ($arguments === [] && $this->binder->hasInjector($class)){
458 458
             return $this->resolveInjector($this->state->bindings[$ctx->class], $ctx, $arguments);
459 459
         }
460 460
 
461
-        if (!$reflection->isInstantiable()) {
461
+        if (!$reflection->isInstantiable()){
462 462
             $itIs = match (true) {
463 463
                 $reflection->isEnum() => 'Enum',
464 464
                 $reflection->isAbstract() => 'Abstract class',
@@ -471,12 +471,12 @@  discard block
 block discarded – undo
471 471
 
472 472
         $constructor = $reflection->getConstructor();
473 473
 
474
-        if ($constructor !== null) {
475
-            try {
474
+        if ($constructor !== null){
475
+            try{
476 476
                 $this->tracer->push(false, action: 'resolve arguments', signature: $constructor);
477 477
                 $this->tracer->push(true);
478 478
                 $args = $this->resolver->resolveArguments($constructor, $arguments, $this->options->validateArguments);
479
-            } catch (ValidationException $e) {
479
+            }catch (ValidationException $e){
480 480
                 throw new ContainerException(
481 481
                     $this->tracer->combineTraceMessage(
482 482
                         \sprintf(
@@ -486,22 +486,22 @@  discard block
 block discarded – undo
486 486
                         )
487 487
                     ),
488 488
                 );
489
-            } finally {
489
+            }finally{
490 490
                 $this->tracer->pop(true);
491 491
                 $this->tracer->pop(false);
492 492
             }
493
-            try {
493
+            try{
494 494
                 // Using constructor with resolved arguments
495 495
                 $this->tracer->push(false, call: "$class::__construct", arguments: $args);
496 496
                 $this->tracer->push(true);
497 497
                 $instance = new $class(...$args);
498
-            } catch (\TypeError $e) {
498
+            }catch (\TypeError $e){
499 499
                 throw new WrongTypeException($constructor, $e);
500
-            } finally {
500
+            }finally{
501 501
                 $this->tracer->pop(true);
502 502
                 $this->tracer->pop(false);
503 503
             }
504
-        } else {
504
+        }else{
505 505
             // No constructor specified
506 506
             $instance = $reflection->newInstance();
507 507
         }
@@ -519,13 +519,13 @@  discard block
 block discarded – undo
519 519
         $instance = $this->runInflector($instance);
520 520
 
521 521
         //Declarative singletons
522
-        if ($this->isSingleton($ctx)) {
522
+        if ($this->isSingleton($ctx)){
523 523
             $this->state->singletons[$ctx->alias] = $instance;
524 524
         }
525 525
 
526 526
         // Register finalizer
527 527
         $finalizer = $this->getFinalizer($ctx, $instance);
528
-        if ($finalizer !== null) {
528
+        if ($finalizer !== null){
529 529
             $this->state->finalizers[] = $finalizer;
530 530
         }
531 531
 
@@ -537,12 +537,12 @@  discard block
 block discarded – undo
537 537
      */
538 538
     private function isSingleton(Ctx $ctx): bool
539 539
     {
540
-        if ($ctx->singleton === true) {
540
+        if ($ctx->singleton === true){
541 541
             return true;
542 542
         }
543 543
 
544 544
         /** @psalm-suppress RedundantCondition https://github.com/vimeo/psalm/issues/9489 */
545
-        if ($ctx->reflection->implementsInterface(SingletonInterface::class)) {
545
+        if ($ctx->reflection->implementsInterface(SingletonInterface::class)){
546 546
             return true;
547 547
         }
548 548
 
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
          * @var Attribute\Finalize|null $attribute
557 557
          */
558 558
         $attribute = ($ctx->reflection->getAttributes(Attribute\Finalize::class)[0] ?? null)?->newInstance();
559
-        if ($attribute === null) {
559
+        if ($attribute === null){
560 560
             return null;
561 561
         }
562 562
 
@@ -570,10 +570,10 @@  discard block
 block discarded – undo
570 570
     {
571 571
         $scope = $this->scope;
572 572
 
573
-        while ($scope !== null) {
574
-            foreach ($this->state->inflectors as $class => $inflectors) {
575
-                if ($instance instanceof $class) {
576
-                    foreach ($inflectors as $inflector) {
573
+        while ($scope !== null){
574
+            foreach ($this->state->inflectors as $class => $inflectors){
575
+                if ($instance instanceof $class){
576
+                    foreach ($inflectors as $inflector){
577 577
                         $instance = $inflector->getParametersCount() > 1
578 578
                             ? $this->invoker->invoke($inflector->inflector, [$instance])
579 579
                             : ($inflector->inflector)($instance);
@@ -589,9 +589,9 @@  discard block
 block discarded – undo
589 589
 
590 590
     private function validateArguments(ContextFunction $reflection, array $arguments = []): bool
591 591
     {
592
-        try {
592
+        try{
593 593
             $this->resolver->validateArguments($reflection, $arguments);
594
-        } catch (\Throwable) {
594
+        }catch (\Throwable){
595 595
             return false;
596 596
         }
597 597
 
Please login to merge, or discard this patch.
src/Core/src/Container.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -48,11 +48,11 @@  discard block
 block discarded – undo
48 48
     public const DEFAULT_ROOT_SCOPE_NAME = 'root';
49 49
 
50 50
     private Internal\State $state;
51
-    private ResolverInterface|Internal\Resolver $resolver;
52
-    private FactoryInterface|Internal\Factory $factory;
53
-    private ContainerInterface|Internal\Container $container;
54
-    private BinderInterface|Internal\Binder $binder;
55
-    private InvokerInterface|Internal\Invoker $invoker;
51
+    private ResolverInterface | Internal\Resolver $resolver;
52
+    private FactoryInterface | Internal\Factory $factory;
53
+    private ContainerInterface | Internal\Container $container;
54
+    private BinderInterface | Internal\Binder $binder;
55
+    private InvokerInterface | Internal\Invoker $invoker;
56 56
     private Internal\Scope $scope;
57 57
 
58 58
     /**
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
60 60
      */
61 61
     public function __construct(
62 62
         private Config $config = new Config(),
63
-        string|\BackedEnum|null $scopeName = self::DEFAULT_ROOT_SCOPE_NAME,
63
+        string | \BackedEnum | null $scopeName = self::DEFAULT_ROOT_SCOPE_NAME,
64 64
         private Options $options = new Options(),
65
-    ) {
66
-        if (\is_object($scopeName)) {
67
-            $scopeName = (string) $scopeName->value;
65
+    ){
66
+        if (\is_object($scopeName)){
67
+            $scopeName = (string)$scopeName->value;
68 68
         }
69 69
 
70 70
         $this->initServices($this, $scopeName);
@@ -118,11 +118,11 @@  discard block
 block discarded – undo
118 118
      * @throws \Throwable
119 119
      * @psalm-suppress TooManyArguments
120 120
      */
121
-    public function make(string $alias, array $parameters = [], \Stringable|string|null $context = null): mixed
121
+    public function make(string $alias, array $parameters = [], \Stringable | string | null $context = null): mixed
122 122
     {
123 123
         return ContainerScope::getContainer() === $this
124 124
             ? $this->factory->make($alias, $parameters, $context)
125
-            : ContainerScope::runScope($this, fn (): mixed => $this->factory->make($alias, $parameters, $context));
125
+            : ContainerScope::runScope($this, fn () : mixed => $this->factory->make($alias, $parameters, $context));
126 126
     }
127 127
 
128 128
     /**
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
      * @throws \Throwable
145 145
      * @psalm-suppress TooManyArguments
146 146
      */
147
-    public function get(string|Autowire $id, \Stringable|string|null $context = null): mixed
147
+    public function get(string | Autowire $id, \Stringable | string | null $context = null): mixed
148 148
     {
149 149
         return ContainerScope::getContainer() === $this
150 150
             ? $this->container->get($id, $context)
@@ -164,9 +164,9 @@  discard block
 block discarded – undo
164 164
      *        If {@see string}, the default binder for the given scope will be returned. Default bindings won't affect
165 165
      *        already created Container instances except the case with the root one.
166 166
      */
167
-    public function getBinder(string|\BackedEnum|null $scope = null): BinderInterface
167
+    public function getBinder(string | \BackedEnum | null $scope = null): BinderInterface
168 168
     {
169
-        $scope = \is_object($scope) ? (string) $scope->value : $scope;
169
+        $scope = \is_object($scope) ? (string)$scope->value : $scope;
170 170
 
171 171
         return $scope === null
172 172
             ? $this->binder
@@ -176,25 +176,25 @@  discard block
 block discarded – undo
176 176
     /**
177 177
      * @throws \Throwable
178 178
      */
179
-    public function runScope(Scope|array $bindings, callable $scope): mixed
179
+    public function runScope(Scope | array $bindings, callable $scope): mixed
180 180
     {
181
-        if (!\is_array($bindings)) {
181
+        if (!\is_array($bindings)){
182 182
             return $this->runIsolatedScope($bindings, $scope);
183 183
         }
184 184
 
185 185
         $binds = &$this->state->bindings;
186 186
         $singletons = &$this->state->singletons;
187 187
         $cleanup = $previous = $prevSin = [];
188
-        foreach ($bindings as $alias => $resolver) {
188
+        foreach ($bindings as $alias => $resolver){
189 189
             // Store previous bindings
190
-            if (isset($binds[$alias])) {
190
+            if (isset($binds[$alias])){
191 191
                 $previous[$alias] = $binds[$alias];
192
-            } else {
192
+            }else{
193 193
                 // Store bindings to be removed
194 194
                 $cleanup[] = $alias;
195 195
             }
196 196
             // Store previous singletons
197
-            if (isset($singletons[$alias])) {
197
+            if (isset($singletons[$alias])){
198 198
                 $prevSin[$alias] = $singletons[$alias];
199 199
                 unset($singletons[$alias]);
200 200
             }
@@ -202,21 +202,21 @@  discard block
 block discarded – undo
202 202
             $this->binder->bind($alias, $resolver);
203 203
         }
204 204
 
205
-        try {
205
+        try{
206 206
             return ContainerScope::getContainer() !== $this
207 207
                 ? ContainerScope::runScope($this, $scope)
208 208
                 : $scope($this);
209
-        } finally {
209
+        }finally{
210 210
             // Remove new bindings
211
-            foreach ($cleanup as $alias) {
211
+            foreach ($cleanup as $alias){
212 212
                 unset($binds[$alias], $singletons[$alias]);
213 213
             }
214 214
             // Restore previous bindings
215
-            foreach ($previous as $alias => $resolver) {
215
+            foreach ($previous as $alias => $resolver){
216 216
                 $binds[$alias] = $resolver;
217 217
             }
218 218
             // Restore singletons
219
-            foreach ($prevSin as $alias => $instance) {
219
+            foreach ($prevSin as $alias => $instance){
220 220
                 $singletons[$alias] = $instance;
221 221
             }
222 222
         }
@@ -264,9 +264,9 @@  discard block
 block discarded – undo
264 264
      *        If the value is null, option {@see Options::$allowSingletonsRebinding} will be used.
265 265
      * @throws SingletonOverloadException
266 266
      */
267
-    public function bindSingleton(string $alias, string|array|callable|object $resolver, ?bool $force = null): void
267
+    public function bindSingleton(string $alias, string | array | callable | object $resolver, ?bool $force = null): void
268 268
     {
269
-        if ($force ?? $this->options->allowSingletonsRebinding) {
269
+        if ($force ?? $this->options->allowSingletonsRebinding){
270 270
             $this->binder->removeBinding($alias);
271 271
         }
272 272
 
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
     {
294 294
         return ContainerScope::getContainer() === $this
295 295
             ? $this->invoker->invoke($target, $parameters)
296
-            : ContainerScope::runScope($this, fn (): mixed => $this->invoker->invoke($target, $parameters));
296
+            : ContainerScope::runScope($this, fn () : mixed => $this->invoker->invoke($target, $parameters));
297 297
     }
298 298
 
299 299
     /**
@@ -337,8 +337,8 @@  discard block
 block discarded – undo
337 337
         ], $this->options);
338 338
 
339 339
         // Create container services
340
-        foreach ($container->config as $property => $class) {
341
-            if (\property_exists($container, $property)) {
340
+        foreach ($container->config as $property => $class){
341
+            if (\property_exists($container, $property)){
342 342
                 $container->$property = $constructor->get($property, $class);
343 343
             }
344 344
         }
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
     private function closeScope(): void
353 353
     {
354 354
         /** @psalm-suppress RedundantPropertyInitializationCheck */
355
-        if (!isset($this->scope)) {
355
+        if (!isset($this->scope)){
356 356
             $this->destruct();
357 357
             return;
358 358
         }
@@ -361,10 +361,10 @@  discard block
 block discarded – undo
361 361
 
362 362
         // Run finalizers
363 363
         $errors = [];
364
-        foreach ($this->state->finalizers as $finalizer) {
365
-            try {
364
+        foreach ($this->state->finalizers as $finalizer){
365
+            try{
366 366
                 $this->invoker->invoke($finalizer);
367
-            } catch (\Throwable $e) {
367
+            }catch (\Throwable $e){
368 368
                 $errors[] = $e;
369 369
             }
370 370
         }
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
         $this->destruct();
374 374
 
375 375
         // Throw collected errors
376
-        if ($errors !== []) {
376
+        if ($errors !== []){
377 377
             throw new FinalizersException($scopeName, $errors);
378 378
         }
379 379
     }
@@ -395,18 +395,18 @@  discard block
 block discarded – undo
395 395
         $container->scope->setParent($this, $this->scope, $this->factory);
396 396
 
397 397
         // Add specific bindings
398
-        foreach ($config->bindings as $alias => $resolver) {
398
+        foreach ($config->bindings as $alias => $resolver){
399 399
             $container->binder->bind($alias, $resolver);
400 400
         }
401 401
 
402 402
         return ContainerScope::runScope(
403 403
             $container,
404 404
             static function (self $container) use ($config, $closure): mixed {
405
-                try {
405
+                try{
406 406
                     return $config->autowire
407 407
                         ? $container->invoke($closure)
408 408
                         : $closure($container);
409
-                } finally {
409
+                }finally{
410 410
                     $container->closeScope();
411 411
                 }
412 412
             }
Please login to merge, or discard this patch.