@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | $this->getArrayInlineCode($this->remoteFk->getUnquotedForeignColumns()), |
185 | 185 | $this->getArrayInlineCode($this->remoteFk->getUnquotedLocalColumns()), |
186 | 186 | $this->getArrayInlineCode($this->localFk->getUnquotedLocalColumns()), |
187 | - '\\' . $this->resultIteratorNamespace . '\\' . $this->getResultIteratorClassName() . '::class' |
|
187 | + '\\'.$this->resultIteratorNamespace.'\\'.$this->getResultIteratorClassName().'::class' |
|
188 | 188 | ); |
189 | 189 | } |
190 | 190 | |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | |
227 | 227 | $getter = new MethodGenerator($this->getName()); |
228 | 228 | $getterDocBlock = new DocBlockGenerator(sprintf('Returns the list of %s associated to this bean via the %s pivot table.', $remoteBeanName, $this->pivotTable->getName())); |
229 | - $getterDocBlock->setTag(new ReturnTag([ $fqcnRemoteBeanName.'[]' ])); |
|
229 | + $getterDocBlock->setTag(new ReturnTag([$fqcnRemoteBeanName.'[]'])); |
|
230 | 230 | $getterDocBlock->setWordWrap(false); |
231 | 231 | $getter->setDocBlock($getterDocBlock); |
232 | 232 | $getter->setReturnType('array'); |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | |
236 | 236 | $adder = new MethodGenerator('add'.$singularName); |
237 | 237 | $adderDocBlock = new DocBlockGenerator(sprintf('Adds a relationship with %s associated to this bean via the %s pivot table.', $remoteBeanName, $this->pivotTable->getName())); |
238 | - $adderDocBlock->setTag(new ParamTag($variableName, [ $fqcnRemoteBeanName ])); |
|
238 | + $adderDocBlock->setTag(new ParamTag($variableName, [$fqcnRemoteBeanName])); |
|
239 | 239 | $adderDocBlock->setWordWrap(false); |
240 | 240 | $adder->setDocBlock($adderDocBlock); |
241 | 241 | $adder->setReturnType('void'); |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | |
245 | 245 | $remover = new MethodGenerator('remove'.$singularName); |
246 | 246 | $removerDocBlock = new DocBlockGenerator(sprintf('Deletes the relationship with %s associated to this bean via the %s pivot table.', $remoteBeanName, $this->pivotTable->getName())); |
247 | - $removerDocBlock->setTag(new ParamTag($variableName, [ $fqcnRemoteBeanName ])); |
|
247 | + $removerDocBlock->setTag(new ParamTag($variableName, [$fqcnRemoteBeanName])); |
|
248 | 248 | $removerDocBlock->setWordWrap(false); |
249 | 249 | $remover->setDocBlock($removerDocBlock); |
250 | 250 | $remover->setReturnType('void'); |
@@ -253,8 +253,8 @@ discard block |
||
253 | 253 | |
254 | 254 | $has = new MethodGenerator('has'.$singularName); |
255 | 255 | $hasDocBlock = new DocBlockGenerator(sprintf('Returns whether this bean is associated with %s via the %s pivot table.', $remoteBeanName, $this->pivotTable->getName())); |
256 | - $hasDocBlock->setTag(new ParamTag($variableName, [ $fqcnRemoteBeanName ])); |
|
257 | - $hasDocBlock->setTag(new ReturnTag([ 'bool' ])); |
|
256 | + $hasDocBlock->setTag(new ParamTag($variableName, [$fqcnRemoteBeanName])); |
|
257 | + $hasDocBlock->setTag(new ReturnTag(['bool'])); |
|
258 | 258 | $hasDocBlock->setWordWrap(false); |
259 | 259 | $has->setDocBlock($hasDocBlock); |
260 | 260 | $has->setReturnType('bool'); |
@@ -264,15 +264,15 @@ discard block |
||
264 | 264 | $setter = new MethodGenerator('set'.$pluralName); |
265 | 265 | $setterDocBlock = new DocBlockGenerator(sprintf('Sets all relationships with %s associated to this bean via the %s pivot table. |
266 | 266 | Exiting relationships will be removed and replaced by the provided relationships.', $remoteBeanName, $this->pivotTable->getName())); |
267 | - $setterDocBlock->setTag(new ParamTag($pluralVariableName, [ $fqcnRemoteBeanName.'[]' ])); |
|
268 | - $setterDocBlock->setTag(new ReturnTag([ 'void' ])); |
|
267 | + $setterDocBlock->setTag(new ParamTag($pluralVariableName, [$fqcnRemoteBeanName.'[]'])); |
|
268 | + $setterDocBlock->setTag(new ReturnTag(['void'])); |
|
269 | 269 | $setterDocBlock->setWordWrap(false); |
270 | 270 | $setter->setDocBlock($setterDocBlock); |
271 | 271 | $setter->setReturnType('void'); |
272 | 272 | $setter->setParameter(new ParameterGenerator($pluralVariableName, 'array')); |
273 | 273 | $setter->setBody(sprintf('$this->setRelationships(%s, $%s);', $pathKey, $pluralVariableName)); |
274 | 274 | |
275 | - return [ $getter, $adder, $remover, $has, $setter ]; |
|
275 | + return [$getter, $adder, $remover, $has, $setter]; |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | /** |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | /** @var Annotation\JsonFormat|null $jsonFormat */ |
302 | 302 | $jsonFormat = $this->findRemoteAnnotation(Annotation\JsonFormat::class); |
303 | 303 | if ($jsonFormat !== null) { |
304 | - $method = $jsonFormat->method ?? 'get' . ucfirst($jsonFormat->property); |
|
304 | + $method = $jsonFormat->method ?? 'get'.ucfirst($jsonFormat->property); |
|
305 | 305 | $format = "$method()"; |
306 | 306 | } else { |
307 | 307 | $stopRecursion = $this->findRemoteAnnotation(Annotation\JsonRecursive::class) ? '' : 'true'; |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function getPhpType(): string |
95 | 95 | { |
96 | - return '\\' . $this->beanNamespace . '\\' . $this->getClassName(); |
|
96 | + return '\\'.$this->beanNamespace.'\\'.$this->getClassName(); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -168,17 +168,17 @@ discard block |
||
168 | 168 | $referencedResultIteratorName = $this->namingStrategy->getResultIteratorClassName($foreignTableName); |
169 | 169 | |
170 | 170 | $getter = new MethodGenerator($getterName); |
171 | - $getter->setDocBlock(new DocBlockGenerator('Returns the ' . $referencedBeanName . ' object bound to this object via the ' . implode(' and ', $this->foreignKey->getUnquotedLocalColumns()) . ' column.')); |
|
171 | + $getter->setDocBlock(new DocBlockGenerator('Returns the '.$referencedBeanName.' object bound to this object via the '.implode(' and ', $this->foreignKey->getUnquotedLocalColumns()).' column.')); |
|
172 | 172 | |
173 | - $getter->setReturnType(($isNullable ? '?' : '') . $this->beanNamespace . '\\' . $referencedBeanName); |
|
173 | + $getter->setReturnType(($isNullable ? '?' : '').$this->beanNamespace.'\\'.$referencedBeanName); |
|
174 | 174 | $tdbmFk = ForeignKey::createFromFk($this->foreignKey); |
175 | 175 | |
176 | 176 | $getter->setBody(sprintf( |
177 | 177 | 'return $this->getRef(%s, %s, %s, %s);', |
178 | 178 | var_export($tdbmFk->getCacheKey(), true), |
179 | 179 | var_export($tableName, true), |
180 | - '\\' . $this->beanNamespace . '\\' . $referencedBeanName . '::class', |
|
181 | - '\\' . $this->resultIteratorNamespace . '\\' . $referencedResultIteratorName . '::class' |
|
180 | + '\\'.$this->beanNamespace.'\\'.$referencedBeanName.'::class', |
|
181 | + '\\'.$this->resultIteratorNamespace.'\\'.$referencedResultIteratorName.'::class' |
|
182 | 182 | )); |
183 | 183 | |
184 | 184 | if ($this->isGetterProtected()) { |
@@ -187,9 +187,9 @@ discard block |
||
187 | 187 | |
188 | 188 | if (!$this->isReadOnly()) { |
189 | 189 | $setter = new MethodGenerator($setterName); |
190 | - $setter->setDocBlock(new DocBlockGenerator('The setter for the ' . $referencedBeanName . ' object bound to this object via the ' . implode(' and ', $this->foreignKey->getUnquotedLocalColumns()) . ' column.')); |
|
190 | + $setter->setDocBlock(new DocBlockGenerator('The setter for the '.$referencedBeanName.' object bound to this object via the '.implode(' and ', $this->foreignKey->getUnquotedLocalColumns()).' column.')); |
|
191 | 191 | |
192 | - $setter->setParameter(new ParameterGenerator('object', ($isNullable ? '?' : '') . $this->beanNamespace . '\\' . $referencedBeanName)); |
|
192 | + $setter->setParameter(new ParameterGenerator('object', ($isNullable ? '?' : '').$this->beanNamespace.'\\'.$referencedBeanName)); |
|
193 | 193 | |
194 | 194 | $setter->setReturnType('void'); |
195 | 195 | |
@@ -198,8 +198,8 @@ discard block |
||
198 | 198 | var_export($tdbmFk->getCacheKey(), true), |
199 | 199 | '$object', |
200 | 200 | var_export($tableName, true), |
201 | - '\\' . $this->beanNamespace . '\\' . $referencedBeanName . '::class', |
|
202 | - '\\' . $this->resultIteratorNamespace . '\\' . $referencedResultIteratorName . '::class' |
|
201 | + '\\'.$this->beanNamespace.'\\'.$referencedBeanName.'::class', |
|
202 | + '\\'.$this->resultIteratorNamespace.'\\'.$referencedResultIteratorName.'::class' |
|
203 | 203 | )); |
204 | 204 | |
205 | 205 | if ($this->isSetterProtected()) { |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | /** @var Annotation\JsonFormat|null $jsonFormat */ |
240 | 240 | $jsonFormat = $this->findAnnotation(Annotation\JsonFormat::class); |
241 | 241 | if ($jsonFormat !== null) { |
242 | - $method = $jsonFormat->method ?? 'get' . ucfirst($jsonFormat->property); |
|
242 | + $method = $jsonFormat->method ?? 'get'.ucfirst($jsonFormat->property); |
|
243 | 243 | $format = "$method()"; |
244 | 244 | } else { |
245 | 245 | $stopRecursion = $this->findAnnotation(Annotation\JsonRecursive::class) ? '' : 'true'; |
@@ -295,10 +295,10 @@ discard block |
||
295 | 295 | } elseif ($descriptor instanceof ScalarBeanPropertyDescriptor) { |
296 | 296 | $rows[] = "'$indexName' => $propertyAccess->$columnGetterName()"; |
297 | 297 | } else { |
298 | - throw new TDBMException('PropertyDescriptor of class `' . get_class($descriptor) . '` cannot be serialized.'); |
|
298 | + throw new TDBMException('PropertyDescriptor of class `'.get_class($descriptor).'` cannot be serialized.'); |
|
299 | 299 | } |
300 | 300 | } |
301 | - return '[' . implode(', ', $rows) . ']'; |
|
301 | + return '['.implode(', ', $rows).']'; |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | private function getBeanPropertyDescriptor(string $column): AbstractBeanPropertyDescriptor |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | return $descriptor; |
312 | 312 | } |
313 | 313 | } |
314 | - throw new TDBMException('PropertyDescriptor for `'.$this->table->getName().'`.`' . $column . '` not found in `' . $this->foreignBeanDescriptor->getTable()->getName() . '`'); |
|
314 | + throw new TDBMException('PropertyDescriptor for `'.$this->table->getName().'`.`'.$column.'` not found in `'.$this->foreignBeanDescriptor->getTable()->getName().'`'); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | /** |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | { |
455 | 455 | $beans = $this->tdbmService->findObjects('person', null, [], 'person.id ASC', [], null, TDBMObject::class, ResultIterator::class); |
456 | 456 | |
457 | - $results = $beans->map(function ($item) { |
|
457 | + $results = $beans->map(function($item) { |
|
458 | 458 | return $item->getProperty('id', 'person'); |
459 | 459 | })->toArray(); |
460 | 460 | |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | // Same test with page |
464 | 464 | $page = $beans->take(0, 2); |
465 | 465 | |
466 | - $results = $page->map(function ($item) { |
|
466 | + $results = $page->map(function($item) { |
|
467 | 467 | return $item->getProperty('id', 'person'); |
468 | 468 | })->toArray(); |
469 | 469 | |
@@ -843,7 +843,7 @@ discard block |
||
843 | 843 | public function testFindObjectsMethodWithoutResultIteratorClass(): void |
844 | 844 | { |
845 | 845 | $this->expectException(TDBMInvalidArgumentException::class); |
846 | - $this->expectExceptionMessageMatches('/^\$resultIteratorClass should be a `' . preg_quote(ResultIterator::class, '/') . '`. `(.*)` provided\.$/'); |
|
846 | + $this->expectExceptionMessageMatches('/^\$resultIteratorClass should be a `'.preg_quote(ResultIterator::class, '/').'`. `(.*)` provided\.$/'); |
|
847 | 847 | $tdbmService = new TDBMService(new Configuration('TheCodingMachine\\TDBM\\Test\\Dao\\Bean', 'TheCodingMachine\\TDBM\\Test\\Dao', self::getConnection(), $this->getNamingStrategy(), null, null, new NullLogger())); |
848 | 848 | |
849 | 849 | $tdbmService->findObjects('', null, [], null, [], null, null, self::class); |
@@ -852,7 +852,7 @@ discard block |
||
852 | 852 | public function testFindObjectsFromSqlMethodWithoutResultIteratorClass(): void |
853 | 853 | { |
854 | 854 | $this->expectException(TDBMInvalidArgumentException::class); |
855 | - $this->expectExceptionMessageMatches('/^\$resultIteratorClass should be a `' . preg_quote(ResultIterator::class, '/') . '`. `(.*)` provided\.$/'); |
|
855 | + $this->expectExceptionMessageMatches('/^\$resultIteratorClass should be a `'.preg_quote(ResultIterator::class, '/').'`. `(.*)` provided\.$/'); |
|
856 | 856 | $tdbmService = new TDBMService(new Configuration('TheCodingMachine\\TDBM\\Test\\Dao\\Bean', 'TheCodingMachine\\TDBM\\Test\\Dao', self::getConnection(), $this->getNamingStrategy(), null, null, new NullLogger())); |
857 | 857 | |
858 | 858 | $tdbmService->findObjectsFromSql('', '', null, [], null, null, null, self::class); |
@@ -861,7 +861,7 @@ discard block |
||
861 | 861 | public function testFindObjectsFromRawSqlMethodWithoutResultIteratorClass(): void |
862 | 862 | { |
863 | 863 | $this->expectException(TDBMInvalidArgumentException::class); |
864 | - $this->expectExceptionMessageMatches('/^\$resultIteratorClass should be a `' . preg_quote(ResultIterator::class, '/') . '`. `(.*)` provided\.$/'); |
|
864 | + $this->expectExceptionMessageMatches('/^\$resultIteratorClass should be a `'.preg_quote(ResultIterator::class, '/').'`. `(.*)` provided\.$/'); |
|
865 | 865 | $tdbmService = new TDBMService(new Configuration('TheCodingMachine\\TDBM\\Test\\Dao\\Bean', 'TheCodingMachine\\TDBM\\Test\\Dao', self::getConnection(), $this->getNamingStrategy(), null, null, new NullLogger())); |
866 | 866 | |
867 | 867 | $tdbmService->findObjectsFromRawSql('', '', [], null, null, null, self::class); |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function __construct(string $targetTable, string $pivotTable, array $joinForeignKeys, array $joinLocalKeys, array $whereKeys, string $resultIteratorClass) |
48 | 48 | { |
49 | - assert(is_a($resultIteratorClass, ResultIterator::class, true), new TDBMInvalidArgumentException('$resultIteratorClass should be a `'. ResultIterator::class. '`. `' . $resultIteratorClass . '` provided.')); |
|
49 | + assert(is_a($resultIteratorClass, ResultIterator::class, true), new TDBMInvalidArgumentException('$resultIteratorClass should be a `'.ResultIterator::class.'`. `'.$resultIteratorClass.'` provided.')); |
|
50 | 50 | $this->targetTable = $targetTable; |
51 | 51 | $this->pivotTable = $pivotTable; |
52 | 52 | $this->joinForeignKeys = $joinForeignKeys; |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | |
58 | 58 | public static function generateModelKey(ForeignKeyConstraint $remoteFk, ForeignKeyConstraint $localFk): string |
59 | 59 | { |
60 | - return $remoteFk->getLocalTableName() . "." . implode("__", $localFk->getUnquotedLocalColumns()); |
|
60 | + return $remoteFk->getLocalTableName().".".implode("__", $localFk->getUnquotedLocalColumns()); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | public function getPivotName(): string |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | ); |
92 | 92 | } |
93 | 93 | |
94 | - return $platform->quoteIdentifier($mainTable) . ' JOIN ' . $platform->quoteIdentifier($pivotTable) . ' ON ' . implode(' AND ', $join); |
|
94 | + return $platform->quoteIdentifier($mainTable).' JOIN '.$platform->quoteIdentifier($pivotTable).' ON '.implode(' AND ', $join); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | { |
117 | 117 | $params = []; |
118 | 118 | foreach ($primaryKeys as $key => $primaryKeyValue) { |
119 | - $params['param' . $key] = $primaryKeyValue; |
|
119 | + $params['param'.$key] = $primaryKeyValue; |
|
120 | 120 | } |
121 | 121 | return $params; |
122 | 122 | } |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | $schemaLockFileDumper = new SchemaLockFileDumper($this->tdbmService->getConnection(), new ArrayCache(), Configuration::getDefaultLockFilePath()); |
113 | 113 | $tdbmSchemaAnalyzer = new TDBMSchemaAnalyzer($this->tdbmService->getConnection(), new ArrayCache(), $schemaAnalyzer, $schemaLockFileDumper); |
114 | 114 | $this->tdbmDaoGenerator = new TDBMDaoGenerator($this->getConfiguration(), $tdbmSchemaAnalyzer); |
115 | - $this->rootPath = __DIR__ . '/../'; |
|
115 | + $this->rootPath = __DIR__.'/../'; |
|
116 | 116 | //$this->tdbmDaoGenerator->setComposerFile($this->rootPath.'composer.json'); |
117 | 117 | } |
118 | 118 | |
@@ -134,10 +134,10 @@ discard block |
||
134 | 134 | public function testDaoGeneration(): void |
135 | 135 | { |
136 | 136 | // Remove all previously generated files. |
137 | - $this->recursiveDelete($this->rootPath . 'src/Test/Dao/'); |
|
138 | - mkdir($this->rootPath . 'src/Test/Dao/Generated', 0755, true); |
|
137 | + $this->recursiveDelete($this->rootPath.'src/Test/Dao/'); |
|
138 | + mkdir($this->rootPath.'src/Test/Dao/Generated', 0755, true); |
|
139 | 139 | // Let's generate a dummy file to see it is indeed removed. |
140 | - $dummyFile = $this->rootPath . 'src/Test/Dao/Generated/foobar.php'; |
|
140 | + $dummyFile = $this->rootPath.'src/Test/Dao/Generated/foobar.php'; |
|
141 | 141 | touch($dummyFile); |
142 | 142 | $this->assertFileExists($dummyFile); |
143 | 143 | |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | |
157 | 157 | // Let's require all files to check they are valid PHP! |
158 | 158 | // Test the daoFactory |
159 | - require_once $this->rootPath . 'src/Test/Dao/Generated/DaoFactory.php'; |
|
159 | + require_once $this->rootPath.'src/Test/Dao/Generated/DaoFactory.php'; |
|
160 | 160 | // Test the others |
161 | 161 | |
162 | 162 | $beanDescriptors = $this->getDummyGeneratorListener()->getBeanDescriptors(); |
@@ -166,10 +166,10 @@ discard block |
||
166 | 166 | $daoBaseName = $beanDescriptor->getBaseDaoClassName(); |
167 | 167 | $beanName = $beanDescriptor->getBeanClassName(); |
168 | 168 | $baseBeanName = $beanDescriptor->getBaseBeanClassName(); |
169 | - require_once $this->rootPath . 'src/Test/Dao/Bean/Generated/' . $baseBeanName . '.php'; |
|
170 | - require_once $this->rootPath . 'src/Test/Dao/Bean/' . $beanName . '.php'; |
|
171 | - require_once $this->rootPath . 'src/Test/Dao/Generated/' . $daoBaseName . '.php'; |
|
172 | - require_once $this->rootPath . 'src/Test/Dao/' . $daoName . '.php'; |
|
169 | + require_once $this->rootPath.'src/Test/Dao/Bean/Generated/'.$baseBeanName.'.php'; |
|
170 | + require_once $this->rootPath.'src/Test/Dao/Bean/'.$beanName.'.php'; |
|
171 | + require_once $this->rootPath.'src/Test/Dao/Generated/'.$daoBaseName.'.php'; |
|
172 | + require_once $this->rootPath.'src/Test/Dao/'.$daoName.'.php'; |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | // Check that pivot tables do not generate DAOs or beans. |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | $schemaLockFileDumper = new SchemaLockFileDumper($this->tdbmService->getConnection(), new ArrayCache(), Configuration::getDefaultLockFilePath()); |
186 | 186 | $tdbmSchemaAnalyzer = new TDBMSchemaAnalyzer($this->tdbmService->getConnection(), new ArrayCache(), $schemaAnalyzer, $schemaLockFileDumper); |
187 | 187 | $tdbmDaoGenerator = new TDBMDaoGenerator($configuration, $tdbmSchemaAnalyzer); |
188 | - $this->rootPath = __DIR__ . '/../../../../'; |
|
188 | + $this->rootPath = __DIR__.'/../../../../'; |
|
189 | 189 | //$tdbmDaoGenerator->setComposerFile($this->rootPath.'composer.json'); |
190 | 190 | |
191 | 191 | $this->expectException(NoPathFoundException::class); |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | if (is_file($str)) { |
204 | 204 | return @unlink($str); |
205 | 205 | } elseif (is_dir($str)) { |
206 | - $scan = glob(rtrim($str, '/') . '/*'); |
|
206 | + $scan = glob(rtrim($str, '/').'/*'); |
|
207 | 207 | foreach ($scan as $index => $path) { |
208 | 208 | $this->recursiveDelete($path); |
209 | 209 | } |
@@ -1643,7 +1643,7 @@ discard block |
||
1643 | 1643 | |
1644 | 1644 | // executes after the command finishes |
1645 | 1645 | if (!$process->isSuccessful()) { |
1646 | - $this->fail('Generated code is not PSR-2 compliant' . PHP_EOL . $process->getErrorOutput()); |
|
1646 | + $this->fail('Generated code is not PSR-2 compliant'.PHP_EOL.$process->getErrorOutput()); |
|
1647 | 1647 | } |
1648 | 1648 | $this->assertTrue($process->isSuccessful()); |
1649 | 1649 | } |
@@ -2082,7 +2082,7 @@ discard block |
||
2082 | 2082 | |
2083 | 2083 | $artists = new ArtistDao($this->tdbmService); |
2084 | 2084 | $pinkFloyd = $artists->getById(1); |
2085 | - $animals = $pinkFloyd->getAlbums()[0]; |
|
2085 | + $animals = $pinkFloyd->getAlbums()[0]; |
|
2086 | 2086 | $json = $pinkFloyd->jsonSerialize(); |
2087 | 2087 | // Collection name properly handled ('discography' instead of default 'albums') |
2088 | 2088 | self::assertTrue(isset($json['discography'])); |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | */ |
216 | 216 | public function getConstructorProperties(): array |
217 | 217 | { |
218 | - $constructorProperties = array_filter($this->beanPropertyDescriptors, static function (AbstractBeanPropertyDescriptor $property) { |
|
218 | + $constructorProperties = array_filter($this->beanPropertyDescriptors, static function(AbstractBeanPropertyDescriptor $property) { |
|
219 | 219 | return !$property instanceof InheritanceReferencePropertyDescriptor && $property->isCompulsory() && !$property->isReadOnly(); |
220 | 220 | }); |
221 | 221 | |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | public function getPropertiesWithDefault(): array |
231 | 231 | { |
232 | 232 | $properties = $this->getPropertiesForTable($this->table); |
233 | - $defaultProperties = array_filter($properties, function (AbstractBeanPropertyDescriptor $property) { |
|
233 | + $defaultProperties = array_filter($properties, function(AbstractBeanPropertyDescriptor $property) { |
|
234 | 234 | return $property->hasDefault(); |
235 | 235 | }); |
236 | 236 | |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | */ |
245 | 245 | public function getExposedProperties(): array |
246 | 246 | { |
247 | - $exposedProperties = array_filter($this->beanPropertyDescriptors, function (AbstractBeanPropertyDescriptor $property) { |
|
247 | + $exposedProperties = array_filter($this->beanPropertyDescriptors, function(AbstractBeanPropertyDescriptor $property) { |
|
248 | 248 | return !$property instanceof InheritanceReferencePropertyDescriptor && $property->getTable()->getName() === $this->table->getName(); |
249 | 249 | }); |
250 | 250 | |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | foreach ($beanPropertyDescriptors as $beanDescriptor) { |
351 | 351 | $name = $beanDescriptor->getGetterName(); |
352 | 352 | if (isset($names[$name])) { |
353 | - throw new TDBMException('Unsolvable name conflict while generating method name "' . $name . '"'); |
|
353 | + throw new TDBMException('Unsolvable name conflict while generating method name "'.$name.'"'); |
|
354 | 354 | } else { |
355 | 355 | $names[$name] = $beanDescriptor; |
356 | 356 | } |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | $assigns[] = $property->assignToDefaultCode()."\n"; |
400 | 400 | } |
401 | 401 | |
402 | - $body = $parentConstructorCode . implode('', $assigns); |
|
402 | + $body = $parentConstructorCode.implode('', $assigns); |
|
403 | 403 | |
404 | 404 | $constructor->setBody($body); |
405 | 405 | |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | $this->descriptorsByMethodName[$name][] = $descriptor; |
474 | 474 | $descriptors = $this->descriptorsByMethodName[$name]; |
475 | 475 | if (count($descriptors) > 1) { |
476 | - $properties = array_filter($descriptors, function ($descriptor) { |
|
476 | + $properties = array_filter($descriptors, function($descriptor) { |
|
477 | 477 | return $descriptor instanceof AbstractBeanPropertyDescriptor; |
478 | 478 | }); |
479 | 479 | $renameProperties = count($properties) > 1; |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | foreach ($this->getExposedProperties() as $beanPropertyDescriptor) { |
525 | 525 | $propertyCode = $beanPropertyDescriptor->getJsonSerializeCode(); |
526 | 526 | if (!empty($propertyCode)) { |
527 | - $body .= PHP_EOL . $propertyCode; |
|
527 | + $body .= PHP_EOL.$propertyCode; |
|
528 | 528 | } |
529 | 529 | } |
530 | 530 | |
@@ -532,11 +532,11 @@ discard block |
||
532 | 532 | foreach ($this->getMethodDescriptors() as $methodDescriptor) { |
533 | 533 | $methodCode = $methodDescriptor->getJsonSerializeCode(); |
534 | 534 | if (!empty($methodCode)) { |
535 | - $body .= PHP_EOL . $methodCode; |
|
535 | + $body .= PHP_EOL.$methodCode; |
|
536 | 536 | } |
537 | 537 | } |
538 | 538 | |
539 | - $body .= PHP_EOL . 'return $array;'; |
|
539 | + $body .= PHP_EOL.'return $array;'; |
|
540 | 540 | |
541 | 541 | $method->setBody($body); |
542 | 542 | |
@@ -632,10 +632,10 @@ discard block |
||
632 | 632 | /** @var AddInterface[] $addInterfaceAnnotations */ |
633 | 633 | $addInterfaceAnnotations = $this->annotationParser->getTableAnnotations($this->table)->findAnnotations(AddInterface::class); |
634 | 634 | |
635 | - $interfaces = [ JsonSerializable::class ]; |
|
635 | + $interfaces = [JsonSerializable::class]; |
|
636 | 636 | foreach ($addInterfaceAnnotations as $annotation) { |
637 | 637 | /** @phpstan-var class-string $className */ |
638 | - $className = $annotation->getName(); |
|
638 | + $className = $annotation->getName(); |
|
639 | 639 | $interfaces[] = $className; |
640 | 640 | } |
641 | 641 | |
@@ -674,7 +674,7 @@ discard block |
||
674 | 674 | } |
675 | 675 | } elseif ($methodDescriptor instanceof PivotTableMethodsDescriptor) { |
676 | 676 | $pivotTableMethodsDescriptors[] = $methodDescriptor; |
677 | - [ $getter, $adder, $remover, $has, $setter ] = $methodDescriptor->getCode(); |
|
677 | + [$getter, $adder, $remover, $has, $setter] = $methodDescriptor->getCode(); |
|
678 | 678 | $methods = $this->codeGeneratorListener->onBaseBeanManyToManyGenerated($getter, $adder, $remover, $has, $setter, $methodDescriptor, $this, $this->configuration, $class); |
679 | 679 | foreach ($methods as $method) { |
680 | 680 | if ($method) { |
@@ -804,7 +804,7 @@ discard block |
||
804 | 804 | $interfaces = []; |
805 | 805 | foreach ($addInterfaceOnDaoAnnotations as $annotation) { |
806 | 806 | /** @phpstan-var class-string $className */ |
807 | - $className = $annotation->getName(); |
|
807 | + $className = $annotation->getName(); |
|
808 | 808 | $interfaces[] = $className; |
809 | 809 | } |
810 | 810 | |
@@ -826,7 +826,7 @@ discard block |
||
826 | 826 | |
827 | 827 | $constructorMethod = new MethodGenerator( |
828 | 828 | '__construct', |
829 | - [ new ParameterGenerator('tdbmService', TDBMService::class) ], |
|
829 | + [new ParameterGenerator('tdbmService', TDBMService::class)], |
|
830 | 830 | MethodGenerator::FLAG_PUBLIC, |
831 | 831 | '$this->tdbmService = $tdbmService;', |
832 | 832 | 'Sets the TDBM service used by this DAO.' |
@@ -838,7 +838,7 @@ discard block |
||
838 | 838 | |
839 | 839 | $saveMethod = new MethodGenerator( |
840 | 840 | 'save', |
841 | - [ new ParameterGenerator('obj', $beanClassName) ], |
|
841 | + [new ParameterGenerator('obj', $beanClassName)], |
|
842 | 842 | MethodGenerator::FLAG_PUBLIC, |
843 | 843 | '$this->tdbmService->save($obj);', |
844 | 844 | (new DocBlockGenerator( |
@@ -886,7 +886,7 @@ discard block |
||
886 | 886 | |
887 | 887 | foreach ($primaryKeyColumns as $primaryKeyColumn) { |
888 | 888 | if ($primaryKeyColumn === $lazyLoadingParameterName) { |
889 | - throw new TDBMException('Primary Column name `' . $lazyLoadingParameterName . '` is not allowed.'); |
|
889 | + throw new TDBMException('Primary Column name `'.$lazyLoadingParameterName.'` is not allowed.'); |
|
890 | 890 | } |
891 | 891 | $phpType = TDBMDaoGenerator::dbalTypeToPhpType($this->table->getColumn($primaryKeyColumn)->getType()); |
892 | 892 | $parameters[] = new ParameterGenerator($primaryKeyColumn, $phpType); |
@@ -902,7 +902,7 @@ discard block |
||
902 | 902 | 'getById', |
903 | 903 | $parameters, |
904 | 904 | MethodGenerator::FLAG_PUBLIC, |
905 | - "return \$this->tdbmService->findObjectByPk('$tableName', [" . implode(', ', $primaryKeyFilter) . "], [], \$$lazyLoadingParameterName, \\$beanClassName::class, \\$resultIteratorClass::class);", |
|
905 | + "return \$this->tdbmService->findObjectByPk('$tableName', [".implode(', ', $primaryKeyFilter)."], [], \$$lazyLoadingParameterName, \\$beanClassName::class, \\$resultIteratorClass::class);", |
|
906 | 906 | (new DocBlockGenerator( |
907 | 907 | "Get $beanClassWithoutNameSpace specified by its ID (its primary key).", |
908 | 908 | 'If the primary key does not exist, an exception is thrown.', |
@@ -1190,7 +1190,7 @@ discard block |
||
1190 | 1190 | $class->addUse(ResultIterator::class); |
1191 | 1191 | $class->setExtendedClass(ResultIterator::class); |
1192 | 1192 | } else { |
1193 | - $class->addUse($this->resultIteratorNamespace . '\\' . $extends); |
|
1193 | + $class->addUse($this->resultIteratorNamespace.'\\'.$extends); |
|
1194 | 1194 | /** @var class-string $extends */ |
1195 | 1195 | $class->setExtendedClass($extends); |
1196 | 1196 | } |
@@ -1198,7 +1198,7 @@ discard block |
||
1198 | 1198 | $class->setDocBlock((new DocBlockGenerator( |
1199 | 1199 | "The $baseClassName class will iterate over results of $beanClassWithoutNameSpace class.", |
1200 | 1200 | null, |
1201 | - [new Tag\MethodTag('getIterator', ['\\' . $beanClassName . '[]']), new Tag\MethodTag('toArray', ['\\' . $beanClassName . '[]'])] |
|
1201 | + [new Tag\MethodTag('getIterator', ['\\'.$beanClassName.'[]']), new Tag\MethodTag('toArray', ['\\'.$beanClassName.'[]'])] |
|
1202 | 1202 | ))->setWordWrap(false)); |
1203 | 1203 | |
1204 | 1204 | $file = $this->codeGeneratorListener->onBaseResultIteratorGenerated($file, $this, $this->configuration); |
@@ -1254,7 +1254,7 @@ discard block |
||
1254 | 1254 | } |
1255 | 1255 | } |
1256 | 1256 | } |
1257 | - usort($methods, static function (MethodGenerator $methodA, MethodGenerator $methodB) { |
|
1257 | + usort($methods, static function(MethodGenerator $methodA, MethodGenerator $methodB) { |
|
1258 | 1258 | return $methodA->getName() <=> $methodB->getName(); |
1259 | 1259 | }); |
1260 | 1260 | |
@@ -1403,11 +1403,11 @@ discard block |
||
1403 | 1403 | |
1404 | 1404 | if ($index->isUnique()) { |
1405 | 1405 | $parameters[] = new ParameterGenerator('additionalTablesFetch', 'array', []); |
1406 | - $params[] = new ParamTag('additionalTablesFetch', [ 'string[]' ], 'A list of additional tables to fetch (for performance improvement)'); |
|
1407 | - $params[] = new ReturnTag([ '\\'.$beanNamespace.'\\'.$beanClassName, 'null' ]); |
|
1406 | + $params[] = new ParamTag('additionalTablesFetch', ['string[]'], 'A list of additional tables to fetch (for performance improvement)'); |
|
1407 | + $params[] = new ReturnTag(['\\'.$beanNamespace.'\\'.$beanClassName, 'null']); |
|
1408 | 1408 | $method->setReturnType('?\\'.$beanNamespace.'\\'.$beanClassName); |
1409 | 1409 | |
1410 | - $docBlock = new DocBlockGenerator("Get a $beanClassName filtered by ".implode(', ', $commentArguments). '.', null, $params); |
|
1410 | + $docBlock = new DocBlockGenerator("Get a $beanClassName filtered by ".implode(', ', $commentArguments).'.', null, $params); |
|
1411 | 1411 | $docBlock->setWordWrap(false); |
1412 | 1412 | |
1413 | 1413 | $body = "\$filter = [ |
@@ -1416,12 +1416,12 @@ discard block |
||
1416 | 1416 | "; |
1417 | 1417 | } else { |
1418 | 1418 | $parameters[] = (new ParameterGenerator('orderBy'))->setDefaultValue(null); |
1419 | - $params[] = new ParamTag('orderBy', [ 'mixed' ], 'The order string'); |
|
1419 | + $params[] = new ParamTag('orderBy', ['mixed'], 'The order string'); |
|
1420 | 1420 | $parameters[] = new ParameterGenerator('additionalTablesFetch', 'array', []); |
1421 | - $params[] = new ParamTag('additionalTablesFetch', [ 'string[]' ], 'A list of additional tables to fetch (for performance improvement)'); |
|
1421 | + $params[] = new ParamTag('additionalTablesFetch', ['string[]'], 'A list of additional tables to fetch (for performance improvement)'); |
|
1422 | 1422 | $parameters[] = (new ParameterGenerator('mode', '?int'))->setDefaultValue(null); |
1423 | - $params[] = new ParamTag('mode', [ 'int', 'null' ], 'Either TDBMService::MODE_ARRAY or TDBMService::MODE_CURSOR (for large datasets). Defaults to TDBMService::MODE_ARRAY.'); |
|
1424 | - $method->setReturnType($this->resultIteratorNamespace . '\\' . $this->getResultIteratorClassName()); |
|
1423 | + $params[] = new ParamTag('mode', ['int', 'null'], 'Either TDBMService::MODE_ARRAY or TDBMService::MODE_CURSOR (for large datasets). Defaults to TDBMService::MODE_ARRAY.'); |
|
1424 | + $method->setReturnType($this->resultIteratorNamespace.'\\'.$this->getResultIteratorClassName()); |
|
1425 | 1425 | |
1426 | 1426 | $docBlock = new DocBlockGenerator("Get a list of $beanClassName filtered by ".implode(', ', $commentArguments).".", null, $params); |
1427 | 1427 | $docBlock->setWordWrap(false); |
@@ -1481,8 +1481,8 @@ discard block |
||
1481 | 1481 | var_export($tdbmFk->getCacheKey(), true), |
1482 | 1482 | 'null', |
1483 | 1483 | var_export($this->table->getName(), true), |
1484 | - '\\' . $this->beanNamespace . '\\' . $this->namingStrategy->getBeanClassName($foreignTableName) . '::class', |
|
1485 | - '\\' . $this->resultIteratorNamespace . '\\' . $this->namingStrategy->getResultIteratorClassName($foreignTableName) . '::class' |
|
1484 | + '\\'.$this->beanNamespace.'\\'.$this->namingStrategy->getBeanClassName($foreignTableName).'::class', |
|
1485 | + '\\'.$this->resultIteratorNamespace.'\\'.$this->namingStrategy->getResultIteratorClassName($foreignTableName).'::class' |
|
1486 | 1486 | ); |
1487 | 1487 | } |
1488 | 1488 | } |
@@ -1756,17 +1756,17 @@ discard block |
||
1756 | 1756 | * @param string $indent |
1757 | 1757 | * @return string |
1758 | 1758 | */ |
1759 | - private function psr2VarExport($var, string $indent=''): string |
|
1759 | + private function psr2VarExport($var, string $indent = ''): string |
|
1760 | 1760 | { |
1761 | 1761 | if (is_array($var)) { |
1762 | 1762 | $indexed = array_keys($var) === range(0, count($var) - 1); |
1763 | 1763 | $r = []; |
1764 | 1764 | foreach ($var as $key => $value) { |
1765 | 1765 | $r[] = "$indent " |
1766 | - . ($indexed ? '' : $this->psr2VarExport($key) . ' => ') |
|
1766 | + . ($indexed ? '' : $this->psr2VarExport($key).' => ') |
|
1767 | 1767 | . $this->psr2VarExport($value, "$indent "); |
1768 | 1768 | } |
1769 | - return "[\n" . implode(",\n", $r) . "\n" . $indent . ']'; |
|
1769 | + return "[\n".implode(",\n", $r)."\n".$indent.']'; |
|
1770 | 1770 | } |
1771 | 1771 | return var_export($var, true); |
1772 | 1772 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | |
52 | 52 | // Let's compute the COUNT. |
53 | 53 | $pkColumnNames = $this->tdbmService->getPrimaryKeyColumns($this->mainTable); |
54 | - $pkColumnNames = array_map(function ($pkColumn) use ($mySqlPlatform) { |
|
54 | + $pkColumnNames = array_map(function($pkColumn) use ($mySqlPlatform) { |
|
55 | 55 | return $mySqlPlatform->quoteIdentifier($this->mainTable).'.'.$mySqlPlatform->quoteIdentifier($pkColumn); |
56 | 56 | }, $pkColumnNames); |
57 | 57 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | */ |
116 | 116 | private function getParentRelationshipForeignKeys(string $tableName): array |
117 | 117 | { |
118 | - return $this->fromCache($this->cachePrefix.'_parentrelationshipfks_'.$tableName, function () use ($tableName) { |
|
118 | + return $this->fromCache($this->cachePrefix.'_parentrelationshipfks_'.$tableName, function() use ($tableName) { |
|
119 | 119 | return $this->getParentRelationshipForeignKeysWithoutCache($tableName); |
120 | 120 | }); |
121 | 121 | } |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | */ |
145 | 145 | private function getChildrenRelationshipForeignKeys(string $tableName): array |
146 | 146 | { |
147 | - return $this->fromCache($this->cachePrefix.'_childrenrelationshipfks_'.$tableName, function () use ($tableName) { |
|
147 | + return $this->fromCache($this->cachePrefix.'_childrenrelationshipfks_'.$tableName, function() use ($tableName) { |
|
148 | 148 | return $this->getChildrenRelationshipForeignKeysWithoutCache($tableName); |
149 | 149 | }); |
150 | 150 | } |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | $children = $this->schemaAnalyzer->getChildrenRelationships($tableName); |
160 | 160 | |
161 | 161 | if (!empty($children)) { |
162 | - $fksTables = array_map(function (ForeignKeyConstraint $fk) { |
|
162 | + $fksTables = array_map(function(ForeignKeyConstraint $fk) { |
|
163 | 163 | return $this->getChildrenRelationshipForeignKeys($fk->getLocalTableName()); |
164 | 164 | }, $children); |
165 | 165 |
@@ -367,10 +367,10 @@ discard block |
||
367 | 367 | |
368 | 368 | $localTableName = $incomingFk->getLocalTableName(); |
369 | 369 | |
370 | - $className = $this->beanNamespace . '\\' . $this->namingStrategy->getBeanClassName($localTableName); |
|
370 | + $className = $this->beanNamespace.'\\'.$this->namingStrategy->getBeanClassName($localTableName); |
|
371 | 371 | assert(class_exists($className)); |
372 | 372 | |
373 | - $resultIteratorClassName = $this->resultIteratorNamespace . '\\' . $this->namingStrategy->getResultIteratorClassName($localTableName); |
|
373 | + $resultIteratorClassName = $this->resultIteratorNamespace.'\\'.$this->namingStrategy->getResultIteratorClassName($localTableName); |
|
374 | 374 | assert(class_exists($resultIteratorClassName)); |
375 | 375 | |
376 | 376 | $results = $this->findObjects( |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | } |
441 | 441 | } |
442 | 442 | |
443 | - return ['(' . implode(') AND (', $sqlParts) . ')', $parameters, $counter]; |
|
443 | + return ['('.implode(') AND (', $sqlParts).')', $parameters, $counter]; |
|
444 | 444 | } elseif ($filter_bag instanceof ResultIterator) { |
445 | 445 | $subQuery = $filter_bag->_getSubQuery(); |
446 | 446 | return [$subQuery, [], $counter]; |
@@ -1019,7 +1019,7 @@ discard block |
||
1019 | 1019 | |
1020 | 1020 | return $this->fromCache( |
1021 | 1021 | $this->cachePrefix.'_linkbetweeninheritedtables_'.implode('__split__', $tables), |
1022 | - function () use ($tables) { |
|
1022 | + function() use ($tables) { |
|
1023 | 1023 | return $this->_getLinkBetweenInheritedTablesWithoutCache($tables); |
1024 | 1024 | } |
1025 | 1025 | ); |
@@ -1067,7 +1067,7 @@ discard block |
||
1067 | 1067 | */ |
1068 | 1068 | public function _getRelatedTablesByInheritance(string $table): array |
1069 | 1069 | { |
1070 | - return $this->fromCache($this->cachePrefix.'_relatedtables_'.$table, function () use ($table) { |
|
1070 | + return $this->fromCache($this->cachePrefix.'_relatedtables_'.$table, function() use ($table) { |
|
1071 | 1071 | return $this->_getRelatedTablesByInheritanceWithoutCache($table); |
1072 | 1072 | }); |
1073 | 1073 | } |
@@ -1156,7 +1156,7 @@ discard block |
||
1156 | 1156 | public function findObjects(string $mainTable, $filter, array $parameters, $orderString, array $additionalTablesFetch, ?int $mode, ?string $className, string $resultIteratorClass): ResultIterator |
1157 | 1157 | { |
1158 | 1158 | if (!is_a($resultIteratorClass, ResultIterator::class, true)) { |
1159 | - throw new TDBMInvalidArgumentException('$resultIteratorClass should be a `'. ResultIterator::class. '`. `' . $resultIteratorClass . '` provided.'); |
|
1159 | + throw new TDBMInvalidArgumentException('$resultIteratorClass should be a `'.ResultIterator::class.'`. `'.$resultIteratorClass.'` provided.'); |
|
1160 | 1160 | } |
1161 | 1161 | // $mainTable is not secured in MagicJoin, let's add a bit of security to avoid SQL injection. |
1162 | 1162 | if (!preg_match('/^[a-zA-Z_][a-zA-Z0-9_]*$/', $mainTable)) { |
@@ -1193,7 +1193,7 @@ discard block |
||
1193 | 1193 | public function findObjectsFromSql(string $mainTable, string $from, $filter, array $parameters, $orderString, ?int $mode, ?string $className, string $resultIteratorClass): ResultIterator |
1194 | 1194 | { |
1195 | 1195 | if (!is_a($resultIteratorClass, ResultIterator::class, true)) { |
1196 | - throw new TDBMInvalidArgumentException('$resultIteratorClass should be a `'. ResultIterator::class. '`. `' . $resultIteratorClass . '` provided.'); |
|
1196 | + throw new TDBMInvalidArgumentException('$resultIteratorClass should be a `'.ResultIterator::class.'`. `'.$resultIteratorClass.'` provided.'); |
|
1197 | 1197 | } |
1198 | 1198 | // $mainTable is not secured in MagicJoin, let's add a bit of security to avoid SQL injection. |
1199 | 1199 | if (!preg_match('/^[a-zA-Z_][a-zA-Z0-9_]*$/', $mainTable)) { |
@@ -1226,8 +1226,8 @@ discard block |
||
1226 | 1226 | */ |
1227 | 1227 | public function findObjectByPk(string $table, array $primaryKeys, array $additionalTablesFetch, bool $lazy, string $className, string $resultIteratorClass): AbstractTDBMObject |
1228 | 1228 | { |
1229 | - assert(is_a($resultIteratorClass, ResultIterator::class, true), new TDBMInvalidArgumentException('$resultIteratorClass should be a `'. ResultIterator::class. '`. `' . $resultIteratorClass . '` provided.')); |
|
1230 | - assert(is_a($className, AbstractTDBMObject::class, true), new TDBMInvalidArgumentException('$className should be a `'. AbstractTDBMObject::class. '`. `' . $className . '` provided.')); |
|
1229 | + assert(is_a($resultIteratorClass, ResultIterator::class, true), new TDBMInvalidArgumentException('$resultIteratorClass should be a `'.ResultIterator::class.'`. `'.$resultIteratorClass.'` provided.')); |
|
1230 | + assert(is_a($className, AbstractTDBMObject::class, true), new TDBMInvalidArgumentException('$className should be a `'.AbstractTDBMObject::class.'`. `'.$className.'` provided.')); |
|
1231 | 1231 | $primaryKeys = $this->_getPrimaryKeysFromObjectData($table, $primaryKeys); |
1232 | 1232 | $hash = $this->getObjectHash($primaryKeys); |
1233 | 1233 | |
@@ -1284,7 +1284,7 @@ discard block |
||
1284 | 1284 | */ |
1285 | 1285 | public function findObject(string $mainTable, $filter, array $parameters, array $additionalTablesFetch, string $className, string $resultIteratorClass): ?AbstractTDBMObject |
1286 | 1286 | { |
1287 | - assert(is_a($resultIteratorClass, ResultIterator::class, true), new TDBMInvalidArgumentException('$resultIteratorClass should be a `'. ResultIterator::class. '`. `' . $resultIteratorClass . '` provided.')); |
|
1287 | + assert(is_a($resultIteratorClass, ResultIterator::class, true), new TDBMInvalidArgumentException('$resultIteratorClass should be a `'.ResultIterator::class.'`. `'.$resultIteratorClass.'` provided.')); |
|
1288 | 1288 | $objects = $this->findObjects($mainTable, $filter, $parameters, null, $additionalTablesFetch, self::MODE_ARRAY, $className, $resultIteratorClass); |
1289 | 1289 | return $this->getAtMostOneObjectOrFail($objects, $mainTable, $filter, $parameters); |
1290 | 1290 | } |
@@ -1306,18 +1306,18 @@ discard block |
||
1306 | 1306 | if ($count > 1) { |
1307 | 1307 | $additionalErrorInfos = ''; |
1308 | 1308 | if (is_string($filter) && !empty($parameters)) { |
1309 | - $additionalErrorInfos = ' for filter "' . $filter.'"'; |
|
1309 | + $additionalErrorInfos = ' for filter "'.$filter.'"'; |
|
1310 | 1310 | foreach ($parameters as $fieldName => $parameter) { |
1311 | 1311 | if (is_array($parameter)) { |
1312 | - $value = '(' . implode(',', $parameter) . ')'; |
|
1312 | + $value = '('.implode(',', $parameter).')'; |
|
1313 | 1313 | } else { |
1314 | 1314 | $value = $parameter; |
1315 | 1315 | } |
1316 | - $additionalErrorInfos = str_replace(':' . $fieldName, var_export($value, true), $additionalErrorInfos); |
|
1316 | + $additionalErrorInfos = str_replace(':'.$fieldName, var_export($value, true), $additionalErrorInfos); |
|
1317 | 1317 | } |
1318 | 1318 | } |
1319 | 1319 | $additionalErrorInfos .= '.'; |
1320 | - 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); |
|
1320 | + 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); |
|
1321 | 1321 | } elseif ($count === 0) { |
1322 | 1322 | return null; |
1323 | 1323 | } |
@@ -1341,7 +1341,7 @@ discard block |
||
1341 | 1341 | */ |
1342 | 1342 | public function findObjectFromSql(string $mainTable, string $from, $filter, array $parameters, ?string $className, string $resultIteratorClass): ?AbstractTDBMObject |
1343 | 1343 | { |
1344 | - assert(is_a($resultIteratorClass, ResultIterator::class, true), new TDBMInvalidArgumentException('$resultIteratorClass should be a `'. ResultIterator::class. '`. `' . $resultIteratorClass . '` provided.')); |
|
1344 | + assert(is_a($resultIteratorClass, ResultIterator::class, true), new TDBMInvalidArgumentException('$resultIteratorClass should be a `'.ResultIterator::class.'`. `'.$resultIteratorClass.'` provided.')); |
|
1345 | 1345 | $objects = $this->findObjectsFromSql($mainTable, $from, $filter, $parameters, null, self::MODE_ARRAY, $className, $resultIteratorClass); |
1346 | 1346 | return $this->getAtMostOneObjectOrFail($objects, $mainTable, $filter, $parameters); |
1347 | 1347 | } |
@@ -1362,7 +1362,7 @@ discard block |
||
1362 | 1362 | public function findObjectsFromRawSql(string $mainTable, string $sql, array $parameters, ?int $mode, ?string $className, ?string $sqlCount, string $resultIteratorClass): ResultIterator |
1363 | 1363 | { |
1364 | 1364 | if (!is_a($resultIteratorClass, ResultIterator::class, true)) { |
1365 | - throw new TDBMInvalidArgumentException('$resultIteratorClass should be a `'. ResultIterator::class. '`. `' . $resultIteratorClass . '` provided.'); |
|
1365 | + throw new TDBMInvalidArgumentException('$resultIteratorClass should be a `'.ResultIterator::class.'`. `'.$resultIteratorClass.'` provided.'); |
|
1366 | 1366 | } |
1367 | 1367 | // $mainTable is not secured in MagicJoin, let's add a bit of security to avoid SQL injection. |
1368 | 1368 | if (!preg_match('/^[a-zA-Z_][a-zA-Z0-9_]*$/', $mainTable)) { |
@@ -1393,7 +1393,7 @@ discard block |
||
1393 | 1393 | */ |
1394 | 1394 | public function findObjectOrFail(string $mainTable, $filter, array $parameters, array $additionalTablesFetch, string $className, string $resultIteratorClass): AbstractTDBMObject |
1395 | 1395 | { |
1396 | - assert(is_a($resultIteratorClass, ResultIterator::class, true), new TDBMInvalidArgumentException('$resultIteratorClass should be a `'. ResultIterator::class. '`. `' . $resultIteratorClass . '` provided.')); |
|
1396 | + assert(is_a($resultIteratorClass, ResultIterator::class, true), new TDBMInvalidArgumentException('$resultIteratorClass should be a `'.ResultIterator::class.'`. `'.$resultIteratorClass.'` provided.')); |
|
1397 | 1397 | $bean = $this->findObject($mainTable, $filter, $parameters, $additionalTablesFetch, $className, $resultIteratorClass); |
1398 | 1398 | if ($bean === null) { |
1399 | 1399 | throw NoBeanFoundException::missFilterRecord($mainTable); |
@@ -1506,7 +1506,7 @@ discard block |
||
1506 | 1506 | $table1 = $fks[0]->getForeignTableName(); |
1507 | 1507 | $table2 = $fks[1]->getForeignTableName(); |
1508 | 1508 | |
1509 | - $beanTables = array_map(function (DbRow $dbRow) { |
|
1509 | + $beanTables = array_map(function(DbRow $dbRow) { |
|
1510 | 1510 | return $dbRow->_getDbTableName(); |
1511 | 1511 | }, $bean->_getDbRows()); |
1512 | 1512 |
@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | public function getName(): string |
71 | 71 | { |
72 | 72 | if (!$this->useAlternateName) { |
73 | - return 'get' . $this->getPropertyName(); |
|
73 | + return 'get'.$this->getPropertyName(); |
|
74 | 74 | } else { |
75 | - $methodName = 'get' . $this->getPropertyName() . 'By'; |
|
75 | + $methodName = 'get'.$this->getPropertyName().'By'; |
|
76 | 76 | |
77 | 77 | $camelizedColumns = array_map([TDBMDaoGenerator::class, 'toCamelCase'], $this->foreignKey->getUnquotedLocalColumns()); |
78 | 78 | |
@@ -137,23 +137,23 @@ discard block |
||
137 | 137 | $getter = new MethodGenerator($this->getName()); |
138 | 138 | |
139 | 139 | if ($this->hasLocalUniqueIndex()) { |
140 | - $classType = '\\' . $this->beanNamespace . '\\' . $beanClass; |
|
140 | + $classType = '\\'.$this->beanNamespace.'\\'.$beanClass; |
|
141 | 141 | $getterDocBlock = new DocBlockGenerator(sprintf('Returns the %s pointing to this bean via the %s column.', $beanClass, implode(', ', $this->foreignKey->getUnquotedLocalColumns()))); |
142 | - $getterDocBlock->setTag([new ReturnTag([$classType . '|null'])]); |
|
142 | + $getterDocBlock->setTag([new ReturnTag([$classType.'|null'])]); |
|
143 | 143 | $getterDocBlock->setWordWrap(false); |
144 | 144 | $getter->setDocBlock($getterDocBlock); |
145 | - $getter->setReturnType('?' . $classType); |
|
145 | + $getter->setReturnType('?'.$classType); |
|
146 | 146 | |
147 | 147 | $code = sprintf( |
148 | 148 | 'return $this->retrieveManyToOneRelationshipsStorage(%s, %s, %s, null, %s)->first();', |
149 | 149 | var_export($this->foreignKey->getLocalTableName(), true), |
150 | 150 | var_export($tdbmFk->getCacheKey(), true), |
151 | 151 | $this->getFilters($this->foreignKey), |
152 | - '\\' . $this->resultIteratorNamespace . '\\' . $this->getResultIteratorClassName() .'::class' |
|
152 | + '\\'.$this->resultIteratorNamespace.'\\'.$this->getResultIteratorClassName().'::class' |
|
153 | 153 | ); |
154 | 154 | } else { |
155 | 155 | $getterDocBlock = new DocBlockGenerator(sprintf('Returns the list of %s pointing to this bean via the %s column.', $beanClass, implode(', ', $this->foreignKey->getUnquotedLocalColumns()))); |
156 | - $getterDocBlock->setTag(new ReturnTag([$beanClass . '[]', '\\' . AlterableResultIterator::class])); |
|
156 | + $getterDocBlock->setTag(new ReturnTag([$beanClass.'[]', '\\'.AlterableResultIterator::class])); |
|
157 | 157 | $getterDocBlock->setWordWrap(false); |
158 | 158 | $getter->setDocBlock($getterDocBlock); |
159 | 159 | $getter->setReturnType(AlterableResultIterator::class); |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | var_export($this->foreignKey->getLocalTableName(), true), |
164 | 164 | var_export($tdbmFk->getCacheKey(), true), |
165 | 165 | $this->getFilters($this->foreignKey), |
166 | - '\\' . $this->resultIteratorNamespace . '\\' . $this->getResultIteratorClassName() .'::class' |
|
166 | + '\\'.$this->resultIteratorNamespace.'\\'.$this->getResultIteratorClassName().'::class' |
|
167 | 167 | ); |
168 | 168 | } |
169 | 169 | |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | $getter->setVisibility(AbstractMemberGenerator::VISIBILITY_PROTECTED); |
174 | 174 | } |
175 | 175 | |
176 | - return [ $getter ]; |
|
176 | + return [$getter]; |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | private function getFilters(ForeignKeyConstraint $fk): string |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | /** @var Annotation\JsonFormat|null $jsonFormat */ |
246 | 246 | $jsonFormat = $this->findAnnotation(Annotation\JsonFormat::class); |
247 | 247 | if ($jsonFormat !== null) { |
248 | - $method = $jsonFormat->method ?? 'get' . ucfirst($jsonFormat->property); |
|
248 | + $method = $jsonFormat->method ?? 'get'.ucfirst($jsonFormat->property); |
|
249 | 249 | $format = "$method()"; |
250 | 250 | } else { |
251 | 251 | $stopRecursion = $this->findAnnotation(Annotation\JsonRecursive::class) ? '' : 'true'; |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | $isIncluded = $this->findAnnotation(Annotation\JsonInclude::class) !== null; |
255 | 255 | $index = $jsonCollection->key ?: lcfirst($this->getPropertyName()); |
256 | 256 | $class = $this->getBeanClassName(); |
257 | - $variableName = '$' . TDBMDaoGenerator::toVariableName($class); |
|
257 | + $variableName = '$'.TDBMDaoGenerator::toVariableName($class); |
|
258 | 258 | $getter = $this->getName(); |
259 | 259 | if ($this->hasLocalUniqueIndex()) { |
260 | 260 | $code = "\$array['$index'] = (\$object = \$this->$getter()) ? \$object->$format : null;"; |