Passed
Pull Request — master (#236)
by
unknown
13:46 queued 09:19
created
src/QueryFactory/FindObjectsFromRawSqlQueryFactory.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
                 $alias = AbstractQueryFactory::getColumnAlias($tableName, $columnName);
216 216
                 $astColumn = [
217 217
                     'expr_type' => 'colref',
218
-                    'base_expr' => $connection->quoteIdentifier($tableName) . '.' . $connection->quoteIdentifier($columnName),
218
+                    'base_expr' => $connection->quoteIdentifier($tableName).'.'.$connection->quoteIdentifier($columnName),
219 219
                     'no_quotes' => [
220 220
                         'delim' => '.',
221 221
                         'parts' => [
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
                 return $this->generateWrappedSqlCount($parsedSql);
304 304
             }
305 305
 
306
-            $countSubExpr = array_map(function (array $item) {
306
+            $countSubExpr = array_map(function(array $item) {
307 307
                 unset($item['alias']);
308 308
                 return $item;
309 309
             }, $parsedSql['SELECT']);
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
                 $item['delim'] = ',';
381 381
                 $innerColumns[] = $item;
382 382
             }
383
-            $innerColumns[count($innerColumns)-1]['delim'] = false;
383
+            $innerColumns[count($innerColumns) - 1]['delim'] = false;
384 384
             $parsedSql['SELECT'] = $innerColumns;
385 385
 
386 386
             $parsedSql = [
Please login to merge, or discard this patch.
tests/TDBMDaoGeneratorTest.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
         $schemaLockFileDumper = new SchemaLockFileDumper($this->tdbmService->getConnection(), new ArrayCache(), Configuration::getDefaultLockFilePath());
111 111
         $tdbmSchemaAnalyzer = new TDBMSchemaAnalyzer($this->tdbmService->getConnection(), new ArrayCache(), $schemaAnalyzer, $schemaLockFileDumper);
112 112
         $this->tdbmDaoGenerator = new TDBMDaoGenerator($this->getConfiguration(), $tdbmSchemaAnalyzer);
113
-        $this->rootPath = __DIR__ . '/../';
113
+        $this->rootPath = __DIR__.'/../';
114 114
         //$this->tdbmDaoGenerator->setComposerFile($this->rootPath.'composer.json');
115 115
     }
116 116
 
@@ -132,10 +132,10 @@  discard block
 block discarded – undo
132 132
     public function testDaoGeneration(): void
133 133
     {
134 134
         // Remove all previously generated files.
135
-        $this->recursiveDelete($this->rootPath . 'src/Test/Dao/');
136
-        mkdir($this->rootPath . 'src/Test/Dao/Generated', 0755, true);
135
+        $this->recursiveDelete($this->rootPath.'src/Test/Dao/');
136
+        mkdir($this->rootPath.'src/Test/Dao/Generated', 0755, true);
137 137
         // Let's generate a dummy file to see it is indeed removed.
138
-        $dummyFile = $this->rootPath . 'src/Test/Dao/Generated/foobar.php';
138
+        $dummyFile = $this->rootPath.'src/Test/Dao/Generated/foobar.php';
139 139
         touch($dummyFile);
140 140
         $this->assertFileExists($dummyFile);
141 141
 
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 
155 155
         // Let's require all files to check they are valid PHP!
156 156
         // Test the daoFactory
157
-        require_once $this->rootPath . 'src/Test/Dao/Generated/DaoFactory.php';
157
+        require_once $this->rootPath.'src/Test/Dao/Generated/DaoFactory.php';
158 158
         // Test the others
159 159
 
160 160
         $beanDescriptors = $this->getDummyGeneratorListener()->getBeanDescriptors();
@@ -164,10 +164,10 @@  discard block
 block discarded – undo
164 164
             $daoBaseName = $beanDescriptor->getBaseDaoClassName();
165 165
             $beanName = $beanDescriptor->getBeanClassName();
166 166
             $baseBeanName = $beanDescriptor->getBaseBeanClassName();
167
-            require_once $this->rootPath . 'src/Test/Dao/Bean/Generated/' . $baseBeanName . '.php';
168
-            require_once $this->rootPath . 'src/Test/Dao/Bean/' . $beanName . '.php';
169
-            require_once $this->rootPath . 'src/Test/Dao/Generated/' . $daoBaseName . '.php';
170
-            require_once $this->rootPath . 'src/Test/Dao/' . $daoName . '.php';
167
+            require_once $this->rootPath.'src/Test/Dao/Bean/Generated/'.$baseBeanName.'.php';
168
+            require_once $this->rootPath.'src/Test/Dao/Bean/'.$beanName.'.php';
169
+            require_once $this->rootPath.'src/Test/Dao/Generated/'.$daoBaseName.'.php';
170
+            require_once $this->rootPath.'src/Test/Dao/'.$daoName.'.php';
171 171
         }
172 172
 
173 173
         // Check that pivot tables do not generate DAOs or beans.
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
         $schemaLockFileDumper = new SchemaLockFileDumper($this->tdbmService->getConnection(), new ArrayCache(), Configuration::getDefaultLockFilePath());
184 184
         $tdbmSchemaAnalyzer = new TDBMSchemaAnalyzer($this->tdbmService->getConnection(), new ArrayCache(), $schemaAnalyzer, $schemaLockFileDumper);
185 185
         $tdbmDaoGenerator = new TDBMDaoGenerator($configuration, $tdbmSchemaAnalyzer);
186
-        $this->rootPath = __DIR__ . '/../../../../';
186
+        $this->rootPath = __DIR__.'/../../../../';
187 187
         //$tdbmDaoGenerator->setComposerFile($this->rootPath.'composer.json');
188 188
 
189 189
         $this->expectException(NoPathFoundException::class);
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
         if (is_file($str)) {
202 202
             return @unlink($str);
203 203
         } elseif (is_dir($str)) {
204
-            $scan = glob(rtrim($str, '/') . '/*');
204
+            $scan = glob(rtrim($str, '/').'/*');
205 205
             foreach ($scan as $index => $path) {
206 206
                 $this->recursiveDelete($path);
207 207
             }
@@ -2037,7 +2037,7 @@  discard block
 block discarded – undo
2037 2037
 
2038 2038
         $artists = new ArtistDao($this->tdbmService);
2039 2039
         $pinkFloyd = $artists->getById(1);
2040
-        $animals =  $pinkFloyd->getAlbums()[0];
2040
+        $animals = $pinkFloyd->getAlbums()[0];
2041 2041
         $json = $pinkFloyd->jsonSerialize();
2042 2042
         // Collection name properly handled ('discography' instead of default 'albums')
2043 2043
         self::assertTrue(isset($json['discography']));
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   +30 added lines, -30 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, '\\$beanClassName');",
889
+                "return \$this->tdbmService->findObjectByPk('$tableName', [".implode(', ', $primaryKeyFilter)."], [], \$$lazyLoadingParameterName, '\\$beanClassName');",
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);
@@ -1174,7 +1174,7 @@  discard block
 block discarded – undo
1174 1174
         $class->setDocBlock((new DocBlockGenerator(
1175 1175
             "The $baseClassName class will iterate over results of $beanClassWithoutNameSpace class.",
1176 1176
             null,
1177
-            [new Tag\MethodTag('getIterator', ['\\' . $beanClassName . '[]'])]
1177
+            [new Tag\MethodTag('getIterator', ['\\'.$beanClassName.'[]'])]
1178 1178
         ))->setWordWrap(false));
1179 1179
 
1180 1180
         $file = $this->codeGeneratorListener->onBaseResultIteratorGenerated($file, $this, $this->configuration);
@@ -1230,7 +1230,7 @@  discard block
 block discarded – undo
1230 1230
                 }
1231 1231
             }
1232 1232
         }
1233
-        usort($methods, static function (MethodGenerator $methodA, MethodGenerator $methodB) {
1233
+        usort($methods, static function(MethodGenerator $methodA, MethodGenerator $methodB) {
1234 1234
             return $methodA->getName() <=> $methodB->getName();
1235 1235
         });
1236 1236
 
@@ -1379,11 +1379,11 @@  discard block
 block discarded – undo
1379 1379
 
1380 1380
         if ($index->isUnique()) {
1381 1381
             $parameters[] = new ParameterGenerator('additionalTablesFetch', 'array', []);
1382
-            $params[] = new ParamTag('additionalTablesFetch', [ 'string[]' ], 'A list of additional tables to fetch (for performance improvement)');
1383
-            $params[] = new ReturnTag([ '\\'.$beanNamespace.'\\'.$beanClassName, 'null' ]);
1382
+            $params[] = new ParamTag('additionalTablesFetch', ['string[]'], 'A list of additional tables to fetch (for performance improvement)');
1383
+            $params[] = new ReturnTag(['\\'.$beanNamespace.'\\'.$beanClassName, 'null']);
1384 1384
             $method->setReturnType('?\\'.$beanNamespace.'\\'.$beanClassName);
1385 1385
 
1386
-            $docBlock = new DocBlockGenerator("Get a $beanClassName filtered by ".implode(', ', $commentArguments). '.', null, $params);
1386
+            $docBlock = new DocBlockGenerator("Get a $beanClassName filtered by ".implode(', ', $commentArguments).'.', null, $params);
1387 1387
             $docBlock->setWordWrap(false);
1388 1388
 
1389 1389
             $body = "\$filter = [
@@ -1392,12 +1392,12 @@  discard block
 block discarded – undo
1392 1392
 ";
1393 1393
         } else {
1394 1394
             $parameters[] = (new ParameterGenerator('orderBy'))->setDefaultValue(null);
1395
-            $params[] = new ParamTag('orderBy', [ 'mixed' ], 'The order string');
1395
+            $params[] = new ParamTag('orderBy', ['mixed'], 'The order string');
1396 1396
             $parameters[] = new ParameterGenerator('additionalTablesFetch', 'array', []);
1397
-            $params[] = new ParamTag('additionalTablesFetch', [ 'string[]' ], 'A list of additional tables to fetch (for performance improvement)');
1397
+            $params[] = new ParamTag('additionalTablesFetch', ['string[]'], 'A list of additional tables to fetch (for performance improvement)');
1398 1398
             $parameters[] = (new ParameterGenerator('mode', '?int'))->setDefaultValue(null);
1399
-            $params[] = new ParamTag('mode', [ 'int', 'null' ], 'Either TDBMService::MODE_ARRAY or TDBMService::MODE_CURSOR (for large datasets). Defaults to TDBMService::MODE_ARRAY.');
1400
-            $method->setReturnType($this->resultIteratorNamespace . '\\' . $this->getResultIteratorClassName());
1399
+            $params[] = new ParamTag('mode', ['int', 'null'], 'Either TDBMService::MODE_ARRAY or TDBMService::MODE_CURSOR (for large datasets). Defaults to TDBMService::MODE_ARRAY.');
1400
+            $method->setReturnType($this->resultIteratorNamespace.'\\'.$this->getResultIteratorClassName());
1401 1401
 
1402 1402
             $docBlock = new DocBlockGenerator("Get a list of $beanClassName filtered by ".implode(', ', $commentArguments).".", null, $params);
1403 1403
             $docBlock->setWordWrap(false);
@@ -1714,17 +1714,17 @@  discard block
 block discarded – undo
1714 1714
      * @param string $indent
1715 1715
      * @return string
1716 1716
      */
1717
-    private function psr2VarExport($var, string $indent=''): string
1717
+    private function psr2VarExport($var, string $indent = ''): string
1718 1718
     {
1719 1719
         if (is_array($var)) {
1720 1720
             $indexed = array_keys($var) === range(0, count($var) - 1);
1721 1721
             $r = [];
1722 1722
             foreach ($var as $key => $value) {
1723 1723
                 $r[] = "$indent    "
1724
-                    . ($indexed ? '' : $this->psr2VarExport($key) . ' => ')
1724
+                    . ($indexed ? '' : $this->psr2VarExport($key).' => ')
1725 1725
                     . $this->psr2VarExport($value, "$indent    ");
1726 1726
             }
1727
-            return "[\n" . implode(",\n", $r) . "\n" . $indent . ']';
1727
+            return "[\n".implode(",\n", $r)."\n".$indent.']';
1728 1728
         }
1729 1729
         return var_export($var, true);
1730 1730
     }
Please login to merge, or discard this patch.