@@ -49,7 +49,7 @@ |
||
49 | 49 | |
50 | 50 | $fromLock = (bool) $input->getOption('from-lock'); |
51 | 51 | |
52 | - $loggers = [ new ConsoleLogger($output) ]; |
|
52 | + $loggers = [new ConsoleLogger($output)]; |
|
53 | 53 | |
54 | 54 | $logger = $alteredConf->getLogger(); |
55 | 55 | if ($logger) { |
@@ -8,7 +8,7 @@ |
||
8 | 8 | { |
9 | 9 | public static function getValidVariableName(string $variableName): string |
10 | 10 | { |
11 | - $valid = preg_replace_callback('/^(\d+)/', static function (array $match) { |
|
11 | + $valid = preg_replace_callback('/^(\d+)/', static function(array $match) { |
|
12 | 12 | $f = new \NumberFormatter('en', \NumberFormatter::SPELLOUT); |
13 | 13 | $number = $f->format((int) $match[0]); |
14 | 14 | return preg_replace('/[^a-z]+/i', '_', $number); |
@@ -215,7 +215,7 @@ discard block |
||
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 |
||
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 |
||
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 = [ |
@@ -110,7 +110,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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'])); |
@@ -262,7 +262,7 @@ |
||
262 | 262 | */ |
263 | 263 | public function jsonSerialize() |
264 | 264 | { |
265 | - return array_map(function (AbstractTDBMObject $item) { |
|
265 | + return array_map(function(AbstractTDBMObject $item) { |
|
266 | 266 | return $item->jsonSerialize(); |
267 | 267 | }, $this->toArray()); |
268 | 268 | } |
@@ -67,7 +67,7 @@ discard block |
||
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 |
||
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 |
@@ -87,7 +87,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | /** |
@@ -48,7 +48,7 @@ discard block |
||
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 |
||
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 |
||
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 | } |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | } |
423 | 423 | } |
424 | 424 | |
425 | - return ['(' . implode(') AND (', $sqlParts) . ')', $parameters, $counter]; |
|
425 | + return ['('.implode(') AND (', $sqlParts).')', $parameters, $counter]; |
|
426 | 426 | } elseif ($filter_bag instanceof ResultIterator) { |
427 | 427 | $subQuery = $filter_bag->_getSubQuery(); |
428 | 428 | return [$subQuery, [], $counter]; |
@@ -1000,7 +1000,7 @@ discard block |
||
1000 | 1000 | |
1001 | 1001 | return $this->fromCache( |
1002 | 1002 | $this->cachePrefix.'_linkbetweeninheritedtables_'.implode('__split__', $tables), |
1003 | - function () use ($tables) { |
|
1003 | + function() use ($tables) { |
|
1004 | 1004 | return $this->_getLinkBetweenInheritedTablesWithoutCache($tables); |
1005 | 1005 | } |
1006 | 1006 | ); |
@@ -1048,7 +1048,7 @@ discard block |
||
1048 | 1048 | */ |
1049 | 1049 | public function _getRelatedTablesByInheritance(string $table): array |
1050 | 1050 | { |
1051 | - return $this->fromCache($this->cachePrefix.'_relatedtables_'.$table, function () use ($table) { |
|
1051 | + return $this->fromCache($this->cachePrefix.'_relatedtables_'.$table, function() use ($table) { |
|
1052 | 1052 | return $this->_getRelatedTablesByInheritanceWithoutCache($table); |
1053 | 1053 | }); |
1054 | 1054 | } |
@@ -1137,7 +1137,7 @@ discard block |
||
1137 | 1137 | public function findObjects(string $mainTable, $filter = null, array $parameters = array(), $orderString = null, array $additionalTablesFetch = array(), ?int $mode = null, string $className = null, string $resultIteratorClass = ResultIterator::class): ResultIterator |
1138 | 1138 | { |
1139 | 1139 | if (!is_a($resultIteratorClass, ResultIterator::class, true)) { |
1140 | - throw new TDBMInvalidArgumentException('$resultIteratorClass should be a `'. ResultIterator::class. '`. `' . $resultIteratorClass . '` provided.'); |
|
1140 | + throw new TDBMInvalidArgumentException('$resultIteratorClass should be a `'.ResultIterator::class.'`. `'.$resultIteratorClass.'` provided.'); |
|
1141 | 1141 | } |
1142 | 1142 | // $mainTable is not secured in MagicJoin, let's add a bit of security to avoid SQL injection. |
1143 | 1143 | if (!preg_match('/^[a-zA-Z_][a-zA-Z0-9_]*$/', $mainTable)) { |
@@ -1174,7 +1174,7 @@ discard block |
||
1174 | 1174 | public function findObjectsFromSql(string $mainTable, string $from, $filter = null, array $parameters = array(), $orderString = null, ?int $mode = null, string $className = null, string $resultIteratorClass = ResultIterator::class): ResultIterator |
1175 | 1175 | { |
1176 | 1176 | if (!is_a($resultIteratorClass, ResultIterator::class, true)) { |
1177 | - throw new TDBMInvalidArgumentException('$resultIteratorClass should be a `'. ResultIterator::class. '`. `' . $resultIteratorClass . '` provided.'); |
|
1177 | + throw new TDBMInvalidArgumentException('$resultIteratorClass should be a `'.ResultIterator::class.'`. `'.$resultIteratorClass.'` provided.'); |
|
1178 | 1178 | } |
1179 | 1179 | // $mainTable is not secured in MagicJoin, let's add a bit of security to avoid SQL injection. |
1180 | 1180 | if (!preg_match('/^[a-zA-Z_][a-zA-Z0-9_]*$/', $mainTable)) { |
@@ -1291,18 +1291,18 @@ discard block |
||
1291 | 1291 | if ($count > 1) { |
1292 | 1292 | $additionalErrorInfos = ''; |
1293 | 1293 | if (is_string($filter) && !empty($parameters)) { |
1294 | - $additionalErrorInfos = ' for filter "' . $filter.'"'; |
|
1294 | + $additionalErrorInfos = ' for filter "'.$filter.'"'; |
|
1295 | 1295 | foreach ($parameters as $fieldName => $parameter) { |
1296 | 1296 | if (is_array($parameter)) { |
1297 | - $value = '(' . implode(',', $parameter) . ')'; |
|
1297 | + $value = '('.implode(',', $parameter).')'; |
|
1298 | 1298 | } else { |
1299 | 1299 | $value = $parameter; |
1300 | 1300 | } |
1301 | - $additionalErrorInfos = str_replace(':' . $fieldName, var_export($value, true), $additionalErrorInfos); |
|
1301 | + $additionalErrorInfos = str_replace(':'.$fieldName, var_export($value, true), $additionalErrorInfos); |
|
1302 | 1302 | } |
1303 | 1303 | } |
1304 | 1304 | $additionalErrorInfos .= '.'; |
1305 | - throw new DuplicateRowException("Error while querying an object in table '$mainTable': More than 1 row have been returned, but we should have received at most one" . $additionalErrorInfos); |
|
1305 | + throw new DuplicateRowException("Error while querying an object in table '$mainTable': More than 1 row have been returned, but we should have received at most one".$additionalErrorInfos); |
|
1306 | 1306 | } elseif ($count === 0) { |
1307 | 1307 | return null; |
1308 | 1308 | } |
@@ -1345,7 +1345,7 @@ discard block |
||
1345 | 1345 | public function findObjectsFromRawSql(string $mainTable, string $sql, array $parameters = array(), ?int $mode = null, string $className = null, string $sqlCount = null, string $resultIteratorClass = ResultIterator::class): ResultIterator |
1346 | 1346 | { |
1347 | 1347 | if (!is_a($resultIteratorClass, ResultIterator::class, true)) { |
1348 | - throw new TDBMInvalidArgumentException('$resultIteratorClass should be a `'. ResultIterator::class. '`. `' . $resultIteratorClass . '` provided.'); |
|
1348 | + throw new TDBMInvalidArgumentException('$resultIteratorClass should be a `'.ResultIterator::class.'`. `'.$resultIteratorClass.'` provided.'); |
|
1349 | 1349 | } |
1350 | 1350 | // $mainTable is not secured in MagicJoin, let's add a bit of security to avoid SQL injection. |
1351 | 1351 | if (!preg_match('/^[a-zA-Z_][a-zA-Z0-9_]*$/', $mainTable)) { |
@@ -1475,7 +1475,7 @@ discard block |
||
1475 | 1475 | $table1 = $fks[0]->getForeignTableName(); |
1476 | 1476 | $table2 = $fks[1]->getForeignTableName(); |
1477 | 1477 | |
1478 | - $beanTables = array_map(function (DbRow $dbRow) { |
|
1478 | + $beanTables = array_map(function(DbRow $dbRow) { |
|
1479 | 1479 | return $dbRow->_getDbTableName(); |
1480 | 1480 | }, $bean->_getDbRows()); |
1481 | 1481 |