Completed
Pull Request — master (#1410)
by Ilya
10:40
created
lib/Doctrine/ORM/Tools/EntityGenerator.php 1 patch
Spacing   +144 added lines, -144 removed lines patch added patch discarded remove patch
@@ -364,14 +364,14 @@  discard block
 block discarded – undo
364 364
      */
365 365
     public function writeEntityClass(ClassMetadataInfo $metadata, $outputDirectory)
366 366
     {
367
-        $path = $outputDirectory . '/' . str_replace('\\', DIRECTORY_SEPARATOR, $metadata->name) . $this->extension;
367
+        $path = $outputDirectory.'/'.str_replace('\\', DIRECTORY_SEPARATOR, $metadata->name).$this->extension;
368 368
         $dir = dirname($path);
369 369
 
370 370
         if ( ! is_dir($dir)) {
371 371
             mkdir($dir, 0775, true);
372 372
         }
373 373
 
374
-        $this->isNew = !file_exists($path) || (file_exists($path) && $this->regenerateEntityIfExists);
374
+        $this->isNew = ! file_exists($path) || (file_exists($path) && $this->regenerateEntityIfExists);
375 375
 
376 376
         if ( ! $this->isNew) {
377 377
             $this->parseTokensInEntityFile(file_get_contents($path));
@@ -380,8 +380,8 @@  discard block
 block discarded – undo
380 380
         }
381 381
 
382 382
         if ($this->backupExisting && file_exists($path)) {
383
-            $backupPath = dirname($path) . DIRECTORY_SEPARATOR . basename($path) . "~";
384
-            if (!copy($path, $backupPath)) {
383
+            $backupPath = dirname($path).DIRECTORY_SEPARATOR.basename($path)."~";
384
+            if ( ! copy($path, $backupPath)) {
385 385
                 throw new \RuntimeException("Attempt to backup overwritten entity file but copy operation failed.");
386 386
             }
387 387
         }
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
             $this->generateEntityBody($metadata)
422 422
         );
423 423
 
424
-        $code = str_replace($placeHolders, $replacements, static::$classTemplate) . "\n";
424
+        $code = str_replace($placeHolders, $replacements, static::$classTemplate)."\n";
425 425
 
426 426
         return str_replace('<spaces>', $this->spaces, $code);
427 427
     }
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
         $body = str_replace('<spaces>', $this->spaces, $body);
443 443
         $last = strrpos($currentCode, '}');
444 444
 
445
-        return substr($currentCode, 0, $last) . $body . (strlen($body) > 0 ? "\n" : '') . "}\n";
445
+        return substr($currentCode, 0, $last).$body.(strlen($body) > 0 ? "\n" : '')."}\n";
446 446
     }
447 447
 
448 448
     /**
@@ -506,7 +506,7 @@  discard block
 block discarded – undo
506 506
     public function setFieldVisibility($visibility)
507 507
     {
508 508
         if ($visibility !== static::FIELD_VISIBLE_PRIVATE && $visibility !== static::FIELD_VISIBLE_PROTECTED) {
509
-            throw new \InvalidArgumentException('Invalid provided visibility (only private and protected are allowed): ' . $visibility);
509
+            throw new \InvalidArgumentException('Invalid provided visibility (only private and protected are allowed): '.$visibility);
510 510
         }
511 511
 
512 512
         $this->fieldVisibility = $visibility;
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
     protected function generateEntityNamespace(ClassMetadataInfo $metadata)
605 605
     {
606 606
         if ($this->hasNamespace($metadata)) {
607
-            return 'namespace ' . $this->getNamespace($metadata) .';';
607
+            return 'namespace '.$this->getNamespace($metadata).';';
608 608
         }
609 609
     }
610 610
 
@@ -624,8 +624,8 @@  discard block
 block discarded – undo
624 624
      */
625 625
     protected function generateEntityClassName(ClassMetadataInfo $metadata)
626 626
     {
627
-        return 'class ' . $this->getClassName($metadata) .
628
-            ($this->extendsClass() ? ' extends ' . $this->getClassToExtendName() : null);
627
+        return 'class '.$this->getClassName($metadata).
628
+            ($this->extendsClass() ? ' extends '.$this->getClassToExtendName() : null);
629 629
     }
630 630
 
631 631
     /**
@@ -727,13 +727,13 @@  discard block
 block discarded – undo
727 727
         $fieldMappings = array_merge($requiredFields, $optionalFields);
728 728
 
729 729
         foreach ($metadata->embeddedClasses as $fieldName => $embeddedClass) {
730
-            $paramType = '\\' . ltrim($embeddedClass['class'], '\\');
731
-            $paramVariable = '$' . $fieldName;
730
+            $paramType = '\\'.ltrim($embeddedClass['class'], '\\');
731
+            $paramVariable = '$'.$fieldName;
732 732
 
733 733
             $paramTypes[] = $paramType;
734 734
             $paramVariables[] = $paramVariable;
735
-            $params[] = $paramType . ' ' . $paramVariable;
736
-            $fields[] = '$this->' . $fieldName . ' = ' . $paramVariable . ';';
735
+            $params[] = $paramType.' '.$paramVariable;
736
+            $fields[] = '$this->'.$fieldName.' = '.$paramVariable.';';
737 737
         }
738 738
 
739 739
         foreach ($fieldMappings as $fieldMapping) {
@@ -743,27 +743,27 @@  discard block
 block discarded – undo
743 743
                 continue;
744 744
             }
745 745
 
746
-            $paramTypes[] = $this->getType($fieldMapping['type']) . (!empty($fieldMapping['nullable']) ? '|null' : '');
747
-            $param = '$' . $fieldMapping['fieldName'];
746
+            $paramTypes[] = $this->getType($fieldMapping['type']).( ! empty($fieldMapping['nullable']) ? '|null' : '');
747
+            $param = '$'.$fieldMapping['fieldName'];
748 748
             $paramVariables[] = $param;
749 749
 
750 750
             if ($fieldMapping['type'] === 'datetime') {
751
-                $param = $this->getType($fieldMapping['type']) . ' ' . $param;
751
+                $param = $this->getType($fieldMapping['type']).' '.$param;
752 752
             }
753 753
 
754
-            if (!empty($fieldMapping['nullable'])) {
754
+            if ( ! empty($fieldMapping['nullable'])) {
755 755
                 $param .= ' = null';
756 756
             }
757 757
 
758 758
             $params[] = $param;
759 759
 
760
-            $fields[] = '$this->' . $fieldMapping['fieldName'] . ' = $' . $fieldMapping['fieldName'] . ';';
760
+            $fields[] = '$this->'.$fieldMapping['fieldName'].' = $'.$fieldMapping['fieldName'].';';
761 761
         }
762 762
 
763 763
         $maxParamTypeLength = max(array_map('strlen', $paramTypes));
764 764
         $paramTags = array_map(
765
-            function ($type, $variable) use ($maxParamTypeLength) {
766
-                return '@param ' . $type . str_repeat(' ', $maxParamTypeLength - strlen($type) + 1) . $variable;
765
+            function($type, $variable) use ($maxParamTypeLength) {
766
+                return '@param '.$type.str_repeat(' ', $maxParamTypeLength - strlen($type) + 1).$variable;
767 767
             },
768 768
             $paramTypes,
769 769
             $paramVariables
@@ -771,8 +771,8 @@  discard block
 block discarded – undo
771 771
 
772 772
         // Generate multi line constructor if the signature exceeds 120 characters.
773 773
         if (array_sum(array_map('strlen', $params)) + count($params) * 2 + 29 > 120) {
774
-            $delimiter = "\n" . $this->spaces;
775
-            $params = $delimiter . implode(',' . $delimiter, $params) . "\n";
774
+            $delimiter = "\n".$this->spaces;
775
+            $params = $delimiter.implode(','.$delimiter, $params)."\n";
776 776
         } else {
777 777
             $params = implode(', ', $params);
778 778
         }
@@ -780,7 +780,7 @@  discard block
 block discarded – undo
780 780
         $replacements = array(
781 781
             '<paramTags>' => implode("\n * ", $paramTags),
782 782
             '<params>'    => $params,
783
-            '<fields>'    => implode("\n" . $this->spaces, $fields),
783
+            '<fields>'    => implode("\n".$this->spaces, $fields),
784 784
         );
785 785
 
786 786
         $constructor = str_replace(
@@ -824,7 +824,7 @@  discard block
 block discarded – undo
824 824
 
825 825
             if ($inClass) {
826 826
                 $inClass = false;
827
-                $lastSeenClass = $lastSeenNamespace . ($lastSeenNamespace ? '\\' : '') . $token[1];
827
+                $lastSeenClass = $lastSeenNamespace.($lastSeenNamespace ? '\\' : '').$token[1];
828 828
                 $this->staticReflection[$lastSeenClass]['properties'] = array();
829 829
                 $this->staticReflection[$lastSeenClass]['methods'] = array();
830 830
             }
@@ -832,16 +832,16 @@  discard block
 block discarded – undo
832 832
             if ($token[0] == T_NAMESPACE) {
833 833
                 $lastSeenNamespace = "";
834 834
                 $inNamespace = true;
835
-            } elseif ($token[0] == T_CLASS && $tokens[$i-1][0] != T_DOUBLE_COLON) {
835
+            } elseif ($token[0] == T_CLASS && $tokens[$i - 1][0] != T_DOUBLE_COLON) {
836 836
                 $inClass = true;
837 837
             } elseif ($token[0] == T_FUNCTION) {
838
-                if ($tokens[$i+2][0] == T_STRING) {
839
-                    $this->staticReflection[$lastSeenClass]['methods'][] = strtolower($tokens[$i+2][1]);
840
-                } elseif ($tokens[$i+2] == "&" && $tokens[$i+3][0] == T_STRING) {
841
-                    $this->staticReflection[$lastSeenClass]['methods'][] = strtolower($tokens[$i+3][1]);
838
+                if ($tokens[$i + 2][0] == T_STRING) {
839
+                    $this->staticReflection[$lastSeenClass]['methods'][] = strtolower($tokens[$i + 2][1]);
840
+                } elseif ($tokens[$i + 2] == "&" && $tokens[$i + 3][0] == T_STRING) {
841
+                    $this->staticReflection[$lastSeenClass]['methods'][] = strtolower($tokens[$i + 3][1]);
842 842
                 }
843
-            } elseif (in_array($token[0], array(T_VAR, T_PUBLIC, T_PRIVATE, T_PROTECTED)) && $tokens[$i+2][0] != T_FUNCTION) {
844
-                $this->staticReflection[$lastSeenClass]['properties'][] = substr($tokens[$i+2][1], 1);
843
+            } elseif (in_array($token[0], array(T_VAR, T_PUBLIC, T_PRIVATE, T_PROTECTED)) && $tokens[$i + 2][0] != T_FUNCTION) {
844
+                $this->staticReflection[$lastSeenClass]['properties'][] = substr($tokens[$i + 2][1], 1);
845 845
             }
846 846
         }
847 847
     }
@@ -854,7 +854,7 @@  discard block
 block discarded – undo
854 854
      */
855 855
     protected function hasProperty($property, ClassMetadataInfo $metadata)
856 856
     {
857
-        if ($this->extendsClass() || (!$this->isNew && class_exists($metadata->name))) {
857
+        if ($this->extendsClass() || ( ! $this->isNew && class_exists($metadata->name))) {
858 858
             // don't generate property if its already on the base class.
859 859
             $reflClass = new \ReflectionClass($this->getClassToExtend() ?: $metadata->name);
860 860
             if ($reflClass->hasProperty($property)) {
@@ -883,7 +883,7 @@  discard block
 block discarded – undo
883 883
      */
884 884
     protected function hasMethod($method, ClassMetadataInfo $metadata)
885 885
     {
886
-        if ($this->extendsClass() || (!$this->isNew && class_exists($metadata->name))) {
886
+        if ($this->extendsClass() || ( ! $this->isNew && class_exists($metadata->name))) {
887 887
             // don't generate method if its already on the base class.
888 888
             $reflClass = new \ReflectionClass($this->getClassToExtend() ?: $metadata->name);
889 889
 
@@ -912,7 +912,7 @@  discard block
 block discarded – undo
912 912
      */
913 913
     protected function getTraits(ClassMetadataInfo $metadata)
914 914
     {
915
-        if (! ($metadata->reflClass !== null || class_exists($metadata->name))) {
915
+        if ( ! ($metadata->reflClass !== null || class_exists($metadata->name))) {
916 916
             return [];
917 917
         }
918 918
 
@@ -964,7 +964,7 @@  discard block
 block discarded – undo
964 964
     {
965 965
         $refl = new \ReflectionClass($this->getClassToExtend());
966 966
 
967
-        return '\\' . $refl->getName();
967
+        return '\\'.$refl->getName();
968 968
     }
969 969
 
970 970
     /**
@@ -997,7 +997,7 @@  discard block
 block discarded – undo
997 997
     {
998 998
         $lines = array();
999 999
         $lines[] = '/**';
1000
-        $lines[] = ' * ' . $this->getClassName($metadata);
1000
+        $lines[] = ' * '.$this->getClassName($metadata);
1001 1001
 
1002 1002
         if ($this->generateAnnotations) {
1003 1003
             $lines[] = ' *';
@@ -1012,12 +1012,12 @@  discard block
 block discarded – undo
1012 1012
 
1013 1013
             foreach ($methods as $method) {
1014 1014
                 if ($code = $this->$method($metadata)) {
1015
-                    $lines[] = ' * ' . $code;
1015
+                    $lines[] = ' * '.$code;
1016 1016
                 }
1017 1017
             }
1018 1018
 
1019 1019
             if (isset($metadata->lifecycleCallbacks) && $metadata->lifecycleCallbacks) {
1020
-                $lines[] = ' * @' . $this->annotationsPrefix . 'HasLifecycleCallbacks';
1020
+                $lines[] = ' * @'.$this->annotationsPrefix.'HasLifecycleCallbacks';
1021 1021
             }
1022 1022
         }
1023 1023
 
@@ -1033,17 +1033,17 @@  discard block
 block discarded – undo
1033 1033
      */
1034 1034
     protected function generateEntityAnnotation(ClassMetadataInfo $metadata)
1035 1035
     {
1036
-        $prefix = '@' . $this->annotationsPrefix;
1036
+        $prefix = '@'.$this->annotationsPrefix;
1037 1037
 
1038 1038
         if ($metadata->isEmbeddedClass) {
1039
-            return $prefix . 'Embeddable';
1039
+            return $prefix.'Embeddable';
1040 1040
         }
1041 1041
 
1042 1042
         $customRepository = $metadata->customRepositoryClassName
1043
-            ? '(repositoryClass="' . $metadata->customRepositoryClassName . '")'
1043
+            ? '(repositoryClass="'.$metadata->customRepositoryClassName.'")'
1044 1044
             : '';
1045 1045
 
1046
-        return $prefix . ($metadata->isMappedSuperclass ? 'MappedSuperclass' : 'Entity') . $customRepository;
1046
+        return $prefix.($metadata->isMappedSuperclass ? 'MappedSuperclass' : 'Entity').$customRepository;
1047 1047
     }
1048 1048
 
1049 1049
     /**
@@ -1060,28 +1060,28 @@  discard block
 block discarded – undo
1060 1060
         $table = array();
1061 1061
 
1062 1062
         if (isset($metadata->table['schema'])) {
1063
-            $table[] = 'schema="' . $metadata->table['schema'] . '"';
1063
+            $table[] = 'schema="'.$metadata->table['schema'].'"';
1064 1064
         }
1065 1065
 
1066 1066
         if (isset($metadata->table['name'])) {
1067
-            $table[] = 'name="' . $metadata->table['name'] . '"';
1067
+            $table[] = 'name="'.$metadata->table['name'].'"';
1068 1068
         }
1069 1069
 
1070 1070
         if (isset($metadata->table['options']) && $metadata->table['options']) {
1071
-            $table[] = 'options={' . $this->exportTableOptions((array) $metadata->table['options']) . '}';
1071
+            $table[] = 'options={'.$this->exportTableOptions((array) $metadata->table['options']).'}';
1072 1072
         }
1073 1073
 
1074 1074
         if (isset($metadata->table['uniqueConstraints']) && $metadata->table['uniqueConstraints']) {
1075 1075
             $constraints = $this->generateTableConstraints('UniqueConstraint', $metadata->table['uniqueConstraints']);
1076
-            $table[] = 'uniqueConstraints={' . $constraints . '}';
1076
+            $table[] = 'uniqueConstraints={'.$constraints.'}';
1077 1077
         }
1078 1078
 
1079 1079
         if (isset($metadata->table['indexes']) && $metadata->table['indexes']) {
1080 1080
             $constraints = $this->generateTableConstraints('Index', $metadata->table['indexes']);
1081
-            $table[] = 'indexes={' . $constraints . '}';
1081
+            $table[] = 'indexes={'.$constraints.'}';
1082 1082
         }
1083 1083
 
1084
-        return '@' . $this->annotationsPrefix . 'Table(' . implode(', ', $table) . ')';
1084
+        return '@'.$this->annotationsPrefix.'Table('.implode(', ', $table).')';
1085 1085
     }
1086 1086
 
1087 1087
     /**
@@ -1096,9 +1096,9 @@  discard block
 block discarded – undo
1096 1096
         foreach ($constraints as $name => $constraint) {
1097 1097
             $columns = array();
1098 1098
             foreach ($constraint['columns'] as $column) {
1099
-                $columns[] = '"' . $column . '"';
1099
+                $columns[] = '"'.$column.'"';
1100 1100
             }
1101
-            $annotations[] = '@' . $this->annotationsPrefix . $constraintName . '(name="' . $name . '", columns={' . implode(', ', $columns) . '})';
1101
+            $annotations[] = '@'.$this->annotationsPrefix.$constraintName.'(name="'.$name.'", columns={'.implode(', ', $columns).'})';
1102 1102
         }
1103 1103
 
1104 1104
         return implode(', ', $annotations);
@@ -1112,7 +1112,7 @@  discard block
 block discarded – undo
1112 1112
     protected function generateInheritanceAnnotation($metadata)
1113 1113
     {
1114 1114
         if ($metadata->inheritanceType != ClassMetadataInfo::INHERITANCE_TYPE_NONE) {
1115
-            return '@' . $this->annotationsPrefix . 'InheritanceType("'.$this->getInheritanceTypeString($metadata->inheritanceType).'")';
1115
+            return '@'.$this->annotationsPrefix.'InheritanceType("'.$this->getInheritanceTypeString($metadata->inheritanceType).'")';
1116 1116
         }
1117 1117
     }
1118 1118
 
@@ -1125,11 +1125,11 @@  discard block
 block discarded – undo
1125 1125
     {
1126 1126
         if ($metadata->inheritanceType != ClassMetadataInfo::INHERITANCE_TYPE_NONE) {
1127 1127
             $discrColumn = $metadata->discriminatorColumn;
1128
-            $columnDefinition = 'name="' . $discrColumn['name']
1129
-                . '", type="' . $discrColumn['type']
1130
-                . '", length=' . $discrColumn['length'];
1128
+            $columnDefinition = 'name="'.$discrColumn['name']
1129
+                . '", type="'.$discrColumn['type']
1130
+                . '", length='.$discrColumn['length'];
1131 1131
 
1132
-            return '@' . $this->annotationsPrefix . 'DiscriminatorColumn(' . $columnDefinition . ')';
1132
+            return '@'.$this->annotationsPrefix.'DiscriminatorColumn('.$columnDefinition.')';
1133 1133
         }
1134 1134
     }
1135 1135
 
@@ -1144,10 +1144,10 @@  discard block
 block discarded – undo
1144 1144
             $inheritanceClassMap = array();
1145 1145
 
1146 1146
             foreach ($metadata->discriminatorMap as $type => $class) {
1147
-                $inheritanceClassMap[] .= '"' . $type . '" = "' . $class . '"';
1147
+                $inheritanceClassMap[] .= '"'.$type.'" = "'.$class.'"';
1148 1148
             }
1149 1149
 
1150
-            return '@' . $this->annotationsPrefix . 'DiscriminatorMap({' . implode(', ', $inheritanceClassMap) . '})';
1150
+            return '@'.$this->annotationsPrefix.'DiscriminatorMap({'.implode(', ', $inheritanceClassMap).'})';
1151 1151
         }
1152 1152
     }
1153 1153
 
@@ -1170,7 +1170,7 @@  discard block
 block discarded – undo
1170 1170
             if (( ! isset($fieldMapping['id']) ||
1171 1171
                     ! $fieldMapping['id'] ||
1172 1172
                     $metadata->generatorType == ClassMetadataInfo::GENERATOR_TYPE_NONE
1173
-                ) && (! $metadata->isEmbeddedClass || ! $this->embeddablesImmutable)
1173
+                ) && ( ! $metadata->isEmbeddedClass || ! $this->embeddablesImmutable)
1174 1174
             ) {
1175 1175
                 if ($code = $this->generateEntityStubMethod($metadata, 'set', $fieldMapping['fieldName'], $fieldMapping['type'])) {
1176 1176
                     $methods[] = $code;
@@ -1242,7 +1242,7 @@  discard block
 block discarded – undo
1242 1242
         }
1243 1243
 
1244 1244
         foreach ($joinColumns as $joinColumn) {
1245
-            if (isset($joinColumn['nullable']) && !$joinColumn['nullable']) {
1245
+            if (isset($joinColumn['nullable']) && ! $joinColumn['nullable']) {
1246 1246
                 return false;
1247 1247
             }
1248 1248
         }
@@ -1285,8 +1285,8 @@  discard block
 block discarded – undo
1285 1285
             }
1286 1286
 
1287 1287
             $lines[] = $this->generateAssociationMappingPropertyDocBlock($associationMapping, $metadata);
1288
-            $lines[] = $this->spaces . $this->fieldVisibility . ' $' . $associationMapping['fieldName']
1289
-                     . ($associationMapping['type'] == 'manyToMany' ? ' = array()' : null) . ";\n";
1288
+            $lines[] = $this->spaces.$this->fieldVisibility.' $'.$associationMapping['fieldName']
1289
+                     . ($associationMapping['type'] == 'manyToMany' ? ' = array()' : null).";\n";
1290 1290
         }
1291 1291
 
1292 1292
         return implode("\n", $lines);
@@ -1313,8 +1313,8 @@  discard block
 block discarded – undo
1313 1313
             }
1314 1314
 
1315 1315
             $lines[] = $this->generateFieldMappingPropertyDocBlock($fieldMapping, $metadata);
1316
-            $lines[] = $this->spaces . $this->fieldVisibility . ' $' . $fieldMapping['fieldName']
1317
-                     . (isset($fieldMapping['options']['default']) ? ' = ' . var_export($fieldMapping['options']['default'], true) : null) . ";\n";
1316
+            $lines[] = $this->spaces.$this->fieldVisibility.' $'.$fieldMapping['fieldName']
1317
+                     . (isset($fieldMapping['options']['default']) ? ' = '.var_export($fieldMapping['options']['default'], true) : null).";\n";
1318 1318
         }
1319 1319
 
1320 1320
         return implode("\n", $lines);
@@ -1335,7 +1335,7 @@  discard block
 block discarded – undo
1335 1335
             }
1336 1336
 
1337 1337
             $lines[] = $this->generateEmbeddedPropertyDocBlock($embeddedClass);
1338
-            $lines[] = $this->spaces . $this->fieldVisibility . ' $' . $fieldName . ";\n";
1338
+            $lines[] = $this->spaces.$this->fieldVisibility.' $'.$fieldName.";\n";
1339 1339
         }
1340 1340
 
1341 1341
         return implode("\n", $lines);
@@ -1350,9 +1350,9 @@  discard block
 block discarded – undo
1350 1350
      *
1351 1351
      * @return string
1352 1352
      */
1353
-    protected function generateEntityStubMethod(ClassMetadataInfo $metadata, $type, $fieldName, $typeHint = null,  $defaultValue = null)
1353
+    protected function generateEntityStubMethod(ClassMetadataInfo $metadata, $type, $fieldName, $typeHint = null, $defaultValue = null)
1354 1354
     {
1355
-        $methodName = $type . Inflector::classify($fieldName);
1355
+        $methodName = $type.Inflector::classify($fieldName);
1356 1356
         $variableName = Inflector::camelize($fieldName);
1357 1357
         if (in_array($type, array("add", "remove"))) {
1358 1358
             $methodName = Inflector::singularize($methodName);
@@ -1372,18 +1372,18 @@  discard block
 block discarded – undo
1372 1372
         $variableType   = $typeHint ? $this->getType($typeHint) : null;
1373 1373
 
1374 1374
         if ($typeHint && ! isset($types[$typeHint])) {
1375
-            $variableType   =  '\\' . ltrim($variableType, '\\');
1376
-            $methodTypeHint =  '\\' . $typeHint . ' ';
1375
+            $variableType   = '\\'.ltrim($variableType, '\\');
1376
+            $methodTypeHint = '\\'.$typeHint.' ';
1377 1377
         }
1378 1378
 
1379 1379
         $replacements = array(
1380
-          '<description>'       => ucfirst($type) . ' ' . $variableName,
1380
+          '<description>'       => ucfirst($type).' '.$variableName,
1381 1381
           '<methodTypeHint>'    => $methodTypeHint,
1382 1382
           '<variableType>'      => $variableType,
1383 1383
           '<variableName>'      => $variableName,
1384 1384
           '<methodName>'        => $methodName,
1385 1385
           '<fieldName>'         => $fieldName,
1386
-          '<variableDefault>'   => ($defaultValue !== null ) ? (' = '.$defaultValue) : '',
1386
+          '<variableDefault>'   => ($defaultValue !== null) ? (' = '.$defaultValue) : '',
1387 1387
           '<entity>'            => $this->getClassName($metadata)
1388 1388
         );
1389 1389
 
@@ -1413,8 +1413,8 @@  discard block
 block discarded – undo
1413 1413
 
1414 1414
         $lifecycles = implode("\n * ",
1415 1415
             array_map(
1416
-                function ($name) {
1417
-                    return '@' . $this->annotationsPrefix . ucfirst($name);
1416
+                function($name) {
1417
+                    return '@'.$this->annotationsPrefix.ucfirst($name);
1418 1418
                 },
1419 1419
                 $lifecycleNames
1420 1420
             )
@@ -1444,30 +1444,30 @@  discard block
 block discarded – undo
1444 1444
         $joinColumnAnnot = array();
1445 1445
 
1446 1446
         if (isset($joinColumn['name'])) {
1447
-            $joinColumnAnnot[] = 'name="' . $joinColumn['name'] . '"';
1447
+            $joinColumnAnnot[] = 'name="'.$joinColumn['name'].'"';
1448 1448
         }
1449 1449
 
1450 1450
         if (isset($joinColumn['referencedColumnName'])) {
1451
-            $joinColumnAnnot[] = 'referencedColumnName="' . $joinColumn['referencedColumnName'] . '"';
1451
+            $joinColumnAnnot[] = 'referencedColumnName="'.$joinColumn['referencedColumnName'].'"';
1452 1452
         }
1453 1453
 
1454 1454
         if (isset($joinColumn['unique']) && $joinColumn['unique']) {
1455
-            $joinColumnAnnot[] = 'unique=' . ($joinColumn['unique'] ? 'true' : 'false');
1455
+            $joinColumnAnnot[] = 'unique='.($joinColumn['unique'] ? 'true' : 'false');
1456 1456
         }
1457 1457
 
1458 1458
         if (isset($joinColumn['nullable'])) {
1459
-            $joinColumnAnnot[] = 'nullable=' . ($joinColumn['nullable'] ? 'true' : 'false');
1459
+            $joinColumnAnnot[] = 'nullable='.($joinColumn['nullable'] ? 'true' : 'false');
1460 1460
         }
1461 1461
 
1462 1462
         if (isset($joinColumn['onDelete'])) {
1463
-            $joinColumnAnnot[] = 'onDelete="' . ($joinColumn['onDelete'] . '"');
1463
+            $joinColumnAnnot[] = 'onDelete="'.($joinColumn['onDelete'].'"');
1464 1464
         }
1465 1465
 
1466 1466
         if (isset($joinColumn['columnDefinition'])) {
1467
-            $joinColumnAnnot[] = 'columnDefinition="' . $joinColumn['columnDefinition'] . '"';
1467
+            $joinColumnAnnot[] = 'columnDefinition="'.$joinColumn['columnDefinition'].'"';
1468 1468
         }
1469 1469
 
1470
-        return '@' . $this->annotationsPrefix . 'JoinColumn(' . implode(', ', $joinColumnAnnot) . ')';
1470
+        return '@'.$this->annotationsPrefix.'JoinColumn('.implode(', ', $joinColumnAnnot).')';
1471 1471
     }
1472 1472
 
1473 1473
     /**
@@ -1479,22 +1479,22 @@  discard block
 block discarded – undo
1479 1479
     protected function generateAssociationMappingPropertyDocBlock(array $associationMapping, ClassMetadataInfo $metadata)
1480 1480
     {
1481 1481
         $lines = array();
1482
-        $lines[] = $this->spaces . '/**';
1482
+        $lines[] = $this->spaces.'/**';
1483 1483
 
1484 1484
         if ($associationMapping['type'] & ClassMetadataInfo::TO_MANY) {
1485
-            $lines[] = $this->spaces . ' * @var \Doctrine\Common\Collections\Collection';
1485
+            $lines[] = $this->spaces.' * @var \Doctrine\Common\Collections\Collection';
1486 1486
         } else {
1487
-            $lines[] = $this->spaces . ' * @var \\' . ltrim($associationMapping['targetEntity'], '\\');
1487
+            $lines[] = $this->spaces.' * @var \\'.ltrim($associationMapping['targetEntity'], '\\');
1488 1488
         }
1489 1489
 
1490 1490
         if ($this->generateAnnotations) {
1491
-            $lines[] = $this->spaces . ' *';
1491
+            $lines[] = $this->spaces.' *';
1492 1492
 
1493 1493
             if (isset($associationMapping['id']) && $associationMapping['id']) {
1494
-                $lines[] = $this->spaces . ' * @' . $this->annotationsPrefix . 'Id';
1494
+                $lines[] = $this->spaces.' * @'.$this->annotationsPrefix.'Id';
1495 1495
 
1496 1496
                 if ($generatorType = $this->getIdGeneratorTypeString($metadata->generatorType)) {
1497
-                    $lines[] = $this->spaces . ' * @' . $this->annotationsPrefix . 'GeneratedValue(strategy="' . $generatorType . '")';
1497
+                    $lines[] = $this->spaces.' * @'.$this->annotationsPrefix.'GeneratedValue(strategy="'.$generatorType.'")';
1498 1498
                 }
1499 1499
             }
1500 1500
 
@@ -1516,15 +1516,15 @@  discard block
 block discarded – undo
1516 1516
             $typeOptions = array();
1517 1517
 
1518 1518
             if (isset($associationMapping['targetEntity'])) {
1519
-                $typeOptions[] = 'targetEntity="' . $associationMapping['targetEntity'] . '"';
1519
+                $typeOptions[] = 'targetEntity="'.$associationMapping['targetEntity'].'"';
1520 1520
             }
1521 1521
 
1522 1522
             if (isset($associationMapping['inversedBy'])) {
1523
-                $typeOptions[] = 'inversedBy="' . $associationMapping['inversedBy'] . '"';
1523
+                $typeOptions[] = 'inversedBy="'.$associationMapping['inversedBy'].'"';
1524 1524
             }
1525 1525
 
1526 1526
             if (isset($associationMapping['mappedBy'])) {
1527
-                $typeOptions[] = 'mappedBy="' . $associationMapping['mappedBy'] . '"';
1527
+                $typeOptions[] = 'mappedBy="'.$associationMapping['mappedBy'].'"';
1528 1528
             }
1529 1529
 
1530 1530
             if ($associationMapping['cascade']) {
@@ -1540,11 +1540,11 @@  discard block
 block discarded – undo
1540 1540
                     $cascades = array('"all"');
1541 1541
                 }
1542 1542
 
1543
-                $typeOptions[] = 'cascade={' . implode(',', $cascades) . '}';
1543
+                $typeOptions[] = 'cascade={'.implode(',', $cascades).'}';
1544 1544
             }
1545 1545
 
1546 1546
             if (isset($associationMapping['orphanRemoval']) && $associationMapping['orphanRemoval']) {
1547
-                $typeOptions[] = 'orphanRemoval=' . ($associationMapping['orphanRemoval'] ? 'true' : 'false');
1547
+                $typeOptions[] = 'orphanRemoval='.($associationMapping['orphanRemoval'] ? 'true' : 'false');
1548 1548
             }
1549 1549
 
1550 1550
             if (isset($associationMapping['fetch']) && $associationMapping['fetch'] !== ClassMetadataInfo::FETCH_LAZY) {
@@ -1553,71 +1553,71 @@  discard block
 block discarded – undo
1553 1553
                     ClassMetadataInfo::FETCH_EAGER      => 'EAGER',
1554 1554
                 );
1555 1555
 
1556
-                $typeOptions[] = 'fetch="' . $fetchMap[$associationMapping['fetch']] . '"';
1556
+                $typeOptions[] = 'fetch="'.$fetchMap[$associationMapping['fetch']].'"';
1557 1557
             }
1558 1558
 
1559
-            $lines[] = $this->spaces . ' * @' . $this->annotationsPrefix . '' . $type . '(' . implode(', ', $typeOptions) . ')';
1559
+            $lines[] = $this->spaces.' * @'.$this->annotationsPrefix.''.$type.'('.implode(', ', $typeOptions).')';
1560 1560
 
1561 1561
             if (isset($associationMapping['joinColumns']) && $associationMapping['joinColumns']) {
1562
-                $lines[] = $this->spaces . ' * @' . $this->annotationsPrefix . 'JoinColumns({';
1562
+                $lines[] = $this->spaces.' * @'.$this->annotationsPrefix.'JoinColumns({';
1563 1563
 
1564 1564
                 $joinColumnsLines = array();
1565 1565
 
1566 1566
                 foreach ($associationMapping['joinColumns'] as $joinColumn) {
1567 1567
                     if ($joinColumnAnnot = $this->generateJoinColumnAnnotation($joinColumn)) {
1568
-                        $joinColumnsLines[] = $this->spaces . ' *   ' . $joinColumnAnnot;
1568
+                        $joinColumnsLines[] = $this->spaces.' *   '.$joinColumnAnnot;
1569 1569
                     }
1570 1570
                 }
1571 1571
 
1572 1572
                 $lines[] = implode(",\n", $joinColumnsLines);
1573
-                $lines[] = $this->spaces . ' * })';
1573
+                $lines[] = $this->spaces.' * })';
1574 1574
             }
1575 1575
 
1576 1576
             if (isset($associationMapping['joinTable']) && $associationMapping['joinTable']) {
1577 1577
                 $joinTable = array();
1578
-                $joinTable[] = 'name="' . $associationMapping['joinTable']['name'] . '"';
1578
+                $joinTable[] = 'name="'.$associationMapping['joinTable']['name'].'"';
1579 1579
 
1580 1580
                 if (isset($associationMapping['joinTable']['schema'])) {
1581
-                    $joinTable[] = 'schema="' . $associationMapping['joinTable']['schema'] . '"';
1581
+                    $joinTable[] = 'schema="'.$associationMapping['joinTable']['schema'].'"';
1582 1582
                 }
1583 1583
 
1584
-                $lines[] = $this->spaces . ' * @' . $this->annotationsPrefix . 'JoinTable(' . implode(', ', $joinTable) . ',';
1585
-                $lines[] = $this->spaces . ' *   joinColumns={';
1584
+                $lines[] = $this->spaces.' * @'.$this->annotationsPrefix.'JoinTable('.implode(', ', $joinTable).',';
1585
+                $lines[] = $this->spaces.' *   joinColumns={';
1586 1586
 
1587 1587
                 $joinColumnsLines = array();
1588 1588
 
1589 1589
                 foreach ($associationMapping['joinTable']['joinColumns'] as $joinColumn) {
1590
-                    $joinColumnsLines[] = $this->spaces . ' *     ' . $this->generateJoinColumnAnnotation($joinColumn);
1590
+                    $joinColumnsLines[] = $this->spaces.' *     '.$this->generateJoinColumnAnnotation($joinColumn);
1591 1591
                 }
1592 1592
 
1593
-                $lines[] = implode(",". PHP_EOL, $joinColumnsLines);
1594
-                $lines[] = $this->spaces . ' *   },';
1595
-                $lines[] = $this->spaces . ' *   inverseJoinColumns={';
1593
+                $lines[] = implode(",".PHP_EOL, $joinColumnsLines);
1594
+                $lines[] = $this->spaces.' *   },';
1595
+                $lines[] = $this->spaces.' *   inverseJoinColumns={';
1596 1596
 
1597 1597
                 $inverseJoinColumnsLines = array();
1598 1598
 
1599 1599
                 foreach ($associationMapping['joinTable']['inverseJoinColumns'] as $joinColumn) {
1600
-                    $inverseJoinColumnsLines[] = $this->spaces . ' *     ' . $this->generateJoinColumnAnnotation($joinColumn);
1600
+                    $inverseJoinColumnsLines[] = $this->spaces.' *     '.$this->generateJoinColumnAnnotation($joinColumn);
1601 1601
                 }
1602 1602
 
1603
-                $lines[] = implode(",". PHP_EOL, $inverseJoinColumnsLines);
1604
-                $lines[] = $this->spaces . ' *   }';
1605
-                $lines[] = $this->spaces . ' * )';
1603
+                $lines[] = implode(",".PHP_EOL, $inverseJoinColumnsLines);
1604
+                $lines[] = $this->spaces.' *   }';
1605
+                $lines[] = $this->spaces.' * )';
1606 1606
             }
1607 1607
 
1608 1608
             if (isset($associationMapping['orderBy'])) {
1609
-                $lines[] = $this->spaces . ' * @' . $this->annotationsPrefix . 'OrderBy({';
1609
+                $lines[] = $this->spaces.' * @'.$this->annotationsPrefix.'OrderBy({';
1610 1610
 
1611 1611
                 foreach ($associationMapping['orderBy'] as $name => $direction) {
1612
-                    $lines[] = $this->spaces . ' *     "' . $name . '"="' . $direction . '",';
1612
+                    $lines[] = $this->spaces.' *     "'.$name.'"="'.$direction.'",';
1613 1613
                 }
1614 1614
 
1615 1615
                 $lines[count($lines) - 1] = substr($lines[count($lines) - 1], 0, strlen($lines[count($lines) - 1]) - 1);
1616
-                $lines[] = $this->spaces . ' * })';
1616
+                $lines[] = $this->spaces.' * })';
1617 1617
             }
1618 1618
         }
1619 1619
 
1620
-        $lines[] = $this->spaces . ' */';
1620
+        $lines[] = $this->spaces.' */';
1621 1621
 
1622 1622
         return implode("\n", $lines);
1623 1623
     }
@@ -1631,35 +1631,35 @@  discard block
 block discarded – undo
1631 1631
     protected function generateFieldMappingPropertyDocBlock(array $fieldMapping, ClassMetadataInfo $metadata)
1632 1632
     {
1633 1633
         $lines = array();
1634
-        $lines[] = $this->spaces . '/**';
1635
-        $lines[] = $this->spaces . ' * @var ' . $this->getType($fieldMapping['type']);
1634
+        $lines[] = $this->spaces.'/**';
1635
+        $lines[] = $this->spaces.' * @var '.$this->getType($fieldMapping['type']);
1636 1636
 
1637 1637
         if ($this->generateAnnotations) {
1638
-            $lines[] = $this->spaces . ' *';
1638
+            $lines[] = $this->spaces.' *';
1639 1639
 
1640 1640
             $column = array();
1641 1641
             if (isset($fieldMapping['columnName'])) {
1642
-                $column[] = 'name="' . $fieldMapping['columnName'] . '"';
1642
+                $column[] = 'name="'.$fieldMapping['columnName'].'"';
1643 1643
             }
1644 1644
 
1645 1645
             if (isset($fieldMapping['type'])) {
1646
-                $column[] = 'type="' . $fieldMapping['type'] . '"';
1646
+                $column[] = 'type="'.$fieldMapping['type'].'"';
1647 1647
             }
1648 1648
 
1649 1649
             if (isset($fieldMapping['length'])) {
1650
-                $column[] = 'length=' . $fieldMapping['length'];
1650
+                $column[] = 'length='.$fieldMapping['length'];
1651 1651
             }
1652 1652
 
1653 1653
             if (isset($fieldMapping['precision'])) {
1654
-                $column[] = 'precision=' .  $fieldMapping['precision'];
1654
+                $column[] = 'precision='.$fieldMapping['precision'];
1655 1655
             }
1656 1656
 
1657 1657
             if (isset($fieldMapping['scale'])) {
1658
-                $column[] = 'scale=' . $fieldMapping['scale'];
1658
+                $column[] = 'scale='.$fieldMapping['scale'];
1659 1659
             }
1660 1660
 
1661 1661
             if (isset($fieldMapping['nullable'])) {
1662
-                $column[] = 'nullable=' .  var_export($fieldMapping['nullable'], true);
1662
+                $column[] = 'nullable='.var_export($fieldMapping['nullable'], true);
1663 1663
             }
1664 1664
 
1665 1665
             $options = [];
@@ -1673,47 +1673,47 @@  discard block
 block discarded – undo
1673 1673
             }
1674 1674
 
1675 1675
             if (isset($fieldMapping['columnDefinition'])) {
1676
-                $column[] = 'columnDefinition="' . $fieldMapping['columnDefinition'] . '"';
1676
+                $column[] = 'columnDefinition="'.$fieldMapping['columnDefinition'].'"';
1677 1677
             }
1678 1678
 
1679 1679
             if (isset($fieldMapping['unique'])) {
1680
-                $column[] = 'unique=' . var_export($fieldMapping['unique'], true);
1680
+                $column[] = 'unique='.var_export($fieldMapping['unique'], true);
1681 1681
             }
1682 1682
 
1683
-            $lines[] = $this->spaces . ' * @' . $this->annotationsPrefix . 'Column(' . implode(', ', $column) . ')';
1683
+            $lines[] = $this->spaces.' * @'.$this->annotationsPrefix.'Column('.implode(', ', $column).')';
1684 1684
 
1685 1685
             if (isset($fieldMapping['id']) && $fieldMapping['id']) {
1686
-                $lines[] = $this->spaces . ' * @' . $this->annotationsPrefix . 'Id';
1686
+                $lines[] = $this->spaces.' * @'.$this->annotationsPrefix.'Id';
1687 1687
 
1688 1688
                 if ($generatorType = $this->getIdGeneratorTypeString($metadata->generatorType)) {
1689
-                    $lines[] = $this->spaces.' * @' . $this->annotationsPrefix . 'GeneratedValue(strategy="' . $generatorType . '")';
1689
+                    $lines[] = $this->spaces.' * @'.$this->annotationsPrefix.'GeneratedValue(strategy="'.$generatorType.'")';
1690 1690
                 }
1691 1691
 
1692 1692
                 if ($metadata->sequenceGeneratorDefinition) {
1693 1693
                     $sequenceGenerator = array();
1694 1694
 
1695 1695
                     if (isset($metadata->sequenceGeneratorDefinition['sequenceName'])) {
1696
-                        $sequenceGenerator[] = 'sequenceName="' . $metadata->sequenceGeneratorDefinition['sequenceName'] . '"';
1696
+                        $sequenceGenerator[] = 'sequenceName="'.$metadata->sequenceGeneratorDefinition['sequenceName'].'"';
1697 1697
                     }
1698 1698
 
1699 1699
                     if (isset($metadata->sequenceGeneratorDefinition['allocationSize'])) {
1700
-                        $sequenceGenerator[] = 'allocationSize=' . $metadata->sequenceGeneratorDefinition['allocationSize'];
1700
+                        $sequenceGenerator[] = 'allocationSize='.$metadata->sequenceGeneratorDefinition['allocationSize'];
1701 1701
                     }
1702 1702
 
1703 1703
                     if (isset($metadata->sequenceGeneratorDefinition['initialValue'])) {
1704
-                        $sequenceGenerator[] = 'initialValue=' . $metadata->sequenceGeneratorDefinition['initialValue'];
1704
+                        $sequenceGenerator[] = 'initialValue='.$metadata->sequenceGeneratorDefinition['initialValue'];
1705 1705
                     }
1706 1706
 
1707
-                    $lines[] = $this->spaces . ' * @' . $this->annotationsPrefix . 'SequenceGenerator(' . implode(', ', $sequenceGenerator) . ')';
1707
+                    $lines[] = $this->spaces.' * @'.$this->annotationsPrefix.'SequenceGenerator('.implode(', ', $sequenceGenerator).')';
1708 1708
                 }
1709 1709
             }
1710 1710
 
1711 1711
             if (isset($fieldMapping['version']) && $fieldMapping['version']) {
1712
-                $lines[] = $this->spaces . ' * @' . $this->annotationsPrefix . 'Version';
1712
+                $lines[] = $this->spaces.' * @'.$this->annotationsPrefix.'Version';
1713 1713
             }
1714 1714
         }
1715 1715
 
1716
-        $lines[] = $this->spaces . ' */';
1716
+        $lines[] = $this->spaces.' */';
1717 1717
 
1718 1718
         return implode("\n", $lines);
1719 1719
     }
@@ -1726,23 +1726,23 @@  discard block
 block discarded – undo
1726 1726
     protected function generateEmbeddedPropertyDocBlock(array $embeddedClass)
1727 1727
     {
1728 1728
         $lines = array();
1729
-        $lines[] = $this->spaces . '/**';
1730
-        $lines[] = $this->spaces . ' * @var \\' . ltrim($embeddedClass['class'], '\\');
1729
+        $lines[] = $this->spaces.'/**';
1730
+        $lines[] = $this->spaces.' * @var \\'.ltrim($embeddedClass['class'], '\\');
1731 1731
 
1732 1732
         if ($this->generateAnnotations) {
1733
-            $lines[] = $this->spaces . ' *';
1733
+            $lines[] = $this->spaces.' *';
1734 1734
 
1735
-            $embedded = array('class="' . $embeddedClass['class'] . '"');
1735
+            $embedded = array('class="'.$embeddedClass['class'].'"');
1736 1736
 
1737 1737
             if (isset($fieldMapping['columnPrefix'])) {
1738
-                $embedded[] = 'columnPrefix=' . var_export($embeddedClass['columnPrefix'], true);
1738
+                $embedded[] = 'columnPrefix='.var_export($embeddedClass['columnPrefix'], true);
1739 1739
             }
1740 1740
 
1741
-            $lines[] = $this->spaces . ' * @' .
1742
-                $this->annotationsPrefix . 'Embedded(' . implode(', ', $embedded) . ')';
1741
+            $lines[] = $this->spaces.' * @'.
1742
+                $this->annotationsPrefix.'Embedded('.implode(', ', $embedded).')';
1743 1743
         }
1744 1744
 
1745
-        $lines[] = $this->spaces . ' */';
1745
+        $lines[] = $this->spaces.' */';
1746 1746
 
1747 1747
         return implode("\n", $lines);
1748 1748
     }
@@ -1759,7 +1759,7 @@  discard block
 block discarded – undo
1759 1759
 
1760 1760
         foreach ($lines as $key => $value) {
1761 1761
             if ( ! empty($value)) {
1762
-                $lines[$key] = str_repeat($this->spaces, $num) . $lines[$key];
1762
+                $lines[$key] = str_repeat($this->spaces, $num).$lines[$key];
1763 1763
             }
1764 1764
         }
1765 1765
 
@@ -1827,9 +1827,9 @@  discard block
 block discarded – undo
1827 1827
 
1828 1828
         foreach ($options as $name => $option) {
1829 1829
             if (is_array($option)) {
1830
-                $optionsStr[] = '"' . $name . '"={' . $this->exportTableOptions($option) . '}';
1830
+                $optionsStr[] = '"'.$name.'"={'.$this->exportTableOptions($option).'}';
1831 1831
             } else {
1832
-                $optionsStr[] = '"' . $name . '"="' . (string) $option . '"';
1832
+                $optionsStr[] = '"'.$name.'"="'.(string) $option.'"';
1833 1833
             }
1834 1834
         }
1835 1835
 
@@ -1845,7 +1845,7 @@  discard block
 block discarded – undo
1845 1845
      */
1846 1846
     private function getLifecycleCallbackMethods(ClassMetadataInfo $metadata)
1847 1847
     {
1848
-        if (!isset($metadata->lifecycleCallbacks)) {
1848
+        if ( ! isset($metadata->lifecycleCallbacks)) {
1849 1849
             return array();
1850 1850
         }
1851 1851
 
Please login to merge, or discard this patch.