Passed
Pull Request — master (#656)
by Abdul Malik
09:21
created
src/Core/src/Container.php 2 patches
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
     {
99 99
         $arguments = [];
100 100
 
101
-        foreach ($reflection->getParameters() as $parameter) {
101
+        foreach ($reflection->getParameters() as $parameter){
102 102
             $type = $parameter->getType();
103 103
             $name = $parameter->getName();
104 104
             $class = null;
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
              * Container do not currently support union types. In the future, we
108 108
              * can provide the possibility of autowiring based on priorities (TBD).
109 109
              */
110
-            if ($type instanceof ReflectionUnionType) {
110
+            if ($type instanceof ReflectionUnionType){
111 111
                 $error = 'Parameter $%s in %s contains a union type hint that cannot be inferred unambiguously';
112 112
                 $error = \sprintf($error, $reflection->getName(), $this->getLocationString($reflection));
113 113
 
@@ -117,17 +117,17 @@  discard block
 block discarded – undo
117 117
             /**
118 118
              * Container do not currently support intersection types.
119 119
              */
120
-            if ($type instanceof ReflectionIntersectionType) {
120
+            if ($type instanceof ReflectionIntersectionType){
121 121
                 $error = 'Parameter $%s in %s contains a intersection type hint that cannot be inferred unambiguously';
122 122
                 $error = \sprintf($error, $reflection->getName(), $this->getLocationString($reflection));
123 123
 
124 124
                 throw new ContainerException($error);
125 125
             }
126 126
 
127
-            if ($type instanceof ReflectionNamedType && !$type->isBuiltin()) {
128
-                try {
127
+            if ($type instanceof ReflectionNamedType && !$type->isBuiltin()){
128
+                try{
129 129
                     $class = new ReflectionClass($type->getName());
130
-                } catch (ReflectionException $e) {
130
+                }catch (ReflectionException $e){
131 131
                     $location = $this->getLocationString($reflection);
132 132
 
133 133
                     $error = 'Unable to resolve `\$%s` parameter in %s: %s';
@@ -137,11 +137,11 @@  discard block
 block discarded – undo
137 137
                 }
138 138
             }
139 139
 
140
-            if (isset($parameters[$name]) && is_object($parameters[$name])) {
141
-                if ($parameters[$name] instanceof Autowire) {
140
+            if (isset($parameters[$name]) && is_object($parameters[$name])){
141
+                if ($parameters[$name] instanceof Autowire){
142 142
                     // Supplied by user as late dependency
143 143
                     $arguments[] = $parameters[$name]->resolve($this);
144
-                } else {
144
+                }else{
145 145
                     // Supplied by user as object
146 146
                     $arguments[] = $parameters[$name];
147 147
                 }
@@ -149,16 +149,16 @@  discard block
 block discarded – undo
149 149
             }
150 150
 
151 151
             // no declared type or scalar type or array
152
-            if (!isset($class)) {
152
+            if (!isset($class)){
153 153
                 // Provided from outside
154
-                if (\array_key_exists($name, $parameters)) {
154
+                if (\array_key_exists($name, $parameters)){
155 155
                     // Make sure it's properly typed
156 156
                     $this->assertType($parameter, $reflection, $parameters[$name]);
157 157
                     $arguments[] = $parameters[$name];
158 158
                     continue;
159 159
                 }
160 160
 
161
-                if ($parameter->isDefaultValueAvailable()) {
161
+                if ($parameter->isDefaultValueAvailable()){
162 162
                     //Default value
163 163
                     $arguments[] = $parameter->getDefaultValue();
164 164
                     continue;
@@ -168,12 +168,12 @@  discard block
 block discarded – undo
168 168
                 throw new ArgumentException($parameter, $reflection);
169 169
             }
170 170
 
171
-            try {
171
+            try{
172 172
                 //Requesting for contextual dependency
173 173
                 $arguments[] = $this->get($class->getName(), $name);
174 174
                 continue;
175
-            } catch (AutowireException $e) {
176
-                if ($parameter->isOptional()) {
175
+            }catch (AutowireException $e){
176
+                if ($parameter->isOptional()){
177 177
                     //This is optional dependency, skip
178 178
                     $arguments[] = null;
179 179
                     continue;
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
      */
210 210
     public function get($id, string $context = null)
211 211
     {
212
-        if ($id instanceof Autowire) {
212
+        if ($id instanceof Autowire){
213 213
             return $id->resolve($this);
214 214
         }
215 215
 
@@ -230,34 +230,34 @@  discard block
 block discarded – undo
230 230
      */
231 231
     public function make(string $alias, array $parameters = [], string $context = null)
232 232
     {
233
-        if (!isset($this->bindings[$alias])) {
233
+        if (!isset($this->bindings[$alias])){
234 234
             //No direct instructions how to construct class, make is automatically
235 235
             return $this->autowire($alias, $parameters, $context);
236 236
         }
237 237
 
238 238
         $binding = $this->bindings[$alias];
239
-        if (\is_object($binding)) {
239
+        if (\is_object($binding)){
240 240
             //When binding is instance, assuming singleton
241 241
             return $binding;
242 242
         }
243 243
 
244
-        if (\is_string($binding)) {
244
+        if (\is_string($binding)){
245 245
             //Binding is pointing to something else
246 246
             return $this->make($binding, $parameters, $context);
247 247
         }
248 248
 
249 249
         unset($this->bindings[$alias]);
250
-        try {
251
-            if ($binding[0] === $alias) {
250
+        try{
251
+            if ($binding[0] === $alias){
252 252
                 $instance = $this->autowire($alias, $parameters, $context);
253
-            } else {
253
+            }else{
254 254
                 $instance = $this->evaluateBinding($alias, $binding[0], $parameters, $context);
255 255
             }
256
-        } finally {
256
+        }finally{
257 257
             $this->bindings[$alias] = $binding;
258 258
         }
259 259
 
260
-        if ($binding[1]) {
260
+        if ($binding[1]){
261 261
             //Indicates singleton
262 262
             $this->bindings[$alias] = $instance;
263 263
         }
@@ -271,28 +271,28 @@  discard block
 block discarded – undo
271 271
     public function runScope(array $bindings, callable $scope)
272 272
     {
273 273
         $cleanup = $previous = [];
274
-        foreach ($bindings as $alias => $resolver) {
275
-            if (isset($this->bindings[$alias])) {
274
+        foreach ($bindings as $alias => $resolver){
275
+            if (isset($this->bindings[$alias])){
276 276
                 $previous[$alias] = $this->bindings[$alias];
277
-            } else {
277
+            }else{
278 278
                 $cleanup[] = $alias;
279 279
             }
280 280
 
281 281
             $this->bind($alias, $resolver);
282 282
         }
283 283
 
284
-        try {
285
-            if (ContainerScope::getContainer() !== $this) {
284
+        try{
285
+            if (ContainerScope::getContainer() !== $this){
286 286
                 return ContainerScope::runScope($this, $scope);
287 287
             }
288 288
 
289 289
             return $scope();
290
-        } finally {
291
-            foreach (\array_reverse($previous) as $alias => $resolver) {
290
+        }finally{
291
+            foreach (\array_reverse($previous) as $alias => $resolver){
292 292
                 $this->bindings[$alias] = $resolver;
293 293
             }
294 294
 
295
-            foreach ($cleanup as $alias) {
295
+            foreach ($cleanup as $alias){
296 296
                 unset($this->bindings[$alias]);
297 297
             }
298 298
         }
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
      */
308 308
     public function bind(string $alias, $resolver): void
309 309
     {
310
-        if (\is_array($resolver) || $resolver instanceof Closure || $resolver instanceof Autowire) {
310
+        if (\is_array($resolver) || $resolver instanceof Closure || $resolver instanceof Autowire){
311 311
             // array means = execute me, false = not singleton
312 312
             $this->bindings[$alias] = [$resolver, false];
313 313
 
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
      */
326 326
     public function bindSingleton(string $alias, $resolver): void
327 327
     {
328
-        if (\is_object($resolver) && !$resolver instanceof Closure && !$resolver instanceof Autowire) {
328
+        if (\is_object($resolver) && !$resolver instanceof Closure && !$resolver instanceof Autowire){
329 329
             // direct binding to an instance
330 330
             $this->bindings[$alias] = $resolver;
331 331
 
@@ -340,11 +340,11 @@  discard block
 block discarded – undo
340 340
      */
341 341
     public function hasInstance(string $alias): bool
342 342
     {
343
-        if (!$this->has($alias)) {
343
+        if (!$this->has($alias)){
344 344
             return false;
345 345
         }
346 346
 
347
-        while (isset($this->bindings[$alias]) && \is_string($this->bindings[$alias])) {
347
+        while (isset($this->bindings[$alias]) && \is_string($this->bindings[$alias])){
348 348
             //Checking alias tree
349 349
             $alias = $this->bindings[$alias];
350 350
         }
@@ -370,18 +370,18 @@  discard block
 block discarded – undo
370 370
      */
371 371
     public function invoke($target, array $parameters = [])
372 372
     {
373
-        if (\is_array($target) && isset($target[1])) {
373
+        if (\is_array($target) && isset($target[1])){
374 374
             // In a form of resolver and method
375 375
             [$resolver, $method] = $target;
376 376
 
377 377
             // Resolver instance (i.e. [ClassName::class, 'method'])
378
-            if (\is_string($resolver)) {
378
+            if (\is_string($resolver)){
379 379
                 $resolver = $this->get($resolver);
380 380
             }
381 381
 
382
-            try {
382
+            try{
383 383
                 $method = new ReflectionMethod($resolver, $method);
384
-            } catch (ReflectionException $e) {
384
+            }catch (ReflectionException $e){
385 385
                 throw new ContainerException($e->getMessage(), $e->getCode(), $e);
386 386
             }
387 387
 
@@ -394,14 +394,14 @@  discard block
 block discarded – undo
394 394
             );
395 395
         }
396 396
 
397
-        if (\is_string($target) && \is_callable($target)) {
397
+        if (\is_string($target) && \is_callable($target)){
398 398
             $target = Closure::fromCallable($target);
399 399
         }
400 400
 
401
-        if ($target instanceof Closure) {
402
-            try {
401
+        if ($target instanceof Closure){
402
+            try{
403 403
                 $reflection = new ReflectionFunction($target);
404
-            } catch (ReflectionException $e) {
404
+            }catch (ReflectionException $e){
405 405
                 throw new ContainerException($e->getMessage(), $e->getCode(), $e);
406 406
             }
407 407
 
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
      */
462 462
     protected function autowire(string $class, array $parameters, string $context = null)
463 463
     {
464
-        if (!\class_exists($class) && !isset($this->injectors[$class])) {
464
+        if (!\class_exists($class) && !isset($this->injectors[$class])){
465 465
             throw new NotFoundException(\sprintf("Undefined class or binding '%s'", $class));
466 466
         }
467 467
 
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
     {
477 477
         $location = $reflection->getName();
478 478
 
479
-        if ($reflection instanceof ReflectionMethod) {
479
+        if ($reflection instanceof ReflectionMethod){
480 480
             return "{$reflection->getDeclaringClass()->getName()}::{$location}()";
481 481
         }
482 482
 
@@ -492,8 +492,8 @@  discard block
 block discarded – undo
492 492
      */
493 493
     private function assertType(ReflectionParameter $parameter, ContextFunction $context, $value): void
494 494
     {
495
-        if ($value === null) {
496
-            if (!$parameter->allowsNull()) {
495
+        if ($value === null){
496
+            if (!$parameter->allowsNull()){
497 497
                 throw new ArgumentException($parameter, $context);
498 498
             }
499 499
 
@@ -501,20 +501,20 @@  discard block
 block discarded – undo
501 501
         }
502 502
 
503 503
         $type = $parameter->getType();
504
-        if ($type === null) {
504
+        if ($type === null){
505 505
             return;
506 506
         }
507 507
 
508 508
         $typeName = $type->getName();
509
-        if ($typeName === 'array' && !\is_array($value)) {
509
+        if ($typeName === 'array' && !\is_array($value)){
510 510
             throw new ArgumentException($parameter, $context);
511 511
         }
512 512
 
513
-        if (($typeName === 'int' || $typeName === 'float') && !\is_numeric($value)) {
513
+        if (($typeName === 'int' || $typeName === 'float') && !\is_numeric($value)){
514 514
             throw new ArgumentException($parameter, $context);
515 515
         }
516 516
 
517
-        if ($typeName === 'bool' && !\is_bool($value) && !\is_numeric($value)) {
517
+        if ($typeName === 'bool' && !\is_bool($value) && !\is_numeric($value)){
518 518
             throw new ArgumentException($parameter, $context);
519 519
         }
520 520
     }
@@ -531,22 +531,22 @@  discard block
 block discarded – undo
531 531
      */
532 532
     private function createInstance(string $class, array $parameters, string $context = null)
533 533
     {
534
-        try {
534
+        try{
535 535
             $reflection = new ReflectionClass($class);
536
-        } catch (ReflectionException $e) {
536
+        }catch (ReflectionException $e){
537 537
             throw new ContainerException($e->getMessage(), $e->getCode(), $e);
538 538
         }
539 539
 
540 540
         //We have to construct class using external injector when we know exact context
541
-        if ($parameters === [] && $this->checkInjector($reflection)) {
541
+        if ($parameters === [] && $this->checkInjector($reflection)){
542 542
             $injector = $this->injectors[$reflection->getName()];
543 543
 
544 544
             $instance = null;
545
-            try {
545
+            try{
546 546
                 /** @var InjectorInterface|mixed $injectorInstance */
547 547
                 $injectorInstance = $this->get($injector);
548 548
 
549
-                if (!$injectorInstance instanceof InjectorInterface) {
549
+                if (!$injectorInstance instanceof InjectorInterface){
550 550
                     throw new InjectionException(
551 551
                         \sprintf(
552 552
                             "Class '%s' must be an instance of InjectorInterface for '%s'",
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
                 }
558 558
 
559 559
                 $instance = $injectorInstance->createInjection($reflection, $context);
560
-                if (!$reflection->isInstance($instance)) {
560
+                if (!$reflection->isInstance($instance)){
561 561
                     throw new InjectionException(
562 562
                         \sprintf(
563 563
                             "Invalid injection response for '%s'",
@@ -565,23 +565,23 @@  discard block
 block discarded – undo
565 565
                         )
566 566
                     );
567 567
                 }
568
-            } finally {
568
+            }finally{
569 569
                 $this->injectors[$reflection->getName()] = $injector;
570 570
             }
571 571
 
572 572
             return $instance;
573 573
         }
574 574
 
575
-        if (!$reflection->isInstantiable()) {
575
+        if (!$reflection->isInstantiable()){
576 576
             throw new ContainerException(\sprintf("Class '%s' can not be constructed", $class));
577 577
         }
578 578
 
579 579
         $constructor = $reflection->getConstructor();
580 580
 
581
-        if ($constructor !== null) {
581
+        if ($constructor !== null){
582 582
             // Using constructor with resolved arguments
583 583
             $instance = $reflection->newInstanceArgs($this->resolveArguments($constructor, $parameters));
584
-        } else {
584
+        }else{
585 585
             // No constructor specified
586 586
             $instance = $reflection->newInstance();
587 587
         }
@@ -595,25 +595,25 @@  discard block
 block discarded – undo
595 595
     private function checkInjector(ReflectionClass $reflection): bool
596 596
     {
597 597
         $class = $reflection->getName();
598
-        if (\array_key_exists($class, $this->injectors)) {
598
+        if (\array_key_exists($class, $this->injectors)){
599 599
             return $this->injectors[$class] !== null;
600 600
         }
601 601
 
602 602
         if (
603 603
             $reflection->implementsInterface(InjectableInterface::class)
604 604
             && $reflection->hasConstant('INJECTOR')
605
-        ) {
605
+        ){
606 606
             $this->injectors[$class] = $reflection->getConstant('INJECTOR');
607 607
 
608 608
             return true;
609 609
         }
610 610
 
611 611
         // check interfaces
612
-        foreach ($this->injectors as $target => $injector) {
612
+        foreach ($this->injectors as $target => $injector){
613 613
             if (
614 614
                 \class_exists($target, true)
615 615
                 && $reflection->isSubclassOf($target)
616
-            ) {
616
+            ){
617 617
                 $this->injectors[$class] = $injector;
618 618
 
619 619
                 return true;
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
             if (
623 623
                 \interface_exists($target, true)
624 624
                 && $reflection->implementsInterface($target)
625
-            ) {
625
+            ){
626 626
                 $this->injectors[$class] = $injector;
627 627
 
628 628
                 return true;
@@ -643,9 +643,9 @@  discard block
 block discarded – undo
643 643
     private function registerInstance($instance, array $parameters)
644 644
     {
645 645
         //Declarative singletons (only when class received via direct get)
646
-        if ($parameters === [] && $instance instanceof SingletonInterface) {
646
+        if ($parameters === [] && $instance instanceof SingletonInterface){
647 647
             $alias = \get_class($instance);
648
-            if (!isset($this->bindings[$alias])) {
648
+            if (!isset($this->bindings[$alias])){
649 649
                 $this->bindings[$alias] = $instance;
650 650
             }
651 651
         }
@@ -663,18 +663,18 @@  discard block
 block discarded – undo
663 663
      */
664 664
     private function evaluateBinding(string $alias, $target, array $parameters, string $context = null)
665 665
     {
666
-        if (\is_string($target)) {
666
+        if (\is_string($target)){
667 667
             // Reference
668 668
             return $this->make($target, $parameters, $context);
669 669
         }
670 670
 
671
-        if ($target instanceof Autowire) {
671
+        if ($target instanceof Autowire){
672 672
             return $target->resolve($this, $parameters);
673 673
         }
674 674
 
675
-        try {
675
+        try{
676 676
             return $this->invoke($target, $parameters);
677
-        } catch (NotCallableException $e) {
677
+        }catch (NotCallableException $e){
678 678
             throw new ContainerException(\sprintf("Invalid binding for '%s'", $alias), $e->getCode(), $e);
679 679
         }
680 680
     }
Please login to merge, or discard this patch.
Braces   +153 added lines, -70 removed lines patch added patch discarded remove patch
@@ -98,7 +98,8 @@  discard block
 block discarded – undo
98 98
     {
99 99
         $arguments = [];
100 100
 
101
-        foreach ($reflection->getParameters() as $parameter) {
101
+        foreach ($reflection->getParameters() as $parameter)
102
+        {
102 103
             $type = $parameter->getType();
103 104
             $name = $parameter->getName();
104 105
             $class = null;
@@ -107,7 +108,8 @@  discard block
 block discarded – undo
107 108
              * Container do not currently support union types. In the future, we
108 109
              * can provide the possibility of autowiring based on priorities (TBD).
109 110
              */
110
-            if ($type instanceof ReflectionUnionType) {
111
+            if ($type instanceof ReflectionUnionType)
112
+            {
111 113
                 $error = 'Parameter $%s in %s contains a union type hint that cannot be inferred unambiguously';
112 114
                 $error = \sprintf($error, $reflection->getName(), $this->getLocationString($reflection));
113 115
 
@@ -117,17 +119,22 @@  discard block
 block discarded – undo
117 119
             /**
118 120
              * Container do not currently support intersection types.
119 121
              */
120
-            if ($type instanceof ReflectionIntersectionType) {
122
+            if ($type instanceof ReflectionIntersectionType)
123
+            {
121 124
                 $error = 'Parameter $%s in %s contains a intersection type hint that cannot be inferred unambiguously';
122 125
                 $error = \sprintf($error, $reflection->getName(), $this->getLocationString($reflection));
123 126
 
124 127
                 throw new ContainerException($error);
125 128
             }
126 129
 
127
-            if ($type instanceof ReflectionNamedType && !$type->isBuiltin()) {
128
-                try {
130
+            if ($type instanceof ReflectionNamedType && !$type->isBuiltin())
131
+            {
132
+                try
133
+                {
129 134
                     $class = new ReflectionClass($type->getName());
130
-                } catch (ReflectionException $e) {
135
+                }
136
+                catch (ReflectionException $e)
137
+                {
131 138
                     $location = $this->getLocationString($reflection);
132 139
 
133 140
                     $error = 'Unable to resolve `\$%s` parameter in %s: %s';
@@ -137,11 +144,15 @@  discard block
 block discarded – undo
137 144
                 }
138 145
             }
139 146
 
140
-            if (isset($parameters[$name]) && is_object($parameters[$name])) {
141
-                if ($parameters[$name] instanceof Autowire) {
147
+            if (isset($parameters[$name]) && is_object($parameters[$name]))
148
+            {
149
+                if ($parameters[$name] instanceof Autowire)
150
+                {
142 151
                     // Supplied by user as late dependency
143 152
                     $arguments[] = $parameters[$name]->resolve($this);
144
-                } else {
153
+                }
154
+                else
155
+                {
145 156
                     // Supplied by user as object
146 157
                     $arguments[] = $parameters[$name];
147 158
                 }
@@ -149,16 +160,19 @@  discard block
 block discarded – undo
149 160
             }
150 161
 
151 162
             // no declared type or scalar type or array
152
-            if (!isset($class)) {
163
+            if (!isset($class))
164
+            {
153 165
                 // Provided from outside
154
-                if (\array_key_exists($name, $parameters)) {
166
+                if (\array_key_exists($name, $parameters))
167
+                {
155 168
                     // Make sure it's properly typed
156 169
                     $this->assertType($parameter, $reflection, $parameters[$name]);
157 170
                     $arguments[] = $parameters[$name];
158 171
                     continue;
159 172
                 }
160 173
 
161
-                if ($parameter->isDefaultValueAvailable()) {
174
+                if ($parameter->isDefaultValueAvailable())
175
+                {
162 176
                     //Default value
163 177
                     $arguments[] = $parameter->getDefaultValue();
164 178
                     continue;
@@ -168,12 +182,16 @@  discard block
 block discarded – undo
168 182
                 throw new ArgumentException($parameter, $reflection);
169 183
             }
170 184
 
171
-            try {
185
+            try
186
+            {
172 187
                 //Requesting for contextual dependency
173 188
                 $arguments[] = $this->get($class->getName(), $name);
174 189
                 continue;
175
-            } catch (AutowireException $e) {
176
-                if ($parameter->isOptional()) {
190
+            }
191
+            catch (AutowireException $e)
192
+            {
193
+                if ($parameter->isOptional())
194
+                {
177 195
                     //This is optional dependency, skip
178 196
                     $arguments[] = null;
179 197
                     continue;
@@ -209,7 +227,8 @@  discard block
 block discarded – undo
209 227
      */
210 228
     public function get($id, string $context = null)
211 229
     {
212
-        if ($id instanceof Autowire) {
230
+        if ($id instanceof Autowire)
231
+        {
213 232
             return $id->resolve($this);
214 233
         }
215 234
 
@@ -230,34 +249,44 @@  discard block
 block discarded – undo
230 249
      */
231 250
     public function make(string $alias, array $parameters = [], string $context = null)
232 251
     {
233
-        if (!isset($this->bindings[$alias])) {
252
+        if (!isset($this->bindings[$alias]))
253
+        {
234 254
             //No direct instructions how to construct class, make is automatically
235 255
             return $this->autowire($alias, $parameters, $context);
236 256
         }
237 257
 
238 258
         $binding = $this->bindings[$alias];
239
-        if (\is_object($binding)) {
259
+        if (\is_object($binding))
260
+        {
240 261
             //When binding is instance, assuming singleton
241 262
             return $binding;
242 263
         }
243 264
 
244
-        if (\is_string($binding)) {
265
+        if (\is_string($binding))
266
+        {
245 267
             //Binding is pointing to something else
246 268
             return $this->make($binding, $parameters, $context);
247 269
         }
248 270
 
249 271
         unset($this->bindings[$alias]);
250
-        try {
251
-            if ($binding[0] === $alias) {
272
+        try
273
+        {
274
+            if ($binding[0] === $alias)
275
+            {
252 276
                 $instance = $this->autowire($alias, $parameters, $context);
253
-            } else {
277
+            }
278
+            else
279
+            {
254 280
                 $instance = $this->evaluateBinding($alias, $binding[0], $parameters, $context);
255 281
             }
256
-        } finally {
282
+        }
283
+        finally
284
+        {
257 285
             $this->bindings[$alias] = $binding;
258 286
         }
259 287
 
260
-        if ($binding[1]) {
288
+        if ($binding[1])
289
+        {
261 290
             //Indicates singleton
262 291
             $this->bindings[$alias] = $instance;
263 292
         }
@@ -271,28 +300,38 @@  discard block
 block discarded – undo
271 300
     public function runScope(array $bindings, callable $scope)
272 301
     {
273 302
         $cleanup = $previous = [];
274
-        foreach ($bindings as $alias => $resolver) {
275
-            if (isset($this->bindings[$alias])) {
303
+        foreach ($bindings as $alias => $resolver)
304
+        {
305
+            if (isset($this->bindings[$alias]))
306
+            {
276 307
                 $previous[$alias] = $this->bindings[$alias];
277
-            } else {
308
+            }
309
+            else
310
+            {
278 311
                 $cleanup[] = $alias;
279 312
             }
280 313
 
281 314
             $this->bind($alias, $resolver);
282 315
         }
283 316
 
284
-        try {
285
-            if (ContainerScope::getContainer() !== $this) {
317
+        try
318
+        {
319
+            if (ContainerScope::getContainer() !== $this)
320
+            {
286 321
                 return ContainerScope::runScope($this, $scope);
287 322
             }
288 323
 
289 324
             return $scope();
290
-        } finally {
291
-            foreach (\array_reverse($previous) as $alias => $resolver) {
325
+        }
326
+        finally
327
+        {
328
+            foreach (\array_reverse($previous) as $alias => $resolver)
329
+            {
292 330
                 $this->bindings[$alias] = $resolver;
293 331
             }
294 332
 
295
-            foreach ($cleanup as $alias) {
333
+            foreach ($cleanup as $alias)
334
+            {
296 335
                 unset($this->bindings[$alias]);
297 336
             }
298 337
         }
@@ -307,7 +346,8 @@  discard block
 block discarded – undo
307 346
      */
308 347
     public function bind(string $alias, $resolver): void
309 348
     {
310
-        if (\is_array($resolver) || $resolver instanceof Closure || $resolver instanceof Autowire) {
349
+        if (\is_array($resolver) || $resolver instanceof Closure || $resolver instanceof Autowire)
350
+        {
311 351
             // array means = execute me, false = not singleton
312 352
             $this->bindings[$alias] = [$resolver, false];
313 353
 
@@ -325,7 +365,8 @@  discard block
 block discarded – undo
325 365
      */
326 366
     public function bindSingleton(string $alias, $resolver): void
327 367
     {
328
-        if (\is_object($resolver) && !$resolver instanceof Closure && !$resolver instanceof Autowire) {
368
+        if (\is_object($resolver) && !$resolver instanceof Closure && !$resolver instanceof Autowire)
369
+        {
329 370
             // direct binding to an instance
330 371
             $this->bindings[$alias] = $resolver;
331 372
 
@@ -340,11 +381,13 @@  discard block
 block discarded – undo
340 381
      */
341 382
     public function hasInstance(string $alias): bool
342 383
     {
343
-        if (!$this->has($alias)) {
384
+        if (!$this->has($alias))
385
+        {
344 386
             return false;
345 387
         }
346 388
 
347
-        while (isset($this->bindings[$alias]) && \is_string($this->bindings[$alias])) {
389
+        while (isset($this->bindings[$alias]) && \is_string($this->bindings[$alias]))
390
+        {
348 391
             //Checking alias tree
349 392
             $alias = $this->bindings[$alias];
350 393
         }
@@ -370,18 +413,23 @@  discard block
 block discarded – undo
370 413
      */
371 414
     public function invoke($target, array $parameters = [])
372 415
     {
373
-        if (\is_array($target) && isset($target[1])) {
416
+        if (\is_array($target) && isset($target[1]))
417
+        {
374 418
             // In a form of resolver and method
375 419
             [$resolver, $method] = $target;
376 420
 
377 421
             // Resolver instance (i.e. [ClassName::class, 'method'])
378
-            if (\is_string($resolver)) {
422
+            if (\is_string($resolver))
423
+            {
379 424
                 $resolver = $this->get($resolver);
380 425
             }
381 426
 
382
-            try {
427
+            try
428
+            {
383 429
                 $method = new ReflectionMethod($resolver, $method);
384
-            } catch (ReflectionException $e) {
430
+            }
431
+            catch (ReflectionException $e)
432
+            {
385 433
                 throw new ContainerException($e->getMessage(), $e->getCode(), $e);
386 434
             }
387 435
 
@@ -394,14 +442,19 @@  discard block
 block discarded – undo
394 442
             );
395 443
         }
396 444
 
397
-        if (\is_string($target) && \is_callable($target)) {
445
+        if (\is_string($target) && \is_callable($target))
446
+        {
398 447
             $target = Closure::fromCallable($target);
399 448
         }
400 449
 
401
-        if ($target instanceof Closure) {
402
-            try {
450
+        if ($target instanceof Closure)
451
+        {
452
+            try
453
+            {
403 454
                 $reflection = new ReflectionFunction($target);
404
-            } catch (ReflectionException $e) {
455
+            }
456
+            catch (ReflectionException $e)
457
+            {
405 458
                 throw new ContainerException($e->getMessage(), $e->getCode(), $e);
406 459
             }
407 460
 
@@ -461,7 +514,8 @@  discard block
 block discarded – undo
461 514
      */
462 515
     protected function autowire(string $class, array $parameters, string $context = null)
463 516
     {
464
-        if (!\class_exists($class) && !isset($this->injectors[$class])) {
517
+        if (!\class_exists($class) && !isset($this->injectors[$class]))
518
+        {
465 519
             throw new NotFoundException(\sprintf("Undefined class or binding '%s'", $class));
466 520
         }
467 521
 
@@ -476,7 +530,8 @@  discard block
 block discarded – undo
476 530
     {
477 531
         $location = $reflection->getName();
478 532
 
479
-        if ($reflection instanceof ReflectionMethod) {
533
+        if ($reflection instanceof ReflectionMethod)
534
+        {
480 535
             return "{$reflection->getDeclaringClass()->getName()}::{$location}()";
481 536
         }
482 537
 
@@ -492,8 +547,10 @@  discard block
 block discarded – undo
492 547
      */
493 548
     private function assertType(ReflectionParameter $parameter, ContextFunction $context, $value): void
494 549
     {
495
-        if ($value === null) {
496
-            if (!$parameter->allowsNull()) {
550
+        if ($value === null)
551
+        {
552
+            if (!$parameter->allowsNull())
553
+            {
497 554
                 throw new ArgumentException($parameter, $context);
498 555
             }
499 556
 
@@ -501,20 +558,24 @@  discard block
 block discarded – undo
501 558
         }
502 559
 
503 560
         $type = $parameter->getType();
504
-        if ($type === null) {
561
+        if ($type === null)
562
+        {
505 563
             return;
506 564
         }
507 565
 
508 566
         $typeName = $type->getName();
509
-        if ($typeName === 'array' && !\is_array($value)) {
567
+        if ($typeName === 'array' && !\is_array($value))
568
+        {
510 569
             throw new ArgumentException($parameter, $context);
511 570
         }
512 571
 
513
-        if (($typeName === 'int' || $typeName === 'float') && !\is_numeric($value)) {
572
+        if (($typeName === 'int' || $typeName === 'float') && !\is_numeric($value))
573
+        {
514 574
             throw new ArgumentException($parameter, $context);
515 575
         }
516 576
 
517
-        if ($typeName === 'bool' && !\is_bool($value) && !\is_numeric($value)) {
577
+        if ($typeName === 'bool' && !\is_bool($value) && !\is_numeric($value))
578
+        {
518 579
             throw new ArgumentException($parameter, $context);
519 580
         }
520 581
     }
@@ -531,22 +592,28 @@  discard block
 block discarded – undo
531 592
      */
532 593
     private function createInstance(string $class, array $parameters, string $context = null)
533 594
     {
534
-        try {
595
+        try
596
+        {
535 597
             $reflection = new ReflectionClass($class);
536
-        } catch (ReflectionException $e) {
598
+        }
599
+        catch (ReflectionException $e)
600
+        {
537 601
             throw new ContainerException($e->getMessage(), $e->getCode(), $e);
538 602
         }
539 603
 
540 604
         //We have to construct class using external injector when we know exact context
541
-        if ($parameters === [] && $this->checkInjector($reflection)) {
605
+        if ($parameters === [] && $this->checkInjector($reflection))
606
+        {
542 607
             $injector = $this->injectors[$reflection->getName()];
543 608
 
544 609
             $instance = null;
545
-            try {
610
+            try
611
+            {
546 612
                 /** @var InjectorInterface|mixed $injectorInstance */
547 613
                 $injectorInstance = $this->get($injector);
548 614
 
549
-                if (!$injectorInstance instanceof InjectorInterface) {
615
+                if (!$injectorInstance instanceof InjectorInterface)
616
+                {
550 617
                     throw new InjectionException(
551 618
                         \sprintf(
552 619
                             "Class '%s' must be an instance of InjectorInterface for '%s'",
@@ -557,7 +624,8 @@  discard block
 block discarded – undo
557 624
                 }
558 625
 
559 626
                 $instance = $injectorInstance->createInjection($reflection, $context);
560
-                if (!$reflection->isInstance($instance)) {
627
+                if (!$reflection->isInstance($instance))
628
+                {
561 629
                     throw new InjectionException(
562 630
                         \sprintf(
563 631
                             "Invalid injection response for '%s'",
@@ -565,23 +633,29 @@  discard block
 block discarded – undo
565 633
                         )
566 634
                     );
567 635
                 }
568
-            } finally {
636
+            }
637
+            finally
638
+            {
569 639
                 $this->injectors[$reflection->getName()] = $injector;
570 640
             }
571 641
 
572 642
             return $instance;
573 643
         }
574 644
 
575
-        if (!$reflection->isInstantiable()) {
645
+        if (!$reflection->isInstantiable())
646
+        {
576 647
             throw new ContainerException(\sprintf("Class '%s' can not be constructed", $class));
577 648
         }
578 649
 
579 650
         $constructor = $reflection->getConstructor();
580 651
 
581
-        if ($constructor !== null) {
652
+        if ($constructor !== null)
653
+        {
582 654
             // Using constructor with resolved arguments
583 655
             $instance = $reflection->newInstanceArgs($this->resolveArguments($constructor, $parameters));
584
-        } else {
656
+        }
657
+        else
658
+        {
585 659
             // No constructor specified
586 660
             $instance = $reflection->newInstance();
587 661
         }
@@ -595,7 +669,8 @@  discard block
 block discarded – undo
595 669
     private function checkInjector(ReflectionClass $reflection): bool
596 670
     {
597 671
         $class = $reflection->getName();
598
-        if (\array_key_exists($class, $this->injectors)) {
672
+        if (\array_key_exists($class, $this->injectors))
673
+        {
599 674
             return $this->injectors[$class] !== null;
600 675
         }
601 676
 
@@ -609,7 +684,8 @@  discard block
 block discarded – undo
609 684
         }
610 685
 
611 686
         // check interfaces
612
-        foreach ($this->injectors as $target => $injector) {
687
+        foreach ($this->injectors as $target => $injector)
688
+        {
613 689
             if (
614 690
                 \class_exists($target, true)
615 691
                 && $reflection->isSubclassOf($target)
@@ -643,9 +719,11 @@  discard block
 block discarded – undo
643 719
     private function registerInstance($instance, array $parameters)
644 720
     {
645 721
         //Declarative singletons (only when class received via direct get)
646
-        if ($parameters === [] && $instance instanceof SingletonInterface) {
722
+        if ($parameters === [] && $instance instanceof SingletonInterface)
723
+        {
647 724
             $alias = \get_class($instance);
648
-            if (!isset($this->bindings[$alias])) {
725
+            if (!isset($this->bindings[$alias]))
726
+            {
649 727
                 $this->bindings[$alias] = $instance;
650 728
             }
651 729
         }
@@ -663,18 +741,23 @@  discard block
 block discarded – undo
663 741
      */
664 742
     private function evaluateBinding(string $alias, $target, array $parameters, string $context = null)
665 743
     {
666
-        if (\is_string($target)) {
744
+        if (\is_string($target))
745
+        {
667 746
             // Reference
668 747
             return $this->make($target, $parameters, $context);
669 748
         }
670 749
 
671
-        if ($target instanceof Autowire) {
750
+        if ($target instanceof Autowire)
751
+        {
672 752
             return $target->resolve($this, $parameters);
673 753
         }
674 754
 
675
-        try {
755
+        try
756
+        {
676 757
             return $this->invoke($target, $parameters);
677
-        } catch (NotCallableException $e) {
758
+        }
759
+        catch (NotCallableException $e)
760
+        {
678 761
             throw new ContainerException(\sprintf("Invalid binding for '%s'", $alias), $e->getCode(), $e);
679 762
         }
680 763
     }
Please login to merge, or discard this patch.
src/Security/src/RuleManager.php 2 patches
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -38,11 +38,11 @@  discard block
 block discarded – undo
38 38
      */
39 39
     public function set(string $name, $rule = null): RuleManager
40 40
     {
41
-        if (empty($rule)) {
41
+        if (empty($rule)){
42 42
             $rule = $name;
43 43
         }
44 44
 
45
-        if (!$this->validateRule($rule)) {
45
+        if (!$this->validateRule($rule)){
46 46
             throw new RuleException("Unable to set rule '{$name}', invalid rule body");
47 47
         }
48 48
 
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
      */
57 57
     public function remove(string $name): RuleManager
58 58
     {
59
-        if (!$this->has($name)) {
59
+        if (!$this->has($name)){
60 60
             throw new RuleException("Undefined rule '{$name}'");
61 61
         }
62 62
 
@@ -70,11 +70,11 @@  discard block
 block discarded – undo
70 70
      */
71 71
     public function has(string $name): bool
72 72
     {
73
-        if (isset($this->rules[$name])) {
73
+        if (isset($this->rules[$name])){
74 74
             return true;
75 75
         }
76 76
 
77
-        if (class_exists($name)) {
77
+        if (class_exists($name)){
78 78
             //We are allowing to use class names without direct registration
79 79
             return true;
80 80
         }
@@ -88,26 +88,26 @@  discard block
 block discarded – undo
88 88
      */
89 89
     public function get(string $name): RuleInterface
90 90
     {
91
-        if (!$this->has($name)) {
91
+        if (!$this->has($name)){
92 92
             throw new RuleException("Undefined rule '{$name}'");
93 93
         }
94 94
 
95
-        if (!isset($this->rules[$name])) {
95
+        if (!isset($this->rules[$name])){
96 96
             //Rule represented as class name
97 97
             $rule = $name;
98
-        } else {
98
+        }else{
99 99
             $rule = $this->rules[$name];
100 100
         }
101 101
 
102
-        if ($rule instanceof RuleInterface) {
102
+        if ($rule instanceof RuleInterface){
103 103
             return $rule;
104 104
         }
105 105
 
106
-        if (is_string($rule)) {
106
+        if (is_string($rule)){
107 107
             //We are expecting that rule points to
108 108
             $rule = $this->container->get($rule);
109 109
 
110
-            if (!$rule instanceof RuleInterface) {
110
+            if (!$rule instanceof RuleInterface){
111 111
                 throw new RuleException(sprintf(
112 112
                     "Rule '%s' must point to RuleInterface, '%s' given",
113 113
                     $name,
@@ -129,18 +129,18 @@  discard block
 block discarded – undo
129 129
      */
130 130
     private function validateRule($rule): bool
131 131
     {
132
-        if ($rule instanceof Closure || $rule instanceof RuleInterface) {
132
+        if ($rule instanceof Closure || $rule instanceof RuleInterface){
133 133
             return true;
134 134
         }
135 135
 
136
-        if (is_array($rule)) {
136
+        if (is_array($rule)){
137 137
             return is_callable($rule, true);
138 138
         }
139 139
 
140
-        if (is_string($rule) && class_exists($rule)) {
141
-            try {
140
+        if (is_string($rule) && class_exists($rule)){
141
+            try{
142 142
                 $reflection = new ReflectionClass($rule);
143
-            } catch (ReflectionException $e) {
143
+            }catch (ReflectionException $e){
144 144
                 return false;
145 145
             }
146 146
 
Please login to merge, or discard this patch.
Braces   +34 added lines, -16 removed lines patch added patch discarded remove patch
@@ -38,11 +38,13 @@  discard block
 block discarded – undo
38 38
      */
39 39
     public function set(string $name, $rule = null): RuleManager
40 40
     {
41
-        if (empty($rule)) {
41
+        if (empty($rule))
42
+        {
42 43
             $rule = $name;
43 44
         }
44 45
 
45
-        if (!$this->validateRule($rule)) {
46
+        if (!$this->validateRule($rule))
47
+        {
46 48
             throw new RuleException("Unable to set rule '{$name}', invalid rule body");
47 49
         }
48 50
 
@@ -56,7 +58,8 @@  discard block
 block discarded – undo
56 58
      */
57 59
     public function remove(string $name): RuleManager
58 60
     {
59
-        if (!$this->has($name)) {
61
+        if (!$this->has($name))
62
+        {
60 63
             throw new RuleException("Undefined rule '{$name}'");
61 64
         }
62 65
 
@@ -70,11 +73,13 @@  discard block
 block discarded – undo
70 73
      */
71 74
     public function has(string $name): bool
72 75
     {
73
-        if (isset($this->rules[$name])) {
76
+        if (isset($this->rules[$name]))
77
+        {
74 78
             return true;
75 79
         }
76 80
 
77
-        if (class_exists($name)) {
81
+        if (class_exists($name))
82
+        {
78 83
             //We are allowing to use class names without direct registration
79 84
             return true;
80 85
         }
@@ -88,26 +93,33 @@  discard block
 block discarded – undo
88 93
      */
89 94
     public function get(string $name): RuleInterface
90 95
     {
91
-        if (!$this->has($name)) {
96
+        if (!$this->has($name))
97
+        {
92 98
             throw new RuleException("Undefined rule '{$name}'");
93 99
         }
94 100
 
95
-        if (!isset($this->rules[$name])) {
101
+        if (!isset($this->rules[$name]))
102
+        {
96 103
             //Rule represented as class name
97 104
             $rule = $name;
98
-        } else {
105
+        }
106
+        else
107
+        {
99 108
             $rule = $this->rules[$name];
100 109
         }
101 110
 
102
-        if ($rule instanceof RuleInterface) {
111
+        if ($rule instanceof RuleInterface)
112
+        {
103 113
             return $rule;
104 114
         }
105 115
 
106
-        if (is_string($rule)) {
116
+        if (is_string($rule))
117
+        {
107 118
             //We are expecting that rule points to
108 119
             $rule = $this->container->get($rule);
109 120
 
110
-            if (!$rule instanceof RuleInterface) {
121
+            if (!$rule instanceof RuleInterface)
122
+            {
111 123
                 throw new RuleException(sprintf(
112 124
                     "Rule '%s' must point to RuleInterface, '%s' given",
113 125
                     $name,
@@ -129,18 +141,24 @@  discard block
 block discarded – undo
129 141
      */
130 142
     private function validateRule($rule): bool
131 143
     {
132
-        if ($rule instanceof Closure || $rule instanceof RuleInterface) {
144
+        if ($rule instanceof Closure || $rule instanceof RuleInterface)
145
+        {
133 146
             return true;
134 147
         }
135 148
 
136
-        if (is_array($rule)) {
149
+        if (is_array($rule))
150
+        {
137 151
             return is_callable($rule, true);
138 152
         }
139 153
 
140
-        if (is_string($rule) && class_exists($rule)) {
141
-            try {
154
+        if (is_string($rule) && class_exists($rule))
155
+        {
156
+            try
157
+            {
142 158
                 $reflection = new ReflectionClass($rule);
143
-            } catch (ReflectionException $e) {
159
+            }
160
+            catch (ReflectionException $e)
161
+            {
144 162
                 return false;
145 163
             }
146 164
 
Please login to merge, or discard this patch.
src/Security/src/Traits/GuardedTrait.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
     public function getGuard(): GuardInterface
28 28
     {
29 29
         $container = ContainerScope::getContainer();
30
-        if (empty($container) || !$container->has(GuardInterface::class)) {
30
+        if (empty($container) || !$container->has(GuardInterface::class)){
31 31
             throw new ScopeException(
32 32
                 'Unable to get `GuardInterface`, binding is missing or container scope is not set'
33 33
             );
@@ -51,9 +51,9 @@  discard block
 block discarded – undo
51 51
      */
52 52
     protected function resolvePermission(string $permission): string
53 53
     {
54
-        if (defined('static::GUARD_NAMESPACE')) {
54
+        if (defined('static::GUARD_NAMESPACE')){
55 55
             // Yay! Isolation
56
-            $permission = constant(static::class . '::' . 'GUARD_NAMESPACE') . '.' . $permission;
56
+            $permission = constant(static::class.'::'.'GUARD_NAMESPACE').'.'.$permission;
57 57
         }
58 58
 
59 59
         return $permission;
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -27,7 +27,8 @@  discard block
 block discarded – undo
27 27
     public function getGuard(): GuardInterface
28 28
     {
29 29
         $container = ContainerScope::getContainer();
30
-        if (empty($container) || !$container->has(GuardInterface::class)) {
30
+        if (empty($container) || !$container->has(GuardInterface::class))
31
+        {
31 32
             throw new ScopeException(
32 33
                 'Unable to get `GuardInterface`, binding is missing or container scope is not set'
33 34
             );
@@ -51,7 +52,8 @@  discard block
 block discarded – undo
51 52
      */
52 53
     protected function resolvePermission(string $permission): string
53 54
     {
54
-        if (defined('static::GUARD_NAMESPACE')) {
55
+        if (defined('static::GUARD_NAMESPACE'))
56
+        {
55 57
             // Yay! Isolation
56 58
             $permission = constant(static::class . '::' . 'GUARD_NAMESPACE') . '.' . $permission;
57 59
         }
Please login to merge, or discard this patch.
src/Security/src/Rule.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -63,20 +63,20 @@
 block discarded – undo
63 63
         $parameters = compact('actor', 'permission', 'context') + $context;
64 64
 
65 65
         //Mounting aliases
66
-        foreach (static::ALIASES as $target => $alias) {
66
+        foreach (static::ALIASES as $target => $alias){
67 67
             $parameters[$target] = $parameters[$alias];
68 68
         }
69 69
 
70
-        try {
70
+        try{
71 71
             $method = new ReflectionMethod($this, static::CHECK_METHOD);
72 72
             $method->setAccessible(true);
73
-        } catch (ReflectionException $e) {
73
+        }catch (ReflectionException $e){
74 74
             throw new RuleException($e->getMessage(), $e->getCode(), $e);
75 75
         }
76 76
 
77
-        try {
77
+        try{
78 78
             return $method->invokeArgs($this, $this->resolver->resolveArguments($method, $parameters));
79
-        } catch (Throwable $e) {
79
+        }catch (Throwable $e){
80 80
             throw new RuleException(sprintf('[%s] %s', get_class($this), $e->getMessage()), $e->getCode(), $e);
81 81
         }
82 82
     }
Please login to merge, or discard this patch.
Braces   +12 added lines, -5 removed lines patch added patch discarded remove patch
@@ -63,20 +63,27 @@
 block discarded – undo
63 63
         $parameters = compact('actor', 'permission', 'context') + $context;
64 64
 
65 65
         //Mounting aliases
66
-        foreach (static::ALIASES as $target => $alias) {
66
+        foreach (static::ALIASES as $target => $alias)
67
+        {
67 68
             $parameters[$target] = $parameters[$alias];
68 69
         }
69 70
 
70
-        try {
71
+        try
72
+        {
71 73
             $method = new ReflectionMethod($this, static::CHECK_METHOD);
72 74
             $method->setAccessible(true);
73
-        } catch (ReflectionException $e) {
75
+        }
76
+        catch (ReflectionException $e)
77
+        {
74 78
             throw new RuleException($e->getMessage(), $e->getCode(), $e);
75 79
         }
76 80
 
77
-        try {
81
+        try
82
+        {
78 83
             return $method->invokeArgs($this, $this->resolver->resolveArguments($method, $parameters));
79
-        } catch (Throwable $e) {
84
+        }
85
+        catch (Throwable $e)
86
+        {
80 87
             throw new RuleException(sprintf('[%s] %s', get_class($this), $e->getMessage()), $e->getCode(), $e);
81 88
         }
82 89
     }
Please login to merge, or discard this patch.
src/Storage/src/Storage.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
     {
74 74
         $name ??= $this->default;
75 75
 
76
-        if (!isset($this->buckets[$name])) {
76
+        if (!isset($this->buckets[$name])){
77 77
             throw new InvalidArgumentException(\sprintf(self::ERROR_NOT_FOUND, $name));
78 78
         }
79 79
 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
      */
96 96
     public function add(string $name, BucketInterface $storage, bool $overwrite = false): void
97 97
     {
98
-        if ($overwrite === false && isset($this->buckets[$name])) {
98
+        if ($overwrite === false && isset($this->buckets[$name])){
99 99
             throw new \InvalidArgumentException(\sprintf(self::ERROR_REDEFINITION, $name));
100 100
         }
101 101
 
@@ -128,22 +128,22 @@  discard block
 block discarded – undo
128 128
         $uri = $this->uriToString($uri);
129 129
         $result = \parse_url($uri);
130 130
 
131
-        if ($result === false) {
131
+        if ($result === false){
132 132
             $message = 'URI argument must be a valid URI in "[STORAGE]://[PATH_TO_FILE]" format, but `%s` given';
133 133
             throw new InvalidArgumentException(\sprintf($message, $uri));
134 134
         }
135 135
 
136
-        if (!isset($result['scheme'])) {
136
+        if (!isset($result['scheme'])){
137 137
             $result['scheme'] = $withScheme ? $this->default : null;
138 138
         }
139 139
 
140
-        if (!isset($result['host'])) {
140
+        if (!isset($result['host'])){
141 141
             $result['host'] = '';
142 142
         }
143 143
 
144 144
         return [
145 145
             $result['scheme'] ?? null,
146
-            $result['host'] . \rtrim($result['path'] ?? '', '/'),
146
+            $result['host'].\rtrim($result['path'] ?? '', '/'),
147 147
         ];
148 148
     }
149 149
 
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
      */
154 154
     private function uriToString($uri): string
155 155
     {
156
-        switch (true) {
156
+        switch (true){
157 157
             case $uri instanceof UriInterface:
158 158
             case $uri instanceof Stringable:
159 159
             case \is_object($uri) && \method_exists($uri, '__toString'):
Please login to merge, or discard this patch.
Braces   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -73,7 +73,8 @@  discard block
 block discarded – undo
73 73
     {
74 74
         $name ??= $this->default;
75 75
 
76
-        if (!isset($this->buckets[$name])) {
76
+        if (!isset($this->buckets[$name]))
77
+        {
77 78
             throw new InvalidArgumentException(\sprintf(self::ERROR_NOT_FOUND, $name));
78 79
         }
79 80
 
@@ -95,7 +96,8 @@  discard block
 block discarded – undo
95 96
      */
96 97
     public function add(string $name, BucketInterface $storage, bool $overwrite = false): void
97 98
     {
98
-        if ($overwrite === false && isset($this->buckets[$name])) {
99
+        if ($overwrite === false && isset($this->buckets[$name]))
100
+        {
99 101
             throw new \InvalidArgumentException(\sprintf(self::ERROR_REDEFINITION, $name));
100 102
         }
101 103
 
@@ -128,16 +130,19 @@  discard block
 block discarded – undo
128 130
         $uri = $this->uriToString($uri);
129 131
         $result = \parse_url($uri);
130 132
 
131
-        if ($result === false) {
133
+        if ($result === false)
134
+        {
132 135
             $message = 'URI argument must be a valid URI in "[STORAGE]://[PATH_TO_FILE]" format, but `%s` given';
133 136
             throw new InvalidArgumentException(\sprintf($message, $uri));
134 137
         }
135 138
 
136
-        if (!isset($result['scheme'])) {
139
+        if (!isset($result['scheme']))
140
+        {
137 141
             $result['scheme'] = $withScheme ? $this->default : null;
138 142
         }
139 143
 
140
-        if (!isset($result['host'])) {
144
+        if (!isset($result['host']))
145
+        {
141 146
             $result['host'] = '';
142 147
         }
143 148
 
@@ -153,7 +158,8 @@  discard block
 block discarded – undo
153 158
      */
154 159
     private function uriToString($uri): string
155 160
     {
156
-        switch (true) {
161
+        switch (true)
162
+        {
157 163
             case $uri instanceof UriInterface:
158 164
             case $uri instanceof Stringable:
159 165
             case \is_object($uri) && \method_exists($uri, '__toString'):
Please login to merge, or discard this patch.
src/Storage/src/File/UriResolvableTrait.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@
 block discarded – undo
32 32
     {
33 33
         $resolver = $this->getResolver();
34 34
 
35
-        if ($resolver === null) {
35
+        if ($resolver === null){
36 36
             throw new LogicException('Can not generate public url: File not accessible by HTTP');
37 37
         }
38 38
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,8 @@
 block discarded – undo
32 32
     {
33 33
         $resolver = $this->getResolver();
34 34
 
35
-        if ($resolver === null) {
35
+        if ($resolver === null)
36
+        {
36 37
             throw new LogicException('Can not generate public url: File not accessible by HTTP');
37 38
         }
38 39
 
Please login to merge, or discard this patch.
src/Storage/src/Bucket/WritableTrait.php 2 patches
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
      */
32 32
     public function create(string $pathname, array $config = []): FileInterface
33 33
     {
34
-        if ($this instanceof ReadableInterface && !$this->exists($pathname)) {
34
+        if ($this instanceof ReadableInterface && !$this->exists($pathname)){
35 35
             return $this->write($pathname, '', $config);
36 36
         }
37 37
 
@@ -47,8 +47,8 @@  discard block
 block discarded – undo
47 47
 
48 48
         $fs = $this->getOperator();
49 49
 
50
-        try {
51
-            switch (true) {
50
+        try{
51
+            switch (true){
52 52
                 case \is_object($content):
53 53
                 case \is_string($content):
54 54
                     $fs->write($pathname, (string)$content, $config);
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
                     $message = 'Content must be a resource stream or stringable type, but %s passed';
63 63
                     throw new InvalidArgumentException(\sprintf($message, \get_debug_type($content)));
64 64
             }
65
-        } catch (FilesystemException $e) {
65
+        }catch (FilesystemException $e){
66 66
             throw new FileOperationException($e->getMessage(), $e->getCode(), $e);
67 67
         }
68 68
 
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
79 79
     ): FileInterface {
80 80
         $fs = $this->getOperator();
81 81
 
82
-        try {
82
+        try{
83 83
             $fs->setVisibility($pathname, $this->toFlysystemVisibility($visibility));
84
-        } catch (FilesystemException $e) {
84
+        }catch (FilesystemException $e){
85 85
             throw new FileOperationException($e->getMessage(), $e->getCode(), $e);
86 86
         }
87 87
 
@@ -99,10 +99,10 @@  discard block
 block discarded – undo
99 99
     ): FileInterface {
100 100
         $fs = $this->getOperator();
101 101
 
102
-        if ($storage === null || $storage === $this) {
103
-            try {
102
+        if ($storage === null || $storage === $this){
103
+            try{
104 104
                 $fs->copy($source, $destination, $config);
105
-            } catch (FilesystemException $e) {
105
+            }catch (FilesystemException $e){
106 106
                 throw new FileOperationException($e->getMessage(), $e->getCode(), $e);
107 107
             }
108 108
 
@@ -123,10 +123,10 @@  discard block
 block discarded – undo
123 123
     ): FileInterface {
124 124
         $fs = $this->getOperator();
125 125
 
126
-        if ($storage === null || $storage === $this) {
127
-            try {
126
+        if ($storage === null || $storage === $this){
127
+            try{
128 128
                 $fs->move($source, $destination, $config);
129
-            } catch (FilesystemException $e) {
129
+            }catch (FilesystemException $e){
130 130
                 throw new FileOperationException($e->getMessage(), $e->getCode(), $e);
131 131
             }
132 132
 
@@ -147,13 +147,13 @@  discard block
 block discarded – undo
147 147
     {
148 148
         $fs = $this->getOperator();
149 149
 
150
-        try {
150
+        try{
151 151
             $fs->delete($pathname);
152 152
 
153
-            if ($clean) {
153
+            if ($clean){
154 154
                 $this->deleteEmptyDirectories($this->getParentDirectory($pathname));
155 155
             }
156
-        } catch (FilesystemException $e) {
156
+        }catch (FilesystemException $e){
157 157
             throw new FileOperationException($e->getMessage(), $e->getCode(), $e);
158 158
         }
159 159
     }
@@ -209,19 +209,19 @@  discard block
 block discarded – undo
209 209
      */
210 210
     private function deleteEmptyDirectories(string $directory): void
211 211
     {
212
-        if (!$this->hasParentDirectory($directory)) {
212
+        if (!$this->hasParentDirectory($directory)){
213 213
             return;
214 214
         }
215 215
 
216 216
         $fs = $this->getOperator();
217 217
 
218
-        try {
219
-            if (!$this->hasFiles($directory)) {
218
+        try{
219
+            if (!$this->hasFiles($directory)){
220 220
                 $fs->deleteDirectory($directory);
221 221
 
222 222
                 $this->deleteEmptyDirectories($this->getParentDirectory($directory));
223 223
             }
224
-        } catch (FilesystemException $e) {
224
+        }catch (FilesystemException $e){
225 225
             throw new FileOperationException($e->getMessage(), $e->getCode(), $e);
226 226
         }
227 227
     }
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
     {
244 244
         $fs = $this->getOperator();
245 245
 
246
-        foreach ($fs->listContents($directory) as $_) {
246
+        foreach ($fs->listContents($directory) as $_){
247 247
             return true;
248 248
         }
249 249
 
@@ -258,15 +258,15 @@  discard block
 block discarded – undo
258 258
      */
259 259
     private function isStringable($value): bool
260 260
     {
261
-        if (\is_string($value)) {
261
+        if (\is_string($value)){
262 262
             return true;
263 263
         }
264 264
 
265
-        if (!\is_object($value)) {
265
+        if (!\is_object($value)){
266 266
             return false;
267 267
         }
268 268
 
269
-        if (\PHP_VERSION_ID >= 80000) {
269
+        if (\PHP_VERSION_ID >= 80000){
270 270
             return $value instanceof Stringable;
271 271
         }
272 272
 
Please login to merge, or discard this patch.
Braces   +52 added lines, -23 removed lines patch added patch discarded remove patch
@@ -31,7 +31,8 @@  discard block
 block discarded – undo
31 31
      */
32 32
     public function create(string $pathname, array $config = []): FileInterface
33 33
     {
34
-        if ($this instanceof ReadableInterface && !$this->exists($pathname)) {
34
+        if ($this instanceof ReadableInterface && !$this->exists($pathname))
35
+        {
35 36
             return $this->write($pathname, '', $config);
36 37
         }
37 38
 
@@ -47,8 +48,10 @@  discard block
 block discarded – undo
47 48
 
48 49
         $fs = $this->getOperator();
49 50
 
50
-        try {
51
-            switch (true) {
51
+        try
52
+        {
53
+            switch (true)
54
+            {
52 55
                 case \is_object($content):
53 56
                 case \is_string($content):
54 57
                     $fs->write($pathname, (string)$content, $config);
@@ -62,7 +65,9 @@  discard block
 block discarded – undo
62 65
                     $message = 'Content must be a resource stream or stringable type, but %s passed';
63 66
                     throw new InvalidArgumentException(\sprintf($message, \get_debug_type($content)));
64 67
             }
65
-        } catch (FilesystemException $e) {
68
+        }
69
+        catch (FilesystemException $e)
70
+        {
66 71
             throw new FileOperationException($e->getMessage(), $e->getCode(), $e);
67 72
         }
68 73
 
@@ -79,9 +84,12 @@  discard block
 block discarded – undo
79 84
     ): FileInterface {
80 85
         $fs = $this->getOperator();
81 86
 
82
-        try {
87
+        try
88
+        {
83 89
             $fs->setVisibility($pathname, $this->toFlysystemVisibility($visibility));
84
-        } catch (FilesystemException $e) {
90
+        }
91
+        catch (FilesystemException $e)
92
+        {
85 93
             throw new FileOperationException($e->getMessage(), $e->getCode(), $e);
86 94
         }
87 95
 
@@ -99,10 +107,14 @@  discard block
 block discarded – undo
99 107
     ): FileInterface {
100 108
         $fs = $this->getOperator();
101 109
 
102
-        if ($storage === null || $storage === $this) {
103
-            try {
110
+        if ($storage === null || $storage === $this)
111
+        {
112
+            try
113
+            {
104 114
                 $fs->copy($source, $destination, $config);
105
-            } catch (FilesystemException $e) {
115
+            }
116
+            catch (FilesystemException $e)
117
+            {
106 118
                 throw new FileOperationException($e->getMessage(), $e->getCode(), $e);
107 119
             }
108 120
 
@@ -123,10 +135,14 @@  discard block
 block discarded – undo
123 135
     ): FileInterface {
124 136
         $fs = $this->getOperator();
125 137
 
126
-        if ($storage === null || $storage === $this) {
127
-            try {
138
+        if ($storage === null || $storage === $this)
139
+        {
140
+            try
141
+            {
128 142
                 $fs->move($source, $destination, $config);
129
-            } catch (FilesystemException $e) {
143
+            }
144
+            catch (FilesystemException $e)
145
+            {
130 146
                 throw new FileOperationException($e->getMessage(), $e->getCode(), $e);
131 147
             }
132 148
 
@@ -147,13 +163,17 @@  discard block
 block discarded – undo
147 163
     {
148 164
         $fs = $this->getOperator();
149 165
 
150
-        try {
166
+        try
167
+        {
151 168
             $fs->delete($pathname);
152 169
 
153
-            if ($clean) {
170
+            if ($clean)
171
+            {
154 172
                 $this->deleteEmptyDirectories($this->getParentDirectory($pathname));
155 173
             }
156
-        } catch (FilesystemException $e) {
174
+        }
175
+        catch (FilesystemException $e)
176
+        {
157 177
             throw new FileOperationException($e->getMessage(), $e->getCode(), $e);
158 178
         }
159 179
     }
@@ -209,19 +229,24 @@  discard block
 block discarded – undo
209 229
      */
210 230
     private function deleteEmptyDirectories(string $directory): void
211 231
     {
212
-        if (!$this->hasParentDirectory($directory)) {
232
+        if (!$this->hasParentDirectory($directory))
233
+        {
213 234
             return;
214 235
         }
215 236
 
216 237
         $fs = $this->getOperator();
217 238
 
218
-        try {
219
-            if (!$this->hasFiles($directory)) {
239
+        try
240
+        {
241
+            if (!$this->hasFiles($directory))
242
+            {
220 243
                 $fs->deleteDirectory($directory);
221 244
 
222 245
                 $this->deleteEmptyDirectories($this->getParentDirectory($directory));
223 246
             }
224
-        } catch (FilesystemException $e) {
247
+        }
248
+        catch (FilesystemException $e)
249
+        {
225 250
             throw new FileOperationException($e->getMessage(), $e->getCode(), $e);
226 251
         }
227 252
     }
@@ -243,7 +268,8 @@  discard block
 block discarded – undo
243 268
     {
244 269
         $fs = $this->getOperator();
245 270
 
246
-        foreach ($fs->listContents($directory) as $_) {
271
+        foreach ($fs->listContents($directory) as $_)
272
+        {
247 273
             return true;
248 274
         }
249 275
 
@@ -258,15 +284,18 @@  discard block
 block discarded – undo
258 284
      */
259 285
     private function isStringable($value): bool
260 286
     {
261
-        if (\is_string($value)) {
287
+        if (\is_string($value))
288
+        {
262 289
             return true;
263 290
         }
264 291
 
265
-        if (!\is_object($value)) {
292
+        if (!\is_object($value))
293
+        {
266 294
             return false;
267 295
         }
268 296
 
269
-        if (\PHP_VERSION_ID >= 80000) {
297
+        if (\PHP_VERSION_ID >= 80000)
298
+        {
270 299
             return $value instanceof Stringable;
271 300
         }
272 301
 
Please login to merge, or discard this patch.
src/Cache/src/Core/CacheInjector.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -27,21 +27,21 @@  discard block
 block discarded – undo
27 27
 
28 28
     public function createInjection(ReflectionClass $class, string $context = null): CacheInterface
29 29
     {
30
-        try {
31
-            if ($context === null) {
30
+        try{
31
+            if ($context === null){
32 32
                 $connection = $this->provider->storage();
33
-            } else {
33
+            }else{
34 34
                 // Get Cache by context
35
-                try {
35
+                try{
36 36
                     $connection = $this->provider->storage($context);
37
-                } catch (InvalidArgumentException $e) {
37
+                }catch (InvalidArgumentException $e){
38 38
                     // Case when context doesn't match to configured connections
39 39
                     return $this->provider->storage();
40 40
                 }
41 41
             }
42 42
 
43 43
             $this->matchType($class, $context, $connection);
44
-        } catch (Throwable $e) {
44
+        }catch (Throwable $e){
45 45
             throw new ContainerException(sprintf("Can't inject the required cache. %s", $e->getMessage()), 0, $e);
46 46
         }
47 47
 
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
     private function matchType(ReflectionClass $class, ?string $context, CacheInterface $connection): void
57 57
     {
58 58
         $className = $class->getName();
59
-        if ($className !== CacheInterface::class && !$connection instanceof $className) {
59
+        if ($className !== CacheInterface::class && !$connection instanceof $className){
60 60
             throw new RuntimeException(
61 61
                 \sprintf(
62 62
                     "The cache obtained by the context `%s` doesn't match the type `%s`.",
Please login to merge, or discard this patch.
Braces   +17 added lines, -7 removed lines patch added patch discarded remove patch
@@ -27,21 +27,30 @@  discard block
 block discarded – undo
27 27
 
28 28
     public function createInjection(ReflectionClass $class, string $context = null): CacheInterface
29 29
     {
30
-        try {
31
-            if ($context === null) {
30
+        try
31
+        {
32
+            if ($context === null)
33
+            {
32 34
                 $connection = $this->provider->storage();
33
-            } else {
35
+            }
36
+            else
37
+            {
34 38
                 // Get Cache by context
35
-                try {
39
+                try
40
+                {
36 41
                     $connection = $this->provider->storage($context);
37
-                } catch (InvalidArgumentException $e) {
42
+                }
43
+                catch (InvalidArgumentException $e)
44
+                {
38 45
                     // Case when context doesn't match to configured connections
39 46
                     return $this->provider->storage();
40 47
                 }
41 48
             }
42 49
 
43 50
             $this->matchType($class, $context, $connection);
44
-        } catch (Throwable $e) {
51
+        }
52
+        catch (Throwable $e)
53
+        {
45 54
             throw new ContainerException(sprintf("Can't inject the required cache. %s", $e->getMessage()), 0, $e);
46 55
         }
47 56
 
@@ -56,7 +65,8 @@  discard block
 block discarded – undo
56 65
     private function matchType(ReflectionClass $class, ?string $context, CacheInterface $connection): void
57 66
     {
58 67
         $className = $class->getName();
59
-        if ($className !== CacheInterface::class && !$connection instanceof $className) {
68
+        if ($className !== CacheInterface::class && !$connection instanceof $className)
69
+        {
60 70
             throw new RuntimeException(
61 71
                 \sprintf(
62 72
                     "The cache obtained by the context `%s` doesn't match the type `%s`.",
Please login to merge, or discard this patch.
src/Cache/src/Storage/FileStorage.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
     {
36 36
         return $this->files->write(
37 37
             $this->makePath($key),
38
-            $this->ttlToTimestamp($ttl) . serialize($value),
38
+            $this->ttlToTimestamp($ttl).serialize($value),
39 39
             null,
40 40
             true
41 41
         );
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 
44 44
     public function delete($key): bool
45 45
     {
46
-        if ($this->has($key)) {
46
+        if ($this->has($key)){
47 47
             return $this->files->delete($this->makePath($key));
48 48
         }
49 49
 
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 
53 53
     public function clear(): bool
54 54
     {
55
-        if (!$this->files->isDirectory($this->path)) {
55
+        if (!$this->files->isDirectory($this->path)){
56 56
             return false;
57 57
         }
58 58
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
     {
66 66
         $result = [];
67 67
 
68
-        foreach ($keys as $key) {
68
+        foreach ($keys as $key){
69 69
             $result[$key] = $this->get($key, $default);
70 70
         }
71 71
 
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     {
77 77
         $state = null;
78 78
 
79
-        foreach ($values as $key => $value) {
79
+        foreach ($values as $key => $value){
80 80
             $result = $this->set($key, $value, $ttl);
81 81
             $state = is_null($state) ? $result : $result && $state;
82 82
         }
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
     public function deleteMultiple($keys)
88 88
     {
89 89
         $state = null;
90
-        foreach ($keys as $key) {
90
+        foreach ($keys as $key){
91 91
             $result = $this->delete($key);
92 92
             $state = is_null($state) ? $result : $result && $state;
93 93
         }
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
     {
108 108
         $parts = array_slice(str_split($hash = sha1($key), 2), 0, 2);
109 109
 
110
-        return $this->path . '/' . implode('/', $parts) . '/' . $hash;
110
+        return $this->path.'/'.implode('/', $parts).'/'.$hash;
111 111
     }
112 112
 
113 113
     /**
@@ -117,25 +117,25 @@  discard block
 block discarded – undo
117 117
     {
118 118
         $path = $this->makePath($key);
119 119
 
120
-        try {
121
-            $expire = (int) substr(
120
+        try{
121
+            $expire = (int)substr(
122 122
                 $contents = $this->files->read($path),
123 123
                 0,
124 124
                 10
125 125
             );
126
-        } catch (FileNotFoundException $e) {
126
+        }catch (FileNotFoundException $e){
127 127
             return $this->makeEmptyPayload();
128 128
         }
129 129
 
130
-        if (time() >= $expire) {
130
+        if (time() >= $expire){
131 131
             $this->delete($key);
132 132
 
133 133
             return $this->makeEmptyPayload();
134 134
         }
135 135
 
136
-        try {
136
+        try{
137 137
             $data = unserialize(substr($contents, 10));
138
-        } catch (Exception $e) {
138
+        }catch (Exception $e){
139 139
             $this->delete($key);
140 140
 
141 141
             return $this->makeEmptyPayload();
Please login to merge, or discard this patch.
Braces   +22 added lines, -10 removed lines patch added patch discarded remove patch
@@ -43,7 +43,8 @@  discard block
 block discarded – undo
43 43
 
44 44
     public function delete($key): bool
45 45
     {
46
-        if ($this->has($key)) {
46
+        if ($this->has($key))
47
+        {
47 48
             return $this->files->delete($this->makePath($key));
48 49
         }
49 50
 
@@ -52,7 +53,8 @@  discard block
 block discarded – undo
52 53
 
53 54
     public function clear(): bool
54 55
     {
55
-        if (!$this->files->isDirectory($this->path)) {
56
+        if (!$this->files->isDirectory($this->path))
57
+        {
56 58
             return false;
57 59
         }
58 60
 
@@ -65,7 +67,8 @@  discard block
 block discarded – undo
65 67
     {
66 68
         $result = [];
67 69
 
68
-        foreach ($keys as $key) {
70
+        foreach ($keys as $key)
71
+        {
69 72
             $result[$key] = $this->get($key, $default);
70 73
         }
71 74
 
@@ -76,7 +79,8 @@  discard block
 block discarded – undo
76 79
     {
77 80
         $state = null;
78 81
 
79
-        foreach ($values as $key => $value) {
82
+        foreach ($values as $key => $value)
83
+        {
80 84
             $result = $this->set($key, $value, $ttl);
81 85
             $state = is_null($state) ? $result : $result && $state;
82 86
         }
@@ -87,7 +91,8 @@  discard block
 block discarded – undo
87 91
     public function deleteMultiple($keys)
88 92
     {
89 93
         $state = null;
90
-        foreach ($keys as $key) {
94
+        foreach ($keys as $key)
95
+        {
91 96
             $result = $this->delete($key);
92 97
             $state = is_null($state) ? $result : $result && $state;
93 98
         }
@@ -117,25 +122,32 @@  discard block
 block discarded – undo
117 122
     {
118 123
         $path = $this->makePath($key);
119 124
 
120
-        try {
125
+        try
126
+        {
121 127
             $expire = (int) substr(
122 128
                 $contents = $this->files->read($path),
123 129
                 0,
124 130
                 10
125 131
             );
126
-        } catch (FileNotFoundException $e) {
132
+        }
133
+        catch (FileNotFoundException $e)
134
+        {
127 135
             return $this->makeEmptyPayload();
128 136
         }
129 137
 
130
-        if (time() >= $expire) {
138
+        if (time() >= $expire)
139
+        {
131 140
             $this->delete($key);
132 141
 
133 142
             return $this->makeEmptyPayload();
134 143
         }
135 144
 
136
-        try {
145
+        try
146
+        {
137 147
             $data = unserialize(substr($contents, 10));
138
-        } catch (Exception $e) {
148
+        }
149
+        catch (Exception $e)
150
+        {
139 151
             $this->delete($key);
140 152
 
141 153
             return $this->makeEmptyPayload();
Please login to merge, or discard this patch.