Passed
Push — master ( 95fdf8...1b835e )
by Kirill
04:44 queued 10s
created
src/DataGridBridge/tests/GeneratorTest.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
                 $this->db->table('users')->select('*'),
131 131
                 $schema
132 132
             )
133
-            ->withView(static function ($u) {
133
+            ->withView(static function ($u){
134 134
                 return $u['name'];
135 135
             });
136 136
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
                 $this->db->table('users')->select('*'),
161 161
                 $schema
162 162
             )
163
-            ->withView(static function ($u) {
163
+            ->withView(static function ($u){
164 164
                 return $u['name'];
165 165
             });
166 166
 
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
                 $this->db->table('users')->select('*'),
190 190
                 $schema
191 191
             )
192
-            ->withView(static function ($u) {
192
+            ->withView(static function ($u){
193 193
                 return $u['name'];
194 194
             });
195 195
 
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
                 $this->db->table('users')->select('*'),
219 219
                 $schema
220 220
             )
221
-            ->withView(static function ($u) {
221
+            ->withView(static function ($u){
222 222
                 return $u['name'];
223 223
             });
224 224
 
Please login to merge, or discard this patch.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -130,7 +130,8 @@  discard block
 block discarded – undo
130 130
                 $this->db->table('users')->select('*'),
131 131
                 $schema
132 132
             )
133
-            ->withView(static function ($u) {
133
+            ->withView(static function ($u)
134
+            {
134 135
                 return $u['name'];
135 136
             });
136 137
 
@@ -160,7 +161,8 @@  discard block
 block discarded – undo
160 161
                 $this->db->table('users')->select('*'),
161 162
                 $schema
162 163
             )
163
-            ->withView(static function ($u) {
164
+            ->withView(static function ($u)
165
+            {
164 166
                 return $u['name'];
165 167
             });
166 168
 
@@ -189,7 +191,8 @@  discard block
 block discarded – undo
189 191
                 $this->db->table('users')->select('*'),
190 192
                 $schema
191 193
             )
192
-            ->withView(static function ($u) {
194
+            ->withView(static function ($u)
195
+            {
193 196
                 return $u['name'];
194 197
             });
195 198
 
@@ -218,7 +221,8 @@  discard block
 block discarded – undo
218 221
                 $this->db->table('users')->select('*'),
219 222
                 $schema
220 223
             )
221
-            ->withView(static function ($u) {
224
+            ->withView(static function ($u)
225
+            {
222 226
                 return $u['name'];
223 227
             });
224 228
 
Please login to merge, or discard this patch.
src/Core/src/Container.php 2 patches
Spacing   +69 added lines, -69 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;
@@ -109,17 +109,17 @@  discard block
 block discarded – undo
109 109
              *
110 110
              * @psalm-suppress UndefinedClass
111 111
              */
112
-            if ($type instanceof \ReflectionUnionType) {
112
+            if ($type instanceof \ReflectionUnionType){
113 113
                 $error = 'Parameter $%s in %s contains a union type hint that cannot be inferred unambiguously';
114 114
                 $error = \sprintf($error, $reflection->getName(), $this->getLocationString($reflection));
115 115
 
116 116
                 throw new ContainerException($error);
117 117
             }
118 118
 
119
-            if ($type instanceof \ReflectionNamedType && !$type->isBuiltin()) {
120
-                try {
119
+            if ($type instanceof \ReflectionNamedType && !$type->isBuiltin()){
120
+                try{
121 121
                     $class = new \ReflectionClass($type->getName());
122
-                } catch (\ReflectionException $e) {
122
+                }catch (\ReflectionException $e){
123 123
                     $location = $this->getLocationString($reflection);
124 124
 
125 125
                     $error = 'Unable to resolve `\$%s` parameter in %s: %s';
@@ -129,11 +129,11 @@  discard block
 block discarded – undo
129 129
                 }
130 130
             }
131 131
 
132
-            if (isset($parameters[$name]) && is_object($parameters[$name])) {
133
-                if ($parameters[$name] instanceof Autowire) {
132
+            if (isset($parameters[$name]) && is_object($parameters[$name])){
133
+                if ($parameters[$name] instanceof Autowire){
134 134
                     // Supplied by user as late dependency
135 135
                     $arguments[] = $parameters[$name]->resolve($this);
136
-                } else {
136
+                }else{
137 137
                     // Supplied by user as object
138 138
                     $arguments[] = $parameters[$name];
139 139
                 }
@@ -141,16 +141,16 @@  discard block
 block discarded – undo
141 141
             }
142 142
 
143 143
             // no declared type or scalar type or array
144
-            if (!isset($class)) {
144
+            if (!isset($class)){
145 145
                 // Provided from outside
146
-                if (\array_key_exists($name, $parameters)) {
146
+                if (\array_key_exists($name, $parameters)){
147 147
                     // Make sure it's properly typed
148 148
                     $this->assertType($parameter, $reflection, $parameters[$name]);
149 149
                     $arguments[] = $parameters[$name];
150 150
                     continue;
151 151
                 }
152 152
 
153
-                if ($parameter->isDefaultValueAvailable()) {
153
+                if ($parameter->isDefaultValueAvailable()){
154 154
                     //Default value
155 155
                     $arguments[] = $parameter->getDefaultValue();
156 156
                     continue;
@@ -160,12 +160,12 @@  discard block
 block discarded – undo
160 160
                 throw new ArgumentException($parameter, $reflection);
161 161
             }
162 162
 
163
-            try {
163
+            try{
164 164
                 //Requesting for contextual dependency
165 165
                 $arguments[] = $this->get($class->getName(), $name);
166 166
                 continue;
167
-            } catch (AutowireException $e) {
168
-                if ($parameter->isOptional()) {
167
+            }catch (AutowireException $e){
168
+                if ($parameter->isOptional()){
169 169
                     //This is optional dependency, skip
170 170
                     $arguments[] = null;
171 171
                     continue;
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
      */
196 196
     public function get($alias, string $context = null)
197 197
     {
198
-        if ($alias instanceof Autowire) {
198
+        if ($alias instanceof Autowire){
199 199
             return $alias->resolve($this);
200 200
         }
201 201
 
@@ -211,34 +211,34 @@  discard block
 block discarded – undo
211 211
      */
212 212
     public function make(string $alias, array $parameters = [], string $context = null)
213 213
     {
214
-        if (!isset($this->bindings[$alias])) {
214
+        if (!isset($this->bindings[$alias])){
215 215
             //No direct instructions how to construct class, make is automatically
216 216
             return $this->autowire($alias, $parameters, $context);
217 217
         }
218 218
 
219 219
         $binding = $this->bindings[$alias];
220
-        if (\is_object($binding)) {
220
+        if (\is_object($binding)){
221 221
             //When binding is instance, assuming singleton
222 222
             return $binding;
223 223
         }
224 224
 
225
-        if (\is_string($binding)) {
225
+        if (\is_string($binding)){
226 226
             //Binding is pointing to something else
227 227
             return $this->make($binding, $parameters, $context);
228 228
         }
229 229
 
230 230
         unset($this->bindings[$alias]);
231
-        try {
232
-            if ($binding[0] === $alias) {
231
+        try{
232
+            if ($binding[0] === $alias){
233 233
                 $instance = $this->autowire($alias, $parameters, $context);
234
-            } else {
234
+            }else{
235 235
                 $instance = $this->evaluateBinding($alias, $binding[0], $parameters, $context);
236 236
             }
237
-        } finally {
237
+        }finally{
238 238
             $this->bindings[$alias] = $binding;
239 239
         }
240 240
 
241
-        if ($binding[1]) {
241
+        if ($binding[1]){
242 242
             //Indicates singleton
243 243
             $this->bindings[$alias] = $instance;
244 244
         }
@@ -252,28 +252,28 @@  discard block
 block discarded – undo
252 252
     public function runScope(array $bindings, callable $scope)
253 253
     {
254 254
         $cleanup = $previous = [];
255
-        foreach ($bindings as $alias => $resolver) {
256
-            if (isset($this->bindings[$alias])) {
255
+        foreach ($bindings as $alias => $resolver){
256
+            if (isset($this->bindings[$alias])){
257 257
                 $previous[$alias] = $this->bindings[$alias];
258
-            } else {
258
+            }else{
259 259
                 $cleanup[] = $alias;
260 260
             }
261 261
 
262 262
             $this->bind($alias, $resolver);
263 263
         }
264 264
 
265
-        try {
266
-            if (ContainerScope::getContainer() !== $this) {
265
+        try{
266
+            if (ContainerScope::getContainer() !== $this){
267 267
                 return ContainerScope::runScope($this, $scope);
268 268
             }
269 269
 
270 270
             return $scope();
271
-        } finally {
272
-            foreach (\array_reverse($previous) as $alias => $resolver) {
271
+        }finally{
272
+            foreach (\array_reverse($previous) as $alias => $resolver){
273 273
                 $this->bindings[$alias] = $resolver;
274 274
             }
275 275
 
276
-            foreach ($cleanup as $alias) {
276
+            foreach ($cleanup as $alias){
277 277
                 unset($this->bindings[$alias]);
278 278
             }
279 279
         }
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
      */
290 290
     public function bind(string $alias, $resolver): void
291 291
     {
292
-        if (\is_array($resolver) || $resolver instanceof \Closure || $resolver instanceof Autowire) {
292
+        if (\is_array($resolver) || $resolver instanceof \Closure || $resolver instanceof Autowire){
293 293
             // array means = execute me, false = not singleton
294 294
             $this->bindings[$alias] = [$resolver, false];
295 295
 
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
      */
309 309
     public function bindSingleton(string $alias, $resolver): void
310 310
     {
311
-        if (\is_object($resolver) && !$resolver instanceof \Closure && !$resolver instanceof Autowire) {
311
+        if (\is_object($resolver) && !$resolver instanceof \Closure && !$resolver instanceof Autowire){
312 312
             // direct binding to an instance
313 313
             $this->bindings[$alias] = $resolver;
314 314
 
@@ -326,11 +326,11 @@  discard block
 block discarded – undo
326 326
      */
327 327
     public function hasInstance(string $alias): bool
328 328
     {
329
-        if (!$this->has($alias)) {
329
+        if (!$this->has($alias)){
330 330
             return false;
331 331
         }
332 332
 
333
-        while (isset($this->bindings[$alias]) && \is_string($this->bindings[$alias])) {
333
+        while (isset($this->bindings[$alias]) && \is_string($this->bindings[$alias])){
334 334
             //Checking alias tree
335 335
             $alias = $this->bindings[$alias];
336 336
         }
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
      */
413 413
     protected function autowire(string $class, array $parameters, string $context = null)
414 414
     {
415
-        if (!\class_exists($class)) {
415
+        if (!\class_exists($class)){
416 416
             throw new NotFoundException(\sprintf("Undefined class or binding '%s'", $class));
417 417
         }
418 418
 
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
     {
432 432
         $location = $reflection->getName();
433 433
 
434
-        if ($reflection instanceof \ReflectionMethod) {
434
+        if ($reflection instanceof \ReflectionMethod){
435 435
             return "{$reflection->getDeclaringClass()->getName()}::{$location}()";
436 436
         }
437 437
 
@@ -450,11 +450,11 @@  discard block
 block discarded – undo
450 450
      */
451 451
     private function assertType(\ReflectionParameter $parameter, ContextFunction $context, $value): void
452 452
     {
453
-        if ($value === null) {
453
+        if ($value === null){
454 454
             if (
455 455
                 !$parameter->isOptional() &&
456 456
                 !($parameter->isDefaultValueAvailable() && $parameter->getDefaultValue() === null)
457
-            ) {
457
+            ){
458 458
                 throw new ArgumentException($parameter, $context);
459 459
             }
460 460
 
@@ -462,20 +462,20 @@  discard block
 block discarded – undo
462 462
         }
463 463
 
464 464
         $type = $parameter->getType();
465
-        if ($type === null) {
465
+        if ($type === null){
466 466
             return;
467 467
         }
468 468
 
469 469
         $typeName = $type->getName();
470
-        if ($typeName === 'array' && !\is_array($value)) {
470
+        if ($typeName === 'array' && !\is_array($value)){
471 471
             throw new ArgumentException($parameter, $context);
472 472
         }
473 473
 
474
-        if (($typeName === 'int' || $typeName === 'float') && !\is_numeric($value)) {
474
+        if (($typeName === 'int' || $typeName === 'float') && !\is_numeric($value)){
475 475
             throw new ArgumentException($parameter, $context);
476 476
         }
477 477
 
478
-        if ($typeName === 'bool' && !\is_bool($value) && !\is_numeric($value)) {
478
+        if ($typeName === 'bool' && !\is_bool($value) && !\is_numeric($value)){
479 479
             throw new ArgumentException($parameter, $context);
480 480
         }
481 481
     }
@@ -493,22 +493,22 @@  discard block
 block discarded – undo
493 493
      */
494 494
     private function createInstance(string $class, array $parameters, string $context = null)
495 495
     {
496
-        try {
496
+        try{
497 497
             $reflection = new \ReflectionClass($class);
498
-        } catch (\ReflectionException $e) {
498
+        }catch (\ReflectionException $e){
499 499
             throw new ContainerException($e->getMessage(), $e->getCode(), $e);
500 500
         }
501 501
 
502 502
         //We have to construct class using external injector when we know exact context
503
-        if ($parameters === [] && $this->checkInjector($reflection)) {
503
+        if ($parameters === [] && $this->checkInjector($reflection)){
504 504
             $injector = $this->injectors[$reflection->getName()];
505 505
 
506 506
             $instance = null;
507
-            try {
507
+            try{
508 508
                 /** @var InjectorInterface $injectorInstance */
509 509
                 $injectorInstance = $this->get($injector);
510 510
 
511
-                if (!$injectorInstance instanceof InjectorInterface) {
511
+                if (!$injectorInstance instanceof InjectorInterface){
512 512
                     throw new InjectionException(
513 513
                         \sprintf(
514 514
                             "Class '%s' must be an instance of InjectorInterface for '%s'",
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
                 }
520 520
 
521 521
                 $instance = $injectorInstance->createInjection($reflection, $context);
522
-                if (!$reflection->isInstance($instance)) {
522
+                if (!$reflection->isInstance($instance)){
523 523
                     throw new InjectionException(
524 524
                         \sprintf(
525 525
                             "Invalid injection response for '%s'",
@@ -527,23 +527,23 @@  discard block
 block discarded – undo
527 527
                         )
528 528
                     );
529 529
                 }
530
-            } finally {
530
+            }finally{
531 531
                 $this->injectors[$reflection->getName()] = $injector;
532 532
             }
533 533
 
534 534
             return $instance;
535 535
         }
536 536
 
537
-        if (!$reflection->isInstantiable()) {
537
+        if (!$reflection->isInstantiable()){
538 538
             throw new ContainerException(\sprintf("Class '%s' can not be constructed", $class));
539 539
         }
540 540
 
541 541
         $constructor = $reflection->getConstructor();
542 542
 
543
-        if ($constructor !== null) {
543
+        if ($constructor !== null){
544 544
             // Using constructor with resolved arguments
545 545
             $instance = $reflection->newInstanceArgs($this->resolveArguments($constructor, $parameters));
546
-        } else {
546
+        }else{
547 547
             // No constructor specified
548 548
             $instance = $reflection->newInstance();
549 549
         }
@@ -560,28 +560,28 @@  discard block
 block discarded – undo
560 560
     private function checkInjector(\ReflectionClass $reflection): bool
561 561
     {
562 562
         $class = $reflection->getName();
563
-        if (\array_key_exists($class, $this->injectors)) {
563
+        if (\array_key_exists($class, $this->injectors)){
564 564
             return $this->injectors[$class] !== null;
565 565
         }
566 566
 
567 567
         if (
568 568
             $reflection->implementsInterface(InjectableInterface::class)
569 569
             && $reflection->hasConstant('INJECTOR')
570
-        ) {
570
+        ){
571 571
             $this->injectors[$class] = $reflection->getConstant('INJECTOR');
572 572
 
573 573
             return true;
574 574
         }
575 575
 
576
-        if (!isset($this->injectorsCache[$class])) {
576
+        if (!isset($this->injectorsCache[$class])){
577 577
             $this->injectorsCache[$class] = null;
578 578
 
579 579
             // check interfaces
580
-            foreach ($this->injectors as $target => $injector) {
580
+            foreach ($this->injectors as $target => $injector){
581 581
                 if (
582 582
                     \class_exists($target, true)
583 583
                     && $reflection->isSubclassOf($target)
584
-                ) {
584
+                ){
585 585
                     $this->injectors[$class] = $injector;
586 586
 
587 587
                     return true;
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
                 if (
591 591
                     \interface_exists($target, true)
592 592
                     && $reflection->implementsInterface($target)
593
-                ) {
593
+                ){
594 594
                     $this->injectors[$class] = $injector;
595 595
 
596 596
                     return true;
@@ -612,9 +612,9 @@  discard block
 block discarded – undo
612 612
     private function registerInstance($instance, array $parameters)
613 613
     {
614 614
         //Declarative singletons (only when class received via direct get)
615
-        if ($parameters === [] && $instance instanceof SingletonInterface) {
615
+        if ($parameters === [] && $instance instanceof SingletonInterface){
616 616
             $alias = \get_class($instance);
617
-            if (!isset($this->bindings[$alias])) {
617
+            if (!isset($this->bindings[$alias])){
618 618
                 $this->bindings[$alias] = $instance;
619 619
             }
620 620
         }
@@ -635,19 +635,19 @@  discard block
 block discarded – undo
635 635
      */
636 636
     private function evaluateBinding(string $alias, $target, array $parameters, string $context = null)
637 637
     {
638
-        if (\is_string($target)) {
638
+        if (\is_string($target)){
639 639
             // Reference
640 640
             return $this->make($target, $parameters, $context);
641 641
         }
642 642
 
643
-        if ($target instanceof Autowire) {
643
+        if ($target instanceof Autowire){
644 644
             return $target->resolve($this, $parameters);
645 645
         }
646 646
 
647
-        if ($target instanceof \Closure) {
648
-            try {
647
+        if ($target instanceof \Closure){
648
+            try{
649 649
                 $reflection = new \ReflectionFunction($target);
650
-            } catch (\ReflectionException $e) {
650
+            }catch (\ReflectionException $e){
651 651
                 throw new ContainerException($e->getMessage(), $e->getCode(), $e);
652 652
             }
653 653
 
@@ -657,16 +657,16 @@  discard block
 block discarded – undo
657 657
             );
658 658
         }
659 659
 
660
-        if (is_array($target) && isset($target[1])) {
660
+        if (is_array($target) && isset($target[1])){
661 661
             // In a form of resolver and method
662 662
             [$resolver, $method] = $target;
663 663
 
664 664
             // Resolver instance (i.e. [ClassName::class, 'method'])
665 665
             $resolver = $this->get($resolver);
666 666
 
667
-            try {
667
+            try{
668 668
                 $method = new \ReflectionMethod($resolver, $method);
669
-            } catch (\ReflectionException $e) {
669
+            }catch (\ReflectionException $e){
670 670
                 throw new ContainerException($e->getMessage(), $e->getCode(), $e);
671 671
             }
672 672
 
Please login to merge, or discard this patch.
Braces   +142 added lines, -65 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;
@@ -109,17 +110,22 @@  discard block
 block discarded – undo
109 110
              *
110 111
              * @psalm-suppress UndefinedClass
111 112
              */
112
-            if ($type instanceof \ReflectionUnionType) {
113
+            if ($type instanceof \ReflectionUnionType)
114
+            {
113 115
                 $error = 'Parameter $%s in %s contains a union type hint that cannot be inferred unambiguously';
114 116
                 $error = \sprintf($error, $reflection->getName(), $this->getLocationString($reflection));
115 117
 
116 118
                 throw new ContainerException($error);
117 119
             }
118 120
 
119
-            if ($type instanceof \ReflectionNamedType && !$type->isBuiltin()) {
120
-                try {
121
+            if ($type instanceof \ReflectionNamedType && !$type->isBuiltin())
122
+            {
123
+                try
124
+                {
121 125
                     $class = new \ReflectionClass($type->getName());
122
-                } catch (\ReflectionException $e) {
126
+                }
127
+                catch (\ReflectionException $e)
128
+                {
123 129
                     $location = $this->getLocationString($reflection);
124 130
 
125 131
                     $error = 'Unable to resolve `\$%s` parameter in %s: %s';
@@ -129,11 +135,15 @@  discard block
 block discarded – undo
129 135
                 }
130 136
             }
131 137
 
132
-            if (isset($parameters[$name]) && is_object($parameters[$name])) {
133
-                if ($parameters[$name] instanceof Autowire) {
138
+            if (isset($parameters[$name]) && is_object($parameters[$name]))
139
+            {
140
+                if ($parameters[$name] instanceof Autowire)
141
+                {
134 142
                     // Supplied by user as late dependency
135 143
                     $arguments[] = $parameters[$name]->resolve($this);
136
-                } else {
144
+                }
145
+                else
146
+                {
137 147
                     // Supplied by user as object
138 148
                     $arguments[] = $parameters[$name];
139 149
                 }
@@ -141,16 +151,19 @@  discard block
 block discarded – undo
141 151
             }
142 152
 
143 153
             // no declared type or scalar type or array
144
-            if (!isset($class)) {
154
+            if (!isset($class))
155
+            {
145 156
                 // Provided from outside
146
-                if (\array_key_exists($name, $parameters)) {
157
+                if (\array_key_exists($name, $parameters))
158
+                {
147 159
                     // Make sure it's properly typed
148 160
                     $this->assertType($parameter, $reflection, $parameters[$name]);
149 161
                     $arguments[] = $parameters[$name];
150 162
                     continue;
151 163
                 }
152 164
 
153
-                if ($parameter->isDefaultValueAvailable()) {
165
+                if ($parameter->isDefaultValueAvailable())
166
+                {
154 167
                     //Default value
155 168
                     $arguments[] = $parameter->getDefaultValue();
156 169
                     continue;
@@ -160,12 +173,16 @@  discard block
 block discarded – undo
160 173
                 throw new ArgumentException($parameter, $reflection);
161 174
             }
162 175
 
163
-            try {
176
+            try
177
+            {
164 178
                 //Requesting for contextual dependency
165 179
                 $arguments[] = $this->get($class->getName(), $name);
166 180
                 continue;
167
-            } catch (AutowireException $e) {
168
-                if ($parameter->isOptional()) {
181
+            }
182
+            catch (AutowireException $e)
183
+            {
184
+                if ($parameter->isOptional())
185
+                {
169 186
                     //This is optional dependency, skip
170 187
                     $arguments[] = null;
171 188
                     continue;
@@ -195,7 +212,8 @@  discard block
 block discarded – undo
195 212
      */
196 213
     public function get($alias, string $context = null)
197 214
     {
198
-        if ($alias instanceof Autowire) {
215
+        if ($alias instanceof Autowire)
216
+        {
199 217
             return $alias->resolve($this);
200 218
         }
201 219
 
@@ -211,34 +229,44 @@  discard block
 block discarded – undo
211 229
      */
212 230
     public function make(string $alias, array $parameters = [], string $context = null)
213 231
     {
214
-        if (!isset($this->bindings[$alias])) {
232
+        if (!isset($this->bindings[$alias]))
233
+        {
215 234
             //No direct instructions how to construct class, make is automatically
216 235
             return $this->autowire($alias, $parameters, $context);
217 236
         }
218 237
 
219 238
         $binding = $this->bindings[$alias];
220
-        if (\is_object($binding)) {
239
+        if (\is_object($binding))
240
+        {
221 241
             //When binding is instance, assuming singleton
222 242
             return $binding;
223 243
         }
224 244
 
225
-        if (\is_string($binding)) {
245
+        if (\is_string($binding))
246
+        {
226 247
             //Binding is pointing to something else
227 248
             return $this->make($binding, $parameters, $context);
228 249
         }
229 250
 
230 251
         unset($this->bindings[$alias]);
231
-        try {
232
-            if ($binding[0] === $alias) {
252
+        try
253
+        {
254
+            if ($binding[0] === $alias)
255
+            {
233 256
                 $instance = $this->autowire($alias, $parameters, $context);
234
-            } else {
257
+            }
258
+            else
259
+            {
235 260
                 $instance = $this->evaluateBinding($alias, $binding[0], $parameters, $context);
236 261
             }
237
-        } finally {
262
+        }
263
+        finally
264
+        {
238 265
             $this->bindings[$alias] = $binding;
239 266
         }
240 267
 
241
-        if ($binding[1]) {
268
+        if ($binding[1])
269
+        {
242 270
             //Indicates singleton
243 271
             $this->bindings[$alias] = $instance;
244 272
         }
@@ -252,28 +280,38 @@  discard block
 block discarded – undo
252 280
     public function runScope(array $bindings, callable $scope)
253 281
     {
254 282
         $cleanup = $previous = [];
255
-        foreach ($bindings as $alias => $resolver) {
256
-            if (isset($this->bindings[$alias])) {
283
+        foreach ($bindings as $alias => $resolver)
284
+        {
285
+            if (isset($this->bindings[$alias]))
286
+            {
257 287
                 $previous[$alias] = $this->bindings[$alias];
258
-            } else {
288
+            }
289
+            else
290
+            {
259 291
                 $cleanup[] = $alias;
260 292
             }
261 293
 
262 294
             $this->bind($alias, $resolver);
263 295
         }
264 296
 
265
-        try {
266
-            if (ContainerScope::getContainer() !== $this) {
297
+        try
298
+        {
299
+            if (ContainerScope::getContainer() !== $this)
300
+            {
267 301
                 return ContainerScope::runScope($this, $scope);
268 302
             }
269 303
 
270 304
             return $scope();
271
-        } finally {
272
-            foreach (\array_reverse($previous) as $alias => $resolver) {
305
+        }
306
+        finally
307
+        {
308
+            foreach (\array_reverse($previous) as $alias => $resolver)
309
+            {
273 310
                 $this->bindings[$alias] = $resolver;
274 311
             }
275 312
 
276
-            foreach ($cleanup as $alias) {
313
+            foreach ($cleanup as $alias)
314
+            {
277 315
                 unset($this->bindings[$alias]);
278 316
             }
279 317
         }
@@ -289,7 +327,8 @@  discard block
 block discarded – undo
289 327
      */
290 328
     public function bind(string $alias, $resolver): void
291 329
     {
292
-        if (\is_array($resolver) || $resolver instanceof \Closure || $resolver instanceof Autowire) {
330
+        if (\is_array($resolver) || $resolver instanceof \Closure || $resolver instanceof Autowire)
331
+        {
293 332
             // array means = execute me, false = not singleton
294 333
             $this->bindings[$alias] = [$resolver, false];
295 334
 
@@ -308,7 +347,8 @@  discard block
 block discarded – undo
308 347
      */
309 348
     public function bindSingleton(string $alias, $resolver): void
310 349
     {
311
-        if (\is_object($resolver) && !$resolver instanceof \Closure && !$resolver instanceof Autowire) {
350
+        if (\is_object($resolver) && !$resolver instanceof \Closure && !$resolver instanceof Autowire)
351
+        {
312 352
             // direct binding to an instance
313 353
             $this->bindings[$alias] = $resolver;
314 354
 
@@ -326,11 +366,13 @@  discard block
 block discarded – undo
326 366
      */
327 367
     public function hasInstance(string $alias): bool
328 368
     {
329
-        if (!$this->has($alias)) {
369
+        if (!$this->has($alias))
370
+        {
330 371
             return false;
331 372
         }
332 373
 
333
-        while (isset($this->bindings[$alias]) && \is_string($this->bindings[$alias])) {
374
+        while (isset($this->bindings[$alias]) && \is_string($this->bindings[$alias]))
375
+        {
334 376
             //Checking alias tree
335 377
             $alias = $this->bindings[$alias];
336 378
         }
@@ -412,7 +454,8 @@  discard block
 block discarded – undo
412 454
      */
413 455
     protected function autowire(string $class, array $parameters, string $context = null)
414 456
     {
415
-        if (!\class_exists($class)) {
457
+        if (!\class_exists($class))
458
+        {
416 459
             throw new NotFoundException(\sprintf("Undefined class or binding '%s'", $class));
417 460
         }
418 461
 
@@ -431,7 +474,8 @@  discard block
 block discarded – undo
431 474
     {
432 475
         $location = $reflection->getName();
433 476
 
434
-        if ($reflection instanceof \ReflectionMethod) {
477
+        if ($reflection instanceof \ReflectionMethod)
478
+        {
435 479
             return "{$reflection->getDeclaringClass()->getName()}::{$location}()";
436 480
         }
437 481
 
@@ -450,7 +494,8 @@  discard block
 block discarded – undo
450 494
      */
451 495
     private function assertType(\ReflectionParameter $parameter, ContextFunction $context, $value): void
452 496
     {
453
-        if ($value === null) {
497
+        if ($value === null)
498
+        {
454 499
             if (
455 500
                 !$parameter->isOptional() &&
456 501
                 !($parameter->isDefaultValueAvailable() && $parameter->getDefaultValue() === null)
@@ -462,20 +507,24 @@  discard block
 block discarded – undo
462 507
         }
463 508
 
464 509
         $type = $parameter->getType();
465
-        if ($type === null) {
510
+        if ($type === null)
511
+        {
466 512
             return;
467 513
         }
468 514
 
469 515
         $typeName = $type->getName();
470
-        if ($typeName === 'array' && !\is_array($value)) {
516
+        if ($typeName === 'array' && !\is_array($value))
517
+        {
471 518
             throw new ArgumentException($parameter, $context);
472 519
         }
473 520
 
474
-        if (($typeName === 'int' || $typeName === 'float') && !\is_numeric($value)) {
521
+        if (($typeName === 'int' || $typeName === 'float') && !\is_numeric($value))
522
+        {
475 523
             throw new ArgumentException($parameter, $context);
476 524
         }
477 525
 
478
-        if ($typeName === 'bool' && !\is_bool($value) && !\is_numeric($value)) {
526
+        if ($typeName === 'bool' && !\is_bool($value) && !\is_numeric($value))
527
+        {
479 528
             throw new ArgumentException($parameter, $context);
480 529
         }
481 530
     }
@@ -493,22 +542,28 @@  discard block
 block discarded – undo
493 542
      */
494 543
     private function createInstance(string $class, array $parameters, string $context = null)
495 544
     {
496
-        try {
545
+        try
546
+        {
497 547
             $reflection = new \ReflectionClass($class);
498
-        } catch (\ReflectionException $e) {
548
+        }
549
+        catch (\ReflectionException $e)
550
+        {
499 551
             throw new ContainerException($e->getMessage(), $e->getCode(), $e);
500 552
         }
501 553
 
502 554
         //We have to construct class using external injector when we know exact context
503
-        if ($parameters === [] && $this->checkInjector($reflection)) {
555
+        if ($parameters === [] && $this->checkInjector($reflection))
556
+        {
504 557
             $injector = $this->injectors[$reflection->getName()];
505 558
 
506 559
             $instance = null;
507
-            try {
560
+            try
561
+            {
508 562
                 /** @var InjectorInterface $injectorInstance */
509 563
                 $injectorInstance = $this->get($injector);
510 564
 
511
-                if (!$injectorInstance instanceof InjectorInterface) {
565
+                if (!$injectorInstance instanceof InjectorInterface)
566
+                {
512 567
                     throw new InjectionException(
513 568
                         \sprintf(
514 569
                             "Class '%s' must be an instance of InjectorInterface for '%s'",
@@ -519,7 +574,8 @@  discard block
 block discarded – undo
519 574
                 }
520 575
 
521 576
                 $instance = $injectorInstance->createInjection($reflection, $context);
522
-                if (!$reflection->isInstance($instance)) {
577
+                if (!$reflection->isInstance($instance))
578
+                {
523 579
                     throw new InjectionException(
524 580
                         \sprintf(
525 581
                             "Invalid injection response for '%s'",
@@ -527,23 +583,29 @@  discard block
 block discarded – undo
527 583
                         )
528 584
                     );
529 585
                 }
530
-            } finally {
586
+            }
587
+            finally
588
+            {
531 589
                 $this->injectors[$reflection->getName()] = $injector;
532 590
             }
533 591
 
534 592
             return $instance;
535 593
         }
536 594
 
537
-        if (!$reflection->isInstantiable()) {
595
+        if (!$reflection->isInstantiable())
596
+        {
538 597
             throw new ContainerException(\sprintf("Class '%s' can not be constructed", $class));
539 598
         }
540 599
 
541 600
         $constructor = $reflection->getConstructor();
542 601
 
543
-        if ($constructor !== null) {
602
+        if ($constructor !== null)
603
+        {
544 604
             // Using constructor with resolved arguments
545 605
             $instance = $reflection->newInstanceArgs($this->resolveArguments($constructor, $parameters));
546
-        } else {
606
+        }
607
+        else
608
+        {
547 609
             // No constructor specified
548 610
             $instance = $reflection->newInstance();
549 611
         }
@@ -560,7 +622,8 @@  discard block
 block discarded – undo
560 622
     private function checkInjector(\ReflectionClass $reflection): bool
561 623
     {
562 624
         $class = $reflection->getName();
563
-        if (\array_key_exists($class, $this->injectors)) {
625
+        if (\array_key_exists($class, $this->injectors))
626
+        {
564 627
             return $this->injectors[$class] !== null;
565 628
         }
566 629
 
@@ -573,11 +636,13 @@  discard block
 block discarded – undo
573 636
             return true;
574 637
         }
575 638
 
576
-        if (!isset($this->injectorsCache[$class])) {
639
+        if (!isset($this->injectorsCache[$class]))
640
+        {
577 641
             $this->injectorsCache[$class] = null;
578 642
 
579 643
             // check interfaces
580
-            foreach ($this->injectors as $target => $injector) {
644
+            foreach ($this->injectors as $target => $injector)
645
+            {
581 646
                 if (
582 647
                     \class_exists($target, true)
583 648
                     && $reflection->isSubclassOf($target)
@@ -612,9 +677,11 @@  discard block
 block discarded – undo
612 677
     private function registerInstance($instance, array $parameters)
613 678
     {
614 679
         //Declarative singletons (only when class received via direct get)
615
-        if ($parameters === [] && $instance instanceof SingletonInterface) {
680
+        if ($parameters === [] && $instance instanceof SingletonInterface)
681
+        {
616 682
             $alias = \get_class($instance);
617
-            if (!isset($this->bindings[$alias])) {
683
+            if (!isset($this->bindings[$alias]))
684
+            {
618 685
                 $this->bindings[$alias] = $instance;
619 686
             }
620 687
         }
@@ -635,19 +702,25 @@  discard block
 block discarded – undo
635 702
      */
636 703
     private function evaluateBinding(string $alias, $target, array $parameters, string $context = null)
637 704
     {
638
-        if (\is_string($target)) {
705
+        if (\is_string($target))
706
+        {
639 707
             // Reference
640 708
             return $this->make($target, $parameters, $context);
641 709
         }
642 710
 
643
-        if ($target instanceof Autowire) {
711
+        if ($target instanceof Autowire)
712
+        {
644 713
             return $target->resolve($this, $parameters);
645 714
         }
646 715
 
647
-        if ($target instanceof \Closure) {
648
-            try {
716
+        if ($target instanceof \Closure)
717
+        {
718
+            try
719
+            {
649 720
                 $reflection = new \ReflectionFunction($target);
650
-            } catch (\ReflectionException $e) {
721
+            }
722
+            catch (\ReflectionException $e)
723
+            {
651 724
                 throw new ContainerException($e->getMessage(), $e->getCode(), $e);
652 725
             }
653 726
 
@@ -657,16 +730,20 @@  discard block
 block discarded – undo
657 730
             );
658 731
         }
659 732
 
660
-        if (is_array($target) && isset($target[1])) {
733
+        if (is_array($target) && isset($target[1]))
734
+        {
661 735
             // In a form of resolver and method
662 736
             [$resolver, $method] = $target;
663 737
 
664 738
             // Resolver instance (i.e. [ClassName::class, 'method'])
665 739
             $resolver = $this->get($resolver);
666 740
 
667
-            try {
741
+            try
742
+            {
668 743
                 $method = new \ReflectionMethod($resolver, $method);
669
-            } catch (\ReflectionException $e) {
744
+            }
745
+            catch (\ReflectionException $e)
746
+            {
670 747
                 throw new ContainerException($e->getMessage(), $e->getCode(), $e);
671 748
             }
672 749
 
Please login to merge, or discard this patch.
src/Framework/Domain/CycleInterceptor.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -46,17 +46,17 @@  discard block
 block discarded – undo
46 46
         $entities = $this->getDeclaredEntities($controller, $action);
47 47
 
48 48
         $contextCandidates = [];
49
-        foreach ($entities as $parameter => $role) {
49
+        foreach ($entities as $parameter => $role){
50 50
             $value = $this->getParameter($parameter, $parameters, count($entities) === 1);
51
-            if ($value === null) {
51
+            if ($value === null){
52 52
                 throw new ControllerException(
53 53
                     "Entity `{$parameter}` can not be found",
54 54
                     ControllerException::NOT_FOUND
55 55
                 );
56 56
             }
57 57
 
58
-            if (is_object($value)) {
59
-                if ($this->orm->getHeap()->has($value)) {
58
+            if (is_object($value)){
59
+                if ($this->orm->getHeap()->has($value)){
60 60
                     $contextCandidates[] = $value;
61 61
                 }
62 62
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
             }
66 66
 
67 67
             $entity = $this->resolveEntity($role, $value);
68
-            if ($entity === null) {
68
+            if ($entity === null){
69 69
                 throw new ControllerException(
70 70
                     "Entity `{$parameter}` can not be found",
71 71
                     ControllerException::NOT_FOUND
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
             $contextCandidates[] = $entity;
77 77
         }
78 78
 
79
-        if (!isset($parameters['@context']) && count($contextCandidates) === 1) {
79
+        if (!isset($parameters['@context']) && count($contextCandidates) === 1){
80 80
             $parameters['@context'] = current($contextCandidates);
81 81
         }
82 82
 
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
      */
92 92
     protected function getParameter(string $role, array $parameters, bool $useDefault = false)
93 93
     {
94
-        if (!$useDefault) {
94
+        if (!$useDefault){
95 95
             return $parameters[$role] ?? null;
96 96
         }
97 97
 
@@ -116,25 +116,25 @@  discard block
 block discarded – undo
116 116
     private function getDeclaredEntities(string $controller, string $action): array
117 117
     {
118 118
         $key = sprintf('%s:%s', $controller, $action);
119
-        if (array_key_exists($key, $this->cache)) {
119
+        if (array_key_exists($key, $this->cache)){
120 120
             return $this->cache[$key];
121 121
         }
122 122
 
123 123
         $this->cache[$key] = [];
124
-        try {
124
+        try{
125 125
             $method = new \ReflectionMethod($controller, $action);
126
-        } catch (\ReflectionException $e) {
126
+        }catch (\ReflectionException $e){
127 127
             return [];
128 128
         }
129 129
 
130
-        foreach ($method->getParameters() as $parameter) {
130
+        foreach ($method->getParameters() as $parameter){
131 131
             $class = $this->getParameterClass($parameter);
132 132
 
133
-            if ($class === null) {
133
+            if ($class === null){
134 134
                 continue;
135 135
             }
136 136
 
137
-            if ($this->orm->getSchema()->defines($class->getName())) {
137
+            if ($this->orm->getSchema()->defines($class->getName())){
138 138
                 $this->cache[$key][$parameter->getName()] = $this->orm->resolveRole($class->getName());
139 139
             }
140 140
         }
@@ -150,11 +150,11 @@  discard block
 block discarded – undo
150 150
     {
151 151
         $type = $parameter->getType();
152 152
 
153
-        if (!$type instanceof \ReflectionNamedType) {
153
+        if (!$type instanceof \ReflectionNamedType){
154 154
             return null;
155 155
         }
156 156
 
157
-        if ($type->isBuiltin()) {
157
+        if ($type->isBuiltin()){
158 158
             return null;
159 159
         }
160 160
 
Please login to merge, or discard this patch.
Braces   +31 added lines, -15 removed lines patch added patch discarded remove patch
@@ -46,17 +46,21 @@  discard block
 block discarded – undo
46 46
         $entities = $this->getDeclaredEntities($controller, $action);
47 47
 
48 48
         $contextCandidates = [];
49
-        foreach ($entities as $parameter => $role) {
49
+        foreach ($entities as $parameter => $role)
50
+        {
50 51
             $value = $this->getParameter($parameter, $parameters, count($entities) === 1);
51
-            if ($value === null) {
52
+            if ($value === null)
53
+            {
52 54
                 throw new ControllerException(
53 55
                     "Entity `{$parameter}` can not be found",
54 56
                     ControllerException::NOT_FOUND
55 57
                 );
56 58
             }
57 59
 
58
-            if (is_object($value)) {
59
-                if ($this->orm->getHeap()->has($value)) {
60
+            if (is_object($value))
61
+            {
62
+                if ($this->orm->getHeap()->has($value))
63
+                {
60 64
                     $contextCandidates[] = $value;
61 65
                 }
62 66
 
@@ -65,7 +69,8 @@  discard block
 block discarded – undo
65 69
             }
66 70
 
67 71
             $entity = $this->resolveEntity($role, $value);
68
-            if ($entity === null) {
72
+            if ($entity === null)
73
+            {
69 74
                 throw new ControllerException(
70 75
                     "Entity `{$parameter}` can not be found",
71 76
                     ControllerException::NOT_FOUND
@@ -76,7 +81,8 @@  discard block
 block discarded – undo
76 81
             $contextCandidates[] = $entity;
77 82
         }
78 83
 
79
-        if (!isset($parameters['@context']) && count($contextCandidates) === 1) {
84
+        if (!isset($parameters['@context']) && count($contextCandidates) === 1)
85
+        {
80 86
             $parameters['@context'] = current($contextCandidates);
81 87
         }
82 88
 
@@ -91,7 +97,8 @@  discard block
 block discarded – undo
91 97
      */
92 98
     protected function getParameter(string $role, array $parameters, bool $useDefault = false)
93 99
     {
94
-        if (!$useDefault) {
100
+        if (!$useDefault)
101
+        {
95 102
             return $parameters[$role] ?? null;
96 103
         }
97 104
 
@@ -116,25 +123,32 @@  discard block
 block discarded – undo
116 123
     private function getDeclaredEntities(string $controller, string $action): array
117 124
     {
118 125
         $key = sprintf('%s:%s', $controller, $action);
119
-        if (array_key_exists($key, $this->cache)) {
126
+        if (array_key_exists($key, $this->cache))
127
+        {
120 128
             return $this->cache[$key];
121 129
         }
122 130
 
123 131
         $this->cache[$key] = [];
124
-        try {
132
+        try
133
+        {
125 134
             $method = new \ReflectionMethod($controller, $action);
126
-        } catch (\ReflectionException $e) {
135
+        }
136
+        catch (\ReflectionException $e)
137
+        {
127 138
             return [];
128 139
         }
129 140
 
130
-        foreach ($method->getParameters() as $parameter) {
141
+        foreach ($method->getParameters() as $parameter)
142
+        {
131 143
             $class = $this->getParameterClass($parameter);
132 144
 
133
-            if ($class === null) {
145
+            if ($class === null)
146
+            {
134 147
                 continue;
135 148
             }
136 149
 
137
-            if ($this->orm->getSchema()->defines($class->getName())) {
150
+            if ($this->orm->getSchema()->defines($class->getName()))
151
+            {
138 152
                 $this->cache[$key][$parameter->getName()] = $this->orm->resolveRole($class->getName());
139 153
             }
140 154
         }
@@ -150,11 +164,13 @@  discard block
 block discarded – undo
150 164
     {
151 165
         $type = $parameter->getType();
152 166
 
153
-        if (!$type instanceof \ReflectionNamedType) {
167
+        if (!$type instanceof \ReflectionNamedType)
168
+        {
154 169
             return null;
155 170
         }
156 171
 
157
-        if ($type->isBuiltin()) {
172
+        if ($type->isBuiltin())
173
+        {
158 174
             return null;
159 175
         }
160 176
 
Please login to merge, or discard this patch.
src/Framework/Domain/FilterInterceptor.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -49,20 +49,20 @@  discard block
 block discarded – undo
49 49
      */
50 50
     public function process(string $controller, string $action, array $parameters, CoreInterface $core)
51 51
     {
52
-        foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass) {
53
-            if (isset($parameters[$parameter])) {
52
+        foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass){
53
+            if (isset($parameters[$parameter])){
54 54
                 continue;
55 55
             }
56 56
 
57 57
             /** @var FilterInterface $filter */
58 58
             $filter = $this->container->get($filterClass);
59 59
 
60
-            if (isset($parameters['@context'])) {
60
+            if (isset($parameters['@context'])){
61 61
                 // other interceptors can define the validation contex
62 62
                 $filter->setContext($parameters['@context']);
63 63
             }
64 64
 
65
-            if (!$filter->isValid()) {
65
+            if (!$filter->isValid()){
66 66
                 return $this->renderInvalid($filter);
67 67
             }
68 68
 
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
      */
81 81
     protected function renderInvalid(FilterInterface $filter)
82 82
     {
83
-        switch ($this->strategy) {
83
+        switch ($this->strategy){
84 84
             case self::STRATEGY_JSON_RESPONSE:
85 85
                 return [
86 86
                     'status' => 400,
@@ -99,25 +99,25 @@  discard block
 block discarded – undo
99 99
     private function getDeclaredFilters(string $controller, string $action): array
100 100
     {
101 101
         $key = sprintf('%s:%s', $controller, $action);
102
-        if (array_key_exists($key, $this->cache)) {
102
+        if (array_key_exists($key, $this->cache)){
103 103
             return $this->cache[$key];
104 104
         }
105 105
 
106 106
         $this->cache[$key] = [];
107
-        try {
107
+        try{
108 108
             $method = new \ReflectionMethod($controller, $action);
109
-        } catch (\ReflectionException $e) {
109
+        }catch (\ReflectionException $e){
110 110
             return [];
111 111
         }
112 112
 
113
-        foreach ($method->getParameters() as $parameter) {
113
+        foreach ($method->getParameters() as $parameter){
114 114
             $class = $this->getParameterClass($parameter);
115 115
 
116
-            if ($class === null) {
116
+            if ($class === null){
117 117
                 continue;
118 118
             }
119 119
 
120
-            if ($class->implementsInterface(FilterInterface::class)) {
120
+            if ($class->implementsInterface(FilterInterface::class)){
121 121
                 $this->cache[$key][$parameter->getName()] = $class->getName();
122 122
             }
123 123
         }
@@ -134,11 +134,11 @@  discard block
 block discarded – undo
134 134
     {
135 135
         $type = $parameter->getType();
136 136
 
137
-        if (!$type instanceof \ReflectionNamedType) {
137
+        if (!$type instanceof \ReflectionNamedType){
138 138
             return null;
139 139
         }
140 140
 
141
-        if ($type->isBuiltin()) {
141
+        if ($type->isBuiltin()){
142 142
             return null;
143 143
         }
144 144
 
Please login to merge, or discard this patch.
Braces   +27 added lines, -13 removed lines patch added patch discarded remove patch
@@ -49,20 +49,24 @@  discard block
 block discarded – undo
49 49
      */
50 50
     public function process(string $controller, string $action, array $parameters, CoreInterface $core)
51 51
     {
52
-        foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass) {
53
-            if (isset($parameters[$parameter])) {
52
+        foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass)
53
+        {
54
+            if (isset($parameters[$parameter]))
55
+            {
54 56
                 continue;
55 57
             }
56 58
 
57 59
             /** @var FilterInterface $filter */
58 60
             $filter = $this->container->get($filterClass);
59 61
 
60
-            if (isset($parameters['@context'])) {
62
+            if (isset($parameters['@context']))
63
+            {
61 64
                 // other interceptors can define the validation contex
62 65
                 $filter->setContext($parameters['@context']);
63 66
             }
64 67
 
65
-            if (!$filter->isValid()) {
68
+            if (!$filter->isValid())
69
+            {
66 70
                 return $this->renderInvalid($filter);
67 71
             }
68 72
 
@@ -80,7 +84,8 @@  discard block
 block discarded – undo
80 84
      */
81 85
     protected function renderInvalid(FilterInterface $filter)
82 86
     {
83
-        switch ($this->strategy) {
87
+        switch ($this->strategy)
88
+        {
84 89
             case self::STRATEGY_JSON_RESPONSE:
85 90
                 return [
86 91
                     'status' => 400,
@@ -99,25 +104,32 @@  discard block
 block discarded – undo
99 104
     private function getDeclaredFilters(string $controller, string $action): array
100 105
     {
101 106
         $key = sprintf('%s:%s', $controller, $action);
102
-        if (array_key_exists($key, $this->cache)) {
107
+        if (array_key_exists($key, $this->cache))
108
+        {
103 109
             return $this->cache[$key];
104 110
         }
105 111
 
106 112
         $this->cache[$key] = [];
107
-        try {
113
+        try
114
+        {
108 115
             $method = new \ReflectionMethod($controller, $action);
109
-        } catch (\ReflectionException $e) {
116
+        }
117
+        catch (\ReflectionException $e)
118
+        {
110 119
             return [];
111 120
         }
112 121
 
113
-        foreach ($method->getParameters() as $parameter) {
122
+        foreach ($method->getParameters() as $parameter)
123
+        {
114 124
             $class = $this->getParameterClass($parameter);
115 125
 
116
-            if ($class === null) {
126
+            if ($class === null)
127
+            {
117 128
                 continue;
118 129
             }
119 130
 
120
-            if ($class->implementsInterface(FilterInterface::class)) {
131
+            if ($class->implementsInterface(FilterInterface::class))
132
+            {
121 133
                 $this->cache[$key][$parameter->getName()] = $class->getName();
122 134
             }
123 135
         }
@@ -134,11 +146,13 @@  discard block
 block discarded – undo
134 146
     {
135 147
         $type = $parameter->getType();
136 148
 
137
-        if (!$type instanceof \ReflectionNamedType) {
149
+        if (!$type instanceof \ReflectionNamedType)
150
+        {
138 151
             return null;
139 152
         }
140 153
 
141
-        if ($type->isBuiltin()) {
154
+        if ($type->isBuiltin())
155
+        {
142 156
             return null;
143 157
         }
144 158
 
Please login to merge, or discard this patch.
src/Framework/Command/PublishCommand.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -52,10 +52,10 @@  discard block
 block discarded – undo
52 52
         FilesInterface $files,
53 53
         DirectoriesInterface $directories
54 54
     ): void {
55
-        switch ($this->argument('type')) {
55
+        switch ($this->argument('type')){
56 56
             case 'replace':
57 57
             case 'follow':
58
-                if ($this->isDirectory()) {
58
+                if ($this->isDirectory()){
59 59
                     $this->sprintf(
60 60
                         '<fg=cyan>•</fg=cyan> publish directory <comment>%s</comment> to <comment>%s</comment>',
61 61
                         $this->getSource($files),
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
                         $this->getMergeMode(),
69 69
                         $this->getFileMode()
70 70
                     );
71
-                } else {
71
+                }else{
72 72
                     $this->sprintf(
73 73
                         '<fg=cyan>•</fg=cyan> publish file <comment>%s</comment> to <comment>%s</comment>',
74 74
                         $this->getSource($files),
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
      */
108 108
     private function getSource(FilesInterface $files): ?string
109 109
     {
110
-        if (!$this->isDirectory()) {
110
+        if (!$this->isDirectory()){
111 111
             return $files->normalizePath($this->argument('source'));
112 112
         }
113 113
 
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
     private function getTarget(FilesInterface $files, DirectoriesInterface $directories): ?string
123 123
     {
124 124
         $target = $this->argument('target');
125
-        foreach ($directories->getAll() as $alias => $value) {
125
+        foreach ($directories->getAll() as $alias => $value){
126 126
             $target = str_replace("@{$alias}", $value, $target);
127 127
         }
128 128
 
@@ -134,11 +134,11 @@  discard block
 block discarded – undo
134 134
      */
135 135
     private function isDirectory(): bool
136 136
     {
137
-        if ($this->argument('type') == 'ensure') {
137
+        if ($this->argument('type') == 'ensure'){
138 138
             return true;
139 139
         }
140 140
 
141
-        if (strpos($this->argument('source'), '*') !== false) {
141
+        if (strpos($this->argument('source'), '*') !== false){
142 142
             return true;
143 143
         }
144 144
 
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
      */
151 151
     private function getMergeMode(): string
152 152
     {
153
-        switch ($this->argument('type')) {
153
+        switch ($this->argument('type')){
154 154
             case 'follow':
155 155
                 return PublisherInterface::FOLLOW;
156 156
             case 'replace':
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
      */
166 166
     private function getFileMode(): int
167 167
     {
168
-        switch ($this->argument('mode')) {
168
+        switch ($this->argument('mode')){
169 169
             case 'readonly':
170 170
                 return FilesInterface::READONLY;
171 171
             case 'runtime':
Please login to merge, or discard this patch.
Braces   +19 added lines, -9 removed lines patch added patch discarded remove patch
@@ -52,10 +52,12 @@  discard block
 block discarded – undo
52 52
         FilesInterface $files,
53 53
         DirectoriesInterface $directories
54 54
     ): void {
55
-        switch ($this->argument('type')) {
55
+        switch ($this->argument('type'))
56
+        {
56 57
             case 'replace':
57 58
             case 'follow':
58
-                if ($this->isDirectory()) {
59
+                if ($this->isDirectory())
60
+                {
59 61
                     $this->sprintf(
60 62
                         '<fg=cyan>•</fg=cyan> publish directory <comment>%s</comment> to <comment>%s</comment>',
61 63
                         $this->getSource($files),
@@ -68,7 +70,9 @@  discard block
 block discarded – undo
68 70
                         $this->getMergeMode(),
69 71
                         $this->getFileMode()
70 72
                     );
71
-                } else {
73
+                }
74
+                else
75
+                {
72 76
                     $this->sprintf(
73 77
                         '<fg=cyan>•</fg=cyan> publish file <comment>%s</comment> to <comment>%s</comment>',
74 78
                         $this->getSource($files),
@@ -107,7 +111,8 @@  discard block
 block discarded – undo
107 111
      */
108 112
     private function getSource(FilesInterface $files): ?string
109 113
     {
110
-        if (!$this->isDirectory()) {
114
+        if (!$this->isDirectory())
115
+        {
111 116
             return $files->normalizePath($this->argument('source'));
112 117
         }
113 118
 
@@ -122,7 +127,8 @@  discard block
 block discarded – undo
122 127
     private function getTarget(FilesInterface $files, DirectoriesInterface $directories): ?string
123 128
     {
124 129
         $target = $this->argument('target');
125
-        foreach ($directories->getAll() as $alias => $value) {
130
+        foreach ($directories->getAll() as $alias => $value)
131
+        {
126 132
             $target = str_replace("@{$alias}", $value, $target);
127 133
         }
128 134
 
@@ -134,11 +140,13 @@  discard block
 block discarded – undo
134 140
      */
135 141
     private function isDirectory(): bool
136 142
     {
137
-        if ($this->argument('type') == 'ensure') {
143
+        if ($this->argument('type') == 'ensure')
144
+        {
138 145
             return true;
139 146
         }
140 147
 
141
-        if (strpos($this->argument('source'), '*') !== false) {
148
+        if (strpos($this->argument('source'), '*') !== false)
149
+        {
142 150
             return true;
143 151
         }
144 152
 
@@ -150,7 +158,8 @@  discard block
 block discarded – undo
150 158
      */
151 159
     private function getMergeMode(): string
152 160
     {
153
-        switch ($this->argument('type')) {
161
+        switch ($this->argument('type'))
162
+        {
154 163
             case 'follow':
155 164
                 return PublisherInterface::FOLLOW;
156 165
             case 'replace':
@@ -165,7 +174,8 @@  discard block
 block discarded – undo
165 174
      */
166 175
     private function getFileMode(): int
167 176
     {
168
-        switch ($this->argument('mode')) {
177
+        switch ($this->argument('mode'))
178
+        {
169 179
             case 'readonly':
170 180
                 return FilesInterface::READONLY;
171 181
             case 'runtime':
Please login to merge, or discard this patch.
src/Framework/Module/Publisher.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -41,17 +41,17 @@  discard block
 block discarded – undo
41 41
         string $mergeMode = self::FOLLOW,
42 42
         int $mode = FilesInterface::READONLY
43 43
     ): void {
44
-        if (!$this->files->isFile($filename)) {
44
+        if (!$this->files->isFile($filename)){
45 45
             throw new PublishException("Given '{$filename}' is not valid file");
46 46
         }
47 47
 
48
-        if ($this->files->exists($destination)) {
49
-            if ($this->files->md5($destination) === $this->files->md5($filename)) {
48
+        if ($this->files->exists($destination)){
49
+            if ($this->files->md5($destination) === $this->files->md5($filename)){
50 50
                 //Nothing to do
51 51
                 return;
52 52
             }
53 53
 
54
-            if ($mergeMode === self::FOLLOW) {
54
+            if ($mergeMode === self::FOLLOW){
55 55
                 return;
56 56
             }
57 57
         }
@@ -73,17 +73,17 @@  discard block
 block discarded – undo
73 73
         string $mergeMode = self::REPLACE,
74 74
         int $mode = FilesInterface::READONLY
75 75
     ): void {
76
-        if (!$this->files->isDirectory($directory)) {
76
+        if (!$this->files->isDirectory($directory)){
77 77
             throw new PublishException("Given '{$directory}' is not valid directory");
78 78
         }
79 79
 
80 80
         $finder = new Finder();
81 81
         $finder->files()->in($directory);
82 82
 
83
-        foreach ($finder->getIterator() as $file) {
83
+        foreach ($finder->getIterator() as $file){
84 84
             $this->publish(
85 85
                 (string)$file,
86
-                $destination . '/' . $file->getRelativePathname(),
86
+                $destination.'/'.$file->getRelativePathname(),
87 87
                 $mergeMode,
88 88
                 $mode
89 89
             );
Please login to merge, or discard this patch.
Braces   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -41,17 +41,21 @@  discard block
 block discarded – undo
41 41
         string $mergeMode = self::FOLLOW,
42 42
         int $mode = FilesInterface::READONLY
43 43
     ): void {
44
-        if (!$this->files->isFile($filename)) {
44
+        if (!$this->files->isFile($filename))
45
+        {
45 46
             throw new PublishException("Given '{$filename}' is not valid file");
46 47
         }
47 48
 
48
-        if ($this->files->exists($destination)) {
49
-            if ($this->files->md5($destination) === $this->files->md5($filename)) {
49
+        if ($this->files->exists($destination))
50
+        {
51
+            if ($this->files->md5($destination) === $this->files->md5($filename))
52
+            {
50 53
                 //Nothing to do
51 54
                 return;
52 55
             }
53 56
 
54
-            if ($mergeMode === self::FOLLOW) {
57
+            if ($mergeMode === self::FOLLOW)
58
+            {
55 59
                 return;
56 60
             }
57 61
         }
@@ -73,14 +77,16 @@  discard block
 block discarded – undo
73 77
         string $mergeMode = self::REPLACE,
74 78
         int $mode = FilesInterface::READONLY
75 79
     ): void {
76
-        if (!$this->files->isDirectory($directory)) {
80
+        if (!$this->files->isDirectory($directory))
81
+        {
77 82
             throw new PublishException("Given '{$directory}' is not valid directory");
78 83
         }
79 84
 
80 85
         $finder = new Finder();
81 86
         $finder->files()->in($directory);
82 87
 
83
-        foreach ($finder->getIterator() as $file) {
88
+        foreach ($finder->getIterator() as $file)
89
+        {
84 90
             $this->publish(
85 91
                 (string)$file,
86 92
                 $destination . '/' . $file->getRelativePathname(),
Please login to merge, or discard this patch.
src/Framework/Broadcast/Middleware/WebsocketsMiddleware.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         ScopeInterface $scope,
51 51
         ResolverInterface $resolver,
52 52
         ResponseFactoryInterface $responseFactory
53
-    ) {
53
+    ){
54 54
         $this->config = $config;
55 55
         $this->scope = $scope;
56 56
         $this->resolver = $resolver;
@@ -67,13 +67,13 @@  discard block
 block discarded – undo
67 67
      */
68 68
     public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
69 69
     {
70
-        if ($request->getUri()->getPath() !== $this->config->getPath()) {
70
+        if ($request->getUri()->getPath() !== $this->config->getPath()){
71 71
             return $handler->handle($request);
72 72
         }
73 73
 
74 74
         // server authorization
75
-        if ($request->getAttribute('ws:joinServer', null) !== null) {
76
-            if (!$this->authorizeServer($request)) {
75
+        if ($request->getAttribute('ws:joinServer', null) !== null){
76
+            if (!$this->authorizeServer($request)){
77 77
                 return $this->responseFactory->createResponse(403);
78 78
             }
79 79
 
@@ -81,10 +81,10 @@  discard block
 block discarded – undo
81 81
         }
82 82
 
83 83
         // topic authorization
84
-        if (is_string($request->getAttribute('ws:joinTopics', null))) {
84
+        if (is_string($request->getAttribute('ws:joinTopics', null))){
85 85
             $topics = explode(',', $request->getAttribute('ws:joinTopics'));
86
-            foreach ($topics as $topic) {
87
-                if (!$this->authorizeTopic($request, $topic)) {
86
+            foreach ($topics as $topic){
87
+                if (!$this->authorizeTopic($request, $topic)){
88 88
                     return $this->responseFactory->createResponse(403);
89 89
                 }
90 90
             }
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
     private function authorizeServer(ServerRequestInterface $request): bool
105 105
     {
106 106
         $callback = $this->config->getServerCallback();
107
-        if ($callback === null) {
107
+        if ($callback === null){
108 108
             return true;
109 109
         }
110 110
 
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
     {
123 123
         $parameters = [];
124 124
         $callback = $this->config->findTopicCallback($topic, $parameters);
125
-        if ($callback === null) {
125
+        if ($callback === null){
126 126
             return false;
127 127
         }
128 128
 
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
      */
140 140
     private function invoke(ServerRequestInterface $request, callable $callback, array $parameters = []): bool
141 141
     {
142
-        switch (true) {
142
+        switch (true){
143 143
             case $callback instanceof \Closure || is_string($callback):
144 144
                 $reflection = new \ReflectionFunction($callback);
145 145
                 break;
Please login to merge, or discard this patch.
Braces   +20 added lines, -10 removed lines patch added patch discarded remove patch
@@ -67,13 +67,16 @@  discard block
 block discarded – undo
67 67
      */
68 68
     public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
69 69
     {
70
-        if ($request->getUri()->getPath() !== $this->config->getPath()) {
70
+        if ($request->getUri()->getPath() !== $this->config->getPath())
71
+        {
71 72
             return $handler->handle($request);
72 73
         }
73 74
 
74 75
         // server authorization
75
-        if ($request->getAttribute('ws:joinServer', null) !== null) {
76
-            if (!$this->authorizeServer($request)) {
76
+        if ($request->getAttribute('ws:joinServer', null) !== null)
77
+        {
78
+            if (!$this->authorizeServer($request))
79
+            {
77 80
                 return $this->responseFactory->createResponse(403);
78 81
             }
79 82
 
@@ -81,10 +84,13 @@  discard block
 block discarded – undo
81 84
         }
82 85
 
83 86
         // topic authorization
84
-        if (is_string($request->getAttribute('ws:joinTopics', null))) {
87
+        if (is_string($request->getAttribute('ws:joinTopics', null)))
88
+        {
85 89
             $topics = explode(',', $request->getAttribute('ws:joinTopics'));
86
-            foreach ($topics as $topic) {
87
-                if (!$this->authorizeTopic($request, $topic)) {
90
+            foreach ($topics as $topic)
91
+            {
92
+                if (!$this->authorizeTopic($request, $topic))
93
+                {
88 94
                     return $this->responseFactory->createResponse(403);
89 95
                 }
90 96
             }
@@ -104,7 +110,8 @@  discard block
 block discarded – undo
104 110
     private function authorizeServer(ServerRequestInterface $request): bool
105 111
     {
106 112
         $callback = $this->config->getServerCallback();
107
-        if ($callback === null) {
113
+        if ($callback === null)
114
+        {
108 115
             return true;
109 116
         }
110 117
 
@@ -122,7 +129,8 @@  discard block
 block discarded – undo
122 129
     {
123 130
         $parameters = [];
124 131
         $callback = $this->config->findTopicCallback($topic, $parameters);
125
-        if ($callback === null) {
132
+        if ($callback === null)
133
+        {
126 134
             return false;
127 135
         }
128 136
 
@@ -139,7 +147,8 @@  discard block
 block discarded – undo
139 147
      */
140 148
     private function invoke(ServerRequestInterface $request, callable $callback, array $parameters = []): bool
141 149
     {
142
-        switch (true) {
150
+        switch (true)
151
+        {
143 152
             case $callback instanceof \Closure || is_string($callback):
144 153
                 $reflection = new \ReflectionFunction($callback);
145 154
                 break;
@@ -160,7 +169,8 @@  discard block
 block discarded – undo
160 169
             [
161 170
                 ServerRequestInterface::class => $request,
162 171
             ],
163
-            function () use ($reflection, $parameters, $callback) {
172
+            function () use ($reflection, $parameters, $callback)
173
+            {
164 174
                 return call_user_func_array(
165 175
                     $callback,
166 176
                     $this->resolver->resolveArguments($reflection, $parameters)
Please login to merge, or discard this patch.
src/Framework/Broadcast/Config/WebsocketsConfig.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
     {
35 35
         parent::__construct($config);
36 36
 
37
-        foreach ($config['authorizeTopics'] as $topic => $callback) {
37
+        foreach ($config['authorizeTopics'] as $topic => $callback){
38 38
             $this->patterns[$this->compilePattern($topic)] = $callback;
39 39
         }
40 40
     }
@@ -62,8 +62,8 @@  discard block
 block discarded – undo
62 62
      */
63 63
     public function findTopicCallback(string $topic, array &$matches): ?callable
64 64
     {
65
-        foreach ($this->patterns as $pattern => $callback) {
66
-            if (preg_match($pattern, $topic, $matches)) {
65
+        foreach ($this->patterns as $pattern => $callback){
66
+            if (preg_match($pattern, $topic, $matches)){
67 67
                 return $callback;
68 68
             }
69 69
         }
@@ -78,13 +78,13 @@  discard block
 block discarded – undo
78 78
     private function compilePattern(string $topic): string
79 79
     {
80 80
         $replaces = [];
81
-        if (preg_match_all('/\{(\w+):?(.*?)?\}/', $topic, $matches)) {
81
+        if (preg_match_all('/\{(\w+):?(.*?)?\}/', $topic, $matches)){
82 82
             $variables = array_combine($matches[1], $matches[2]);
83
-            foreach ($variables as $key => $_) {
84
-                $replaces['{' . $key . '}'] = '(?P<' . $key . '>[^\/\.]+)';
83
+            foreach ($variables as $key => $_){
84
+                $replaces['{'.$key.'}'] = '(?P<'.$key.'>[^\/\.]+)';
85 85
             }
86 86
         }
87 87
 
88
-        return '/^' . strtr($topic, $replaces + ['/' => '\\/', '[' => '(?:', ']' => ')?', '.' => '\.']) . '$/iu';
88
+        return '/^'.strtr($topic, $replaces + ['/' => '\\/', '[' => '(?:', ']' => ')?', '.' => '\.']).'$/iu';
89 89
     }
90 90
 }
Please login to merge, or discard this patch.
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -34,7 +34,8 @@  discard block
 block discarded – undo
34 34
     {
35 35
         parent::__construct($config);
36 36
 
37
-        foreach ($config['authorizeTopics'] as $topic => $callback) {
37
+        foreach ($config['authorizeTopics'] as $topic => $callback)
38
+        {
38 39
             $this->patterns[$this->compilePattern($topic)] = $callback;
39 40
         }
40 41
     }
@@ -62,8 +63,10 @@  discard block
 block discarded – undo
62 63
      */
63 64
     public function findTopicCallback(string $topic, array &$matches): ?callable
64 65
     {
65
-        foreach ($this->patterns as $pattern => $callback) {
66
-            if (preg_match($pattern, $topic, $matches)) {
66
+        foreach ($this->patterns as $pattern => $callback)
67
+        {
68
+            if (preg_match($pattern, $topic, $matches))
69
+            {
67 70
                 return $callback;
68 71
             }
69 72
         }
@@ -78,9 +81,11 @@  discard block
 block discarded – undo
78 81
     private function compilePattern(string $topic): string
79 82
     {
80 83
         $replaces = [];
81
-        if (preg_match_all('/\{(\w+):?(.*?)?\}/', $topic, $matches)) {
84
+        if (preg_match_all('/\{(\w+):?(.*?)?\}/', $topic, $matches))
85
+        {
82 86
             $variables = array_combine($matches[1], $matches[2]);
83
-            foreach ($variables as $key => $_) {
87
+            foreach ($variables as $key => $_)
88
+            {
84 89
                 $replaces['{' . $key . '}'] = '(?P<' . $key . '>[^\/\.]+)';
85 90
             }
86 91
         }
Please login to merge, or discard this patch.
src/Translator/src/Catalogue/CatalogueLoader.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      */
49 49
     public function getLocales(): array
50 50
     {
51
-        if (!is_dir($this->config->getLocalesDirectory())) {
51
+        if (!is_dir($this->config->getLocalesDirectory())){
52 52
             return [];
53 53
         }
54 54
 
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 
58 58
         $locales = [];
59 59
 
60
-        foreach ($finder->directories() as $directory) {
60
+        foreach ($finder->directories() as $directory){
61 61
             $locales[] = $directory->getFilename();
62 62
         }
63 63
 
@@ -72,14 +72,14 @@  discard block
 block discarded – undo
72 72
         $locale = preg_replace('/[^a-zA-Z_]/', '', mb_strtolower($locale));
73 73
         $catalogue = new Catalogue($locale);
74 74
 
75
-        if (!$this->hasLocale($locale)) {
75
+        if (!$this->hasLocale($locale)){
76 76
             return $catalogue;
77 77
         }
78 78
 
79 79
         $finder = new Finder();
80 80
         $finder->in($this->config->getLocaleDirectory($locale));
81 81
 
82
-        foreach ($finder->getIterator() as $file) {
82
+        foreach ($finder->getIterator() as $file){
83 83
             $this->getLogger()->info(
84 84
                 sprintf(
85 85
                     "found locale domain file '%s'",
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
             //Per application agreement domain name must present in filename
92 92
             $domain = strstr($file->getFilename(), '.', true);
93 93
 
94
-            if (!$this->config->hasLoader($file->getExtension())) {
94
+            if (!$this->config->hasLoader($file->getExtension())){
95 95
                 $this->getLogger()->warning(
96 96
                     sprintf(
97 97
                         "unable to load domain file '%s', no loader found",
Please login to merge, or discard this patch.
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -48,7 +48,8 @@  discard block
 block discarded – undo
48 48
      */
49 49
     public function getLocales(): array
50 50
     {
51
-        if (!is_dir($this->config->getLocalesDirectory())) {
51
+        if (!is_dir($this->config->getLocalesDirectory()))
52
+        {
52 53
             return [];
53 54
         }
54 55
 
@@ -57,7 +58,8 @@  discard block
 block discarded – undo
57 58
 
58 59
         $locales = [];
59 60
 
60
-        foreach ($finder->directories() as $directory) {
61
+        foreach ($finder->directories() as $directory)
62
+        {
61 63
             $locales[] = $directory->getFilename();
62 64
         }
63 65
 
@@ -72,14 +74,16 @@  discard block
 block discarded – undo
72 74
         $locale = preg_replace('/[^a-zA-Z_]/', '', mb_strtolower($locale));
73 75
         $catalogue = new Catalogue($locale);
74 76
 
75
-        if (!$this->hasLocale($locale)) {
77
+        if (!$this->hasLocale($locale))
78
+        {
76 79
             return $catalogue;
77 80
         }
78 81
 
79 82
         $finder = new Finder();
80 83
         $finder->in($this->config->getLocaleDirectory($locale));
81 84
 
82
-        foreach ($finder->getIterator() as $file) {
85
+        foreach ($finder->getIterator() as $file)
86
+        {
83 87
             $this->getLogger()->info(
84 88
                 sprintf(
85 89
                     "found locale domain file '%s'",
@@ -91,7 +95,8 @@  discard block
 block discarded – undo
91 95
             //Per application agreement domain name must present in filename
92 96
             $domain = strstr($file->getFilename(), '.', true);
93 97
 
94
-            if (!$this->config->hasLoader($file->getExtension())) {
98
+            if (!$this->config->hasLoader($file->getExtension()))
99
+            {
95 100
                 $this->getLogger()->warning(
96 101
                     sprintf(
97 102
                         "unable to load domain file '%s', no loader found",
Please login to merge, or discard this patch.