Passed
Pull Request — master (#242)
by Dorian
13:57
created
src/Utils/AbstractBeanPropertyDescriptor.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
      */
68 68
     public function getParamAnnotation(): ParamTag
69 69
     {
70
-        return new ParamTag($this->getSafeVariableName(), [ $this->getPhpType() ]);
70
+        return new ParamTag($this->getSafeVariableName(), [$this->getPhpType()]);
71 71
     }
72 72
 
73 73
     public function getVariableName(): string
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 
78 78
     public function getSafeVariableName(): string
79 79
     {
80
-        return '$' . StringUtils::getValidVariableName(ltrim($this->getVariableName(), '$'));
80
+        return '$'.StringUtils::getValidVariableName(ltrim($this->getVariableName(), '$'));
81 81
     }
82 82
 
83 83
     public function getSetterName(): string
Please login to merge, or discard this patch.
src/Utils/ObjectBeanPropertyDescriptor.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
      */
88 88
     public function getPhpType(): string
89 89
     {
90
-        return '\\' . $this->beanNamespace . '\\' . $this->getClassName();
90
+        return '\\'.$this->beanNamespace.'\\'.$this->getClassName();
91 91
     }
92 92
 
93 93
     /**
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
         $referencedBeanName = $this->namingStrategy->getBeanClassName($this->foreignKey->getForeignTableName());
161 161
 
162 162
         $getter = new MethodGenerator($getterName);
163
-        $getter->setDocBlock(new DocBlockGenerator('Returns the ' . $referencedBeanName . ' object bound to this object via the ' . implode(' and ', $this->foreignKey->getUnquotedLocalColumns()) . ' column.'));
163
+        $getter->setDocBlock(new DocBlockGenerator('Returns the '.$referencedBeanName.' object bound to this object via the '.implode(' and ', $this->foreignKey->getUnquotedLocalColumns()).' column.'));
164 164
 
165 165
         /*$types = [ $referencedBeanName ];
166 166
         if ($isNullable) {
@@ -168,10 +168,10 @@  discard block
 block discarded – undo
168 168
         }
169 169
         $getter->getDocBlock()->setTag(new ReturnTag($types));*/
170 170
 
171
-        $getter->setReturnType(($isNullable ? '?' : '') . $this->beanNamespace . '\\' . $referencedBeanName);
171
+        $getter->setReturnType(($isNullable ? '?' : '').$this->beanNamespace.'\\'.$referencedBeanName);
172 172
         $tdbmFk = ForeignKey::createFromFk($this->foreignKey);
173 173
 
174
-        $getter->setBody('return $this->getRef(' . var_export($tdbmFk->getCacheKey(), true) . ', ' . var_export($tableName, true) . ');');
174
+        $getter->setBody('return $this->getRef('.var_export($tdbmFk->getCacheKey(), true).', '.var_export($tableName, true).');');
175 175
 
176 176
         if ($this->isGetterProtected()) {
177 177
             $getter->setVisibility(AbstractMemberGenerator::VISIBILITY_PROTECTED);
@@ -179,13 +179,13 @@  discard block
 block discarded – undo
179 179
 
180 180
         if (!$this->isReadOnly()) {
181 181
             $setter = new MethodGenerator($setterName);
182
-            $setter->setDocBlock(new DocBlockGenerator('The setter for the ' . $referencedBeanName . ' object bound to this object via the ' . implode(' and ', $this->foreignKey->getUnquotedLocalColumns()) . ' column.'));
182
+            $setter->setDocBlock(new DocBlockGenerator('The setter for the '.$referencedBeanName.' object bound to this object via the '.implode(' and ', $this->foreignKey->getUnquotedLocalColumns()).' column.'));
183 183
 
184
-            $setter->setParameter(new ParameterGenerator('object', ($isNullable ? '?' : '') . $this->beanNamespace . '\\' . $referencedBeanName));
184
+            $setter->setParameter(new ParameterGenerator('object', ($isNullable ? '?' : '').$this->beanNamespace.'\\'.$referencedBeanName));
185 185
 
186 186
             $setter->setReturnType('void');
187 187
 
188
-            $setter->setBody('$this->setRef(' . var_export($tdbmFk->getCacheKey(), true) . ', $object, ' . var_export($tableName, true) . ');');
188
+            $setter->setBody('$this->setRef('.var_export($tdbmFk->getCacheKey(), true).', $object, '.var_export($tableName, true).');');
189 189
 
190 190
             if ($this->isSetterProtected()) {
191 191
                 $setter->setVisibility(AbstractMemberGenerator::VISIBILITY_PROTECTED);
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
             /** @var Annotation\JsonFormat|null $jsonFormat */
225 225
             $jsonFormat = $this->findAnnotation(Annotation\JsonFormat::class);
226 226
             if ($jsonFormat !== null) {
227
-                $method = $jsonFormat->method ?? 'get' . ucfirst($jsonFormat->property);
227
+                $method = $jsonFormat->method ?? 'get'.ucfirst($jsonFormat->property);
228 228
                 $format = "$method()";
229 229
             } else {
230 230
                 $stopRecursion = $this->findAnnotation(Annotation\JsonRecursive::class) ? '' : 'true';
@@ -280,10 +280,10 @@  discard block
 block discarded – undo
280 280
             } elseif ($descriptor instanceof ScalarBeanPropertyDescriptor) {
281 281
                 $rows[] = "'$indexName' => $propertyAccess->$columnGetterName()";
282 282
             } else {
283
-                throw new TDBMException('PropertyDescriptor of class `' . get_class($descriptor) . '` cannot be serialized.');
283
+                throw new TDBMException('PropertyDescriptor of class `'.get_class($descriptor).'` cannot be serialized.');
284 284
             }
285 285
         }
286
-        return '[' . implode(', ', $rows) . ']';
286
+        return '['.implode(', ', $rows).']';
287 287
     }
288 288
 
289 289
     private function getBeanPropertyDescriptor(string $column): AbstractBeanPropertyDescriptor
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
                 return $descriptor;
297 297
             }
298 298
         }
299
-        throw new TDBMException('PropertyDescriptor for `'.$this->table->getName().'`.`' . $column . '` not found in `' . $this->foreignBeanDescriptor->getTable()->getName() . '`');
299
+        throw new TDBMException('PropertyDescriptor for `'.$this->table->getName().'`.`'.$column.'` not found in `'.$this->foreignBeanDescriptor->getTable()->getName().'`');
300 300
     }
301 301
 
302 302
     /**
Please login to merge, or discard this patch.
src/Utils/ManyToManyRelationshipPathDescriptor.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 
49 49
     public static function generateModelKey(ForeignKeyConstraint $remoteFk, ForeignKeyConstraint $localFk): string
50 50
     {
51
-        return $remoteFk->getLocalTableName() . "." . implode("__", $localFk->getUnquotedLocalColumns());
51
+        return $remoteFk->getLocalTableName().".".implode("__", $localFk->getUnquotedLocalColumns());
52 52
     }
53 53
 
54 54
     public function getPivotName(): string
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
             $join[] = sprintf('%s.%s = %s.%s', $mainTable, $column, $pivotTable, $this->joinLocalKeys[$key]);
72 72
         }
73 73
 
74
-        return $mainTable . ' JOIN ' . $pivotTable . ' ON ' . implode(' AND ', $join);
74
+        return $mainTable.' JOIN '.$pivotTable.' ON '.implode(' AND ', $join);
75 75
     }
76 76
 
77 77
     public function getPivotWhere(): string
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
     {
92 92
         $params = [];
93 93
         foreach ($primaryKeys as $key => $primaryKeyValue) {
94
-            $params['param' . $key] = $primaryKeyValue;
94
+            $params['param'.$key] = $primaryKeyValue;
95 95
         }
96 96
         return $params;
97 97
     }
Please login to merge, or discard this patch.
src/Utils/BeanDescriptor.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
      */
215 215
     public function getConstructorProperties(): array
216 216
     {
217
-        $constructorProperties = array_filter($this->beanPropertyDescriptors, static function (AbstractBeanPropertyDescriptor $property) {
217
+        $constructorProperties = array_filter($this->beanPropertyDescriptors, static function(AbstractBeanPropertyDescriptor $property) {
218 218
             return !$property instanceof InheritanceReferencePropertyDescriptor && $property->isCompulsory() && !$property->isReadOnly();
219 219
         });
220 220
 
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
     public function getPropertiesWithDefault(): array
230 230
     {
231 231
         $properties = $this->getPropertiesForTable($this->table);
232
-        $defaultProperties = array_filter($properties, function (AbstractBeanPropertyDescriptor $property) {
232
+        $defaultProperties = array_filter($properties, function(AbstractBeanPropertyDescriptor $property) {
233 233
             return $property->hasDefault();
234 234
         });
235 235
 
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
      */
244 244
     public function getExposedProperties(): array
245 245
     {
246
-        $exposedProperties = array_filter($this->beanPropertyDescriptors, function (AbstractBeanPropertyDescriptor $property) {
246
+        $exposedProperties = array_filter($this->beanPropertyDescriptors, function(AbstractBeanPropertyDescriptor $property) {
247 247
             return !$property instanceof InheritanceReferencePropertyDescriptor && $property->getTable()->getName() === $this->table->getName();
248 248
         });
249 249
 
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
         foreach ($beanPropertyDescriptors as $beanDescriptor) {
350 350
             $name = $beanDescriptor->getGetterName();
351 351
             if (isset($names[$name])) {
352
-                throw new TDBMException('Unsolvable name conflict while generating method name "' . $name . '"');
352
+                throw new TDBMException('Unsolvable name conflict while generating method name "'.$name.'"');
353 353
             } else {
354 354
                 $names[$name] = $beanDescriptor;
355 355
             }
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
             $assigns[] = $property->assignToDefaultCode()."\n";
399 399
         }
400 400
 
401
-        $body = $parentConstructorCode . implode('', $assigns);
401
+        $body = $parentConstructorCode.implode('', $assigns);
402 402
 
403 403
         $constructor->setBody($body);
404 404
 
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
         foreach ($this->getExposedProperties() as $beanPropertyDescriptor) {
516 516
             $propertyCode = $beanPropertyDescriptor->getJsonSerializeCode();
517 517
             if (!empty($propertyCode)) {
518
-                $body .= PHP_EOL . $propertyCode;
518
+                $body .= PHP_EOL.$propertyCode;
519 519
             }
520 520
         }
521 521
 
@@ -523,11 +523,11 @@  discard block
 block discarded – undo
523 523
         foreach ($this->getMethodDescriptors() as $methodDescriptor) {
524 524
             $methodCode = $methodDescriptor->getJsonSerializeCode();
525 525
             if (!empty($methodCode)) {
526
-                $body .= PHP_EOL . $methodCode;
526
+                $body .= PHP_EOL.$methodCode;
527 527
             }
528 528
         }
529 529
 
530
-        $body .= PHP_EOL . 'return $array;';
530
+        $body .= PHP_EOL.'return $array;';
531 531
 
532 532
         $method->setBody($body);
533 533
 
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
         /** @var AddInterface[] $addInterfaceAnnotations */
623 623
         $addInterfaceAnnotations = $this->annotationParser->getTableAnnotations($this->table)->findAnnotations(AddInterface::class);
624 624
 
625
-        $interfaces = [ JsonSerializable::class ];
625
+        $interfaces = [JsonSerializable::class];
626 626
         foreach ($addInterfaceAnnotations as $annotation) {
627 627
             $interfaces[] = $annotation->getName();
628 628
         }
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
                 }
663 663
             } elseif ($methodDescriptor instanceof PivotTableMethodsDescriptor) {
664 664
                 $pivotTableMethodsDescriptors[] = $methodDescriptor;
665
-                [ $getter, $adder, $remover, $has, $setter ] = $methodDescriptor->getCode();
665
+                [$getter, $adder, $remover, $has, $setter] = $methodDescriptor->getCode();
666 666
                 $methods = $this->codeGeneratorListener->onBaseBeanManyToManyGenerated($getter, $adder, $remover, $has, $setter, $methodDescriptor, $this, $this->configuration, $class);
667 667
                 foreach ($methods as $method) {
668 668
                     if ($method) {
@@ -810,7 +810,7 @@  discard block
 block discarded – undo
810 810
 
811 811
         $constructorMethod = new MethodGenerator(
812 812
             '__construct',
813
-            [ new ParameterGenerator('tdbmService', TDBMService::class) ],
813
+            [new ParameterGenerator('tdbmService', TDBMService::class)],
814 814
             MethodGenerator::FLAG_PUBLIC,
815 815
             '$this->tdbmService = $tdbmService;',
816 816
             'Sets the TDBM service used by this DAO.'
@@ -822,7 +822,7 @@  discard block
 block discarded – undo
822 822
 
823 823
         $saveMethod = new MethodGenerator(
824 824
             'save',
825
-            [ new ParameterGenerator('obj', $beanClassName) ],
825
+            [new ParameterGenerator('obj', $beanClassName)],
826 826
             MethodGenerator::FLAG_PUBLIC,
827 827
             '$this->tdbmService->save($obj);',
828 828
             (new DocBlockGenerator(
@@ -856,7 +856,7 @@  discard block
 block discarded – undo
856 856
             $findAllBody,
857 857
             (new DocBlockGenerator("Get all $beanClassWithoutNameSpace records."))->setWordWrap(false)
858 858
         );
859
-        $findAllMethod->setReturnType($this->resultIteratorNamespace . '\\' . $this->getResultIteratorClassName());
859
+        $findAllMethod->setReturnType($this->resultIteratorNamespace.'\\'.$this->getResultIteratorClassName());
860 860
         $findAllMethod = $this->codeGeneratorListener->onBaseDaoFindAllGenerated($findAllMethod, $this, $this->configuration, $class);
861 861
         if ($findAllMethod !== null) {
862 862
             $class->addMethodFromGenerator($findAllMethod);
@@ -870,7 +870,7 @@  discard block
 block discarded – undo
870 870
 
871 871
             foreach ($primaryKeyColumns as $primaryKeyColumn) {
872 872
                 if ($primaryKeyColumn === $lazyLoadingParameterName) {
873
-                    throw new TDBMException('Primary Column name `' . $lazyLoadingParameterName . '` is not allowed.');
873
+                    throw new TDBMException('Primary Column name `'.$lazyLoadingParameterName.'` is not allowed.');
874 874
                 }
875 875
                 $phpType = TDBMDaoGenerator::dbalTypeToPhpType($this->table->getColumn($primaryKeyColumn)->getType());
876 876
                 $parameters[] = new ParameterGenerator($primaryKeyColumn, $phpType);
@@ -886,7 +886,7 @@  discard block
 block discarded – undo
886 886
                 'getById',
887 887
                 $parameters,
888 888
                 MethodGenerator::FLAG_PUBLIC,
889
-                "return \$this->tdbmService->findObjectByPk('$tableName', [" . implode(', ', $primaryKeyFilter) . "], [], \$$lazyLoadingParameterName);",
889
+                "return \$this->tdbmService->findObjectByPk('$tableName', [".implode(', ', $primaryKeyFilter)."], [], \$$lazyLoadingParameterName);",
890 890
                 (new DocBlockGenerator(
891 891
                     "Get $beanClassWithoutNameSpace specified by its ID (its primary key).",
892 892
                     'If the primary key does not exist, an exception is thrown.',
@@ -963,7 +963,7 @@  discard block
 block discarded – undo
963 963
                 ]
964 964
             ))->setWordWrap(false)
965 965
         );
966
-        $findMethod->setReturnType($this->resultIteratorNamespace . '\\' . $this->getResultIteratorClassName());
966
+        $findMethod->setReturnType($this->resultIteratorNamespace.'\\'.$this->getResultIteratorClassName());
967 967
         $findMethod = $this->codeGeneratorListener->onBaseDaoFindGenerated($findMethod, $this, $this->configuration, $class);
968 968
         if ($findMethod !== null) {
969 969
             $class->addMethodFromGenerator($findMethod);
@@ -1005,7 +1005,7 @@  discard block
 block discarded – undo
1005 1005
                 ]
1006 1006
             ))->setWordWrap(false)
1007 1007
         );
1008
-        $findFromSqlMethod->setReturnType($this->resultIteratorNamespace . '\\' . $this->getResultIteratorClassName());
1008
+        $findFromSqlMethod->setReturnType($this->resultIteratorNamespace.'\\'.$this->getResultIteratorClassName());
1009 1009
         $findFromSqlMethod = $this->codeGeneratorListener->onBaseDaoFindFromSqlGenerated($findFromSqlMethod, $this, $this->configuration, $class);
1010 1010
         if ($findFromSqlMethod !== null) {
1011 1011
             $class->addMethodFromGenerator($findFromSqlMethod);
@@ -1040,7 +1040,7 @@  discard block
 block discarded – undo
1040 1040
                 ]
1041 1041
             ))->setWordWrap(false)
1042 1042
         );
1043
-        $findFromRawSqlMethod->setReturnType($this->resultIteratorNamespace . '\\' . $this->getResultIteratorClassName());
1043
+        $findFromRawSqlMethod->setReturnType($this->resultIteratorNamespace.'\\'.$this->getResultIteratorClassName());
1044 1044
         $findFromRawSqlMethod = $this->codeGeneratorListener->onBaseDaoFindFromRawSqlGenerated($findFromRawSqlMethod, $this, $this->configuration, $class);
1045 1045
         if ($findFromRawSqlMethod !== null) {
1046 1046
             $class->addMethodFromGenerator($findFromRawSqlMethod);
@@ -1184,8 +1184,8 @@  discard block
 block discarded – undo
1184 1184
             [
1185 1185
                 new Tag\MethodTag('first', [$beanClassName]),
1186 1186
                 new Tag\MethodTag('offsetGet', [$beanClassName]),
1187
-                new Tag\MethodTag('getIterator', [$beanClassName . '[]']),
1188
-                new Tag\MethodTag('toArray', [$beanClassName . '[]']),
1187
+                new Tag\MethodTag('getIterator', [$beanClassName.'[]']),
1188
+                new Tag\MethodTag('toArray', [$beanClassName.'[]']),
1189 1189
                 new Tag\MethodTag('withOrder', [$className]),
1190 1190
                 new Tag\MethodTag('withParameters', [$className]),
1191 1191
             ]
@@ -1244,7 +1244,7 @@  discard block
 block discarded – undo
1244 1244
                 }
1245 1245
             }
1246 1246
         }
1247
-        usort($methods, static function (MethodGenerator $methodA, MethodGenerator $methodB) {
1247
+        usort($methods, static function(MethodGenerator $methodA, MethodGenerator $methodB) {
1248 1248
             return $methodA->getName() <=> $methodB->getName();
1249 1249
         });
1250 1250
 
@@ -1393,11 +1393,11 @@  discard block
 block discarded – undo
1393 1393
 
1394 1394
         if ($index->isUnique()) {
1395 1395
             $parameters[] = new ParameterGenerator('additionalTablesFetch', 'array', []);
1396
-            $params[] = new ParamTag('additionalTablesFetch', [ 'string[]' ], 'A list of additional tables to fetch (for performance improvement)');
1397
-            $params[] = new ReturnTag([ '\\'.$beanNamespace.'\\'.$beanClassName, 'null' ]);
1396
+            $params[] = new ParamTag('additionalTablesFetch', ['string[]'], 'A list of additional tables to fetch (for performance improvement)');
1397
+            $params[] = new ReturnTag(['\\'.$beanNamespace.'\\'.$beanClassName, 'null']);
1398 1398
             $method->setReturnType('?\\'.$beanNamespace.'\\'.$beanClassName);
1399 1399
 
1400
-            $docBlock = new DocBlockGenerator("Get a $beanClassName filtered by ".implode(', ', $commentArguments). '.', null, $params);
1400
+            $docBlock = new DocBlockGenerator("Get a $beanClassName filtered by ".implode(', ', $commentArguments).'.', null, $params);
1401 1401
             $docBlock->setWordWrap(false);
1402 1402
 
1403 1403
             $body = "\$filter = [
@@ -1406,12 +1406,12 @@  discard block
 block discarded – undo
1406 1406
 ";
1407 1407
         } else {
1408 1408
             $parameters[] = (new ParameterGenerator('orderBy'))->setDefaultValue(null);
1409
-            $params[] = new ParamTag('orderBy', [ 'mixed' ], 'The order string');
1409
+            $params[] = new ParamTag('orderBy', ['mixed'], 'The order string');
1410 1410
             $parameters[] = new ParameterGenerator('additionalTablesFetch', 'array', []);
1411
-            $params[] = new ParamTag('additionalTablesFetch', [ 'string[]' ], 'A list of additional tables to fetch (for performance improvement)');
1411
+            $params[] = new ParamTag('additionalTablesFetch', ['string[]'], 'A list of additional tables to fetch (for performance improvement)');
1412 1412
             $parameters[] = (new ParameterGenerator('mode', '?int'))->setDefaultValue(null);
1413
-            $params[] = new ParamTag('mode', [ 'int', 'null' ], 'Either TDBMService::MODE_ARRAY or TDBMService::MODE_CURSOR (for large datasets). Defaults to TDBMService::MODE_ARRAY.');
1414
-            $method->setReturnType($this->resultIteratorNamespace . '\\' . $this->getResultIteratorClassName());
1413
+            $params[] = new ParamTag('mode', ['int', 'null'], 'Either TDBMService::MODE_ARRAY or TDBMService::MODE_CURSOR (for large datasets). Defaults to TDBMService::MODE_ARRAY.');
1414
+            $method->setReturnType($this->resultIteratorNamespace.'\\'.$this->getResultIteratorClassName());
1415 1415
 
1416 1416
             $docBlock = new DocBlockGenerator("Get a list of $beanClassName filtered by ".implode(', ', $commentArguments).".", null, $params);
1417 1417
             $docBlock->setWordWrap(false);
@@ -1728,17 +1728,17 @@  discard block
 block discarded – undo
1728 1728
      * @param string $indent
1729 1729
      * @return string
1730 1730
      */
1731
-    private function psr2VarExport($var, string $indent=''): string
1731
+    private function psr2VarExport($var, string $indent = ''): string
1732 1732
     {
1733 1733
         if (is_array($var)) {
1734 1734
             $indexed = array_keys($var) === range(0, count($var) - 1);
1735 1735
             $r = [];
1736 1736
             foreach ($var as $key => $value) {
1737 1737
                 $r[] = "$indent    "
1738
-                    . ($indexed ? '' : $this->psr2VarExport($key) . ' => ')
1738
+                    . ($indexed ? '' : $this->psr2VarExport($key).' => ')
1739 1739
                     . $this->psr2VarExport($value, "$indent    ");
1740 1740
             }
1741
-            return "[\n" . implode(",\n", $r) . "\n" . $indent . ']';
1741
+            return "[\n".implode(",\n", $r)."\n".$indent.']';
1742 1742
         }
1743 1743
         return var_export($var, true);
1744 1744
     }
Please login to merge, or discard this patch.