Passed
Pull Request — master (#941)
by Aleksei
09:16
created
src/Core/src/Config/Inflector.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
      */
19 19
     public function __construct(
20 20
         public readonly \Closure $inflector,
21
-    ) {
21
+    ){
22 22
         $this->parametersCount = (new \ReflectionFunction($inflector))->getNumberOfParameters();
23 23
     }
24 24
 
Please login to merge, or discard this patch.
src/Core/src/Config/WeakReference.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 {
12 12
     public function __construct(
13 13
         public \WeakReference $reference,
14
-    ) {
14
+    ){
15 15
     }
16 16
 
17 17
     public function __toString(): string
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
@@ -11,11 +11,11 @@
 block discarded – undo
11 11
 {
12 12
     public function __construct(
13 13
         public readonly object $value,
14
-    ) {
14
+    ){
15 15
     }
16 16
 
17 17
     public function __toString(): string
18 18
     {
19
-        return 'Shared object of class ' . $this->value::class;
19
+        return 'Shared object of class '.$this->value::class;
20 20
     }
21 21
 }
Please login to merge, or discard this patch.
src/Core/src/Config/Alias.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
     public function __construct(
13 13
         public readonly string $alias,
14 14
         public readonly bool $singleton = false,
15
-    ) {
15
+    ){
16 16
     }
17 17
 
18 18
     public function __toString(): string
Please login to merge, or discard this patch.
src/Core/src/Config/DeferredFactory.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
     public function __construct(
16 16
         public readonly array $factory,
17 17
         public readonly bool $singleton = false,
18
-    ) {
18
+    ){
19 19
     }
20 20
 
21 21
     public function __toString(): string
Please login to merge, or discard this patch.
src/Core/src/Config/Factory.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
     public function __construct(
19 19
         callable $callable,
20 20
         public readonly bool $singleton = false,
21
-    ) {
21
+    ){
22 22
         $this->factory = $callable(...);
23 23
         $this->parametersCount = (new \ReflectionFunction($this->factory))->getNumberOfParameters();
24 24
         $this->definition = match (true) {
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
                 \is_object($callable[0]) ? $callable[0]::class : $callable[0],
29 29
                 $callable[1]
30 30
             ),
31
-            \is_object($callable) && $callable::class !== \Closure::class => 'object ' . $callable::class,
31
+            \is_object($callable) && $callable::class !== \Closure::class => 'object '.$callable::class,
32 32
             default => null,
33 33
         };
34 34
     }
Please login to merge, or discard this patch.
src/Core/src/Config/Autowire.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
     public function __construct(
15 15
         public readonly AutowireAlias $autowire,
16 16
         public readonly bool $singleton = false,
17
-    ) {
17
+    ){
18 18
     }
19 19
 
20 20
     public function __toString(): string
Please login to merge, or discard this patch.
src/Core/src/Container.php 2 patches
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -49,11 +49,11 @@  discard block
 block discarded – undo
49 49
     public const DEFAULT_ROOT_SCOPE_NAME = 'root';
50 50
 
51 51
     private Internal\State $state;
52
-    private ResolverInterface|Internal\Resolver $resolver;
53
-    private FactoryInterface|Internal\Factory $factory;
54
-    private ContainerInterface|Internal\Container $container;
55
-    private BinderInterface|Internal\Binder $binder;
56
-    private InvokerInterface|Internal\Invoker $invoker;
52
+    private ResolverInterface | Internal\Resolver $resolver;
53
+    private FactoryInterface | Internal\Factory $factory;
54
+    private ContainerInterface | Internal\Container $container;
55
+    private BinderInterface | Internal\Binder $binder;
56
+    private InvokerInterface | Internal\Invoker $invoker;
57 57
     private Internal\Scope $scope;
58 58
 
59 59
     /**
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
     public function __construct(
63 63
         private Config $config = new Config(),
64 64
         ?string $scopeName = self::DEFAULT_ROOT_SCOPE_NAME,
65
-    ) {
65
+    ){
66 66
         $this->initServices($this, $scopeName);
67 67
 
68 68
         /** @psalm-suppress RedundantPropertyInitializationCheck */
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
      *
141 141
      * @psalm-suppress InvalidArgument, InvalidCast
142 142
      */
143
-    public function get(string|Autowire $id, string $context = null): mixed
143
+    public function get(string | Autowire $id, string $context = null): mixed
144 144
     {
145 145
         /** @psalm-suppress TooManyArguments */
146 146
         return $this->container->get($id, $context);
@@ -168,16 +168,16 @@  discard block
 block discarded – undo
168 168
         $binds = &$this->state->bindings;
169 169
         $singletons = &$this->state->singletons;
170 170
         $cleanup = $previous = $prevSin = [];
171
-        foreach ($bindings as $alias => $resolver) {
171
+        foreach ($bindings as $alias => $resolver){
172 172
             // Store previous bindings
173
-            if (isset($binds[$alias])) {
173
+            if (isset($binds[$alias])){
174 174
                 $previous[$alias] = $binds[$alias];
175
-            } else {
175
+            }else{
176 176
                 // Store bindings to be removed
177 177
                 $cleanup[] = $alias;
178 178
             }
179 179
             // Store previous singletons
180
-            if (isset($singletons[$alias])) {
180
+            if (isset($singletons[$alias])){
181 181
                 $prevSin[$alias] = $singletons[$alias];
182 182
                 unset($singletons[$alias]);
183 183
             }
@@ -185,21 +185,21 @@  discard block
 block discarded – undo
185 185
             $this->binder->bind($alias, $resolver);
186 186
         }
187 187
 
188
-        try {
188
+        try{
189 189
             return ContainerScope::getContainer() !== $this
190 190
                 ? ContainerScope::runScope($this, $scope)
191 191
                 : $scope($this);
192
-        } finally {
192
+        }finally{
193 193
             // Remove new bindings
194
-            foreach ($cleanup as $alias) {
194
+            foreach ($cleanup as $alias){
195 195
                 unset($binds[$alias], $singletons[$alias]);
196 196
             }
197 197
             // Restore previous bindings
198
-            foreach ($previous as $alias => $resolver) {
198
+            foreach ($previous as $alias => $resolver){
199 199
                 $binds[$alias] = $resolver;
200 200
             }
201 201
             // Restore singletons
202
-            foreach ($prevSin as $alias => $instance) {
202
+            foreach ($prevSin as $alias => $instance){
203 203
                 $singletons[$alias] = $instance;
204 204
             }
205 205
         }
@@ -213,32 +213,32 @@  discard block
 block discarded – undo
213 213
         // Open scope
214 214
         $container = new self($this->config, $name);
215 215
 
216
-        try {
216
+        try{
217 217
             // Configure scope
218 218
             $container->scope->setParent($this, $this->scope);
219 219
 
220 220
             // Add specific bindings
221
-            foreach ($bindings as $alias => $resolver) {
221
+            foreach ($bindings as $alias => $resolver){
222 222
                 $container->binder->bind($alias, $resolver);
223 223
             }
224 224
 
225 225
             return ContainerScope::runScope(
226 226
                 $container,
227 227
                 static function (self $container) use ($autowire, $closure): mixed {
228
-                    try {
228
+                    try{
229 229
                         return $autowire
230 230
                             ? $container->invoke($closure)
231 231
                             : $closure($container);
232
-                    } finally {
232
+                    }finally{
233 233
                         $container->closeScope();
234 234
                     }
235 235
                 }
236 236
             );
237
-        } finally {
237
+        }finally{
238 238
             // Check the container has not been leaked
239 239
             $link = \WeakReference::create($container);
240 240
             unset($container);
241
-            if ($link->get() !== null) {
241
+            if ($link->get() !== null){
242 242
                 throw new ScopeContainerLeakedException($name, $this->scope->getParentScopeNames());
243 243
             }
244 244
         }
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
      *
271 271
      * @psalm-param TResolver $resolver
272 272
      */
273
-    public function bindSingleton(string $alias, string|array|callable|object $resolver): void
273
+    public function bindSingleton(string $alias, string | array | callable | object $resolver): void
274 274
     {
275 275
         $this->binder->bindSingleton($alias, $resolver);
276 276
     }
@@ -340,8 +340,8 @@  discard block
 block discarded – undo
340 340
         ]);
341 341
 
342 342
         // Create container services
343
-        foreach ($container->config as $property => $class) {
344
-            if (\property_exists($container, $property)) {
343
+        foreach ($container->config as $property => $class){
344
+            if (\property_exists($container, $property)){
345 345
                 $container->$property = $constructor->get($property, $class);
346 346
             }
347 347
         }
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
     private function closeScope(): void
356 356
     {
357 357
         /** @psalm-suppress RedundantPropertyInitializationCheck */
358
-        if (!isset($this->scope)) {
358
+        if (!isset($this->scope)){
359 359
             $this->destruct();
360 360
             return;
361 361
         }
@@ -364,10 +364,10 @@  discard block
 block discarded – undo
364 364
 
365 365
         // Run finalizers
366 366
         $errors = [];
367
-        foreach ($this->state->finalizers as $finalizer) {
368
-            try {
367
+        foreach ($this->state->finalizers as $finalizer){
368
+            try{
369 369
                 $this->invoker->invoke($finalizer);
370
-            } catch (\Throwable $e) {
370
+            }catch (\Throwable $e){
371 371
                 $errors[] = $e;
372 372
             }
373 373
         }
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
         $this->destruct();
377 377
 
378 378
         // Throw collected errors
379
-        if ($errors !== []) {
379
+        if ($errors !== []){
380 380
             throw new FinalizersException($scopeName, $errors);
381 381
         }
382 382
     }
Please login to merge, or discard this patch.
Braces   +49 added lines, -22 removed lines patch added patch discarded remove patch
@@ -168,16 +168,21 @@  discard block
 block discarded – undo
168 168
         $binds = &$this->state->bindings;
169 169
         $singletons = &$this->state->singletons;
170 170
         $cleanup = $previous = $prevSin = [];
171
-        foreach ($bindings as $alias => $resolver) {
171
+        foreach ($bindings as $alias => $resolver)
172
+        {
172 173
             // Store previous bindings
173
-            if (isset($binds[$alias])) {
174
+            if (isset($binds[$alias]))
175
+            {
174 176
                 $previous[$alias] = $binds[$alias];
175
-            } else {
177
+            }
178
+            else
179
+            {
176 180
                 // Store bindings to be removed
177 181
                 $cleanup[] = $alias;
178 182
             }
179 183
             // Store previous singletons
180
-            if (isset($singletons[$alias])) {
184
+            if (isset($singletons[$alias]))
185
+            {
181 186
                 $prevSin[$alias] = $singletons[$alias];
182 187
                 unset($singletons[$alias]);
183 188
             }
@@ -185,21 +190,27 @@  discard block
 block discarded – undo
185 190
             $this->binder->bind($alias, $resolver);
186 191
         }
187 192
 
188
-        try {
193
+        try
194
+        {
189 195
             return ContainerScope::getContainer() !== $this
190 196
                 ? ContainerScope::runScope($this, $scope)
191 197
                 : $scope($this);
192
-        } finally {
198
+        }
199
+        finally
200
+        {
193 201
             // Remove new bindings
194
-            foreach ($cleanup as $alias) {
202
+            foreach ($cleanup as $alias)
203
+            {
195 204
                 unset($binds[$alias], $singletons[$alias]);
196 205
             }
197 206
             // Restore previous bindings
198
-            foreach ($previous as $alias => $resolver) {
207
+            foreach ($previous as $alias => $resolver)
208
+            {
199 209
                 $binds[$alias] = $resolver;
200 210
             }
201 211
             // Restore singletons
202
-            foreach ($prevSin as $alias => $instance) {
212
+            foreach ($prevSin as $alias => $instance)
213
+            {
203 214
                 $singletons[$alias] = $instance;
204 215
             }
205 216
         }
@@ -213,32 +224,40 @@  discard block
 block discarded – undo
213 224
         // Open scope
214 225
         $container = new self($this->config, $name);
215 226
 
216
-        try {
227
+        try
228
+        {
217 229
             // Configure scope
218 230
             $container->scope->setParent($this, $this->scope);
219 231
 
220 232
             // Add specific bindings
221
-            foreach ($bindings as $alias => $resolver) {
233
+            foreach ($bindings as $alias => $resolver)
234
+            {
222 235
                 $container->binder->bind($alias, $resolver);
223 236
             }
224 237
 
225 238
             return ContainerScope::runScope(
226 239
                 $container,
227 240
                 static function (self $container) use ($autowire, $closure): mixed {
228
-                    try {
241
+                    try
242
+                    {
229 243
                         return $autowire
230 244
                             ? $container->invoke($closure)
231 245
                             : $closure($container);
232
-                    } finally {
246
+                    }
247
+                    finally
248
+                    {
233 249
                         $container->closeScope();
234 250
                     }
235 251
                 }
236 252
             );
237
-        } finally {
253
+        }
254
+        finally
255
+        {
238 256
             // Check the container has not been leaked
239 257
             $link = \WeakReference::create($container);
240 258
             unset($container);
241
-            if ($link->get() !== null) {
259
+            if ($link->get() !== null)
260
+            {
242 261
                 throw new ScopeContainerLeakedException($name, $this->scope->getParentScopeNames());
243 262
             }
244 263
         }
@@ -340,8 +359,10 @@  discard block
 block discarded – undo
340 359
         ]);
341 360
 
342 361
         // Create container services
343
-        foreach ($container->config as $property => $class) {
344
-            if (\property_exists($container, $property)) {
362
+        foreach ($container->config as $property => $class)
363
+        {
364
+            if (\property_exists($container, $property))
365
+            {
345 366
                 $container->$property = $constructor->get($property, $class);
346 367
             }
347 368
         }
@@ -355,7 +376,8 @@  discard block
 block discarded – undo
355 376
     private function closeScope(): void
356 377
     {
357 378
         /** @psalm-suppress RedundantPropertyInitializationCheck */
358
-        if (!isset($this->scope)) {
379
+        if (!isset($this->scope))
380
+        {
359 381
             $this->destruct();
360 382
             return;
361 383
         }
@@ -364,10 +386,14 @@  discard block
 block discarded – undo
364 386
 
365 387
         // Run finalizers
366 388
         $errors = [];
367
-        foreach ($this->state->finalizers as $finalizer) {
368
-            try {
389
+        foreach ($this->state->finalizers as $finalizer)
390
+        {
391
+            try
392
+            {
369 393
                 $this->invoker->invoke($finalizer);
370
-            } catch (\Throwable $e) {
394
+            }
395
+            catch (\Throwable $e)
396
+            {
371 397
                 $errors[] = $e;
372 398
             }
373 399
         }
@@ -376,7 +402,8 @@  discard block
 block discarded – undo
376 402
         $this->destruct();
377 403
 
378 404
         // Throw collected errors
379
-        if ($errors !== []) {
405
+        if ($errors !== [])
406
+        {
380 407
             throw new FinalizersException($scopeName, $errors);
381 408
         }
382 409
     }
Please login to merge, or discard this patch.