Passed
Pull Request — master (#1196)
by Abdul Malik
11:01
created
src/Events/src/Bootloader/EventsBootloader.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 
49 49
     public function __construct(
50 50
         private readonly ConfiguratorInterface $configs
51
-    ) {
51
+    ){
52 52
     }
53 53
 
54 54
     public function init(): void
@@ -72,11 +72,11 @@  discard block
 block discarded – undo
72 72
         FinalizerInterface $finalizer,
73 73
         ?EventDispatcherInterface $eventDispatcher = null
74 74
     ): void {
75
-        if ($eventDispatcher instanceof \Psr\EventDispatcher\EventDispatcherInterface) {
75
+        if ($eventDispatcher instanceof \Psr\EventDispatcher\EventDispatcherInterface){
76 76
             $this->initEventDispatcher(new Core($eventDispatcher), $config, $container, $factory);
77 77
         }
78 78
 
79
-        foreach ($config->getProcessors() as $processor) {
79
+        foreach ($config->getProcessors() as $processor){
80 80
             $processor = $this->autowire($processor, $container, $factory);
81 81
 
82 82
             \assert($processor instanceof ProcessorInterface);
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
             $registry->process();
88 88
         });
89 89
 
90
-        if ($finalizer instanceof EventDispatcherAwareInterface && $eventDispatcher instanceof \Psr\EventDispatcher\EventDispatcherInterface) {
90
+        if ($finalizer instanceof EventDispatcherAwareInterface && $eventDispatcher instanceof \Psr\EventDispatcher\EventDispatcherInterface){
91 91
             $finalizer->setEventDispatcher($eventDispatcher);
92 92
         }
93 93
     }
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
      * @param TInterceptor $interceptor
97 97
      */
98 98
     public function addInterceptor(
99
-        string|InterceptorInterface|CoreInterceptorInterface|Container\Autowire $interceptor,
99
+        string | InterceptorInterface | CoreInterceptorInterface | Container\Autowire $interceptor,
100 100
     ): void {
101 101
         $this->configs->modify(EventsConfig::CONFIG, new Append('interceptors', null, $interceptor));
102 102
     }
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
     ): void {
110 110
         $builder = new CompatiblePipelineBuilder();
111 111
         $list = [];
112
-        foreach ($config->getInterceptors() as $interceptor) {
112
+        foreach ($config->getInterceptors() as $interceptor){
113 113
             $list[] = $this->autowire($interceptor, $container, $factory);
114 114
         }
115 115
 
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
      *
128 128
      * @throws ContainerExceptionInterface
129 129
      */
130
-    private function autowire(string|object $id, ContainerInterface $container, FactoryInterface $factory): object
130
+    private function autowire(string | object $id, ContainerInterface $container, FactoryInterface $factory): object
131 131
     {
132 132
         return match (true) {
133 133
             \is_string($id) => $container->get($id),
Please login to merge, or discard this patch.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -72,11 +72,13 @@  discard block
 block discarded – undo
72 72
         FinalizerInterface $finalizer,
73 73
         ?EventDispatcherInterface $eventDispatcher = null
74 74
     ): void {
75
-        if ($eventDispatcher instanceof \Psr\EventDispatcher\EventDispatcherInterface) {
75
+        if ($eventDispatcher instanceof \Psr\EventDispatcher\EventDispatcherInterface)
76
+        {
76 77
             $this->initEventDispatcher(new Core($eventDispatcher), $config, $container, $factory);
77 78
         }
78 79
 
79
-        foreach ($config->getProcessors() as $processor) {
80
+        foreach ($config->getProcessors() as $processor)
81
+        {
80 82
             $processor = $this->autowire($processor, $container, $factory);
81 83
 
82 84
             \assert($processor instanceof ProcessorInterface);
@@ -87,7 +89,8 @@  discard block
 block discarded – undo
87 89
             $registry->process();
88 90
         });
89 91
 
90
-        if ($finalizer instanceof EventDispatcherAwareInterface && $eventDispatcher instanceof \Psr\EventDispatcher\EventDispatcherInterface) {
92
+        if ($finalizer instanceof EventDispatcherAwareInterface && $eventDispatcher instanceof \Psr\EventDispatcher\EventDispatcherInterface)
93
+        {
91 94
             $finalizer->setEventDispatcher($eventDispatcher);
92 95
         }
93 96
     }
@@ -109,7 +112,8 @@  discard block
 block discarded – undo
109 112
     ): void {
110 113
         $builder = new CompatiblePipelineBuilder();
111 114
         $list = [];
112
-        foreach ($config->getInterceptors() as $interceptor) {
115
+        foreach ($config->getInterceptors() as $interceptor)
116
+        {
113 117
             $list[] = $this->autowire($interceptor, $container, $factory);
114 118
         }
115 119
 
Please login to merge, or discard this patch.
src/Core/src/Internal/Factory.php 2 patches
Spacing   +68 added lines, -68 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 instanceof \Closure
205 205
                 ? ($binding->fallbackFactory)($this->container, $context->context)
206 206
                 : throw new RecursiveProxyException(
@@ -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,13 +221,13 @@  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
         return $avoidCache
229 229
             ? $this->createInstance(
230
-                new Ctx(alias: $alias, class: $binding->value::class, context: $context),
230
+                new Ctx(alias : $alias, class : $binding->value::class, context : $context),
231 231
                 $arguments,
232 232
             )
233 233
             : $binding->value;
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
     private function resolveAutowire(
237 237
         Config\Autowire $binding,
238 238
         string $alias,
239
-        Stringable|string|null $context,
239
+        Stringable | string | null $context,
240 240
         array $arguments,
241 241
     ): mixed {
242 242
         $target = $binding->autowire->alias;
@@ -250,17 +250,17 @@  discard block
 block discarded – undo
250 250
     }
251 251
 
252 252
     private function resolveFactory(
253
-        Config\Factory|Config\DeferredFactory $binding,
253
+        Config\Factory | Config\DeferredFactory $binding,
254 254
         string $alias,
255
-        Stringable|string|null $context,
255
+        Stringable | string | null $context,
256 256
         array $arguments,
257 257
     ): mixed {
258 258
         $ctx = new Ctx(alias: $alias, class: $alias, context: $context, singleton: $binding->singleton);
259
-        try {
259
+        try{
260 260
             $instance = $binding::class === Config\Factory::class && $binding->getParametersCount() === 0
261 261
                 ? ($binding->factory)()
262 262
                 : $this->invoker->invoke($binding->factory, $arguments);
263
-        } catch (NotCallableException $e) {
263
+        }catch (NotCallableException $e){
264 264
             throw new ContainerException(
265 265
                 $this->tracer->combineTraceMessage(\sprintf('Invalid binding for `%s`.', $ctx->alias)),
266 266
                 $e->getCode(),
@@ -274,24 +274,24 @@  discard block
 block discarded – undo
274 274
     private function resolveWeakReference(
275 275
         Config\WeakReference $binding,
276 276
         string $alias,
277
-        Stringable|string|null $context,
277
+        Stringable | string | null $context,
278 278
         array $arguments,
279 279
     ): ?object {
280 280
         $avoidCache = $arguments !== [];
281 281
 
282
-        if (($avoidCache || $binding->reference->get() === null) && \class_exists($alias)) {
283
-            try {
282
+        if (($avoidCache || $binding->reference->get() === null) && \class_exists($alias)){
283
+            try{
284 284
                 $this->tracer->push(false, alias: $alias, source: WeakReference::class, context: $context);
285 285
 
286 286
                 $object = $this->createInstance(
287 287
                     new Ctx(alias: $alias, class: $alias, context: $context),
288 288
                     $arguments,
289 289
                 );
290
-                if ($avoidCache) {
290
+                if ($avoidCache){
291 291
                     return $object;
292 292
                 }
293 293
                 $binding->reference = WeakReference::create($object);
294
-            } catch (\Throwable) {
294
+            }catch (\Throwable){
295 295
                 throw new ContainerException(
296 296
                     $this->tracer->combineTraceMessage(
297 297
                         \sprintf(
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
                         )
302 302
                     )
303 303
                 );
304
-            } finally {
304
+            }finally{
305 305
                 $this->tracer->pop();
306 306
             }
307 307
         }
@@ -312,23 +312,23 @@  discard block
 block discarded – undo
312 312
     private function resolveWithoutBinding(
313 313
         string $alias,
314 314
         array $parameters = [],
315
-        Stringable|string|null $context = null
315
+        Stringable | string | null $context = null
316 316
     ): mixed {
317 317
         $parent = $this->scope->getParentFactory();
318 318
 
319
-        if ($parent instanceof \Spiral\Core\FactoryInterface) {
320
-            try {
319
+        if ($parent instanceof \Spiral\Core\FactoryInterface){
320
+            try{
321 321
                 $this->tracer->push(false, ...[
322 322
                     'current scope' => $this->scope->getScopeName(),
323 323
                     'jump to parent scope' => $this->scope->getParentScope()->getScopeName(),
324 324
                 ]);
325 325
                 /** @psalm-suppress TooManyArguments */
326 326
                 return $parent->make($alias, $parameters, $context);
327
-            } catch (BadScopeException $e) {
328
-                if ($this->scope->getScopeName() !== $e->getScope()) {
327
+            }catch (BadScopeException $e){
328
+                if ($this->scope->getScopeName() !== $e->getScope()){
329 329
                     throw $e;
330 330
                 }
331
-            } catch (ContainerExceptionInterface $e) {
331
+            }catch (ContainerExceptionInterface $e){
332 332
                 $className = match (true) {
333 333
                     $e instanceof NotFoundException => NotFoundException::class,
334 334
                     $e instanceof RecursiveProxyException => throw $e,
@@ -338,19 +338,19 @@  discard block
 block discarded – undo
338 338
                     'Can\'t resolve `%s`.',
339 339
                     $alias,
340 340
                 )), previous: $e);
341
-            } finally {
341
+            }finally{
342 342
                 $this->tracer->pop(false);
343 343
             }
344 344
         }
345 345
 
346 346
         $this->tracer->push(false, action: 'autowire', alias: $alias, context: $context);
347
-        try {
347
+        try{
348 348
             //No direct instructions how to construct class, make is automatically
349 349
             return $this->autowire(
350 350
                 new Ctx(alias: $alias, class: $alias, context: $context),
351 351
                 $parameters,
352 352
             );
353
-        } finally {
353
+        }finally{
354 354
             $this->tracer->pop(false);
355 355
         }
356 356
     }
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
                 &&
372 372
                 (isset($this->state->injectors[$ctx->class]) || $this->binder->hasInjector($ctx->class))
373 373
         ))
374
-        ) {
374
+        ){
375 375
             throw new NotFoundException($this->tracer->combineTraceMessage(\sprintf(
376 376
                 'Can\'t resolve `%s`: undefined class or binding `%s`.',
377 377
                 $this->tracer->getRootAlias(),
@@ -397,13 +397,13 @@  discard block
 block discarded – undo
397 397
         Ctx $ctx,
398 398
         array $arguments,
399 399
     ): object {
400
-        if ($this->options->checkScope) {
400
+        if ($this->options->checkScope){
401 401
             // Check scope name
402 402
             $ctx->reflection = new \ReflectionClass($instance);
403 403
             $scopeName = ($ctx->reflection->getAttributes(Attribute\Scope::class)[0] ?? null)?->newInstance()->name;
404
-            if ($scopeName !== null) {
404
+            if ($scopeName !== null){
405 405
                 $scope = $this->scope;
406
-                while ($scope->getScopeName() !== $scopeName) {
406
+                while ($scope->getScopeName() !== $scopeName){
407 407
                     $scope = $scope->getParentScope() ?? throw new BadScopeException($scopeName, $instance::class);
408 408
                 }
409 409
             }
@@ -432,26 +432,26 @@  discard block
 block discarded – undo
432 432
         array $arguments,
433 433
     ): object {
434 434
         $class = $ctx->class;
435
-        try {
435
+        try{
436 436
             $ctx->reflection = $reflection = new \ReflectionClass($class);
437
-        } catch (\ReflectionException $e) {
437
+        }catch (\ReflectionException $e){
438 438
             throw new ContainerException($e->getMessage(), $e->getCode(), $e);
439 439
         }
440 440
 
441 441
         // Check scope name
442
-        if ($this->options->checkScope) {
442
+        if ($this->options->checkScope){
443 443
             $scope = ($reflection->getAttributes(Attribute\Scope::class)[0] ?? null)?->newInstance()->name;
444
-            if ($scope !== null && $scope !== $this->scope->getScopeName()) {
444
+            if ($scope !== null && $scope !== $this->scope->getScopeName()){
445 445
                 throw new BadScopeException($scope, $class);
446 446
             }
447 447
         }
448 448
 
449 449
         // We have to construct class using external injector when we know the exact context
450
-        if ($arguments === [] && $this->binder->hasInjector($class)) {
450
+        if ($arguments === [] && $this->binder->hasInjector($class)){
451 451
             return $this->resolveInjector($this->state->bindings[$ctx->class], $ctx, $arguments);
452 452
         }
453 453
 
454
-        if (!$reflection->isInstantiable()) {
454
+        if (!$reflection->isInstantiable()){
455 455
             $itIs = match (true) {
456 456
                 $reflection->isEnum() => 'Enum',
457 457
                 $reflection->isAbstract() => 'Abstract class',
@@ -464,12 +464,12 @@  discard block
 block discarded – undo
464 464
 
465 465
         $constructor = $reflection->getConstructor();
466 466
 
467
-        if ($constructor !== null) {
468
-            try {
467
+        if ($constructor !== null){
468
+            try{
469 469
                 $this->tracer->push(false, action: 'resolve arguments', signature: $constructor);
470 470
                 $this->tracer->push(true);
471 471
                 $args = $this->resolver->resolveArguments($constructor, $arguments, $this->options->validateArguments);
472
-            } catch (ValidationException $e) {
472
+            }catch (ValidationException $e){
473 473
                 throw new ContainerException(
474 474
                     $this->tracer->combineTraceMessage(
475 475
                         \sprintf(
@@ -479,22 +479,22 @@  discard block
 block discarded – undo
479 479
                         )
480 480
                     ),
481 481
                 );
482
-            } finally {
482
+            }finally{
483 483
                 $this->tracer->pop(true);
484 484
                 $this->tracer->pop(false);
485 485
             }
486
-            try {
486
+            try{
487 487
                 // Using constructor with resolved arguments
488 488
                 $this->tracer->push(false, call: "$class::__construct", arguments: $args);
489 489
                 $this->tracer->push(true);
490 490
                 $instance = new $class(...$args);
491
-            } catch (\TypeError $e) {
491
+            }catch (\TypeError $e){
492 492
                 throw new WrongTypeException($constructor, $e);
493
-            } finally {
493
+            }finally{
494 494
                 $this->tracer->pop(true);
495 495
                 $this->tracer->pop(false);
496 496
             }
497
-        } else {
497
+        }else{
498 498
             // No constructor specified
499 499
             $instance = $reflection->newInstance();
500 500
         }
@@ -512,13 +512,13 @@  discard block
 block discarded – undo
512 512
         $instance = $this->runInflector($instance);
513 513
 
514 514
         //Declarative singletons
515
-        if ($this->isSingleton($ctx)) {
515
+        if ($this->isSingleton($ctx)){
516 516
             $this->state->singletons[$ctx->alias] = $instance;
517 517
         }
518 518
 
519 519
         // Register finalizer
520 520
         $finalizer = $this->getFinalizer($ctx, $instance);
521
-        if ($finalizer !== null) {
521
+        if ($finalizer !== null){
522 522
             $this->state->finalizers[] = $finalizer;
523 523
         }
524 524
 
@@ -530,12 +530,12 @@  discard block
 block discarded – undo
530 530
      */
531 531
     private function isSingleton(Ctx $ctx): bool
532 532
     {
533
-        if ($ctx->singleton === true) {
533
+        if ($ctx->singleton === true){
534 534
             return true;
535 535
         }
536 536
 
537 537
         /** @psalm-suppress RedundantCondition https://github.com/vimeo/psalm/issues/9489 */
538
-        if ($ctx->reflection->implementsInterface(SingletonInterface::class)) {
538
+        if ($ctx->reflection->implementsInterface(SingletonInterface::class)){
539 539
             return true;
540 540
         }
541 541
 
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
          * @var Attribute\Finalize|null $attribute
550 550
          */
551 551
         $attribute = ($ctx->reflection->getAttributes(Attribute\Finalize::class)[0] ?? null)?->newInstance();
552
-        if ($attribute === null) {
552
+        if ($attribute === null){
553 553
             return null;
554 554
         }
555 555
 
@@ -563,10 +563,10 @@  discard block
 block discarded – undo
563 563
     {
564 564
         $scope = $this->scope;
565 565
 
566
-        while ($scope instanceof \Spiral\Core\Internal\Scope) {
567
-            foreach ($this->state->inflectors as $class => $inflectors) {
568
-                if ($instance instanceof $class) {
569
-                    foreach ($inflectors as $inflector) {
566
+        while ($scope instanceof \Spiral\Core\Internal\Scope){
567
+            foreach ($this->state->inflectors as $class => $inflectors){
568
+                if ($instance instanceof $class){
569
+                    foreach ($inflectors as $inflector){
570 570
                         $instance = $inflector->getParametersCount() > 1
571 571
                             ? $this->invoker->invoke($inflector->inflector, [$instance])
572 572
                             : ($inflector->inflector)($instance);
@@ -582,9 +582,9 @@  discard block
 block discarded – undo
582 582
 
583 583
     private function validateArguments(ContextFunction $reflection, array $arguments = []): bool
584 584
     {
585
-        try {
585
+        try{
586 586
             $this->resolver->validateArguments($reflection, $arguments);
587
-        } catch (\Throwable) {
587
+        }catch (\Throwable){
588 588
             return false;
589 589
         }
590 590
 
Please login to merge, or discard this patch.
Braces   +129 added lines, -56 removed lines patch added patch discarded remove patch
@@ -70,17 +70,20 @@  discard block
 block discarded – undo
70 70
      */
71 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 75
             return $this->state->singletons[$alias];
75 76
         }
76 77
 
77 78
         $binding = $this->state->bindings[$alias] ?? null;
78 79
 
79
-        if ($binding === null) {
80
+        if ($binding === null)
81
+        {
80 82
             return $this->resolveWithoutBinding($alias, $parameters, $context);
81 83
         }
82 84
 
83
-        try {
85
+        try
86
+        {
84 87
             $this->tracer->push(
85 88
                 false,
86 89
                 action: 'resolve from binding',
@@ -110,7 +113,9 @@  discard block
 block discarded – undo
110 113
                     ->resolveWeakReference($binding, $alias, $context, $parameters),
111 114
                 default => $binding,
112 115
             };
113
-        } finally {
116
+        }
117
+        finally
118
+        {
114 119
             $this->state->bindings[$alias] ??= $binding;
115 120
             $this->tracer->pop(true);
116 121
             $this->tracer->pop(false);
@@ -124,18 +129,23 @@  discard block
 block discarded – undo
124 129
     private function resolveInjector(Config\Injectable $binding, Ctx $ctx, array $arguments)
125 130
     {
126 131
         $context = $ctx->context;
127
-        try {
132
+        try
133
+        {
128 134
             $reflection = $ctx->reflection ??= new \ReflectionClass($ctx->class);
129
-        } catch (\ReflectionException $e) {
135
+        }
136
+        catch (\ReflectionException $e)
137
+        {
130 138
             throw new ContainerException($e->getMessage(), $e->getCode(), $e);
131 139
         }
132 140
 
133 141
         $injector = $binding->injector;
134 142
 
135
-        try {
143
+        try
144
+        {
136 145
             $injectorInstance = \is_object($injector) ? $injector : $this->container->get($injector);
137 146
 
138
-            if (!$injectorInstance instanceof InjectorInterface) {
147
+            if (!$injectorInstance instanceof InjectorInterface)
148
+            {
139 149
                 throw new InjectionException(
140 150
                     \sprintf(
141 151
                         "Class '%s' must be an instance of InjectorInterface for '%s'.",
@@ -162,7 +172,8 @@  discard block
 block discarded – undo
162 172
                 default => (string)$context,
163 173
             });
164 174
 
165
-            if (!$reflection->isInstance($instance)) {
175
+            if (!$reflection->isInstance($instance))
176
+            {
166 177
                 throw new InjectionException(
167 178
                     \sprintf(
168 179
                         "Invalid injection response for '%s'.",
@@ -172,7 +183,9 @@  discard block
 block discarded – undo
172 183
             }
173 184
 
174 185
             return $instance;
175
-        } finally {
186
+        }
187
+        finally
188
+        {
176 189
             $this->state->bindings[$ctx->class] ??= $binding;
177 190
         }
178 191
     }
@@ -191,7 +204,8 @@  discard block
 block discarded – undo
191 204
             //Binding is pointing to something else
192 205
             : $this->make($binding->alias, $arguments, $context);
193 206
 
194
-        if ($binding->singleton && $arguments === []) {
207
+        if ($binding->singleton && $arguments === [])
208
+        {
195 209
             $this->state->singletons[$alias] = $result;
196 210
         }
197 211
 
@@ -200,7 +214,8 @@  discard block
 block discarded – undo
200 214
 
201 215
     private function resolveProxy(Config\Proxy $binding, string $alias, Stringable|string|null $context): mixed
202 216
     {
203
-        if ($context instanceof RetryContext) {
217
+        if ($context instanceof RetryContext)
218
+        {
204 219
             return $binding->fallbackFactory instanceof \Closure
205 220
                 ? ($binding->fallbackFactory)($this->container, $context->context)
206 221
                 : throw new RecursiveProxyException(
@@ -211,7 +226,8 @@  discard block
 block discarded – undo
211 226
 
212 227
         $result = Proxy::create(new \ReflectionClass($binding->getInterface()), $context, new Attribute\Proxy());
213 228
 
214
-        if ($binding->singleton) {
229
+        if ($binding->singleton)
230
+        {
215 231
             $this->state->singletons[$alias] = $result;
216 232
         }
217 233
 
@@ -256,11 +272,14 @@  discard block
 block discarded – undo
256 272
         array $arguments,
257 273
     ): mixed {
258 274
         $ctx = new Ctx(alias: $alias, class: $alias, context: $context, singleton: $binding->singleton);
259
-        try {
275
+        try
276
+        {
260 277
             $instance = $binding::class === Config\Factory::class && $binding->getParametersCount() === 0
261 278
                 ? ($binding->factory)()
262 279
                 : $this->invoker->invoke($binding->factory, $arguments);
263
-        } catch (NotCallableException $e) {
280
+        }
281
+        catch (NotCallableException $e)
282
+        {
264 283
             throw new ContainerException(
265 284
                 $this->tracer->combineTraceMessage(\sprintf('Invalid binding for `%s`.', $ctx->alias)),
266 285
                 $e->getCode(),
@@ -279,19 +298,24 @@  discard block
 block discarded – undo
279 298
     ): ?object {
280 299
         $avoidCache = $arguments !== [];
281 300
 
282
-        if (($avoidCache || $binding->reference->get() === null) && \class_exists($alias)) {
283
-            try {
301
+        if (($avoidCache || $binding->reference->get() === null) && \class_exists($alias))
302
+        {
303
+            try
304
+            {
284 305
                 $this->tracer->push(false, alias: $alias, source: WeakReference::class, context: $context);
285 306
 
286 307
                 $object = $this->createInstance(
287 308
                     new Ctx(alias: $alias, class: $alias, context: $context),
288 309
                     $arguments,
289 310
                 );
290
-                if ($avoidCache) {
311
+                if ($avoidCache)
312
+                {
291 313
                     return $object;
292 314
                 }
293 315
                 $binding->reference = WeakReference::create($object);
294
-            } catch (\Throwable) {
316
+            }
317
+            catch (\Throwable)
318
+            {
295 319
                 throw new ContainerException(
296 320
                     $this->tracer->combineTraceMessage(
297 321
                         \sprintf(
@@ -301,7 +325,9 @@  discard block
 block discarded – undo
301 325
                         )
302 326
                     )
303 327
                 );
304
-            } finally {
328
+            }
329
+            finally
330
+            {
305 331
                 $this->tracer->pop();
306 332
             }
307 333
         }
@@ -316,19 +342,26 @@  discard block
 block discarded – undo
316 342
     ): mixed {
317 343
         $parent = $this->scope->getParentFactory();
318 344
 
319
-        if ($parent instanceof \Spiral\Core\FactoryInterface) {
320
-            try {
345
+        if ($parent instanceof \Spiral\Core\FactoryInterface)
346
+        {
347
+            try
348
+            {
321 349
                 $this->tracer->push(false, ...[
322 350
                     'current scope' => $this->scope->getScopeName(),
323 351
                     'jump to parent scope' => $this->scope->getParentScope()->getScopeName(),
324 352
                 ]);
325 353
                 /** @psalm-suppress TooManyArguments */
326 354
                 return $parent->make($alias, $parameters, $context);
327
-            } catch (BadScopeException $e) {
328
-                if ($this->scope->getScopeName() !== $e->getScope()) {
355
+            }
356
+            catch (BadScopeException $e)
357
+            {
358
+                if ($this->scope->getScopeName() !== $e->getScope())
359
+                {
329 360
                     throw $e;
330 361
                 }
331
-            } catch (ContainerExceptionInterface $e) {
362
+            }
363
+            catch (ContainerExceptionInterface $e)
364
+            {
332 365
                 $className = match (true) {
333 366
                     $e instanceof NotFoundException => NotFoundException::class,
334 367
                     $e instanceof RecursiveProxyException => throw $e,
@@ -338,19 +371,24 @@  discard block
 block discarded – undo
338 371
                     'Can\'t resolve `%s`.',
339 372
                     $alias,
340 373
                 )), previous: $e);
341
-            } finally {
374
+            }
375
+            finally
376
+            {
342 377
                 $this->tracer->pop(false);
343 378
             }
344 379
         }
345 380
 
346 381
         $this->tracer->push(false, action: 'autowire', alias: $alias, context: $context);
347
-        try {
382
+        try
383
+        {
348 384
             //No direct instructions how to construct class, make is automatically
349 385
             return $this->autowire(
350 386
                 new Ctx(alias: $alias, class: $alias, context: $context),
351 387
                 $parameters,
352 388
             );
353
-        } finally {
389
+        }
390
+        finally
391
+        {
354 392
             $this->tracer->pop(false);
355 393
         }
356 394
     }
@@ -397,13 +435,16 @@  discard block
 block discarded – undo
397 435
         Ctx $ctx,
398 436
         array $arguments,
399 437
     ): object {
400
-        if ($this->options->checkScope) {
438
+        if ($this->options->checkScope)
439
+        {
401 440
             // Check scope name
402 441
             $ctx->reflection = new \ReflectionClass($instance);
403 442
             $scopeName = ($ctx->reflection->getAttributes(Attribute\Scope::class)[0] ?? null)?->newInstance()->name;
404
-            if ($scopeName !== null) {
443
+            if ($scopeName !== null)
444
+            {
405 445
                 $scope = $this->scope;
406
-                while ($scope->getScopeName() !== $scopeName) {
446
+                while ($scope->getScopeName() !== $scopeName)
447
+                {
407 448
                     $scope = $scope->getParentScope() ?? throw new BadScopeException($scopeName, $instance::class);
408 449
                 }
409 450
             }
@@ -432,26 +473,33 @@  discard block
 block discarded – undo
432 473
         array $arguments,
433 474
     ): object {
434 475
         $class = $ctx->class;
435
-        try {
476
+        try
477
+        {
436 478
             $ctx->reflection = $reflection = new \ReflectionClass($class);
437
-        } catch (\ReflectionException $e) {
479
+        }
480
+        catch (\ReflectionException $e)
481
+        {
438 482
             throw new ContainerException($e->getMessage(), $e->getCode(), $e);
439 483
         }
440 484
 
441 485
         // Check scope name
442
-        if ($this->options->checkScope) {
486
+        if ($this->options->checkScope)
487
+        {
443 488
             $scope = ($reflection->getAttributes(Attribute\Scope::class)[0] ?? null)?->newInstance()->name;
444
-            if ($scope !== null && $scope !== $this->scope->getScopeName()) {
489
+            if ($scope !== null && $scope !== $this->scope->getScopeName())
490
+            {
445 491
                 throw new BadScopeException($scope, $class);
446 492
             }
447 493
         }
448 494
 
449 495
         // We have to construct class using external injector when we know the exact context
450
-        if ($arguments === [] && $this->binder->hasInjector($class)) {
496
+        if ($arguments === [] && $this->binder->hasInjector($class))
497
+        {
451 498
             return $this->resolveInjector($this->state->bindings[$ctx->class], $ctx, $arguments);
452 499
         }
453 500
 
454
-        if (!$reflection->isInstantiable()) {
501
+        if (!$reflection->isInstantiable())
502
+        {
455 503
             $itIs = match (true) {
456 504
                 $reflection->isEnum() => 'Enum',
457 505
                 $reflection->isAbstract() => 'Abstract class',
@@ -464,12 +512,16 @@  discard block
 block discarded – undo
464 512
 
465 513
         $constructor = $reflection->getConstructor();
466 514
 
467
-        if ($constructor !== null) {
468
-            try {
515
+        if ($constructor !== null)
516
+        {
517
+            try
518
+            {
469 519
                 $this->tracer->push(false, action: 'resolve arguments', signature: $constructor);
470 520
                 $this->tracer->push(true);
471 521
                 $args = $this->resolver->resolveArguments($constructor, $arguments, $this->options->validateArguments);
472
-            } catch (ValidationException $e) {
522
+            }
523
+            catch (ValidationException $e)
524
+            {
473 525
                 throw new ContainerException(
474 526
                     $this->tracer->combineTraceMessage(
475 527
                         \sprintf(
@@ -479,22 +531,31 @@  discard block
 block discarded – undo
479 531
                         )
480 532
                     ),
481 533
                 );
482
-            } finally {
534
+            }
535
+            finally
536
+            {
483 537
                 $this->tracer->pop(true);
484 538
                 $this->tracer->pop(false);
485 539
             }
486
-            try {
540
+            try
541
+            {
487 542
                 // Using constructor with resolved arguments
488 543
                 $this->tracer->push(false, call: "$class::__construct", arguments: $args);
489 544
                 $this->tracer->push(true);
490 545
                 $instance = new $class(...$args);
491
-            } catch (\TypeError $e) {
546
+            }
547
+            catch (\TypeError $e)
548
+            {
492 549
                 throw new WrongTypeException($constructor, $e);
493
-            } finally {
550
+            }
551
+            finally
552
+            {
494 553
                 $this->tracer->pop(true);
495 554
                 $this->tracer->pop(false);
496 555
             }
497
-        } else {
556
+        }
557
+        else
558
+        {
498 559
             // No constructor specified
499 560
             $instance = $reflection->newInstance();
500 561
         }
@@ -512,13 +573,15 @@  discard block
 block discarded – undo
512 573
         $instance = $this->runInflector($instance);
513 574
 
514 575
         //Declarative singletons
515
-        if ($this->isSingleton($ctx)) {
576
+        if ($this->isSingleton($ctx))
577
+        {
516 578
             $this->state->singletons[$ctx->alias] = $instance;
517 579
         }
518 580
 
519 581
         // Register finalizer
520 582
         $finalizer = $this->getFinalizer($ctx, $instance);
521
-        if ($finalizer !== null) {
583
+        if ($finalizer !== null)
584
+        {
522 585
             $this->state->finalizers[] = $finalizer;
523 586
         }
524 587
 
@@ -530,12 +593,14 @@  discard block
 block discarded – undo
530 593
      */
531 594
     private function isSingleton(Ctx $ctx): bool
532 595
     {
533
-        if ($ctx->singleton === true) {
596
+        if ($ctx->singleton === true)
597
+        {
534 598
             return true;
535 599
         }
536 600
 
537 601
         /** @psalm-suppress RedundantCondition https://github.com/vimeo/psalm/issues/9489 */
538
-        if ($ctx->reflection->implementsInterface(SingletonInterface::class)) {
602
+        if ($ctx->reflection->implementsInterface(SingletonInterface::class))
603
+        {
539 604
             return true;
540 605
         }
541 606
 
@@ -549,7 +614,8 @@  discard block
 block discarded – undo
549 614
          * @var Attribute\Finalize|null $attribute
550 615
          */
551 616
         $attribute = ($ctx->reflection->getAttributes(Attribute\Finalize::class)[0] ?? null)?->newInstance();
552
-        if ($attribute === null) {
617
+        if ($attribute === null)
618
+        {
553 619
             return null;
554 620
         }
555 621
 
@@ -563,10 +629,14 @@  discard block
 block discarded – undo
563 629
     {
564 630
         $scope = $this->scope;
565 631
 
566
-        while ($scope instanceof \Spiral\Core\Internal\Scope) {
567
-            foreach ($this->state->inflectors as $class => $inflectors) {
568
-                if ($instance instanceof $class) {
569
-                    foreach ($inflectors as $inflector) {
632
+        while ($scope instanceof \Spiral\Core\Internal\Scope)
633
+        {
634
+            foreach ($this->state->inflectors as $class => $inflectors)
635
+            {
636
+                if ($instance instanceof $class)
637
+                {
638
+                    foreach ($inflectors as $inflector)
639
+                    {
570 640
                         $instance = $inflector->getParametersCount() > 1
571 641
                             ? $this->invoker->invoke($inflector->inflector, [$instance])
572 642
                             : ($inflector->inflector)($instance);
@@ -582,9 +652,12 @@  discard block
 block discarded – undo
582 652
 
583 653
     private function validateArguments(ContextFunction $reflection, array $arguments = []): bool
584 654
     {
585
-        try {
655
+        try
656
+        {
586 657
             $this->resolver->validateArguments($reflection, $arguments);
587
-        } catch (\Throwable) {
658
+        }
659
+        catch (\Throwable)
660
+        {
588 661
             return false;
589 662
         }
590 663
 
Please login to merge, or discard this patch.
src/Core/src/Internal/Resolver.php 2 patches
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
     ): array {
54 54
         $state = new ResolvingState($reflection, $parameters);
55 55
 
56
-        foreach ($reflection->getParameters() as $parameter) {
56
+        foreach ($reflection->getParameters() as $parameter){
57 57
             $this->resolveParameter($parameter, $state, $validate)
58 58
             or
59 59
             throw new ArgumentResolvingException($reflection, $parameter->getName());
@@ -67,47 +67,47 @@  discard block
 block discarded – undo
67 67
         $positional = true;
68 68
         $variadic = false;
69 69
         $parameters = $reflection->getParameters();
70
-        if (\count($parameters) === 0) {
70
+        if (\count($parameters) === 0){
71 71
             return;
72 72
         }
73 73
 
74 74
         $parameter = null;
75
-        while (\count($parameters) > 0 || \count($arguments) > 0) {
75
+        while (\count($parameters) > 0 || \count($arguments) > 0){
76 76
             // get related argument value
77 77
             $key = \key($arguments);
78 78
 
79 79
             // For a variadic parameter it's no sense - named or positional argument will be sent
80 80
             // But you can't send positional argument after named in any case
81
-            if (\is_int($key) && !$positional) {
81
+            if (\is_int($key) && !$positional){
82 82
                 throw new PositionalArgumentException($reflection, $key);
83 83
             }
84 84
 
85 85
             $positional = $positional && \is_int($key);
86 86
 
87
-            if (!$variadic) {
87
+            if (!$variadic){
88 88
                 $parameter = \array_shift($parameters);
89 89
                 $variadic = $parameter?->isVariadic() ?? false;
90 90
             }
91 91
 
92
-            if ($parameter === null) {
92
+            if ($parameter === null){
93 93
                 throw new UnknownParameterException($reflection, $key);
94 94
             }
95 95
             $name = $parameter->getName();
96 96
 
97
-            if (($positional || $variadic) && $key !== null) {
97
+            if (($positional || $variadic) && $key !== null){
98 98
                 /** @psalm-suppress ReferenceReusedFromConfusingScope */
99 99
                 $value = \array_shift($arguments);
100
-            } elseif ($key === null || !\array_key_exists($name, $arguments)) {
101
-                if ($parameter->isOptional()) {
100
+            } elseif ($key === null || !\array_key_exists($name, $arguments)){
101
+                if ($parameter->isOptional()){
102 102
                     continue;
103 103
                 }
104 104
                 throw new MissingRequiredArgumentException($reflection, $name);
105
-            } else {
105
+            }else{
106 106
                 $value = &$arguments[$name];
107 107
                 unset($arguments[$name]);
108 108
             }
109 109
 
110
-            if (!$this->validateValueToParameter($parameter, $value)) {
110
+            if (!$this->validateValueToParameter($parameter, $value)){
111 111
                 throw new InvalidArgumentException($reflection, $name);
112 112
             }
113 113
         }
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 
116 116
     private function validateValueToParameter(ReflectionParameter $parameter, mixed $value): bool
117 117
     {
118
-        if (!$parameter->hasType() || ($parameter->allowsNull() && $value === null)) {
118
+        if (!$parameter->hasType() || ($parameter->allowsNull() && $value === null)){
119 119
             return true;
120 120
         }
121 121
         $type = $parameter->getType();
@@ -126,17 +126,17 @@  discard block
 block discarded – undo
126 126
             $type instanceof ReflectionIntersectionType => [false, $type->getTypes()],
127 127
         };
128 128
 
129
-        foreach ($types as $t) {
129
+        foreach ($types as $t){
130 130
             \assert($t instanceof ReflectionNamedType);
131
-            if (!$this->validateValueNamedType($t, $value)) {
131
+            if (!$this->validateValueNamedType($t, $value)){
132 132
                 // If it is TypeIntersection
133
-                if ($or) {
133
+                if ($or){
134 134
                     continue;
135 135
                 }
136 136
                 return false;
137 137
             }
138 138
             // If it is not type intersection then we can skip that value after first successful check
139
-            if ($or) {
139
+            if ($or){
140 140
                 return true;
141 141
             }
142 142
         }
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
     {
152 152
         $name = $type->getName();
153 153
 
154
-        if ($type->isBuiltin()) {
154
+        if ($type->isBuiltin()){
155 155
             return match ($name) {
156 156
                 'mixed' => true,
157 157
                 'string' => \is_string($value),
@@ -184,13 +184,13 @@  discard block
 block discarded – undo
184 184
 
185 185
         // Try to resolve parameter by name
186 186
         $res = $state->resolveParameterByNameOrPosition($param, $isVariadic);
187
-        if ($res !== [] || $isVariadic) {
187
+        if ($res !== [] || $isVariadic){
188 188
             // validate
189
-            if ($isVariadic) {
190
-                foreach ($res as $k => &$v) {
191
-                    $this->processArgument($state, $v, validateWith: $validate ? $param : null, key: $k);
189
+            if ($isVariadic){
190
+                foreach ($res as $k => &$v){
191
+                    $this->processArgument($state, $v, validateWith: $validate ? $param : null, key : $k);
192 192
                 }
193
-            } else {
193
+            }else{
194 194
                 $this->processArgument($state, $res[0], validateWith: $validate ? $param : null);
195 195
             }
196 196
 
@@ -198,18 +198,18 @@  discard block
 block discarded – undo
198 198
         }
199 199
 
200 200
         $error = null;
201
-        while ($hasType) {
201
+        while ($hasType){
202 202
             /** @var ReflectionIntersectionType|ReflectionUnionType|ReflectionNamedType $refType */
203 203
             $refType = $param->getType();
204 204
 
205
-            if ($refType::class === ReflectionNamedType::class) {
206
-                if ($refType->isBuiltin()) {
205
+            if ($refType::class === ReflectionNamedType::class){
206
+                if ($refType->isBuiltin()){
207 207
                     break;
208 208
                 }
209 209
 
210 210
                 if (\interface_exists($refType->getName()) && !empty(
211 211
                     $attrs = $param->getAttributes(ProxyAttribute::class)
212
-                )) {
212
+                )){
213 213
                     $proxy = Proxy::create(
214 214
                         new \ReflectionClass($refType->getName()),
215 215
                         $param,
@@ -219,23 +219,23 @@  discard block
 block discarded – undo
219 219
                     return true;
220 220
                 }
221 221
 
222
-                try {
223
-                    if ($this->resolveObject($state, $refType, $param, $validate)) {
222
+                try{
223
+                    if ($this->resolveObject($state, $refType, $param, $validate)){
224 224
                         return true;
225 225
                     }
226
-                } catch (Throwable $e) {
226
+                }catch (Throwable $e){
227 227
                     $error = $e;
228 228
                 }
229 229
                 break;
230 230
             }
231 231
 
232
-            if ($refType::class === ReflectionUnionType::class) {
233
-                foreach ($refType->getTypes() as $namedType) {
234
-                    try {
235
-                        if (!$namedType->isBuiltin() && $this->resolveObject($state, $namedType, $param, $validate)) {
232
+            if ($refType::class === ReflectionUnionType::class){
233
+                foreach ($refType->getTypes() as $namedType){
234
+                    try{
235
+                        if (!$namedType->isBuiltin() && $this->resolveObject($state, $namedType, $param, $validate)){
236 236
                             return true;
237 237
                         }
238
-                    } catch (Throwable $e) {
238
+                    }catch (Throwable $e){
239 239
                         $error = $e;
240 240
                     }
241 241
                 }
@@ -245,19 +245,19 @@  discard block
 block discarded – undo
245 245
             throw new UnsupportedTypeException($param->getDeclaringFunction(), $param->getName());
246 246
         }
247 247
 
248
-        if ($param->isDefaultValueAvailable()) {
248
+        if ($param->isDefaultValueAvailable()){
249 249
             $argument = $param->getDefaultValue();
250 250
             $this->processArgument($state, $argument);
251 251
             return true;
252 252
         }
253 253
 
254
-        if ($hasType && $param->allowsNull()) {
254
+        if ($hasType && $param->allowsNull()){
255 255
             $argument = null;
256 256
             $this->processArgument($state, $argument);
257 257
             return true;
258 258
         }
259 259
 
260
-        if (!$error instanceof \Throwable) {
260
+        if (!$error instanceof \Throwable){
261 261
             return false;
262 262
         }
263 263
 
@@ -295,15 +295,15 @@  discard block
 block discarded – undo
295 295
         ResolvingState $state,
296 296
         mixed &$value,
297 297
         ?ReflectionParameter $validateWith = null,
298
-        int|string|null $key = null
298
+        int | string | null $key = null
299 299
     ): void {
300 300
         // Resolve Autowire objects
301
-        if ($value instanceof Autowire) {
301
+        if ($value instanceof Autowire){
302 302
             $value = $value->resolve($this->factory);
303 303
         }
304 304
 
305 305
         // Validation
306
-        if ($validateWith instanceof \ReflectionParameter && !$this->validateValueToParameter($validateWith, $value)) {
306
+        if ($validateWith instanceof \ReflectionParameter && !$this->validateValueToParameter($validateWith, $value)){
307 307
             throw new InvalidArgumentException(
308 308
                 $validateWith->getDeclaringFunction(),
309 309
                 $validateWith->getName()
Please login to merge, or discard this patch.
Braces   +81 added lines, -38 removed lines patch added patch discarded remove patch
@@ -53,7 +53,8 @@  discard block
 block discarded – undo
53 53
     ): array {
54 54
         $state = new ResolvingState($reflection, $parameters);
55 55
 
56
-        foreach ($reflection->getParameters() as $parameter) {
56
+        foreach ($reflection->getParameters() as $parameter)
57
+        {
57 58
             $this->resolveParameter($parameter, $state, $validate)
58 59
             or
59 60
             throw new ArgumentResolvingException($reflection, $parameter->getName());
@@ -67,47 +68,59 @@  discard block
 block discarded – undo
67 68
         $positional = true;
68 69
         $variadic = false;
69 70
         $parameters = $reflection->getParameters();
70
-        if (\count($parameters) === 0) {
71
+        if (\count($parameters) === 0)
72
+        {
71 73
             return;
72 74
         }
73 75
 
74 76
         $parameter = null;
75
-        while (\count($parameters) > 0 || \count($arguments) > 0) {
77
+        while (\count($parameters) > 0 || \count($arguments) > 0)
78
+        {
76 79
             // get related argument value
77 80
             $key = \key($arguments);
78 81
 
79 82
             // For a variadic parameter it's no sense - named or positional argument will be sent
80 83
             // But you can't send positional argument after named in any case
81
-            if (\is_int($key) && !$positional) {
84
+            if (\is_int($key) && !$positional)
85
+            {
82 86
                 throw new PositionalArgumentException($reflection, $key);
83 87
             }
84 88
 
85 89
             $positional = $positional && \is_int($key);
86 90
 
87
-            if (!$variadic) {
91
+            if (!$variadic)
92
+            {
88 93
                 $parameter = \array_shift($parameters);
89 94
                 $variadic = $parameter?->isVariadic() ?? false;
90 95
             }
91 96
 
92
-            if ($parameter === null) {
97
+            if ($parameter === null)
98
+            {
93 99
                 throw new UnknownParameterException($reflection, $key);
94 100
             }
95 101
             $name = $parameter->getName();
96 102
 
97
-            if (($positional || $variadic) && $key !== null) {
103
+            if (($positional || $variadic) && $key !== null)
104
+            {
98 105
                 /** @psalm-suppress ReferenceReusedFromConfusingScope */
99 106
                 $value = \array_shift($arguments);
100
-            } elseif ($key === null || !\array_key_exists($name, $arguments)) {
101
-                if ($parameter->isOptional()) {
107
+            }
108
+            elseif ($key === null || !\array_key_exists($name, $arguments))
109
+            {
110
+                if ($parameter->isOptional())
111
+                {
102 112
                     continue;
103 113
                 }
104 114
                 throw new MissingRequiredArgumentException($reflection, $name);
105
-            } else {
115
+            }
116
+            else
117
+            {
106 118
                 $value = &$arguments[$name];
107 119
                 unset($arguments[$name]);
108 120
             }
109 121
 
110
-            if (!$this->validateValueToParameter($parameter, $value)) {
122
+            if (!$this->validateValueToParameter($parameter, $value))
123
+            {
111 124
                 throw new InvalidArgumentException($reflection, $name);
112 125
             }
113 126
         }
@@ -115,7 +128,8 @@  discard block
 block discarded – undo
115 128
 
116 129
     private function validateValueToParameter(ReflectionParameter $parameter, mixed $value): bool
117 130
     {
118
-        if (!$parameter->hasType() || ($parameter->allowsNull() && $value === null)) {
131
+        if (!$parameter->hasType() || ($parameter->allowsNull() && $value === null))
132
+        {
119 133
             return true;
120 134
         }
121 135
         $type = $parameter->getType();
@@ -126,17 +140,21 @@  discard block
 block discarded – undo
126 140
             $type instanceof ReflectionIntersectionType => [false, $type->getTypes()],
127 141
         };
128 142
 
129
-        foreach ($types as $t) {
143
+        foreach ($types as $t)
144
+        {
130 145
             \assert($t instanceof ReflectionNamedType);
131
-            if (!$this->validateValueNamedType($t, $value)) {
146
+            if (!$this->validateValueNamedType($t, $value))
147
+            {
132 148
                 // If it is TypeIntersection
133
-                if ($or) {
149
+                if ($or)
150
+                {
134 151
                     continue;
135 152
                 }
136 153
                 return false;
137 154
             }
138 155
             // If it is not type intersection then we can skip that value after first successful check
139
-            if ($or) {
156
+            if ($or)
157
+            {
140 158
                 return true;
141 159
             }
142 160
         }
@@ -151,7 +169,8 @@  discard block
 block discarded – undo
151 169
     {
152 170
         $name = $type->getName();
153 171
 
154
-        if ($type->isBuiltin()) {
172
+        if ($type->isBuiltin())
173
+        {
155 174
             return match ($name) {
156 175
                 'mixed' => true,
157 176
                 'string' => \is_string($value),
@@ -184,13 +203,18 @@  discard block
 block discarded – undo
184 203
 
185 204
         // Try to resolve parameter by name
186 205
         $res = $state->resolveParameterByNameOrPosition($param, $isVariadic);
187
-        if ($res !== [] || $isVariadic) {
206
+        if ($res !== [] || $isVariadic)
207
+        {
188 208
             // validate
189
-            if ($isVariadic) {
190
-                foreach ($res as $k => &$v) {
209
+            if ($isVariadic)
210
+            {
211
+                foreach ($res as $k => &$v)
212
+                {
191 213
                     $this->processArgument($state, $v, validateWith: $validate ? $param : null, key: $k);
192 214
                 }
193
-            } else {
215
+            }
216
+            else
217
+            {
194 218
                 $this->processArgument($state, $res[0], validateWith: $validate ? $param : null);
195 219
             }
196 220
 
@@ -198,18 +222,22 @@  discard block
 block discarded – undo
198 222
         }
199 223
 
200 224
         $error = null;
201
-        while ($hasType) {
225
+        while ($hasType)
226
+        {
202 227
             /** @var ReflectionIntersectionType|ReflectionUnionType|ReflectionNamedType $refType */
203 228
             $refType = $param->getType();
204 229
 
205
-            if ($refType::class === ReflectionNamedType::class) {
206
-                if ($refType->isBuiltin()) {
230
+            if ($refType::class === ReflectionNamedType::class)
231
+            {
232
+                if ($refType->isBuiltin())
233
+                {
207 234
                     break;
208 235
                 }
209 236
 
210 237
                 if (\interface_exists($refType->getName()) && !empty(
211 238
                     $attrs = $param->getAttributes(ProxyAttribute::class)
212
-                )) {
239
+                ))
240
+                {
213 241
                     $proxy = Proxy::create(
214 242
                         new \ReflectionClass($refType->getName()),
215 243
                         $param,
@@ -219,23 +247,33 @@  discard block
 block discarded – undo
219 247
                     return true;
220 248
                 }
221 249
 
222
-                try {
223
-                    if ($this->resolveObject($state, $refType, $param, $validate)) {
250
+                try
251
+                {
252
+                    if ($this->resolveObject($state, $refType, $param, $validate))
253
+                    {
224 254
                         return true;
225 255
                     }
226
-                } catch (Throwable $e) {
256
+                }
257
+                catch (Throwable $e)
258
+                {
227 259
                     $error = $e;
228 260
                 }
229 261
                 break;
230 262
             }
231 263
 
232
-            if ($refType::class === ReflectionUnionType::class) {
233
-                foreach ($refType->getTypes() as $namedType) {
234
-                    try {
235
-                        if (!$namedType->isBuiltin() && $this->resolveObject($state, $namedType, $param, $validate)) {
264
+            if ($refType::class === ReflectionUnionType::class)
265
+            {
266
+                foreach ($refType->getTypes() as $namedType)
267
+                {
268
+                    try
269
+                    {
270
+                        if (!$namedType->isBuiltin() && $this->resolveObject($state, $namedType, $param, $validate))
271
+                        {
236 272
                             return true;
237 273
                         }
238
-                    } catch (Throwable $e) {
274
+                    }
275
+                    catch (Throwable $e)
276
+                    {
239 277
                         $error = $e;
240 278
                     }
241 279
                 }
@@ -245,19 +283,22 @@  discard block
 block discarded – undo
245 283
             throw new UnsupportedTypeException($param->getDeclaringFunction(), $param->getName());
246 284
         }
247 285
 
248
-        if ($param->isDefaultValueAvailable()) {
286
+        if ($param->isDefaultValueAvailable())
287
+        {
249 288
             $argument = $param->getDefaultValue();
250 289
             $this->processArgument($state, $argument);
251 290
             return true;
252 291
         }
253 292
 
254
-        if ($hasType && $param->allowsNull()) {
293
+        if ($hasType && $param->allowsNull())
294
+        {
255 295
             $argument = null;
256 296
             $this->processArgument($state, $argument);
257 297
             return true;
258 298
         }
259 299
 
260
-        if (!$error instanceof \Throwable) {
300
+        if (!$error instanceof \Throwable)
301
+        {
261 302
             return false;
262 303
         }
263 304
 
@@ -298,12 +339,14 @@  discard block
 block discarded – undo
298 339
         int|string|null $key = null
299 340
     ): void {
300 341
         // Resolve Autowire objects
301
-        if ($value instanceof Autowire) {
342
+        if ($value instanceof Autowire)
343
+        {
302 344
             $value = $value->resolve($this->factory);
303 345
         }
304 346
 
305 347
         // Validation
306
-        if ($validateWith instanceof \ReflectionParameter && !$this->validateValueToParameter($validateWith, $value)) {
348
+        if ($validateWith instanceof \ReflectionParameter && !$this->validateValueToParameter($validateWith, $value))
349
+        {
307 350
             throw new InvalidArgumentException(
308 351
                 $validateWith->getDeclaringFunction(),
309 352
                 $validateWith->getName()
Please login to merge, or discard this patch.
src/Core/src/Internal/Binder.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,11 +32,11 @@
 block discarded – undo
32 32
     public function hasInstance(string $alias): bool
33 33
     {
34 34
         $parent = $this->scope->getParent();
35
-        if ($parent instanceof \Spiral\Core\Container && $parent->hasInstance($alias)) {
35
+        if ($parent instanceof \Spiral\Core\Container && $parent->hasInstance($alias)){
36 36
             return true;
37 37
         }
38 38
 
39
-        if (!$this->container->has($alias)) {
39
+        if (!$this->container->has($alias)){
40 40
             return false;
41 41
         }
42 42
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,11 +32,13 @@
 block discarded – undo
32 32
     public function hasInstance(string $alias): bool
33 33
     {
34 34
         $parent = $this->scope->getParent();
35
-        if ($parent instanceof \Spiral\Core\Container && $parent->hasInstance($alias)) {
35
+        if ($parent instanceof \Spiral\Core\Container && $parent->hasInstance($alias))
36
+        {
36 37
             return true;
37 38
         }
38 39
 
39
-        if (!$this->container->has($alias)) {
40
+        if (!$this->container->has($alias))
41
+        {
40 42
             return false;
41 43
         }
42 44
 
Please login to merge, or discard this patch.
src/Core/src/Internal/Scope.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 
19 19
     public function __construct(
20 20
         private readonly ?string $scopeName = null,
21
-    ) {
21
+    ){
22 22
     }
23 23
 
24 24
     public function getScopeName(): ?string
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
         $this->parentFactory = $factory;
39 39
 
40 40
         // Check a scope with the same name is not already registered
41
-        if ($this->scopeName !== null) {
41
+        if ($this->scopeName !== null){
42 42
             $tmp = $this;
43
-            while ($tmp->parentScope instanceof \Spiral\Core\Internal\Scope) {
43
+            while ($tmp->parentScope instanceof \Spiral\Core\Internal\Scope){
44 44
                 $tmp = $tmp->parentScope;
45 45
                 $tmp->scopeName !== $this->scopeName ?: throw new NamedScopeDuplicationException($this->scopeName);
46 46
             }
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
         $result = [$this->scopeName];
69 69
 
70 70
         $parent = $this;
71
-        while ($parent->parentScope instanceof \Spiral\Core\Internal\Scope) {
71
+        while ($parent->parentScope instanceof \Spiral\Core\Internal\Scope){
72 72
             $parent = $parent->parentScope;
73 73
             $result[] = $parent->scopeName;
74 74
         }
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -38,9 +38,11 @@  discard block
 block discarded – undo
38 38
         $this->parentFactory = $factory;
39 39
 
40 40
         // Check a scope with the same name is not already registered
41
-        if ($this->scopeName !== null) {
41
+        if ($this->scopeName !== null)
42
+        {
42 43
             $tmp = $this;
43
-            while ($tmp->parentScope instanceof \Spiral\Core\Internal\Scope) {
44
+            while ($tmp->parentScope instanceof \Spiral\Core\Internal\Scope)
45
+            {
44 46
                 $tmp = $tmp->parentScope;
45 47
                 $tmp->scopeName !== $this->scopeName ?: throw new NamedScopeDuplicationException($this->scopeName);
46 48
             }
@@ -68,7 +70,8 @@  discard block
 block discarded – undo
68 70
         $result = [$this->scopeName];
69 71
 
70 72
         $parent = $this;
71
-        while ($parent->parentScope instanceof \Spiral\Core\Internal\Scope) {
73
+        while ($parent->parentScope instanceof \Spiral\Core\Internal\Scope)
74
+        {
72 75
             $parent = $parent->parentScope;
73 76
             $result[] = $parent->scopeName;
74 77
         }
Please login to merge, or discard this patch.
src/Core/src/Internal/Tracer.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 
21 21
     public function __toString(): string
22 22
     {
23
-        return $this->traces === [] ? '' : "Container trace list:\n" . $this->renderTraceList($this->traces);
23
+        return $this->traces === [] ? '' : "Container trace list:\n".$this->renderTraceList($this->traces);
24 24
     }
25 25
 
26 26
     /**
@@ -34,19 +34,19 @@  discard block
 block discarded – undo
34 34
     public function push(bool $nextLevel, mixed ...$details): void
35 35
     {
36 36
         $trace = $details === [] ? null : new Trace($details);
37
-        if ($nextLevel || $this->traces === []) {
37
+        if ($nextLevel || $this->traces === []){
38 38
             $this->traces[] = $trace instanceof \Spiral\Core\Internal\Tracer\Trace ? [$trace] : [];
39
-        } elseif ($trace instanceof \Spiral\Core\Internal\Tracer\Trace) {
39
+        } elseif ($trace instanceof \Spiral\Core\Internal\Tracer\Trace){
40 40
             $this->traces[\array_key_last($this->traces)][] = $trace;
41 41
         }
42 42
     }
43 43
 
44 44
     public function pop(bool $previousLevel = false): void
45 45
     {
46
-        if ($this->traces === []) {
46
+        if ($this->traces === []){
47 47
             return;
48 48
         }
49
-        if ($previousLevel) {
49
+        if ($previousLevel){
50 50
             \array_pop($this->traces);
51 51
             return;
52 52
         }
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
     {
68 68
         $result = [];
69 69
         $i = 0;
70
-        foreach ($blocks as $block) {
70
+        foreach ($blocks as $block){
71 71
             \array_push($result, ...$this->blockToStringList($block, $i++));
72 72
         }
73 73
         return \implode("\n", $result);
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
         // Separator
88 88
         $s = "\n";
89 89
         $nexPrefix = "$s$padding  ";
90
-        foreach ($items as $item) {
91
-            $result[] = $firstPrefix . \str_replace($s, $nexPrefix, (string)$item);
90
+        foreach ($items as $item){
91
+            $result[] = $firstPrefix.\str_replace($s, $nexPrefix, (string)$item);
92 92
         }
93 93
         return $result;
94 94
     }
Please login to merge, or discard this patch.
Braces   +13 added lines, -6 removed lines patch added patch discarded remove patch
@@ -34,19 +34,24 @@  discard block
 block discarded – undo
34 34
     public function push(bool $nextLevel, mixed ...$details): void
35 35
     {
36 36
         $trace = $details === [] ? null : new Trace($details);
37
-        if ($nextLevel || $this->traces === []) {
37
+        if ($nextLevel || $this->traces === [])
38
+        {
38 39
             $this->traces[] = $trace instanceof \Spiral\Core\Internal\Tracer\Trace ? [$trace] : [];
39
-        } elseif ($trace instanceof \Spiral\Core\Internal\Tracer\Trace) {
40
+        }
41
+        elseif ($trace instanceof \Spiral\Core\Internal\Tracer\Trace)
42
+        {
40 43
             $this->traces[\array_key_last($this->traces)][] = $trace;
41 44
         }
42 45
     }
43 46
 
44 47
     public function pop(bool $previousLevel = false): void
45 48
     {
46
-        if ($this->traces === []) {
49
+        if ($this->traces === [])
50
+        {
47 51
             return;
48 52
         }
49
-        if ($previousLevel) {
53
+        if ($previousLevel)
54
+        {
50 55
             \array_pop($this->traces);
51 56
             return;
52 57
         }
@@ -67,7 +72,8 @@  discard block
 block discarded – undo
67 72
     {
68 73
         $result = [];
69 74
         $i = 0;
70
-        foreach ($blocks as $block) {
75
+        foreach ($blocks as $block)
76
+        {
71 77
             \array_push($result, ...$this->blockToStringList($block, $i++));
72 78
         }
73 79
         return \implode("\n", $result);
@@ -87,7 +93,8 @@  discard block
 block discarded – undo
87 93
         // Separator
88 94
         $s = "\n";
89 95
         $nexPrefix = "$s$padding  ";
90
-        foreach ($items as $item) {
96
+        foreach ($items as $item)
97
+        {
91 98
             $result[] = $firstPrefix . \str_replace($s, $nexPrefix, (string)$item);
92 99
         }
93 100
         return $result;
Please login to merge, or discard this patch.
src/Core/src/ContainerScope.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -34,26 +34,26 @@  discard block
 block discarded – undo
34 34
      */
35 35
     public static function runScope(ContainerInterface $container, callable $scope): mixed
36 36
     {
37
-        if (Proxy::isProxy($container)) {
37
+        if (Proxy::isProxy($container)){
38 38
             // Ignore Proxy to avoid recursion
39 39
             $container = $previous = self::$container ?? throw new ContainerException('Proxy is out of scope.');
40
-        } else {
40
+        }else{
41 41
             [$previous, self::$container] = [self::$container, $container];
42 42
         }
43 43
 
44
-        try {
45
-            if (!Fiber::getCurrent() instanceof \Fiber) {
44
+        try{
45
+            if (!Fiber::getCurrent() instanceof \Fiber){
46 46
                 return $scope(self::$container);
47 47
             }
48 48
 
49 49
             // Wrap scope into fiber
50 50
             $fiber = new Fiber(static fn () => $scope(self::$container));
51 51
             $value = $fiber->start();
52
-            while (!$fiber->isTerminated()) {
52
+            while (!$fiber->isTerminated()){
53 53
                 self::$container = $previous;
54
-                try {
54
+                try{
55 55
                     $resume = Fiber::suspend($value);
56
-                } catch (Throwable $e) {
56
+                }catch (Throwable $e){
57 57
                     self::$container = $container;
58 58
                     $value = $fiber->throw($e);
59 59
                     continue;
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
                 $value = $fiber->resume($resume);
64 64
             }
65 65
             return $fiber->getReturn();
66
-        } finally {
66
+        }finally{
67 67
             self::$container = $previous;
68 68
         }
69 69
     }
Please login to merge, or discard this patch.
Braces   +19 added lines, -8 removed lines patch added patch discarded remove patch
@@ -34,26 +34,35 @@  discard block
 block discarded – undo
34 34
      */
35 35
     public static function runScope(ContainerInterface $container, callable $scope): mixed
36 36
     {
37
-        if (Proxy::isProxy($container)) {
37
+        if (Proxy::isProxy($container))
38
+        {
38 39
             // Ignore Proxy to avoid recursion
39 40
             $container = $previous = self::$container ?? throw new ContainerException('Proxy is out of scope.');
40
-        } else {
41
+        }
42
+        else
43
+        {
41 44
             [$previous, self::$container] = [self::$container, $container];
42 45
         }
43 46
 
44
-        try {
45
-            if (!Fiber::getCurrent() instanceof \Fiber) {
47
+        try
48
+        {
49
+            if (!Fiber::getCurrent() instanceof \Fiber)
50
+            {
46 51
                 return $scope(self::$container);
47 52
             }
48 53
 
49 54
             // Wrap scope into fiber
50 55
             $fiber = new Fiber(static fn () => $scope(self::$container));
51 56
             $value = $fiber->start();
52
-            while (!$fiber->isTerminated()) {
57
+            while (!$fiber->isTerminated())
58
+            {
53 59
                 self::$container = $previous;
54
-                try {
60
+                try
61
+                {
55 62
                     $resume = Fiber::suspend($value);
56
-                } catch (Throwable $e) {
63
+                }
64
+                catch (Throwable $e)
65
+                {
57 66
                     self::$container = $container;
58 67
                     $value = $fiber->throw($e);
59 68
                     continue;
@@ -63,7 +72,9 @@  discard block
 block discarded – undo
63 72
                 $value = $fiber->resume($resume);
64 73
             }
65 74
             return $fiber->getReturn();
66
-        } finally {
75
+        }
76
+        finally
77
+        {
67 78
             self::$container = $previous;
68 79
         }
69 80
     }
Please login to merge, or discard this patch.
src/Stempler/tests/Transform/BaseTestCase.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 {
28 28
     protected function compile(string $source, array $visitors = [], ?LoaderInterface $loader = null)
29 29
     {
30
-        if (!$loader instanceof \Spiral\Stempler\Loader\LoaderInterface) {
30
+        if (!$loader instanceof \Spiral\Stempler\Loader\LoaderInterface){
31 31
             $loader = new StringLoader();
32 32
             $loader->set('root', $source);
33 33
         }
@@ -62,11 +62,11 @@  discard block
 block discarded – undo
62 62
         $builder->getCompiler()->addRenderer(new DynamicRenderer(new DirectiveGroup()));
63 63
         $builder->getCompiler()->addRenderer(new HTMLRenderer());
64 64
 
65
-        foreach ($this->getVisitors() as $visitor) {
65
+        foreach ($this->getVisitors() as $visitor){
66 66
             $builder->addVisitor($visitor);
67 67
         }
68 68
 
69
-        foreach ($visitors as $visitor) {
69
+        foreach ($visitors as $visitor){
70 70
             $builder->addVisitor($visitor);
71 71
         }
72 72
 
@@ -80,6 +80,6 @@  discard block
 block discarded – undo
80 80
 
81 81
     protected function getFixtureLoader(): LoaderInterface
82 82
     {
83
-        return new DirectoryLoader(__DIR__ . '/../fixtures');
83
+        return new DirectoryLoader(__DIR__.'/../fixtures');
84 84
     }
85 85
 }
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -27,7 +27,8 @@  discard block
 block discarded – undo
27 27
 {
28 28
     protected function compile(string $source, array $visitors = [], ?LoaderInterface $loader = null)
29 29
     {
30
-        if (!$loader instanceof \Spiral\Stempler\Loader\LoaderInterface) {
30
+        if (!$loader instanceof \Spiral\Stempler\Loader\LoaderInterface)
31
+        {
31 32
             $loader = new StringLoader();
32 33
             $loader->set('root', $source);
33 34
         }
@@ -62,11 +63,13 @@  discard block
 block discarded – undo
62 63
         $builder->getCompiler()->addRenderer(new DynamicRenderer(new DirectiveGroup()));
63 64
         $builder->getCompiler()->addRenderer(new HTMLRenderer());
64 65
 
65
-        foreach ($this->getVisitors() as $visitor) {
66
+        foreach ($this->getVisitors() as $visitor)
67
+        {
66 68
             $builder->addVisitor($visitor);
67 69
         }
68 70
 
69
-        foreach ($visitors as $visitor) {
71
+        foreach ($visitors as $visitor)
72
+        {
70 73
             $builder->addVisitor($visitor);
71 74
         }
72 75
 
Please login to merge, or discard this patch.
src/Stempler/src/Transform/Import/Bundle.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -23,19 +23,19 @@  discard block
 block discarded – undo
23 23
         private string $path,
24 24
         private ?string $prefix = null,
25 25
         ?Context $context = null,
26
-    ) {
26
+    ){
27 27
         $this->context = $context;
28 28
     }
29 29
 
30 30
     public function resolve(Builder $builder, string $name): ?Template
31 31
     {
32
-        if (!$this->template instanceof \Spiral\Stempler\Node\Template) {
32
+        if (!$this->template instanceof \Spiral\Stempler\Node\Template){
33 33
             $this->template = $builder->load($this->path);
34 34
         }
35 35
 
36 36
         $path = $name;
37
-        if ($this->prefix !== null) {
38
-            if (!TagHelper::hasPrefix($name, $this->prefix)) {
37
+        if ($this->prefix !== null){
38
+            if (!TagHelper::hasPrefix($name, $this->prefix)){
39 39
                 return null;
40 40
             }
41 41
 
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
         }
44 44
 
45 45
         /** @var ImportInterface $import */
46
-        foreach ($this->template->getAttribute(ImportContext::class, []) as $import) {
46
+        foreach ($this->template->getAttribute(ImportContext::class, []) as $import){
47 47
             $tpl = $import->resolve($builder, $path);
48
-            if ($tpl !== null) {
48
+            if ($tpl !== null){
49 49
                 return $tpl;
50 50
             }
51 51
         }
Please login to merge, or discard this patch.
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -29,13 +29,16 @@  discard block
 block discarded – undo
29 29
 
30 30
     public function resolve(Builder $builder, string $name): ?Template
31 31
     {
32
-        if (!$this->template instanceof \Spiral\Stempler\Node\Template) {
32
+        if (!$this->template instanceof \Spiral\Stempler\Node\Template)
33
+        {
33 34
             $this->template = $builder->load($this->path);
34 35
         }
35 36
 
36 37
         $path = $name;
37
-        if ($this->prefix !== null) {
38
-            if (!TagHelper::hasPrefix($name, $this->prefix)) {
38
+        if ($this->prefix !== null)
39
+        {
40
+            if (!TagHelper::hasPrefix($name, $this->prefix))
41
+            {
39 42
                 return null;
40 43
             }
41 44
 
@@ -43,9 +46,11 @@  discard block
 block discarded – undo
43 46
         }
44 47
 
45 48
         /** @var ImportInterface $import */
46
-        foreach ($this->template->getAttribute(ImportContext::class, []) as $import) {
49
+        foreach ($this->template->getAttribute(ImportContext::class, []) as $import)
50
+        {
47 51
             $tpl = $import->resolve($builder, $path);
48
-            if ($tpl !== null) {
52
+            if ($tpl !== null)
53
+            {
49 54
                 return $tpl;
50 55
             }
51 56
         }
Please login to merge, or discard this patch.