Passed
Push — feature-FRAM-29-php-8-entity-g... ( 102654 )
by Vincent
21:47
created
src/Entity/EntityGenerator.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
         $body = str_replace('<spaces>', $this->spaces, $body);
408 408
         $last = strrpos($currentCode, '}');
409 409
 
410
-        return substr($currentCode, 0, $last) . $body . (strlen($body) > 0 ? "\n" : '') . "}\n";
410
+        return substr($currentCode, 0, $last).$body.(strlen($body) > 0 ? "\n" : '')."}\n";
411 411
     }
412 412
 
413 413
     /**
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
     protected function generateEntityNamespace(): string
417 417
     {
418 418
         if ($this->hasNamespace($this->mapperInfo->className())) {
419
-            return 'namespace ' . $this->getNamespace($this->mapperInfo->className()) .';' . "\n\n";
419
+            return 'namespace '.$this->getNamespace($this->mapperInfo->className()).';'."\n\n";
420 420
         }
421 421
 
422 422
         return '';
@@ -432,18 +432,18 @@  discard block
 block discarded – undo
432 432
         $use = [];
433 433
 
434 434
         if (($parentClass = $this->getClassToExtend()) && $this->hasNamespace($parentClass)) {
435
-            $use[$parentClass] = 'use ' . $parentClass . ';';
435
+            $use[$parentClass] = 'use '.$parentClass.';';
436 436
         }
437 437
 
438 438
         foreach ($this->interfaces as $interface) {
439 439
             if ($this->hasNamespace($interface)) {
440
-                $use[$interface] = 'use ' . $interface . ';';
440
+                $use[$interface] = 'use '.$interface.';';
441 441
             }
442 442
         }
443 443
 
444 444
         foreach ($this->traits as $trait) {
445 445
             if ($this->hasNamespace($trait)) {
446
-                $use[$trait] = 'use ' . $trait . ';';
446
+                $use[$trait] = 'use '.$trait.';';
447 447
             }
448 448
         }
449 449
 
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
 
474 474
         sort($use);
475 475
 
476
-        return implode("\n", $use) . "\n\n";
476
+        return implode("\n", $use)."\n\n";
477 477
     }
478 478
 
479 479
     /**
@@ -481,9 +481,9 @@  discard block
 block discarded – undo
481 481
      */
482 482
     protected function generateEntityClassName()
483 483
     {
484
-        return 'class ' . $this->getClassName($this->mapperInfo->className()) .
485
-            ($this->classToExtend ? ' extends ' . $this->getClassToExtendName() : null) .
486
-            ($this->interfaces ? ' implements ' . $this->getInterfacesToImplement() : null);
484
+        return 'class '.$this->getClassName($this->mapperInfo->className()).
485
+            ($this->classToExtend ? ' extends '.$this->getClassToExtendName() : null).
486
+            ($this->interfaces ? ' implements '.$this->getInterfacesToImplement() : null);
487 487
     }
488 488
 
489 489
     /**
@@ -498,10 +498,10 @@  discard block
 block discarded – undo
498 498
         $traits = '';
499 499
 
500 500
         foreach ($this->traits as $trait) {
501
-            $traits .= $this->spaces . 'use ' . $this->getRelativeClassName($trait) . ';' . "\n";
501
+            $traits .= $this->spaces.'use '.$this->getRelativeClassName($trait).';'."\n";
502 502
         }
503 503
 
504
-        return $traits . "\n";
504
+        return $traits."\n";
505 505
     }
506 506
 
507 507
     /**
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
     {
669 669
         $lines = [];
670 670
         $lines[] = '/**';
671
-        $lines[] = ' * ' . $this->getClassName($this->mapperInfo->className());
671
+        $lines[] = ' * '.$this->getClassName($this->mapperInfo->className());
672 672
         $lines[] = ' */';
673 673
 
674 674
         return implode("\n", $lines);
@@ -769,7 +769,7 @@  discard block
 block discarded – undo
769 769
 
770 770
             if (!$property->isRelation()) {
771 771
                 $lines[] = $this->generateEmbeddedPropertyDocBlock($property);
772
-                $lines[] = $this->spaces . $this->fieldVisibility . $this->getPropertyTypeHintForObject($property, $forceNullable) . ' $'.$property->name().";\n";
772
+                $lines[] = $this->spaces.$this->fieldVisibility.$this->getPropertyTypeHintForObject($property, $forceNullable).' $'.$property->name().";\n";
773 773
             } else {
774 774
                 $name = $property->name();
775 775
                 $default = '';
@@ -785,7 +785,7 @@  discard block
 block discarded – undo
785 785
                 }
786 786
 
787 787
                 $lines[] = $this->generateEmbeddedPropertyDocBlock($property);
788
-                $lines[] = $this->spaces . $this->fieldVisibility . $this->getPropertyTypeHintForObject($property, $forceNullable) . ' $' . $name . $default .";\n";
788
+                $lines[] = $this->spaces.$this->fieldVisibility.$this->getPropertyTypeHintForObject($property, $forceNullable).' $'.$name.$default.";\n";
789 789
             }
790 790
         }
791 791
 
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
             $variableName = $this->inflector->camelize($fieldName);
814 814
             $methodName = $variableName;
815 815
         } else {
816
-            $methodName = $type . $this->inflector->classify($fieldName);
816
+            $methodName = $type.$this->inflector->classify($fieldName);
817 817
             $variableName = $this->inflector->camelize($fieldName);
818 818
         }
819 819
 
@@ -831,7 +831,7 @@  discard block
 block discarded – undo
831 831
         if ($propertyInfo->isObject()) {
832 832
             /** @var ObjectPropertyInfo $propertyInfo */
833 833
             $variableType = $this->getRelativeClassName($propertyInfo->className());
834
-            $methodTypeHint =  $variableType.' ';
834
+            $methodTypeHint = $variableType.' ';
835 835
         } else {
836 836
             /** @var PropertyInfo $propertyInfo */
837 837
             $variableType = $propertyInfo->phpType();
@@ -938,9 +938,9 @@  discard block
 block discarded – undo
938 938
     protected function generateFieldMappingPropertyDocBlock($property)
939 939
     {
940 940
         $lines = [];
941
-        $lines[] = $this->spaces . '/**';
942
-        $lines[] = $this->spaces . ' * @var '.$property->phpType();
943
-        $lines[] = $this->spaces . ' */';
941
+        $lines[] = $this->spaces.'/**';
942
+        $lines[] = $this->spaces.' * @var '.$property->phpType();
943
+        $lines[] = $this->spaces.' */';
944 944
 
945 945
         return implode("\n", $lines);
946 946
     }
@@ -969,9 +969,9 @@  discard block
 block discarded – undo
969 969
         }
970 970
 
971 971
         $lines = [];
972
-        $lines[] = $this->spaces . '/**';
973
-        $lines[] = $this->spaces . ' * @var '.$className;
974
-        $lines[] = $this->spaces . ' */';
972
+        $lines[] = $this->spaces.'/**';
973
+        $lines[] = $this->spaces.' * @var '.$className;
974
+        $lines[] = $this->spaces.' */';
975 975
 
976 976
         return implode("\n", $lines);
977 977
     }
@@ -1012,7 +1012,7 @@  discard block
 block discarded – undo
1012 1012
 
1013 1013
             if ($inClass) {
1014 1014
                 $inClass = false;
1015
-                $lastSeenClass = $lastSeenNamespace . ($lastSeenNamespace ? '\\' : '') . $token[1];
1015
+                $lastSeenClass = $lastSeenNamespace.($lastSeenNamespace ? '\\' : '').$token[1];
1016 1016
                 $this->staticReflection[$lastSeenClass]['properties'] = [];
1017 1017
                 $this->staticReflection[$lastSeenClass]['methods'] = [];
1018 1018
             }
@@ -1020,16 +1020,16 @@  discard block
 block discarded – undo
1020 1020
             if ($token[0] == T_NAMESPACE) {
1021 1021
                 $lastSeenNamespace = "";
1022 1022
                 $inNamespace = true;
1023
-            } elseif ($token[0] == T_CLASS && $tokens[$i-1][0] != T_DOUBLE_COLON) {
1023
+            } elseif ($token[0] == T_CLASS && $tokens[$i - 1][0] != T_DOUBLE_COLON) {
1024 1024
                 $inClass = true;
1025 1025
             } elseif ($token[0] == T_FUNCTION) {
1026
-                if ($tokens[$i+2][0] == T_STRING) {
1027
-                    $this->staticReflection[$lastSeenClass]['methods'][] = strtolower($tokens[$i+2][1]);
1028
-                } elseif ($tokens[$i+2] == "&" && $tokens[$i+3][0] == T_STRING) {
1029
-                    $this->staticReflection[$lastSeenClass]['methods'][] = strtolower($tokens[$i+3][1]);
1026
+                if ($tokens[$i + 2][0] == T_STRING) {
1027
+                    $this->staticReflection[$lastSeenClass]['methods'][] = strtolower($tokens[$i + 2][1]);
1028
+                } elseif ($tokens[$i + 2] == "&" && $tokens[$i + 3][0] == T_STRING) {
1029
+                    $this->staticReflection[$lastSeenClass]['methods'][] = strtolower($tokens[$i + 3][1]);
1030 1030
                 }
1031
-            } elseif (in_array($token[0], [T_VAR, T_PUBLIC, T_PRIVATE, T_PROTECTED]) && $tokens[$i+2][0] != T_FUNCTION) {
1032
-                $this->staticReflection[$lastSeenClass]['properties'][] = substr($tokens[$i+2][1], 1);
1031
+            } elseif (in_array($token[0], [T_VAR, T_PUBLIC, T_PRIVATE, T_PROTECTED]) && $tokens[$i + 2][0] != T_FUNCTION) {
1032
+                $this->staticReflection[$lastSeenClass]['properties'][] = substr($tokens[$i + 2][1], 1);
1033 1033
             }
1034 1034
         }
1035 1035
     }
@@ -1104,7 +1104,7 @@  discard block
 block discarded – undo
1104 1104
         if ($this->hasNamespace($className)) {
1105 1105
             return $this->getClassName($className);
1106 1106
         } else {
1107
-            return '\\' . $className;
1107
+            return '\\'.$className;
1108 1108
         }
1109 1109
     }
1110 1110
 
@@ -1205,8 +1205,8 @@  discard block
 block discarded – undo
1205 1205
         $lines = explode("\n", $code);
1206 1206
 
1207 1207
         foreach ($lines as $key => $value) {
1208
-            if (! empty($value)) {
1209
-                $lines[$key] = str_repeat($this->spaces, $num) . $lines[$key];
1208
+            if (!empty($value)) {
1209
+                $lines[$key] = str_repeat($this->spaces, $num).$lines[$key];
1210 1210
             }
1211 1211
         }
1212 1212
 
@@ -1235,7 +1235,7 @@  discard block
 block discarded – undo
1235 1235
         }
1236 1236
 
1237 1237
         if (is_string($value)) {
1238
-            return "'" . $value . "'";
1238
+            return "'".$value."'";
1239 1239
         }
1240 1240
 
1241 1241
         if (is_bool($value)) {
@@ -1268,7 +1268,7 @@  discard block
 block discarded – undo
1268 1268
             $type = self::PROPERTY_TYPE_MAP[$type] ?? $type;
1269 1269
         }
1270 1270
 
1271
-        return ($nullable ? '?' : '') . $type;
1271
+        return ($nullable ? '?' : '').$type;
1272 1272
     }
1273 1273
 
1274 1274
     /**
@@ -1288,7 +1288,7 @@  discard block
 block discarded – undo
1288 1288
             return '';
1289 1289
         }
1290 1290
 
1291
-        return ' ' . $this->getPropertyTypeHint($property->phpType(), $forceNullable || $property->isNullable());
1291
+        return ' '.$this->getPropertyTypeHint($property->phpType(), $forceNullable || $property->isNullable());
1292 1292
     }
1293 1293
 
1294 1294
     /**
@@ -1323,7 +1323,7 @@  discard block
 block discarded – undo
1323 1323
             }
1324 1324
         }
1325 1325
 
1326
-        return ' ' . $this->getPropertyTypeHint($type, $forceNullable || $property->isRelation());
1326
+        return ' '.$this->getPropertyTypeHint($type, $forceNullable || $property->isRelation());
1327 1327
     }
1328 1328
 
1329 1329
     //---------------------- mutators
@@ -1457,7 +1457,7 @@  discard block
 block discarded – undo
1457 1457
     public function setFieldVisibility(string $visibility): void
1458 1458
     {
1459 1459
         if ($visibility !== static::FIELD_VISIBLE_PRIVATE && $visibility !== static::FIELD_VISIBLE_PROTECTED) {
1460
-            throw new \InvalidArgumentException('Invalid provided visibility (only private and protected are allowed): ' . $visibility);
1460
+            throw new \InvalidArgumentException('Invalid provided visibility (only private and protected are allowed): '.$visibility);
1461 1461
         }
1462 1462
 
1463 1463
         $this->fieldVisibility = $visibility;
Please login to merge, or discard this patch.