Passed
Pull Request — master (#1221)
by Aleksei
10:45
created
src/Core/tests/ExceptionsTest.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -208,10 +208,10 @@  discard block
 block discarded – undo
208 208
                 context: Parameter #1 [ <required> Spiral\Tests\Core\Fixtures\InvalidClass $class ]
209 209
             MARKDOWN;
210 210
 
211
-        try {
211
+        try{
212 212
             $container->get(InvalidWithContainerInside::class);
213 213
             self::fail('Exception `ContainerException` expected');
214
-        } catch (ContainerException $e) {
214
+        }catch (ContainerException $e){
215 215
             self::assertSame($expectedMessage, $e->getMessage());
216 216
         }
217 217
     }
@@ -234,9 +234,9 @@  discard block
 block discarded – undo
234 234
     {
235 235
         $container = new Container();
236 236
 
237
-        try {
237
+        try{
238 238
             $container->get('invalid');
239
-        } catch (ContainerException $e) {
239
+        }catch (ContainerException $e){
240 240
             self::assertSame(<<<MARKDOWN
241 241
                 Can't autowire `invalid`: class or injector not found.
242 242
                 Resolving trace:
@@ -267,9 +267,9 @@  discard block
 block discarded – undo
267 267
     {
268 268
         $this->expectException(ContainerException::class);
269 269
 
270
-        try {
270
+        try{
271 271
             $container->get(ClassWithUndefinedDependency::class);
272
-        } catch (ContainerException $e) {
272
+        }catch (ContainerException $e){
273 273
             self::assertSame($message, $e->getMessage());
274 274
 
275 275
             throw $e;
Please login to merge, or discard this patch.
src/Core/tests/Scope/ScopeAttributeTest.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 
167 167
         $root = self::makeContainer();
168 168
 
169
-        try {
169
+        try{
170 170
             $root->runScoped(static function (Container $c1): void {
171 171
                 $c1->runScoped(static function (Container $c2): void {
172 172
                     $c2->runScoped(static function (Container $c3): void {
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
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
         }
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
     #[Group('scrutinizer-ignore')]
188 188
     public function testBadScopeException(): void
189 189
     {
190
-        try {
190
+        try{
191 191
             $root = self::makeContainer();
192 192
             $root->runScoped(static function (Container $c1): void {
193 193
                 $c1->runScoped(static function (Container $c2): void {
@@ -195,8 +195,8 @@  discard block
 block discarded – undo
195 195
                 });
196 196
             }, name: 'bar');
197 197
 
198
-            self::fail(BadScopeException::class . ' should be thrown');
199
-        } catch (BadScopeException $e) {
198
+            self::fail(BadScopeException::class.' should be thrown');
199
+        }catch (BadScopeException $e){
200 200
             self::assertSame('foo', $e->getScope());
201 201
         }
202 202
     }
Please login to merge, or discard this patch.
src/Core/tests/Fixtures/PrivateConstructor.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
 
7 7
 final class PrivateConstructor
8 8
 {
9
-    private function __construct() {}
9
+    private function __construct(){}
10 10
 
11 11
     private static function privateMethod(int $result): int
12 12
     {
Please login to merge, or discard this patch.
src/Core/src/Internal/Scope.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 
18 18
     public function __construct(
19 19
         private readonly ?string $scopeName = null,
20
-    ) {}
20
+    ){}
21 21
 
22 22
     public function getScopeName(): ?string
23 23
     {
@@ -39,9 +39,9 @@  discard block
 block discarded – undo
39 39
         $this->parentActor = $actor;
40 40
 
41 41
         // Check a scope with the same name is not already registered
42
-        if ($this->scopeName !== null) {
42
+        if ($this->scopeName !== null){
43 43
             $tmp = $this;
44
-            while ($tmp->parentScope !== null) {
44
+            while ($tmp->parentScope !== null){
45 45
                 $tmp = $tmp->parentScope;
46 46
                 $tmp->scopeName !== $this->scopeName ?: throw new NamedScopeDuplicationException($this->scopeName);
47 47
             }
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
         $result = [$this->scopeName];
65 65
 
66 66
         $parent = $this;
67
-        while ($parent->parentScope !== null) {
67
+        while ($parent->parentScope !== null){
68 68
             $parent = $parent->parentScope;
69 69
             $result[] = $parent->scopeName;
70 70
         }
Please login to merge, or discard this patch.
src/Core/src/Internal/Tracer.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -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 === null ? [] : [$trace];
39
-        } elseif ($trace !== null) {
39
+        } elseif ($trace !== null){
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
         }
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 
63 63
     public function __toString(): string
64 64
     {
65
-        return $this->traces === [] ? '' : "Resolving trace:\n" . self::renderTraceList($this->traces);
65
+        return $this->traces === [] ? '' : "Resolving trace:\n".self::renderTraceList($this->traces);
66 66
     }
67 67
 
68 68
     /**
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
     {
73 73
         $result = [];
74 74
         $i = 0;
75
-        foreach ($blocks as $block) {
75
+        foreach ($blocks as $block){
76 76
             \array_push($result, ...self::blockToStringList($block, $i++));
77 77
         }
78 78
         return \implode("\n", $result);
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
         // Separator
93 93
         $s = "\n";
94 94
         $nexPrefix = "$s$padding  ";
95
-        foreach ($items as $item) {
96
-            $result[] = $firstPrefix . \str_replace($s, $nexPrefix, (string) $item);
95
+        foreach ($items as $item){
96
+            $result[] = $firstPrefix.\str_replace($s, $nexPrefix, (string)$item);
97 97
         }
98 98
         return $result;
99 99
     }
Please login to merge, or discard this patch.
src/Core/src/Container.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -48,11 +48,11 @@  discard block
 block discarded – undo
48 48
     public const DEFAULT_ROOT_SCOPE_NAME = 'root';
49 49
 
50 50
     private Internal\State $state;
51
-    private ResolverInterface|Internal\Resolver $resolver;
52
-    private FactoryInterface|Internal\Factory $factory;
53
-    private ContainerInterface|Internal\Container $container;
54
-    private BinderInterface|Internal\Binder $binder;
55
-    private InvokerInterface|Internal\Invoker $invoker;
51
+    private ResolverInterface | Internal\Resolver $resolver;
52
+    private FactoryInterface | Internal\Factory $factory;
53
+    private ContainerInterface | Internal\Container $container;
54
+    private BinderInterface | Internal\Binder $binder;
55
+    private InvokerInterface | Internal\Invoker $invoker;
56 56
     private Internal\Scope $scope;
57 57
     private Internal\Actor $actor;
58 58
 
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
      */
62 62
     public function __construct(
63 63
         private Config $config = new Config(),
64
-        string|\BackedEnum|null $scopeName = self::DEFAULT_ROOT_SCOPE_NAME,
64
+        string | \BackedEnum | null $scopeName = self::DEFAULT_ROOT_SCOPE_NAME,
65 65
         private Options $options = new Options(),
66
-    ) {
67
-        if (\is_object($scopeName)) {
68
-            $scopeName = (string) $scopeName->value;
66
+    ){
67
+        if (\is_object($scopeName)){
68
+            $scopeName = (string)$scopeName->value;
69 69
         }
70 70
 
71 71
         $this->initServices($this, $scopeName);
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
      * @throws \Throwable
107 107
      * @psalm-suppress TooManyArguments
108 108
      */
109
-    public function make(string $alias, array $parameters = [], \Stringable|string|null $context = null): mixed
109
+    public function make(string $alias, array $parameters = [], \Stringable | string | null $context = null): mixed
110 110
     {
111 111
         return ContainerScope::getContainer() === $this
112 112
             ? $this->factory->make($alias, $parameters, $context)
113
-            : ContainerScope::runScope($this, fn(): mixed => $this->factory->make($alias, $parameters, $context));
113
+            : ContainerScope::runScope($this, fn() : mixed => $this->factory->make($alias, $parameters, $context));
114 114
     }
115 115
 
116 116
     /**
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
      * @throws \Throwable
133 133
      * @psalm-suppress TooManyArguments
134 134
      */
135
-    public function get(string|Autowire $id, \Stringable|string|null $context = null): mixed
135
+    public function get(string | Autowire $id, \Stringable | string | null $context = null): mixed
136 136
     {
137 137
         return ContainerScope::getContainer() === $this
138 138
             ? $this->container->get($id, $context)
@@ -152,9 +152,9 @@  discard block
 block discarded – undo
152 152
      *        If {@see string}, the default binder for the given scope will be returned. Default bindings won't affect
153 153
      *        already created Container instances except the case with the root one.
154 154
      */
155
-    public function getBinder(string|\BackedEnum|null $scope = null): BinderInterface
155
+    public function getBinder(string | \BackedEnum | null $scope = null): BinderInterface
156 156
     {
157
-        $scope = \is_object($scope) ? (string) $scope->value : $scope;
157
+        $scope = \is_object($scope) ? (string)$scope->value : $scope;
158 158
 
159 159
         return $scope === null
160 160
             ? $this->binder
@@ -164,25 +164,25 @@  discard block
 block discarded – undo
164 164
     /**
165 165
      * @throws \Throwable
166 166
      */
167
-    public function runScope(Scope|array $bindings, callable $scope): mixed
167
+    public function runScope(Scope | array $bindings, callable $scope): mixed
168 168
     {
169
-        if (!\is_array($bindings)) {
169
+        if (!\is_array($bindings)){
170 170
             return $this->runIsolatedScope($bindings, $scope);
171 171
         }
172 172
 
173 173
         $binds = &$this->state->bindings;
174 174
         $singletons = &$this->state->singletons;
175 175
         $cleanup = $previous = $prevSin = [];
176
-        foreach ($bindings as $alias => $resolver) {
176
+        foreach ($bindings as $alias => $resolver){
177 177
             // Store previous bindings
178
-            if (isset($binds[$alias])) {
178
+            if (isset($binds[$alias])){
179 179
                 $previous[$alias] = $binds[$alias];
180
-            } else {
180
+            }else{
181 181
                 // Store bindings to be removed
182 182
                 $cleanup[] = $alias;
183 183
             }
184 184
             // Store previous singletons
185
-            if (isset($singletons[$alias])) {
185
+            if (isset($singletons[$alias])){
186 186
                 $prevSin[$alias] = $singletons[$alias];
187 187
                 unset($singletons[$alias]);
188 188
             }
@@ -190,21 +190,21 @@  discard block
 block discarded – undo
190 190
             $this->binder->bind($alias, $resolver);
191 191
         }
192 192
 
193
-        try {
193
+        try{
194 194
             return ContainerScope::getContainer() !== $this
195 195
                 ? ContainerScope::runScope($this, $scope)
196 196
                 : $scope($this);
197
-        } finally {
197
+        }finally{
198 198
             // Remove new bindings
199
-            foreach ($cleanup as $alias) {
199
+            foreach ($cleanup as $alias){
200 200
                 unset($binds[$alias], $singletons[$alias]);
201 201
             }
202 202
             // Restore previous bindings
203
-            foreach ($previous as $alias => $resolver) {
203
+            foreach ($previous as $alias => $resolver){
204 204
                 $binds[$alias] = $resolver;
205 205
             }
206 206
             // Restore singletons
207
-            foreach ($prevSin as $alias => $instance) {
207
+            foreach ($prevSin as $alias => $instance){
208 208
                 $singletons[$alias] = $instance;
209 209
             }
210 210
         }
@@ -252,9 +252,9 @@  discard block
 block discarded – undo
252 252
      *        If the value is null, option {@see Options::$allowSingletonsRebinding} will be used.
253 253
      * @throws SingletonOverloadException
254 254
      */
255
-    public function bindSingleton(string $alias, string|array|callable|object $resolver, ?bool $force = null): void
255
+    public function bindSingleton(string $alias, string | array | callable | object $resolver, ?bool $force = null): void
256 256
     {
257
-        if ($force ?? $this->options->allowSingletonsRebinding) {
257
+        if ($force ?? $this->options->allowSingletonsRebinding){
258 258
             $this->binder->removeBinding($alias);
259 259
         }
260 260
 
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
     {
282 282
         return ContainerScope::getContainer() === $this
283 283
             ? $this->invoker->invoke($target, $parameters)
284
-            : ContainerScope::runScope($this, fn(): mixed => $this->invoker->invoke($target, $parameters));
284
+            : ContainerScope::runScope($this, fn() : mixed => $this->invoker->invoke($target, $parameters));
285 285
     }
286 286
 
287 287
     /**
@@ -338,8 +338,8 @@  discard block
 block discarded – undo
338 338
         ], $this->options);
339 339
 
340 340
         // Create container services
341
-        foreach ($container->config as $property => $class) {
342
-            if (\property_exists($container, $property)) {
341
+        foreach ($container->config as $property => $class){
342
+            if (\property_exists($container, $property)){
343 343
                 $container->$property = $constructor->get($property, $class);
344 344
             }
345 345
         }
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
     private function closeScope(): void
354 354
     {
355 355
         /** @psalm-suppress RedundantPropertyInitializationCheck */
356
-        if (!isset($this->scope)) {
356
+        if (!isset($this->scope)){
357 357
             $this->destruct();
358 358
             return;
359 359
         }
@@ -362,10 +362,10 @@  discard block
 block discarded – undo
362 362
 
363 363
         // Run finalizers
364 364
         $errors = [];
365
-        foreach ($this->state->finalizers as $finalizer) {
366
-            try {
365
+        foreach ($this->state->finalizers as $finalizer){
366
+            try{
367 367
                 $this->invoker->invoke($finalizer);
368
-            } catch (\Throwable $e) {
368
+            }catch (\Throwable $e){
369 369
                 $errors[] = $e;
370 370
             }
371 371
         }
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
         $this->destruct();
375 375
 
376 376
         // Throw collected errors
377
-        if ($errors !== []) {
377
+        if ($errors !== []){
378 378
             throw new FinalizersException($scopeName, $errors);
379 379
         }
380 380
     }
@@ -396,18 +396,18 @@  discard block
 block discarded – undo
396 396
         $container->scope->setParent($this, $this->scope, $this->actor);
397 397
 
398 398
         // Add specific bindings
399
-        foreach ($config->bindings as $alias => $resolver) {
399
+        foreach ($config->bindings as $alias => $resolver){
400 400
             $container->binder->bind($alias, $resolver);
401 401
         }
402 402
 
403 403
         return ContainerScope::runScope(
404 404
             $container,
405 405
             static function (self $container) use ($config, $closure): mixed {
406
-                try {
406
+                try{
407 407
                     return $config->autowire
408 408
                         ? $container->invoke($closure)
409 409
                         : $closure($container);
410
-                } finally {
410
+                }finally{
411 411
                     $container->closeScope();
412 412
                 }
413 413
             },
Please login to merge, or discard this patch.
src/Core/src/Config.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         public readonly string $container = Container::class,
51 51
         public readonly string $binder = Binder::class,
52 52
         public readonly string $invoker = Invoker::class,
53
-    ) {
53
+    ){
54 54
         $this->scope = Scope::class;
55 55
         $this->scopedBindings = new Internal\Config\StateStorage();
56 56
         $this->actor = Actor::class;
@@ -75,9 +75,9 @@  discard block
 block discarded – undo
75 75
      */
76 76
     public function lockRoot(): bool
77 77
     {
78
-        try {
78
+        try{
79 79
             return $this->rootLocked;
80
-        } finally {
80
+        }finally{
81 81
             $this->rootLocked = false;
82 82
         }
83 83
     }
Please login to merge, or discard this patch.
src/Core/src/Config/Factory.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,13 +22,13 @@  discard block
 block discarded – undo
22 22
     public function __construct(
23 23
         callable $callable,
24 24
         public readonly bool $singleton = false,
25
-    ) {
25
+    ){
26 26
         $this->factory = $callable(...);
27 27
         $reflection = new \ReflectionFunction($this->factory);
28 28
         $this->parametersCount = $reflection->getNumberOfParameters();
29 29
 
30 30
         // Detect the return type of the factory
31
-        $returnType = (string) $reflection->getReturnType();
31
+        $returnType = (string)$reflection->getReturnType();
32 32
         $this->returnClass = \class_exists($returnType) ? $returnType : null;
33 33
 
34 34
         /** @psalm-suppress TypeDoesNotContainType */
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
                 \is_object($callable[0]) ? $callable[0]::class : $callable[0],
40 40
                 $callable[1],
41 41
             ),
42
-            \is_object($callable) && $callable::class !== \Closure::class => 'object ' . $callable::class,
42
+            \is_object($callable) && $callable::class !== \Closure::class => 'object '.$callable::class,
43 43
             default => null,
44 44
         };
45 45
     }
Please login to merge, or discard this patch.
src/Core/src/Config/Shared.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,11 +12,11 @@
 block discarded – undo
12 12
     public function __construct(
13 13
         public readonly object $value,
14 14
         public readonly bool $singleton = false,
15
-    ) {}
15
+    ){}
16 16
 
17 17
     public function __toString(): string
18 18
     {
19
-        return 'Shared object of class ' . $this->value::class;
19
+        return 'Shared object of class '.$this->value::class;
20 20
     }
21 21
 
22 22
     /**
Please login to merge, or discard this patch.