Test Failed
Pull Request — master (#1082)
by Maxim
11:40
created
src/Core/tests/Internal/Common/RegistryTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
         $option->checkScope = true;
32 32
         yield [$option];
33 33
 
34
-        $option = new class extends Options {
34
+        $option = new class extends Options{
35 35
             public int $customOption = 3;
36 36
         };
37 37
         $option->customOption = 5;
Please login to merge, or discard this patch.
src/Core/tests/Scope/ScopeAttributeTest.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
     {
41 41
         $root = self::makeContainer();
42 42
 
43
-        $root->runScoped(static function (Container $c1) {
43
+        $root->runScoped(static function (Container $c1){
44 44
             $c1->runScoped(static function (Container $c2) use ($c1) {
45 45
                 $obj1 = $c1->get(AttrScopeFooSingleton::class);
46 46
                 $obj2 = $c2->get(AttrScopeFooSingleton::class);
@@ -55,8 +55,8 @@  discard block
 block discarded – undo
55 55
         $root = self::makeContainer();
56 56
         $root->getBinder('bar')->bindSingleton('binding', static fn () => new AttrScopeFoo());
57 57
 
58
-        $root->runScoped(static function (Container $fooScope) {
59
-            $fooScope->runScoped(static function (Container $container) {
58
+        $root->runScoped(static function (Container $fooScope){
59
+            $fooScope->runScoped(static function (Container $container){
60 60
                 self::assertInstanceOf(AttrScopeFoo::class, $container->get('binding'));
61 61
             }, name: 'bar');
62 62
         }, name: 'foo');
@@ -70,8 +70,8 @@  discard block
 block discarded – undo
70 70
         $root = self::makeContainer();
71 71
         $root->getBinder('bar')->bindSingleton('binding', static fn () => new AttrScopeFoo());
72 72
 
73
-        $root->runScoped(static function (Container $fooScope) {
74
-            $fooScope->runScoped(static function (Container $container) {
73
+        $root->runScoped(static function (Container $fooScope){
74
+            $fooScope->runScoped(static function (Container $container){
75 75
                 $container->get('binding');
76 76
             }, name: 'bar');
77 77
         }, name: 'baz');
@@ -82,8 +82,8 @@  discard block
 block discarded – undo
82 82
         $root = self::makeContainer(false);
83 83
         $root->getBinder('bar')->bindSingleton('binding', static fn () => new AttrScopeFoo());
84 84
 
85
-        $root->runScoped(static function (Container $fooScope) {
86
-            $fooScope->runScoped(static function (Container $container) {
85
+        $root->runScoped(static function (Container $fooScope){
86
+            $fooScope->runScoped(static function (Container $container){
87 87
                 self::assertInstanceOf(AttrScopeFoo::class, $container->get('binding'));
88 88
             }, name: 'bar');
89 89
         }, name: 'baz');
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
         $root = self::makeContainer();
103 103
         $root->bind('foo', self::makeFooScopeObject(...));
104 104
 
105
-        $root->runScoped(static function (Container $c1) {
106
-            $c1->runScoped(static function (Container $c2) {
105
+        $root->runScoped(static function (Container $c1){
106
+            $c1->runScoped(static function (Container $c2){
107 107
                 $c2->get('foo');
108 108
             }, name: 'foo');
109 109
         });
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
         $root = self::makeContainer(false);
116 116
         $root->bind('foo', self::makeFooScopeObject(...));
117 117
 
118
-        $root->runScoped(static function (Container $c1) {
119
-            $c1->runScoped(static function (Container $c2) {
118
+        $root->runScoped(static function (Container $c1){
119
+            $c1->runScoped(static function (Container $c2){
120 120
                 self::assertInstanceOf(AttrScopeFoo::class, $c2->get('foo'));
121 121
             }, name: 'foo');
122 122
         });
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
         $root = self::makeContainer();
135 135
         $root->bind('foo', self::makeFooScopeObject(...));
136 136
 
137
-        $root->runScoped(static function (Container $c1) {
138
-            $c1->runScoped(static function (Container $c2) {
137
+        $root->runScoped(static function (Container $c1){
138
+            $c1->runScoped(static function (Container $c2){
139 139
                 $c2->get('foo');
140 140
             });
141 141
         });
@@ -147,8 +147,8 @@  discard block
 block discarded – undo
147 147
         $root = self::makeContainer(false);
148 148
         $root->bind('foo', self::makeFooScopeObject(...));
149 149
 
150
-        $root->runScoped(static function (Container $c1) {
151
-            $c1->runScoped(static function (Container $c2) {
150
+        $root->runScoped(static function (Container $c1){
151
+            $c1->runScoped(static function (Container $c2){
152 152
                 self::assertInstanceOf(AttrScopeFoo::class, $c2->get('foo'));
153 153
             });
154 154
         });
@@ -166,15 +166,15 @@  discard block
 block discarded – undo
166 166
 
167 167
         $root = self::makeContainer();
168 168
 
169
-        try {
170
-            $root->runScoped(static function (Container $c1) {
171
-                $c1->runScoped(static function (Container $c2) {
172
-                    $c2->runScoped(static function (Container $c3) {
169
+        try{
170
+            $root->runScoped(static function (Container $c1){
171
+                $c1->runScoped(static function (Container $c2){
172
+                    $c2->runScoped(static function (Container $c3){
173 173
                         // do nothing
174 174
                     }, name: 'root');
175 175
                 });
176 176
             });
177
-        } catch (NamedScopeDuplicationException $e) {
177
+        }catch (NamedScopeDuplicationException $e){
178 178
             self::assertSame('root', $e->getScope());
179 179
             throw $e;
180 180
         }
@@ -189,14 +189,14 @@  discard block
 block discarded – undo
189 189
     {
190 190
         self::expectException(BadScopeException::class);
191 191
 
192
-        try {
192
+        try{
193 193
             $root = self::makeContainer();
194
-            $root->runScoped(static function (Container $c1) {
195
-                $c1->runScoped(static function (Container $c2) {
194
+            $root->runScoped(static function (Container $c1){
195
+                $c1->runScoped(static function (Container $c2){
196 196
                     $c2->get(AttrScopeFoo::class);
197 197
                 });
198 198
             }, name: 'bar');
199
-        } catch (BadScopeException $e) {
199
+        }catch (BadScopeException $e){
200 200
             self::assertSame('foo', $e->getScope());
201 201
             throw $e;
202 202
         }
Please login to merge, or discard this patch.
src/Core/src/Internal/Factory.php 1 patch
Spacing   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -66,19 +66,19 @@  discard block
 block discarded – undo
66 66
      *
67 67
      * @throws \Throwable
68 68
      */
69
-    public function make(string $alias, array $parameters = [], Stringable|string|null $context = null): mixed
69
+    public function make(string $alias, array $parameters = [], Stringable | string | null $context = null): mixed
70 70
     {
71
-        if ($parameters === [] && \array_key_exists($alias, $this->state->singletons)) {
71
+        if ($parameters === [] && \array_key_exists($alias, $this->state->singletons)){
72 72
             return $this->state->singletons[$alias];
73 73
         }
74 74
 
75 75
         $binding = $this->state->bindings[$alias] ?? null;
76 76
 
77
-        if ($binding === null) {
77
+        if ($binding === null){
78 78
             return $this->resolveWithoutBinding($alias, $parameters, $context);
79 79
         }
80 80
 
81
-        try {
81
+        try{
82 82
             $this->tracer->push(
83 83
                 false,
84 84
                 action: 'resolve from binding',
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
                     ->resolveWeakReference($binding, $alias, $context, $parameters),
109 109
                 default => $binding,
110 110
             };
111
-        } finally {
111
+        }finally{
112 112
             $this->state->bindings[$alias] ??= $binding;
113 113
             $this->tracer->pop(true);
114 114
             $this->tracer->pop(false);
@@ -122,18 +122,18 @@  discard block
 block discarded – undo
122 122
     private function resolveInjector(Config\Injectable $binding, Ctx $ctx, array $arguments)
123 123
     {
124 124
         $context = $ctx->context;
125
-        try {
125
+        try{
126 126
             $reflection = $ctx->reflection ??= new \ReflectionClass($ctx->class);
127
-        } catch (\ReflectionException $e) {
127
+        }catch (\ReflectionException $e){
128 128
             throw new ContainerException($e->getMessage(), $e->getCode(), $e);
129 129
         }
130 130
 
131 131
         $injector = $binding->injector;
132 132
 
133
-        try {
133
+        try{
134 134
             $injectorInstance = \is_object($injector) ? $injector : $this->container->get($injector);
135 135
 
136
-            if (!$injectorInstance instanceof InjectorInterface) {
136
+            if (!$injectorInstance instanceof InjectorInterface){
137 137
                 throw new InjectionException(
138 138
                     \sprintf(
139 139
                         "Class '%s' must be an instance of InjectorInterface for '%s'.",
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
                 default => (string)$context,
161 161
             });
162 162
 
163
-            if (!$reflection->isInstance($instance)) {
163
+            if (!$reflection->isInstance($instance)){
164 164
                 throw new InjectionException(
165 165
                     \sprintf(
166 166
                         "Invalid injection response for '%s'.",
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
             }
171 171
 
172 172
             return $instance;
173
-        } finally {
173
+        }finally{
174 174
             $this->state->bindings[$ctx->class] ??= $binding;
175 175
         }
176 176
     }
@@ -178,29 +178,29 @@  discard block
 block discarded – undo
178 178
     private function resolveAlias(
179 179
         Config\Alias $binding,
180 180
         string $alias,
181
-        Stringable|string|null $context,
181
+        Stringable | string | null $context,
182 182
         array $arguments,
183 183
     ): mixed {
184 184
         $result = $binding->alias === $alias
185 185
             ? $this->autowire(
186
-                new Ctx(alias: $alias, class: $binding->alias, context: $context, singleton: $binding->singleton),
186
+                new Ctx(alias : $alias, class : $binding->alias, context : $context, singleton : $binding->singleton),
187 187
                 $arguments,
188 188
             )
189 189
             //Binding is pointing to something else
190 190
             : $this->make($binding->alias, $arguments, $context);
191 191
 
192
-        if ($binding->singleton && $arguments === []) {
192
+        if ($binding->singleton && $arguments === []){
193 193
             $this->state->singletons[$alias] = $result;
194 194
         }
195 195
 
196 196
         return $result;
197 197
     }
198 198
 
199
-    private function resolveProxy(Config\Proxy $binding, string $alias, Stringable|string|null $context): mixed
199
+    private function resolveProxy(Config\Proxy $binding, string $alias, Stringable | string | null $context): mixed
200 200
     {
201 201
         $result = Proxy::create(new \ReflectionClass($binding->getInterface()), $context, new Attribute\Proxy());
202 202
 
203
-        if ($binding->singleton) {
203
+        if ($binding->singleton){
204 204
             $this->state->singletons[$alias] = $result;
205 205
         }
206 206
 
@@ -210,13 +210,13 @@  discard block
 block discarded – undo
210 210
     private function resolveShared(
211 211
         Config\Shared $binding,
212 212
         string $alias,
213
-        Stringable|string|null $context,
213
+        Stringable | string | null $context,
214 214
         array $arguments,
215 215
     ): object {
216 216
         $avoidCache = $arguments !== [];
217 217
         return $avoidCache
218 218
             ? $this->createInstance(
219
-                new Ctx(alias: $alias, class: $binding->value::class, context: $context),
219
+                new Ctx(alias : $alias, class : $binding->value::class, context : $context),
220 220
                 $arguments,
221 221
             )
222 222
             : $binding->value;
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
     private function resolveAutowire(
226 226
         Config\Autowire $binding,
227 227
         string $alias,
228
-        Stringable|string|null $context,
228
+        Stringable | string | null $context,
229 229
         array $arguments,
230 230
     ): mixed {
231 231
         $instance = $binding->autowire->resolve($this, $arguments);
@@ -235,17 +235,17 @@  discard block
 block discarded – undo
235 235
     }
236 236
 
237 237
     private function resolveFactory(
238
-        Config\Factory|Config\DeferredFactory $binding,
238
+        Config\Factory | Config\DeferredFactory $binding,
239 239
         string $alias,
240
-        Stringable|string|null $context,
240
+        Stringable | string | null $context,
241 241
         array $arguments,
242 242
     ): mixed {
243 243
         $ctx = new Ctx(alias: $alias, class: $alias, context: $context, singleton: $binding->singleton);
244
-        try {
244
+        try{
245 245
             $instance = $binding::class === Config\Factory::class && $binding->getParametersCount() === 0
246 246
                 ? ($binding->factory)()
247 247
                 : $this->invoker->invoke($binding->factory, $arguments);
248
-        } catch (NotCallableException $e) {
248
+        }catch (NotCallableException $e){
249 249
             throw new ContainerException(
250 250
                 $this->tracer->combineTraceMessage(\sprintf('Invalid binding for `%s`.', $ctx->alias)),
251 251
                 $e->getCode(),
@@ -259,24 +259,24 @@  discard block
 block discarded – undo
259 259
     private function resolveWeakReference(
260 260
         Config\WeakReference $binding,
261 261
         string $alias,
262
-        Stringable|string|null $context,
262
+        Stringable | string | null $context,
263 263
         array $arguments,
264 264
     ): ?object {
265 265
         $avoidCache = $arguments !== [];
266 266
 
267
-        if (($avoidCache || $binding->reference->get() === null) && \class_exists($alias)) {
268
-            try {
267
+        if (($avoidCache || $binding->reference->get() === null) && \class_exists($alias)){
268
+            try{
269 269
                 $this->tracer->push(false, alias: $alias, source: WeakReference::class, context: $context);
270 270
 
271 271
                 $object = $this->createInstance(
272 272
                     new Ctx(alias: $alias, class: $alias, context: $context),
273 273
                     $arguments,
274 274
                 );
275
-                if ($avoidCache) {
275
+                if ($avoidCache){
276 276
                     return $object;
277 277
                 }
278 278
                 $binding->reference = WeakReference::create($object);
279
-            } catch (\Throwable) {
279
+            }catch (\Throwable){
280 280
                 throw new ContainerException(
281 281
                     $this->tracer->combineTraceMessage(
282 282
                         \sprintf(
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
                         )
287 287
                     )
288 288
                 );
289
-            } finally {
289
+            }finally{
290 290
                 $this->tracer->pop();
291 291
             }
292 292
         }
@@ -297,23 +297,23 @@  discard block
 block discarded – undo
297 297
     private function resolveWithoutBinding(
298 298
         string $alias,
299 299
         array $parameters = [],
300
-        Stringable|string|null $context = null
300
+        Stringable | string | null $context = null
301 301
     ): mixed {
302 302
         $parent = $this->scope->getParentFactory();
303 303
 
304
-        if ($parent !== null) {
305
-            try {
304
+        if ($parent !== null){
305
+            try{
306 306
                 $this->tracer->push(false, ...[
307 307
                     'current scope' => $this->scope->getScopeName(),
308 308
                     'jump to parent scope' => $this->scope->getParentScope()->getScopeName(),
309 309
                 ]);
310 310
                 /** @psalm-suppress TooManyArguments */
311 311
                 return $parent->make($alias, $parameters, $context);
312
-            } catch (BadScopeException $e) {
313
-                if ($this->scope->getScopeName() !== $e->getScope()) {
312
+            }catch (BadScopeException $e){
313
+                if ($this->scope->getScopeName() !== $e->getScope()){
314 314
                     throw $e;
315 315
                 }
316
-            } catch (ContainerExceptionInterface $e) {
316
+            }catch (ContainerExceptionInterface $e){
317 317
                 $className = match (true) {
318 318
                     $e instanceof NotFoundException => NotFoundException::class,
319 319
                     default => ContainerException::class,
@@ -322,19 +322,19 @@  discard block
 block discarded – undo
322 322
                     'Can\'t resolve `%s`.',
323 323
                     $alias,
324 324
                 )), previous: $e);
325
-            } finally {
325
+            }finally{
326 326
                 $this->tracer->pop(false);
327 327
             }
328 328
         }
329 329
 
330 330
         $this->tracer->push(false, action: 'autowire', alias: $alias, context: $context);
331
-        try {
331
+        try{
332 332
             //No direct instructions how to construct class, make is automatically
333 333
             return $this->autowire(
334 334
                 new Ctx(alias: $alias, class: $alias, context: $context),
335 335
                 $parameters,
336 336
             );
337
-        } finally {
337
+        }finally{
338 338
             $this->tracer->pop(false);
339 339
         }
340 340
     }
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
                 &&
356 356
                 (isset($this->state->injectors[$ctx->class]) || $this->binder->hasInjector($ctx->class))
357 357
         ))
358
-        ) {
358
+        ){
359 359
             throw new NotFoundException($this->tracer->combineTraceMessage(\sprintf(
360 360
                 'Can\'t resolve `%s`: undefined class or binding `%s`.',
361 361
                 $this->tracer->getRootAlias(),
@@ -384,9 +384,9 @@  discard block
 block discarded – undo
384 384
         // Check scope name
385 385
         $ctx->reflection = new \ReflectionClass($instance);
386 386
         $scopeName = ($ctx->reflection->getAttributes(Attribute\Scope::class)[0] ?? null)?->newInstance()->name;
387
-        if ($scopeName !== null && $this->options->checkScope) {
387
+        if ($scopeName !== null && $this->options->checkScope){
388 388
             $scope = $this->scope;
389
-            while ($scope->getScopeName() !== $scopeName) {
389
+            while ($scope->getScopeName() !== $scopeName){
390 390
                 $scope = $scope->getParentScope() ?? throw new BadScopeException($scopeName, $instance::class);
391 391
             }
392 392
         }
@@ -414,24 +414,24 @@  discard block
 block discarded – undo
414 414
         array $arguments,
415 415
     ): object {
416 416
         $class = $ctx->class;
417
-        try {
417
+        try{
418 418
             $ctx->reflection = $reflection = new \ReflectionClass($class);
419
-        } catch (\ReflectionException $e) {
419
+        }catch (\ReflectionException $e){
420 420
             throw new ContainerException($e->getMessage(), $e->getCode(), $e);
421 421
         }
422 422
 
423 423
         // Check scope name
424 424
         $scope = ($reflection->getAttributes(Attribute\Scope::class)[0] ?? null)?->newInstance()->name;
425
-        if ($this->options->checkScope && $scope !== null && $scope !== $this->scope->getScopeName()) {
425
+        if ($this->options->checkScope && $scope !== null && $scope !== $this->scope->getScopeName()){
426 426
             throw new BadScopeException($scope, $class);
427 427
         }
428 428
 
429 429
         // We have to construct class using external injector when we know the exact context
430
-        if ($arguments === [] && $this->binder->hasInjector($class)) {
430
+        if ($arguments === [] && $this->binder->hasInjector($class)){
431 431
             return $this->resolveInjector($this->state->bindings[$ctx->class], $ctx, $arguments);
432 432
         }
433 433
 
434
-        if (!$reflection->isInstantiable()) {
434
+        if (!$reflection->isInstantiable()){
435 435
             $itIs = match (true) {
436 436
                 $reflection->isEnum() => 'Enum',
437 437
                 $reflection->isAbstract() => 'Abstract class',
@@ -444,12 +444,12 @@  discard block
 block discarded – undo
444 444
 
445 445
         $constructor = $reflection->getConstructor();
446 446
 
447
-        if ($constructor !== null) {
448
-            try {
447
+        if ($constructor !== null){
448
+            try{
449 449
                 $this->tracer->push(false, action: 'resolve arguments', signature: $constructor);
450 450
                 $this->tracer->push(true);
451 451
                 $args = $this->resolver->resolveArguments($constructor, $arguments);
452
-            } catch (ValidationException $e) {
452
+            }catch (ValidationException $e){
453 453
                 throw new ContainerException(
454 454
                     $this->tracer->combineTraceMessage(
455 455
                         \sprintf(
@@ -459,22 +459,22 @@  discard block
 block discarded – undo
459 459
                         )
460 460
                     ),
461 461
                 );
462
-            } finally {
462
+            }finally{
463 463
                 $this->tracer->pop(true);
464 464
                 $this->tracer->pop(false);
465 465
             }
466
-            try {
466
+            try{
467 467
                 // Using constructor with resolved arguments
468 468
                 $this->tracer->push(false, call: "$class::__construct", arguments: $args);
469 469
                 $this->tracer->push(true);
470 470
                 $instance = new $class(...$args);
471
-            } catch (\TypeError $e) {
471
+            }catch (\TypeError $e){
472 472
                 throw new WrongTypeException($constructor, $e);
473
-            } finally {
473
+            }finally{
474 474
                 $this->tracer->pop(true);
475 475
                 $this->tracer->pop(false);
476 476
             }
477
-        } else {
477
+        }else{
478 478
             // No constructor specified
479 479
             $instance = $reflection->newInstance();
480 480
         }
@@ -492,13 +492,13 @@  discard block
 block discarded – undo
492 492
         $instance = $this->runInflector($instance);
493 493
 
494 494
         //Declarative singletons
495
-        if ($this->isSingleton($ctx)) {
495
+        if ($this->isSingleton($ctx)){
496 496
             $this->state->singletons[$ctx->alias] = $instance;
497 497
         }
498 498
 
499 499
         // Register finalizer
500 500
         $finalizer = $this->getFinalizer($ctx, $instance);
501
-        if ($finalizer !== null) {
501
+        if ($finalizer !== null){
502 502
             $this->state->finalizers[] = $finalizer;
503 503
         }
504 504
 
@@ -510,12 +510,12 @@  discard block
 block discarded – undo
510 510
      */
511 511
     private function isSingleton(Ctx $ctx): bool
512 512
     {
513
-        if ($ctx->singleton === true) {
513
+        if ($ctx->singleton === true){
514 514
             return true;
515 515
         }
516 516
 
517 517
         /** @psalm-suppress RedundantCondition https://github.com/vimeo/psalm/issues/9489 */
518
-        if ($ctx->reflection->implementsInterface(SingletonInterface::class)) {
518
+        if ($ctx->reflection->implementsInterface(SingletonInterface::class)){
519 519
             return true;
520 520
         }
521 521
 
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
          * @var Attribute\Finalize|null $attribute
530 530
          */
531 531
         $attribute = ($ctx->reflection->getAttributes(Attribute\Finalize::class)[0] ?? null)?->newInstance();
532
-        if ($attribute === null) {
532
+        if ($attribute === null){
533 533
             return null;
534 534
         }
535 535
 
@@ -543,10 +543,10 @@  discard block
 block discarded – undo
543 543
     {
544 544
         $scope = $this->scope;
545 545
 
546
-        while ($scope !== null) {
547
-            foreach ($this->state->inflectors as $class => $inflectors) {
548
-                if ($instance instanceof $class) {
549
-                    foreach ($inflectors as $inflector) {
546
+        while ($scope !== null){
547
+            foreach ($this->state->inflectors as $class => $inflectors){
548
+                if ($instance instanceof $class){
549
+                    foreach ($inflectors as $inflector){
550 550
                         $instance = $inflector->getParametersCount() > 1
551 551
                             ? $this->invoker->invoke($inflector->inflector, [$instance])
552 552
                             : ($inflector->inflector)($instance);
@@ -562,9 +562,9 @@  discard block
 block discarded – undo
562 562
 
563 563
     private function validateArguments(ContextFunction $reflection, array $arguments = []): bool
564 564
     {
565
-        try {
565
+        try{
566 566
             $this->resolver->validateArguments($reflection, $arguments);
567
-        } catch (\Throwable) {
567
+        }catch (\Throwable){
568 568
             return false;
569 569
         }
570 570
 
Please login to merge, or discard this patch.
src/Core/src/Internal/Common/Registry.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
         private Config $config,
20 20
         private array $objects = [],
21 21
         private Options $options = new Options(),
22
-    ) {
22
+    ){
23 23
     }
24 24
 
25 25
     public function set(string $name, object $value): void
Please login to merge, or discard this patch.
src/Core/src/Container.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -47,11 +47,11 @@  discard block
 block discarded – undo
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
     /**
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
         private Config $config = new Config(),
62 62
         ?string $scopeName = self::DEFAULT_ROOT_SCOPE_NAME,
63 63
         private Options $options = new Options(),
64
-    ) {
64
+    ){
65 65
         $this->initServices($this, $scopeName);
66 66
 
67 67
         /** @psalm-suppress RedundantPropertyInitializationCheck */
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
      * @throws \Throwable
114 114
      * @psalm-suppress TooManyArguments
115 115
      */
116
-    public function make(string $alias, array $parameters = [], \Stringable|string|null $context = null): mixed
116
+    public function make(string $alias, array $parameters = [], \Stringable | string | null $context = null): mixed
117 117
     {
118 118
         return ContainerScope::getContainer() === $this
119 119
             ? $this->factory->make($alias, $parameters, $context)
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
      * @throws \Throwable
140 140
      * @psalm-suppress TooManyArguments
141 141
      */
142
-    public function get(string|Autowire $id, \Stringable|string|null $context = null): mixed
142
+    public function get(string | Autowire $id, \Stringable | string | null $context = null): mixed
143 143
     {
144 144
         return ContainerScope::getContainer() === $this
145 145
             ? $this->container->get($id, $context)
@@ -169,25 +169,25 @@  discard block
 block discarded – undo
169 169
     /**
170 170
      * @throws \Throwable
171 171
      */
172
-    public function runScope(Scope|array $bindings, callable $scope): mixed
172
+    public function runScope(Scope | array $bindings, callable $scope): mixed
173 173
     {
174
-        if (!\is_array($bindings)) {
174
+        if (!\is_array($bindings)){
175 175
             return $this->runIsolatedScope($bindings, $scope);
176 176
         }
177 177
 
178 178
         $binds = &$this->state->bindings;
179 179
         $singletons = &$this->state->singletons;
180 180
         $cleanup = $previous = $prevSin = [];
181
-        foreach ($bindings as $alias => $resolver) {
181
+        foreach ($bindings as $alias => $resolver){
182 182
             // Store previous bindings
183
-            if (isset($binds[$alias])) {
183
+            if (isset($binds[$alias])){
184 184
                 $previous[$alias] = $binds[$alias];
185
-            } else {
185
+            }else{
186 186
                 // Store bindings to be removed
187 187
                 $cleanup[] = $alias;
188 188
             }
189 189
             // Store previous singletons
190
-            if (isset($singletons[$alias])) {
190
+            if (isset($singletons[$alias])){
191 191
                 $prevSin[$alias] = $singletons[$alias];
192 192
                 unset($singletons[$alias]);
193 193
             }
@@ -195,21 +195,21 @@  discard block
 block discarded – undo
195 195
             $this->binder->bind($alias, $resolver);
196 196
         }
197 197
 
198
-        try {
198
+        try{
199 199
             return ContainerScope::getContainer() !== $this
200 200
                 ? ContainerScope::runScope($this, $scope)
201 201
                 : $scope($this);
202
-        } finally {
202
+        }finally{
203 203
             // Remove new bindings
204
-            foreach ($cleanup as $alias) {
204
+            foreach ($cleanup as $alias){
205 205
                 unset($binds[$alias], $singletons[$alias]);
206 206
             }
207 207
             // Restore previous bindings
208
-            foreach ($previous as $alias => $resolver) {
208
+            foreach ($previous as $alias => $resolver){
209 209
                 $binds[$alias] = $resolver;
210 210
             }
211 211
             // Restore singletons
212
-            foreach ($prevSin as $alias => $instance) {
212
+            foreach ($prevSin as $alias => $instance){
213 213
                 $singletons[$alias] = $instance;
214 214
             }
215 215
         }
@@ -255,9 +255,9 @@  discard block
 block discarded – undo
255 255
      * @param bool $force If the value is false, an exception will be thrown when attempting
256 256
      *  to bind an already constructed singleton.
257 257
      */
258
-    public function bindSingleton(string $alias, string|array|callable|object $resolver, bool $force = true): void
258
+    public function bindSingleton(string $alias, string | array | callable | object $resolver, bool $force = true): void
259 259
     {
260
-        if ($force) {
260
+        if ($force){
261 261
             $this->binder->removeBinding($alias);
262 262
         }
263 263
 
@@ -328,8 +328,8 @@  discard block
 block discarded – undo
328 328
         ], $this->options);
329 329
 
330 330
         // Create container services
331
-        foreach ($container->config as $property => $class) {
332
-            if (\property_exists($container, $property)) {
331
+        foreach ($container->config as $property => $class){
332
+            if (\property_exists($container, $property)){
333 333
                 $container->$property = $constructor->get($property, $class);
334 334
             }
335 335
         }
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
     private function closeScope(): void
344 344
     {
345 345
         /** @psalm-suppress RedundantPropertyInitializationCheck */
346
-        if (!isset($this->scope)) {
346
+        if (!isset($this->scope)){
347 347
             $this->destruct();
348 348
             return;
349 349
         }
@@ -352,10 +352,10 @@  discard block
 block discarded – undo
352 352
 
353 353
         // Run finalizers
354 354
         $errors = [];
355
-        foreach ($this->state->finalizers as $finalizer) {
356
-            try {
355
+        foreach ($this->state->finalizers as $finalizer){
356
+            try{
357 357
                 $this->invoker->invoke($finalizer);
358
-            } catch (\Throwable $e) {
358
+            }catch (\Throwable $e){
359 359
                 $errors[] = $e;
360 360
             }
361 361
         }
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
         $this->destruct();
365 365
 
366 366
         // Throw collected errors
367
-        if ($errors !== []) {
367
+        if ($errors !== []){
368 368
             throw new FinalizersException($scopeName, $errors);
369 369
         }
370 370
     }
@@ -386,18 +386,18 @@  discard block
 block discarded – undo
386 386
         $container->scope->setParent($this, $this->scope, $this->factory);
387 387
 
388 388
         // Add specific bindings
389
-        foreach ($config->bindings as $alias => $resolver) {
389
+        foreach ($config->bindings as $alias => $resolver){
390 390
             $container->binder->bind($alias, $resolver);
391 391
         }
392 392
 
393 393
         return ContainerScope::runScope(
394 394
             $container,
395 395
             static function (self $container) use ($config, $closure): mixed {
396
-                try {
396
+                try{
397 397
                     return $config->autowire
398 398
                         ? $container->invoke($closure)
399 399
                         : $closure($container);
400
-                } finally {
400
+                }finally{
401 401
                     $container->closeScope();
402 402
                 }
403 403
             }
Please login to merge, or discard this patch.