Passed
Pull Request — master (#411)
by Saif Eddin
06:12 queued 11s
created
src/DataGrid/src/Specification/Value/SubsetValue.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -35,11 +35,11 @@
 block discarded – undo
35 35
     {
36 36
         $values = (array)$value;
37 37
 
38
-        if (count($values) === 1) {
38
+        if (count($values) === 1){
39 39
             return $this->enum->accepts(array_values($values)[0]);
40 40
         }
41 41
 
42
-        if (empty($values)) {
42
+        if (empty($values)){
43 43
             return false;
44 44
         }
45 45
 
Please login to merge, or discard this patch.
src/DataGrid/src/Specification/Value/IntersectValue.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -35,12 +35,12 @@  discard block
 block discarded – undo
35 35
     {
36 36
         $values = (array)$value;
37 37
 
38
-        if (count($values) === 1) {
38
+        if (count($values) === 1){
39 39
             return $this->enum->accepts(array_values($values)[0]);
40 40
         }
41 41
 
42
-        foreach ($values as $v) {
43
-            if ($this->enum->accepts($v)) {
42
+        foreach ($values as $v){
43
+            if ($this->enum->accepts($v)){
44 44
                 return true;
45 45
             }
46 46
         }
@@ -55,8 +55,8 @@  discard block
 block discarded – undo
55 55
     public function convert($value): array
56 56
     {
57 57
         $result = [];
58
-        foreach ((array)$value as $v) {
59
-            if ($this->enum->accepts($v)) {
58
+        foreach ((array)$value as $v){
59
+            if ($this->enum->accepts($v)){
60 60
                 $result[] = $this->enum->convert($v);
61 61
             }
62 62
         }
Please login to merge, or discard this patch.
src/Validation/src/Checker/StringChecker.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -88,7 +88,7 @@
 block discarded – undo
88 88
      */
89 89
     public function range($value, int $min, int $max): bool
90 90
     {
91
-        if (!is_string($value)) {
91
+        if (!is_string($value)){
92 92
             return false;
93 93
         }
94 94
 
Please login to merge, or discard this patch.
src/Core/src/Container.php 1 patch
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;
@@ -107,17 +107,17 @@  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
 
114 114
                 throw new ContainerException($error);
115 115
             }
116 116
 
117
-            if ($type instanceof \ReflectionNamedType && !$type->isBuiltin()) {
118
-                try {
117
+            if ($type instanceof \ReflectionNamedType && !$type->isBuiltin()){
118
+                try{
119 119
                     $class = new \ReflectionClass($type->getName());
120
-                } catch (\ReflectionException $e) {
120
+                }catch (\ReflectionException $e){
121 121
                     $location = $this->getLocationString($reflection);
122 122
 
123 123
                     $error = 'Unable to resolve `\$%s` parameter in %s: %s';
@@ -127,11 +127,11 @@  discard block
 block discarded – undo
127 127
                 }
128 128
             }
129 129
 
130
-            if (isset($parameters[$name]) && is_object($parameters[$name])) {
131
-                if ($parameters[$name] instanceof Autowire) {
130
+            if (isset($parameters[$name]) && is_object($parameters[$name])){
131
+                if ($parameters[$name] instanceof Autowire){
132 132
                     // Supplied by user as late dependency
133 133
                     $arguments[] = $parameters[$name]->resolve($this);
134
-                } else {
134
+                }else{
135 135
                     // Supplied by user as object
136 136
                     $arguments[] = $parameters[$name];
137 137
                 }
@@ -139,16 +139,16 @@  discard block
 block discarded – undo
139 139
             }
140 140
 
141 141
             // no declared type or scalar type or array
142
-            if (!isset($class)) {
142
+            if (!isset($class)){
143 143
                 // Provided from outside
144
-                if (\array_key_exists($name, $parameters)) {
144
+                if (\array_key_exists($name, $parameters)){
145 145
                     // Make sure it's properly typed
146 146
                     $this->assertType($parameter, $reflection, $parameters[$name]);
147 147
                     $arguments[] = $parameters[$name];
148 148
                     continue;
149 149
                 }
150 150
 
151
-                if ($parameter->isDefaultValueAvailable()) {
151
+                if ($parameter->isDefaultValueAvailable()){
152 152
                     //Default value
153 153
                     $arguments[] = $parameter->getDefaultValue();
154 154
                     continue;
@@ -158,12 +158,12 @@  discard block
 block discarded – undo
158 158
                 throw new ArgumentException($parameter, $reflection);
159 159
             }
160 160
 
161
-            try {
161
+            try{
162 162
                 //Requesting for contextual dependency
163 163
                 $arguments[] = $this->get($class->getName(), $name);
164 164
                 continue;
165
-            } catch (AutowireException $e) {
166
-                if ($parameter->isOptional()) {
165
+            }catch (AutowireException $e){
166
+                if ($parameter->isOptional()){
167 167
                     //This is optional dependency, skip
168 168
                     $arguments[] = null;
169 169
                     continue;
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
      */
194 194
     public function get($id, string $context = null)
195 195
     {
196
-        if ($id instanceof Autowire) {
196
+        if ($id instanceof Autowire){
197 197
             return $id->resolve($this);
198 198
         }
199 199
 
@@ -209,34 +209,34 @@  discard block
 block discarded – undo
209 209
      */
210 210
     public function make(string $alias, array $parameters = [], string $context = null)
211 211
     {
212
-        if (!isset($this->bindings[$alias])) {
212
+        if (!isset($this->bindings[$alias])){
213 213
             //No direct instructions how to construct class, make is automatically
214 214
             return $this->autowire($alias, $parameters, $context);
215 215
         }
216 216
 
217 217
         $binding = $this->bindings[$alias];
218
-        if (\is_object($binding)) {
218
+        if (\is_object($binding)){
219 219
             //When binding is instance, assuming singleton
220 220
             return $binding;
221 221
         }
222 222
 
223
-        if (\is_string($binding)) {
223
+        if (\is_string($binding)){
224 224
             //Binding is pointing to something else
225 225
             return $this->make($binding, $parameters, $context);
226 226
         }
227 227
 
228 228
         unset($this->bindings[$alias]);
229
-        try {
230
-            if ($binding[0] === $alias) {
229
+        try{
230
+            if ($binding[0] === $alias){
231 231
                 $instance = $this->autowire($alias, $parameters, $context);
232
-            } else {
232
+            }else{
233 233
                 $instance = $this->evaluateBinding($alias, $binding[0], $parameters, $context);
234 234
             }
235
-        } finally {
235
+        }finally{
236 236
             $this->bindings[$alias] = $binding;
237 237
         }
238 238
 
239
-        if ($binding[1]) {
239
+        if ($binding[1]){
240 240
             //Indicates singleton
241 241
             $this->bindings[$alias] = $instance;
242 242
         }
@@ -250,28 +250,28 @@  discard block
 block discarded – undo
250 250
     public function runScope(array $bindings, callable $scope)
251 251
     {
252 252
         $cleanup = $previous = [];
253
-        foreach ($bindings as $alias => $resolver) {
254
-            if (isset($this->bindings[$alias])) {
253
+        foreach ($bindings as $alias => $resolver){
254
+            if (isset($this->bindings[$alias])){
255 255
                 $previous[$alias] = $this->bindings[$alias];
256
-            } else {
256
+            }else{
257 257
                 $cleanup[] = $alias;
258 258
             }
259 259
 
260 260
             $this->bind($alias, $resolver);
261 261
         }
262 262
 
263
-        try {
264
-            if (ContainerScope::getContainer() !== $this) {
263
+        try{
264
+            if (ContainerScope::getContainer() !== $this){
265 265
                 return ContainerScope::runScope($this, $scope);
266 266
             }
267 267
 
268 268
             return $scope();
269
-        } finally {
270
-            foreach (\array_reverse($previous) as $alias => $resolver) {
269
+        }finally{
270
+            foreach (\array_reverse($previous) as $alias => $resolver){
271 271
                 $this->bindings[$alias] = $resolver;
272 272
             }
273 273
 
274
-            foreach ($cleanup as $alias) {
274
+            foreach ($cleanup as $alias){
275 275
                 unset($this->bindings[$alias]);
276 276
             }
277 277
         }
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
      */
288 288
     public function bind(string $alias, $resolver): void
289 289
     {
290
-        if (\is_array($resolver) || $resolver instanceof \Closure || $resolver instanceof Autowire) {
290
+        if (\is_array($resolver) || $resolver instanceof \Closure || $resolver instanceof Autowire){
291 291
             // array means = execute me, false = not singleton
292 292
             $this->bindings[$alias] = [$resolver, false];
293 293
 
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
      */
307 307
     public function bindSingleton(string $alias, $resolver): void
308 308
     {
309
-        if (\is_object($resolver) && !$resolver instanceof \Closure && !$resolver instanceof Autowire) {
309
+        if (\is_object($resolver) && !$resolver instanceof \Closure && !$resolver instanceof Autowire){
310 310
             // direct binding to an instance
311 311
             $this->bindings[$alias] = $resolver;
312 312
 
@@ -324,11 +324,11 @@  discard block
 block discarded – undo
324 324
      */
325 325
     public function hasInstance(string $alias): bool
326 326
     {
327
-        if (!$this->has($alias)) {
327
+        if (!$this->has($alias)){
328 328
             return false;
329 329
         }
330 330
 
331
-        while (isset($this->bindings[$alias]) && \is_string($this->bindings[$alias])) {
331
+        while (isset($this->bindings[$alias]) && \is_string($this->bindings[$alias])){
332 332
             //Checking alias tree
333 333
             $alias = $this->bindings[$alias];
334 334
         }
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
      */
411 411
     protected function autowire(string $class, array $parameters, string $context = null)
412 412
     {
413
-        if (!\class_exists($class)) {
413
+        if (!\class_exists($class)){
414 414
             throw new NotFoundException(\sprintf("Undefined class or binding '%s'", $class));
415 415
         }
416 416
 
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
     {
430 430
         $location = $reflection->getName();
431 431
 
432
-        if ($reflection instanceof \ReflectionMethod) {
432
+        if ($reflection instanceof \ReflectionMethod){
433 433
             return "{$reflection->getDeclaringClass()->getName()}::{$location}()";
434 434
         }
435 435
 
@@ -448,11 +448,11 @@  discard block
 block discarded – undo
448 448
      */
449 449
     private function assertType(\ReflectionParameter $parameter, ContextFunction $context, $value): void
450 450
     {
451
-        if ($value === null) {
451
+        if ($value === null){
452 452
             if (
453 453
                 !$parameter->isOptional() &&
454 454
                 !($parameter->isDefaultValueAvailable() && $parameter->getDefaultValue() === null)
455
-            ) {
455
+            ){
456 456
                 throw new ArgumentException($parameter, $context);
457 457
             }
458 458
 
@@ -460,20 +460,20 @@  discard block
 block discarded – undo
460 460
         }
461 461
 
462 462
         $type = $parameter->getType();
463
-        if ($type === null) {
463
+        if ($type === null){
464 464
             return;
465 465
         }
466 466
 
467 467
         $typeName = $type->getName();
468
-        if ($typeName === 'array' && !\is_array($value)) {
468
+        if ($typeName === 'array' && !\is_array($value)){
469 469
             throw new ArgumentException($parameter, $context);
470 470
         }
471 471
 
472
-        if (($typeName === 'int' || $typeName === 'float') && !\is_numeric($value)) {
472
+        if (($typeName === 'int' || $typeName === 'float') && !\is_numeric($value)){
473 473
             throw new ArgumentException($parameter, $context);
474 474
         }
475 475
 
476
-        if ($typeName === 'bool' && !\is_bool($value) && !\is_numeric($value)) {
476
+        if ($typeName === 'bool' && !\is_bool($value) && !\is_numeric($value)){
477 477
             throw new ArgumentException($parameter, $context);
478 478
         }
479 479
     }
@@ -491,22 +491,22 @@  discard block
 block discarded – undo
491 491
      */
492 492
     private function createInstance(string $class, array $parameters, string $context = null)
493 493
     {
494
-        try {
494
+        try{
495 495
             $reflection = new \ReflectionClass($class);
496
-        } catch (\ReflectionException $e) {
496
+        }catch (\ReflectionException $e){
497 497
             throw new ContainerException($e->getMessage(), $e->getCode(), $e);
498 498
         }
499 499
 
500 500
         //We have to construct class using external injector when we know exact context
501
-        if ($parameters === [] && $this->checkInjector($reflection)) {
501
+        if ($parameters === [] && $this->checkInjector($reflection)){
502 502
             $injector = $this->injectors[$reflection->getName()];
503 503
 
504 504
             $instance = null;
505
-            try {
505
+            try{
506 506
                 /** @var InjectorInterface $injectorInstance */
507 507
                 $injectorInstance = $this->get($injector);
508 508
 
509
-                if (!$injectorInstance instanceof InjectorInterface) {
509
+                if (!$injectorInstance instanceof InjectorInterface){
510 510
                     throw new InjectionException(
511 511
                         \sprintf(
512 512
                             "Class '%s' must be an instance of InjectorInterface for '%s'",
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
                 }
518 518
 
519 519
                 $instance = $injectorInstance->createInjection($reflection, $context);
520
-                if (!$reflection->isInstance($instance)) {
520
+                if (!$reflection->isInstance($instance)){
521 521
                     throw new InjectionException(
522 522
                         \sprintf(
523 523
                             "Invalid injection response for '%s'",
@@ -525,23 +525,23 @@  discard block
 block discarded – undo
525 525
                         )
526 526
                     );
527 527
                 }
528
-            } finally {
528
+            }finally{
529 529
                 $this->injectors[$reflection->getName()] = $injector;
530 530
             }
531 531
 
532 532
             return $instance;
533 533
         }
534 534
 
535
-        if (!$reflection->isInstantiable()) {
535
+        if (!$reflection->isInstantiable()){
536 536
             throw new ContainerException(\sprintf("Class '%s' can not be constructed", $class));
537 537
         }
538 538
 
539 539
         $constructor = $reflection->getConstructor();
540 540
 
541
-        if ($constructor !== null) {
541
+        if ($constructor !== null){
542 542
             // Using constructor with resolved arguments
543 543
             $instance = $reflection->newInstanceArgs($this->resolveArguments($constructor, $parameters));
544
-        } else {
544
+        }else{
545 545
             // No constructor specified
546 546
             $instance = $reflection->newInstance();
547 547
         }
@@ -558,28 +558,28 @@  discard block
 block discarded – undo
558 558
     private function checkInjector(\ReflectionClass $reflection): bool
559 559
     {
560 560
         $class = $reflection->getName();
561
-        if (\array_key_exists($class, $this->injectors)) {
561
+        if (\array_key_exists($class, $this->injectors)){
562 562
             return $this->injectors[$class] !== null;
563 563
         }
564 564
 
565 565
         if (
566 566
             $reflection->implementsInterface(InjectableInterface::class)
567 567
             && $reflection->hasConstant('INJECTOR')
568
-        ) {
568
+        ){
569 569
             $this->injectors[$class] = $reflection->getConstant('INJECTOR');
570 570
 
571 571
             return true;
572 572
         }
573 573
 
574
-        if (!isset($this->injectorsCache[$class])) {
574
+        if (!isset($this->injectorsCache[$class])){
575 575
             $this->injectorsCache[$class] = null;
576 576
 
577 577
             // check interfaces
578
-            foreach ($this->injectors as $target => $injector) {
578
+            foreach ($this->injectors as $target => $injector){
579 579
                 if (
580 580
                     \class_exists($target, true)
581 581
                     && $reflection->isSubclassOf($target)
582
-                ) {
582
+                ){
583 583
                     $this->injectors[$class] = $injector;
584 584
 
585 585
                     return true;
@@ -588,7 +588,7 @@  discard block
 block discarded – undo
588 588
                 if (
589 589
                     \interface_exists($target, true)
590 590
                     && $reflection->implementsInterface($target)
591
-                ) {
591
+                ){
592 592
                     $this->injectors[$class] = $injector;
593 593
 
594 594
                     return true;
@@ -610,9 +610,9 @@  discard block
 block discarded – undo
610 610
     private function registerInstance($instance, array $parameters)
611 611
     {
612 612
         //Declarative singletons (only when class received via direct get)
613
-        if ($parameters === [] && $instance instanceof SingletonInterface) {
613
+        if ($parameters === [] && $instance instanceof SingletonInterface){
614 614
             $alias = \get_class($instance);
615
-            if (!isset($this->bindings[$alias])) {
615
+            if (!isset($this->bindings[$alias])){
616 616
                 $this->bindings[$alias] = $instance;
617 617
             }
618 618
         }
@@ -633,19 +633,19 @@  discard block
 block discarded – undo
633 633
      */
634 634
     private function evaluateBinding(string $alias, $target, array $parameters, string $context = null)
635 635
     {
636
-        if (\is_string($target)) {
636
+        if (\is_string($target)){
637 637
             // Reference
638 638
             return $this->make($target, $parameters, $context);
639 639
         }
640 640
 
641
-        if ($target instanceof Autowire) {
641
+        if ($target instanceof Autowire){
642 642
             return $target->resolve($this, $parameters);
643 643
         }
644 644
 
645
-        if ($target instanceof \Closure) {
646
-            try {
645
+        if ($target instanceof \Closure){
646
+            try{
647 647
                 $reflection = new \ReflectionFunction($target);
648
-            } catch (\ReflectionException $e) {
648
+            }catch (\ReflectionException $e){
649 649
                 throw new ContainerException($e->getMessage(), $e->getCode(), $e);
650 650
             }
651 651
 
@@ -655,16 +655,16 @@  discard block
 block discarded – undo
655 655
             );
656 656
         }
657 657
 
658
-        if (is_array($target) && isset($target[1])) {
658
+        if (is_array($target) && isset($target[1])){
659 659
             // In a form of resolver and method
660 660
             [$resolver, $method] = $target;
661 661
 
662 662
             // Resolver instance (i.e. [ClassName::class, 'method'])
663 663
             $resolver = $this->get($resolver);
664 664
 
665
-            try {
665
+            try{
666 666
                 $method = new \ReflectionMethod($resolver, $method);
667
-            } catch (\ReflectionException $e) {
667
+            }catch (\ReflectionException $e){
668 668
                 throw new ContainerException($e->getMessage(), $e->getCode(), $e);
669 669
             }
670 670
 
Please login to merge, or discard this patch.
src/Models/src/DataEntity.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -72,11 +72,11 @@  discard block
 block discarded – undo
72 72
      */
73 73
     protected function isFillable(string $field): bool
74 74
     {
75
-        if (!empty(static::FILLABLE)) {
75
+        if (!empty(static::FILLABLE)){
76 76
             return in_array($field, static::FILLABLE);
77 77
         }
78 78
 
79
-        if (static::SECURED === '*') {
79
+        if (static::SECURED === '*'){
80 80
             return false;
81 81
         }
82 82
 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
     protected function getMutator(string $field, string $type)
96 96
     {
97 97
         $target = [];
98
-        switch ($type) {
98
+        switch ($type){
99 99
             case ModelSchema::MUTATOR_ACCESSOR:
100 100
                 $target = static::ACCESSORS;
101 101
                 break;
Please login to merge, or discard this patch.
src/Models/src/SchematicEntity.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -34,15 +34,15 @@
 block discarded – undo
34 34
      */
35 35
     protected function isFillable(string $field): bool
36 36
     {
37
-        if (!empty($this->schema[ModelSchema::FILLABLE]) && $this->schema[ModelSchema::FILLABLE] === '*') {
37
+        if (!empty($this->schema[ModelSchema::FILLABLE]) && $this->schema[ModelSchema::FILLABLE] === '*'){
38 38
             return true;
39 39
         }
40 40
 
41
-        if (!empty($this->schema[ModelSchema::FILLABLE])) {
41
+        if (!empty($this->schema[ModelSchema::FILLABLE])){
42 42
             return in_array($field, $this->schema[ModelSchema::FILLABLE], true);
43 43
         }
44 44
 
45
-        if (!empty($this->schema[ModelSchema::SECURED]) && $this->schema[ModelSchema::SECURED] === '*') {
45
+        if (!empty($this->schema[ModelSchema::SECURED]) && $this->schema[ModelSchema::SECURED] === '*'){
46 46
             return false;
47 47
         }
48 48
 
Please login to merge, or discard this patch.
src/Prototype/src/ClassNode/ConstructorParam.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -55,14 +55,14 @@
 block discarded – undo
55 55
         $stmt = new self();
56 56
         $stmt->name = $parameter->getName();
57 57
 
58
-        if ($parameter->hasType()) {
58
+        if ($parameter->hasType()){
59 59
             $type = $parameter->getType();
60 60
             $stmt->type = Type::create($type->getName());
61 61
             $stmt->builtIn = $type->isBuiltin();
62 62
             $stmt->nullable = $type->allowsNull();
63 63
         }
64 64
 
65
-        if ($parameter->isDefaultValueAvailable()) {
65
+        if ($parameter->isDefaultValueAvailable()){
66 66
             $stmt->hasDefault = true;
67 67
             $stmt->default = $parameter->getDefaultValue();
68 68
         }
Please login to merge, or discard this patch.
src/Translator/src/Catalogue.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
      */
58 58
     public function has(string $domain, string $id): bool
59 59
     {
60
-        if (!isset($this->data[$domain])) {
60
+        if (!isset($this->data[$domain])){
61 61
             return false;
62 62
         }
63 63
 
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
      */
70 70
     public function get(string $domain, string $id): string
71 71
     {
72
-        if (!$this->has($domain, $id)) {
72
+        if (!$this->has($domain, $id)){
73 73
             throw new CatalogueException("Undefined string in domain '{$domain}'");
74 74
         }
75 75
 
@@ -99,15 +99,15 @@  discard block
 block discarded – undo
99 99
      */
100 100
     public function mergeFrom(MessageCatalogue $catalogue, bool $follow = true): void
101 101
     {
102
-        foreach ($catalogue->all() as $domain => $messages) {
103
-            if (!isset($this->data[$domain])) {
102
+        foreach ($catalogue->all() as $domain => $messages){
103
+            if (!isset($this->data[$domain])){
104 104
                 $this->data[$domain] = [];
105 105
             }
106 106
 
107
-            if ($follow) {
107
+            if ($follow){
108 108
                 //MessageCatalogue string has higher priority that string stored in memory
109 109
                 $this->data[$domain] = array_merge($messages, $this->data[$domain]);
110
-            } else {
110
+            }else{
111 111
                 $this->data[$domain] = array_merge($this->data[$domain], $messages);
112 112
             }
113 113
         }
Please login to merge, or discard this patch.