@@ -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 | /** |
@@ -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 | |
@@ -631,7 +631,7 @@ discard block |
||
| 631 | 631 | /** @var AddInterface[] $addInterfaceAnnotations */ |
| 632 | 632 | $addInterfaceAnnotations = $this->annotationParser->getTableAnnotations($this->table)->findAnnotations(AddInterface::class); |
| 633 | 633 | |
| 634 | - $interfaces = [ JsonSerializable::class ]; |
|
| 634 | + $interfaces = [JsonSerializable::class]; |
|
| 635 | 635 | foreach ($addInterfaceAnnotations as $annotation) { |
| 636 | 636 | $interfaces[] = $annotation->getName(); |
| 637 | 637 | } |
@@ -671,7 +671,7 @@ discard block |
||
| 671 | 671 | } |
| 672 | 672 | } elseif ($methodDescriptor instanceof PivotTableMethodsDescriptor) { |
| 673 | 673 | $pivotTableMethodsDescriptors[] = $methodDescriptor; |
| 674 | - [ $getter, $adder, $remover, $has, $setter ] = $methodDescriptor->getCode(); |
|
| 674 | + [$getter, $adder, $remover, $has, $setter] = $methodDescriptor->getCode(); |
|
| 675 | 675 | $methods = $this->codeGeneratorListener->onBaseBeanManyToManyGenerated($getter, $adder, $remover, $has, $setter, $methodDescriptor, $this, $this->configuration, $class); |
| 676 | 676 | foreach ($methods as $method) { |
| 677 | 677 | if ($method) { |
@@ -821,7 +821,7 @@ discard block |
||
| 821 | 821 | |
| 822 | 822 | $constructorMethod = new MethodGenerator( |
| 823 | 823 | '__construct', |
| 824 | - [ new ParameterGenerator('tdbmService', TDBMService::class) ], |
|
| 824 | + [new ParameterGenerator('tdbmService', TDBMService::class)], |
|
| 825 | 825 | MethodGenerator::FLAG_PUBLIC, |
| 826 | 826 | '$this->tdbmService = $tdbmService;', |
| 827 | 827 | 'Sets the TDBM service used by this DAO.' |
@@ -833,7 +833,7 @@ discard block |
||
| 833 | 833 | |
| 834 | 834 | $saveMethod = new MethodGenerator( |
| 835 | 835 | 'save', |
| 836 | - [ new ParameterGenerator('obj', $beanClassName) ], |
|
| 836 | + [new ParameterGenerator('obj', $beanClassName)], |
|
| 837 | 837 | MethodGenerator::FLAG_PUBLIC, |
| 838 | 838 | '$this->tdbmService->save($obj);', |
| 839 | 839 | (new DocBlockGenerator( |
@@ -881,7 +881,7 @@ discard block |
||
| 881 | 881 | |
| 882 | 882 | foreach ($primaryKeyColumns as $primaryKeyColumn) { |
| 883 | 883 | if ($primaryKeyColumn === $lazyLoadingParameterName) { |
| 884 | - throw new TDBMException('Primary Column name `' . $lazyLoadingParameterName . '` is not allowed.'); |
|
| 884 | + throw new TDBMException('Primary Column name `'.$lazyLoadingParameterName.'` is not allowed.'); |
|
| 885 | 885 | } |
| 886 | 886 | $phpType = TDBMDaoGenerator::dbalTypeToPhpType($this->table->getColumn($primaryKeyColumn)->getType()); |
| 887 | 887 | $parameters[] = new ParameterGenerator($primaryKeyColumn, $phpType); |
@@ -897,7 +897,7 @@ discard block |
||
| 897 | 897 | 'getById', |
| 898 | 898 | $parameters, |
| 899 | 899 | MethodGenerator::FLAG_PUBLIC, |
| 900 | - "return \$this->tdbmService->findObjectByPk('$tableName', [" . implode(', ', $primaryKeyFilter) . "], [], \$$lazyLoadingParameterName, \\$beanClassName::class, \\$resultIteratorClass::class);", |
|
| 900 | + "return \$this->tdbmService->findObjectByPk('$tableName', [".implode(', ', $primaryKeyFilter)."], [], \$$lazyLoadingParameterName, \\$beanClassName::class, \\$resultIteratorClass::class);", |
|
| 901 | 901 | (new DocBlockGenerator( |
| 902 | 902 | "Get $beanClassWithoutNameSpace specified by its ID (its primary key).", |
| 903 | 903 | 'If the primary key does not exist, an exception is thrown.', |
@@ -1185,14 +1185,14 @@ discard block |
||
| 1185 | 1185 | $class->addUse(ResultIterator::class); |
| 1186 | 1186 | $class->setExtendedClass(ResultIterator::class); |
| 1187 | 1187 | } else { |
| 1188 | - $class->addUse($this->resultIteratorNamespace . '\\' . $extends); |
|
| 1188 | + $class->addUse($this->resultIteratorNamespace.'\\'.$extends); |
|
| 1189 | 1189 | $class->setExtendedClass($extends); |
| 1190 | 1190 | } |
| 1191 | 1191 | |
| 1192 | 1192 | $class->setDocBlock((new DocBlockGenerator( |
| 1193 | 1193 | "The $baseClassName class will iterate over results of $beanClassWithoutNameSpace class.", |
| 1194 | 1194 | null, |
| 1195 | - [new Tag\MethodTag('getIterator', ['\\' . $beanClassName . '[]'])] |
|
| 1195 | + [new Tag\MethodTag('getIterator', ['\\'.$beanClassName.'[]'])] |
|
| 1196 | 1196 | ))->setWordWrap(false)); |
| 1197 | 1197 | |
| 1198 | 1198 | $file = $this->codeGeneratorListener->onBaseResultIteratorGenerated($file, $this, $this->configuration); |
@@ -1248,7 +1248,7 @@ discard block |
||
| 1248 | 1248 | } |
| 1249 | 1249 | } |
| 1250 | 1250 | } |
| 1251 | - usort($methods, static function (MethodGenerator $methodA, MethodGenerator $methodB) { |
|
| 1251 | + usort($methods, static function(MethodGenerator $methodA, MethodGenerator $methodB) { |
|
| 1252 | 1252 | return $methodA->getName() <=> $methodB->getName(); |
| 1253 | 1253 | }); |
| 1254 | 1254 | |
@@ -1397,11 +1397,11 @@ discard block |
||
| 1397 | 1397 | |
| 1398 | 1398 | if ($index->isUnique()) { |
| 1399 | 1399 | $parameters[] = new ParameterGenerator('additionalTablesFetch', 'array', []); |
| 1400 | - $params[] = new ParamTag('additionalTablesFetch', [ 'string[]' ], 'A list of additional tables to fetch (for performance improvement)'); |
|
| 1401 | - $params[] = new ReturnTag([ '\\'.$beanNamespace.'\\'.$beanClassName, 'null' ]); |
|
| 1400 | + $params[] = new ParamTag('additionalTablesFetch', ['string[]'], 'A list of additional tables to fetch (for performance improvement)'); |
|
| 1401 | + $params[] = new ReturnTag(['\\'.$beanNamespace.'\\'.$beanClassName, 'null']); |
|
| 1402 | 1402 | $method->setReturnType('?\\'.$beanNamespace.'\\'.$beanClassName); |
| 1403 | 1403 | |
| 1404 | - $docBlock = new DocBlockGenerator("Get a $beanClassName filtered by ".implode(', ', $commentArguments). '.', null, $params); |
|
| 1404 | + $docBlock = new DocBlockGenerator("Get a $beanClassName filtered by ".implode(', ', $commentArguments).'.', null, $params); |
|
| 1405 | 1405 | $docBlock->setWordWrap(false); |
| 1406 | 1406 | |
| 1407 | 1407 | $body = "\$filter = [ |
@@ -1410,12 +1410,12 @@ discard block |
||
| 1410 | 1410 | "; |
| 1411 | 1411 | } else { |
| 1412 | 1412 | $parameters[] = (new ParameterGenerator('orderBy'))->setDefaultValue(null); |
| 1413 | - $params[] = new ParamTag('orderBy', [ 'mixed' ], 'The order string'); |
|
| 1413 | + $params[] = new ParamTag('orderBy', ['mixed'], 'The order string'); |
|
| 1414 | 1414 | $parameters[] = new ParameterGenerator('additionalTablesFetch', 'array', []); |
| 1415 | - $params[] = new ParamTag('additionalTablesFetch', [ 'string[]' ], 'A list of additional tables to fetch (for performance improvement)'); |
|
| 1415 | + $params[] = new ParamTag('additionalTablesFetch', ['string[]'], 'A list of additional tables to fetch (for performance improvement)'); |
|
| 1416 | 1416 | $parameters[] = (new ParameterGenerator('mode', '?int'))->setDefaultValue(null); |
| 1417 | - $params[] = new ParamTag('mode', [ 'int', 'null' ], 'Either TDBMService::MODE_ARRAY or TDBMService::MODE_CURSOR (for large datasets). Defaults to TDBMService::MODE_ARRAY.'); |
|
| 1418 | - $method->setReturnType($this->resultIteratorNamespace . '\\' . $this->getResultIteratorClassName()); |
|
| 1417 | + $params[] = new ParamTag('mode', ['int', 'null'], 'Either TDBMService::MODE_ARRAY or TDBMService::MODE_CURSOR (for large datasets). Defaults to TDBMService::MODE_ARRAY.'); |
|
| 1418 | + $method->setReturnType($this->resultIteratorNamespace.'\\'.$this->getResultIteratorClassName()); |
|
| 1419 | 1419 | |
| 1420 | 1420 | $docBlock = new DocBlockGenerator("Get a list of $beanClassName filtered by ".implode(', ', $commentArguments).".", null, $params); |
| 1421 | 1421 | $docBlock->setWordWrap(false); |
@@ -1475,8 +1475,8 @@ discard block |
||
| 1475 | 1475 | var_export($tdbmFk->getCacheKey(), true), |
| 1476 | 1476 | 'null', |
| 1477 | 1477 | var_export($this->table->getName(), true), |
| 1478 | - '\\' . $this->beanNamespace . '\\' . $this->namingStrategy->getBeanClassName($foreignTableName) . '::class', |
|
| 1479 | - '\\' . $this->resultIteratorNamespace . '\\' . $this->namingStrategy->getResultIteratorClassName($foreignTableName) . '::class' |
|
| 1478 | + '\\'.$this->beanNamespace.'\\'.$this->namingStrategy->getBeanClassName($foreignTableName).'::class', |
|
| 1479 | + '\\'.$this->resultIteratorNamespace.'\\'.$this->namingStrategy->getResultIteratorClassName($foreignTableName).'::class' |
|
| 1480 | 1480 | ); |
| 1481 | 1481 | } |
| 1482 | 1482 | } |
@@ -1750,17 +1750,17 @@ discard block |
||
| 1750 | 1750 | * @param string $indent |
| 1751 | 1751 | * @return string |
| 1752 | 1752 | */ |
| 1753 | - private function psr2VarExport($var, string $indent=''): string |
|
| 1753 | + private function psr2VarExport($var, string $indent = ''): string |
|
| 1754 | 1754 | { |
| 1755 | 1755 | if (is_array($var)) { |
| 1756 | 1756 | $indexed = array_keys($var) === range(0, count($var) - 1); |
| 1757 | 1757 | $r = []; |
| 1758 | 1758 | foreach ($var as $key => $value) { |
| 1759 | 1759 | $r[] = "$indent " |
| 1760 | - . ($indexed ? '' : $this->psr2VarExport($key) . ' => ') |
|
| 1760 | + . ($indexed ? '' : $this->psr2VarExport($key).' => ') |
|
| 1761 | 1761 | . $this->psr2VarExport($value, "$indent "); |
| 1762 | 1762 | } |
| 1763 | - return "[\n" . implode(",\n", $r) . "\n" . $indent . ']'; |
|
| 1763 | + return "[\n".implode(",\n", $r)."\n".$indent.']'; |
|
| 1764 | 1764 | } |
| 1765 | 1765 | return var_export($var, true); |
| 1766 | 1766 | } |
@@ -77,9 +77,9 @@ discard block |
||
| 77 | 77 | public function getName() : string |
| 78 | 78 | { |
| 79 | 79 | if (!$this->useAlternateName) { |
| 80 | - return 'get' . $this->getPropertyName(); |
|
| 80 | + return 'get'.$this->getPropertyName(); |
|
| 81 | 81 | } else { |
| 82 | - $methodName = 'get' . $this->getPropertyName() . 'By'; |
|
| 82 | + $methodName = 'get'.$this->getPropertyName().'By'; |
|
| 83 | 83 | |
| 84 | 84 | $camelizedColumns = array_map([TDBMDaoGenerator::class, 'toCamelCase'], $this->foreignKey->getUnquotedLocalColumns()); |
| 85 | 85 | |
@@ -144,23 +144,23 @@ discard block |
||
| 144 | 144 | $getter = new MethodGenerator($this->getName()); |
| 145 | 145 | |
| 146 | 146 | if ($this->hasLocalUniqueIndex()) { |
| 147 | - $classType = '\\' . $this->beanNamespace . '\\' . $beanClass; |
|
| 147 | + $classType = '\\'.$this->beanNamespace.'\\'.$beanClass; |
|
| 148 | 148 | $getterDocBlock = new DocBlockGenerator(sprintf('Returns the %s pointing to this bean via the %s column.', $beanClass, implode(', ', $this->foreignKey->getUnquotedLocalColumns()))); |
| 149 | - $getterDocBlock->setTag([new ReturnTag([$classType . '|null'])]); |
|
| 149 | + $getterDocBlock->setTag([new ReturnTag([$classType.'|null'])]); |
|
| 150 | 150 | $getterDocBlock->setWordWrap(false); |
| 151 | 151 | $getter->setDocBlock($getterDocBlock); |
| 152 | - $getter->setReturnType('?' . $classType); |
|
| 152 | + $getter->setReturnType('?'.$classType); |
|
| 153 | 153 | |
| 154 | 154 | $code = sprintf( |
| 155 | 155 | 'return $this->retrieveManyToOneRelationshipsStorage(%s, %s, %s, null, %s)->first();', |
| 156 | 156 | var_export($this->foreignKey->getLocalTableName(), true), |
| 157 | 157 | var_export($tdbmFk->getCacheKey(), true), |
| 158 | 158 | $this->getFilters($this->foreignKey), |
| 159 | - '\\' . $this->resultIteratorNamespace . '\\' . $this->getResultIteratorClassName() .'::class' |
|
| 159 | + '\\'.$this->resultIteratorNamespace.'\\'.$this->getResultIteratorClassName().'::class' |
|
| 160 | 160 | ); |
| 161 | 161 | } else { |
| 162 | 162 | $getterDocBlock = new DocBlockGenerator(sprintf('Returns the list of %s pointing to this bean via the %s column.', $beanClass, implode(', ', $this->foreignKey->getUnquotedLocalColumns()))); |
| 163 | - $getterDocBlock->setTag(new ReturnTag([$beanClass . '[]', '\\' . AlterableResultIterator::class])); |
|
| 163 | + $getterDocBlock->setTag(new ReturnTag([$beanClass.'[]', '\\'.AlterableResultIterator::class])); |
|
| 164 | 164 | $getterDocBlock->setWordWrap(false); |
| 165 | 165 | $getter->setDocBlock($getterDocBlock); |
| 166 | 166 | $getter->setReturnType(AlterableResultIterator::class); |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | var_export($this->foreignKey->getLocalTableName(), true), |
| 171 | 171 | var_export($tdbmFk->getCacheKey(), true), |
| 172 | 172 | $this->getFilters($this->foreignKey), |
| 173 | - '\\' . $this->resultIteratorNamespace . '\\' . $this->getResultIteratorClassName() .'::class' |
|
| 173 | + '\\'.$this->resultIteratorNamespace.'\\'.$this->getResultIteratorClassName().'::class' |
|
| 174 | 174 | ); |
| 175 | 175 | } |
| 176 | 176 | |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | $getter->setVisibility(AbstractMemberGenerator::VISIBILITY_PROTECTED); |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - return [ $getter ]; |
|
| 183 | + return [$getter]; |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | private function getFilters(ForeignKeyConstraint $fk) : string |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | /** @var Annotation\JsonFormat|null $jsonFormat */ |
| 252 | 252 | $jsonFormat = $this->findAnnotation(Annotation\JsonFormat::class); |
| 253 | 253 | if ($jsonFormat !== null) { |
| 254 | - $method = $jsonFormat->method ?? 'get' . ucfirst($jsonFormat->property); |
|
| 254 | + $method = $jsonFormat->method ?? 'get'.ucfirst($jsonFormat->property); |
|
| 255 | 255 | $format = "$method()"; |
| 256 | 256 | } else { |
| 257 | 257 | $stopRecursion = $this->findAnnotation(Annotation\JsonRecursive::class) ? '' : 'true'; |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | $isIncluded = $this->findAnnotation(Annotation\JsonInclude::class) !== null; |
| 261 | 261 | $index = $jsonCollection->key ?: lcfirst($this->getPropertyName()); |
| 262 | 262 | $class = $this->getBeanClassName(); |
| 263 | - $variableName = '$' . TDBMDaoGenerator::toVariableName($class); |
|
| 263 | + $variableName = '$'.TDBMDaoGenerator::toVariableName($class); |
|
| 264 | 264 | $getter = $this->getName(); |
| 265 | 265 | if ($this->hasLocalUniqueIndex()) { |
| 266 | 266 | $code = "\$array['$index'] = (\$object = \$this->$getter()) ? \$object->$format : null;"; |
@@ -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); |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | |
| 254 | 254 | protected function setRef(string $foreignKeyName, ?AbstractTDBMObject $bean, string $tableName, string $className, string $resultIteratorClass): void |
| 255 | 255 | { |
| 256 | - assert($bean === null || is_a($bean, $className), new TDBMInvalidArgumentException('$bean should be `null` or `' . $className . '`. `' . ($bean === null ? 'null' : get_class($bean)) . '` provided.')); |
|
| 256 | + assert($bean === null || is_a($bean, $className), new TDBMInvalidArgumentException('$bean should be `null` or `'.$className.'`. `'.($bean === null ? 'null' : get_class($bean)).'` provided.')); |
|
| 257 | 257 | |
| 258 | 258 | if (!isset($this->dbRows[$tableName])) { |
| 259 | 259 | $this->registerTable($tableName); |
@@ -515,7 +515,7 @@ discard block |
||
| 515 | 515 | */ |
| 516 | 516 | protected function retrieveManyToOneRelationshipsStorage(string $tableName, string $foreignKeyName, array $searchFilter, ?string $orderString, string $resultIteratorClass) : AlterableResultIterator |
| 517 | 517 | { |
| 518 | - assert(is_a($resultIteratorClass, ResultIterator::class, true), new TDBMInvalidArgumentException('$resultIteratorClass should be a `'. ResultIterator::class. '`. `' . $resultIteratorClass . '` provided.')); |
|
| 518 | + assert(is_a($resultIteratorClass, ResultIterator::class, true), new TDBMInvalidArgumentException('$resultIteratorClass should be a `'.ResultIterator::class.'`. `'.$resultIteratorClass.'` provided.')); |
|
| 519 | 519 | $key = $tableName.'___'.$foreignKeyName; |
| 520 | 520 | $alterableResultIterator = $this->getManyToOneAlterableResultIterator($tableName, $foreignKeyName); |
| 521 | 521 | if ($this->status === TDBMObjectStateEnum::STATE_DETACHED || $this->status === TDBMObjectStateEnum::STATE_NEW || (isset($this->manyToOneRelationships[$key]) && $this->manyToOneRelationships[$key]->getUnderlyingResultIterator() !== null)) { |
@@ -377,8 +377,8 @@ discard block |
||
| 377 | 377 | null, |
| 378 | 378 | [], |
| 379 | 379 | null, |
| 380 | - $this->beanNamespace . '\\' . $this->namingStrategy->getBeanClassName($localTableName), |
|
| 381 | - $this->resultIteratorNamespace . '\\' . $this->namingStrategy->getResultIteratorClassName($localTableName) |
|
| 380 | + $this->beanNamespace.'\\'.$this->namingStrategy->getBeanClassName($localTableName), |
|
| 381 | + $this->resultIteratorNamespace.'\\'.$this->namingStrategy->getResultIteratorClassName($localTableName) |
|
| 382 | 382 | ); |
| 383 | 383 | |
| 384 | 384 | foreach ($results as $bean) { |
@@ -437,7 +437,7 @@ discard block |
||
| 437 | 437 | } |
| 438 | 438 | } |
| 439 | 439 | |
| 440 | - return ['(' . implode(') AND (', $sqlParts) . ')', $parameters, $counter]; |
|
| 440 | + return ['('.implode(') AND (', $sqlParts).')', $parameters, $counter]; |
|
| 441 | 441 | } elseif ($filter_bag instanceof ResultIterator) { |
| 442 | 442 | $subQuery = $filter_bag->_getSubQuery(); |
| 443 | 443 | return [$subQuery, [], $counter]; |
@@ -1015,7 +1015,7 @@ discard block |
||
| 1015 | 1015 | |
| 1016 | 1016 | return $this->fromCache( |
| 1017 | 1017 | $this->cachePrefix.'_linkbetweeninheritedtables_'.implode('__split__', $tables), |
| 1018 | - function () use ($tables) { |
|
| 1018 | + function() use ($tables) { |
|
| 1019 | 1019 | return $this->_getLinkBetweenInheritedTablesWithoutCache($tables); |
| 1020 | 1020 | } |
| 1021 | 1021 | ); |
@@ -1063,7 +1063,7 @@ discard block |
||
| 1063 | 1063 | */ |
| 1064 | 1064 | public function _getRelatedTablesByInheritance(string $table): array |
| 1065 | 1065 | { |
| 1066 | - return $this->fromCache($this->cachePrefix.'_relatedtables_'.$table, function () use ($table) { |
|
| 1066 | + return $this->fromCache($this->cachePrefix.'_relatedtables_'.$table, function() use ($table) { |
|
| 1067 | 1067 | return $this->_getRelatedTablesByInheritanceWithoutCache($table); |
| 1068 | 1068 | }); |
| 1069 | 1069 | } |
@@ -1152,7 +1152,7 @@ discard block |
||
| 1152 | 1152 | public function findObjects(string $mainTable, $filter, array $parameters, $orderString, array $additionalTablesFetch, ?int $mode, ?string $className, string $resultIteratorClass): ResultIterator |
| 1153 | 1153 | { |
| 1154 | 1154 | if (!is_a($resultIteratorClass, ResultIterator::class, true)) { |
| 1155 | - throw new TDBMInvalidArgumentException('$resultIteratorClass should be a `'. ResultIterator::class. '`. `' . $resultIteratorClass . '` provided.'); |
|
| 1155 | + throw new TDBMInvalidArgumentException('$resultIteratorClass should be a `'.ResultIterator::class.'`. `'.$resultIteratorClass.'` provided.'); |
|
| 1156 | 1156 | } |
| 1157 | 1157 | // $mainTable is not secured in MagicJoin, let's add a bit of security to avoid SQL injection. |
| 1158 | 1158 | if (!preg_match('/^[a-zA-Z_][a-zA-Z0-9_]*$/', $mainTable)) { |
@@ -1189,7 +1189,7 @@ discard block |
||
| 1189 | 1189 | public function findObjectsFromSql(string $mainTable, string $from, $filter, array $parameters, $orderString, ?int $mode, ?string $className, string $resultIteratorClass): ResultIterator |
| 1190 | 1190 | { |
| 1191 | 1191 | if (!is_a($resultIteratorClass, ResultIterator::class, true)) { |
| 1192 | - throw new TDBMInvalidArgumentException('$resultIteratorClass should be a `'. ResultIterator::class. '`. `' . $resultIteratorClass . '` provided.'); |
|
| 1192 | + throw new TDBMInvalidArgumentException('$resultIteratorClass should be a `'.ResultIterator::class.'`. `'.$resultIteratorClass.'` provided.'); |
|
| 1193 | 1193 | } |
| 1194 | 1194 | // $mainTable is not secured in MagicJoin, let's add a bit of security to avoid SQL injection. |
| 1195 | 1195 | if (!preg_match('/^[a-zA-Z_][a-zA-Z0-9_]*$/', $mainTable)) { |
@@ -1222,8 +1222,8 @@ discard block |
||
| 1222 | 1222 | */ |
| 1223 | 1223 | public function findObjectByPk(string $table, array $primaryKeys, array $additionalTablesFetch, bool $lazy, string $className, string $resultIteratorClass): AbstractTDBMObject |
| 1224 | 1224 | { |
| 1225 | - assert(is_a($resultIteratorClass, ResultIterator::class, true), new TDBMInvalidArgumentException('$resultIteratorClass should be a `'. ResultIterator::class. '`. `' . $resultIteratorClass . '` provided.')); |
|
| 1226 | - assert(is_a($className, AbstractTDBMObject::class, true), new TDBMInvalidArgumentException('$className should be a `'. AbstractTDBMObject::class. '`. `' . $className . '` provided.')); |
|
| 1225 | + assert(is_a($resultIteratorClass, ResultIterator::class, true), new TDBMInvalidArgumentException('$resultIteratorClass should be a `'.ResultIterator::class.'`. `'.$resultIteratorClass.'` provided.')); |
|
| 1226 | + assert(is_a($className, AbstractTDBMObject::class, true), new TDBMInvalidArgumentException('$className should be a `'.AbstractTDBMObject::class.'`. `'.$className.'` provided.')); |
|
| 1227 | 1227 | $primaryKeys = $this->_getPrimaryKeysFromObjectData($table, $primaryKeys); |
| 1228 | 1228 | $hash = $this->getObjectHash($primaryKeys); |
| 1229 | 1229 | |
@@ -1279,7 +1279,7 @@ discard block |
||
| 1279 | 1279 | */ |
| 1280 | 1280 | public function findObject(string $mainTable, $filter, array $parameters, array $additionalTablesFetch, string $className, string $resultIteratorClass) : ?AbstractTDBMObject |
| 1281 | 1281 | { |
| 1282 | - assert(is_a($resultIteratorClass, ResultIterator::class, true), new TDBMInvalidArgumentException('$resultIteratorClass should be a `'. ResultIterator::class. '`. `' . $resultIteratorClass . '` provided.')); |
|
| 1282 | + assert(is_a($resultIteratorClass, ResultIterator::class, true), new TDBMInvalidArgumentException('$resultIteratorClass should be a `'.ResultIterator::class.'`. `'.$resultIteratorClass.'` provided.')); |
|
| 1283 | 1283 | $objects = $this->findObjects($mainTable, $filter, $parameters, null, $additionalTablesFetch, self::MODE_ARRAY, $className, $resultIteratorClass); |
| 1284 | 1284 | return $this->getAtMostOneObjectOrFail($objects, $mainTable, $filter, $parameters); |
| 1285 | 1285 | } |
@@ -1301,18 +1301,18 @@ discard block |
||
| 1301 | 1301 | if ($count > 1) { |
| 1302 | 1302 | $additionalErrorInfos = ''; |
| 1303 | 1303 | if (is_string($filter) && !empty($parameters)) { |
| 1304 | - $additionalErrorInfos = ' for filter "' . $filter.'"'; |
|
| 1304 | + $additionalErrorInfos = ' for filter "'.$filter.'"'; |
|
| 1305 | 1305 | foreach ($parameters as $fieldName => $parameter) { |
| 1306 | 1306 | if (is_array($parameter)) { |
| 1307 | - $value = '(' . implode(',', $parameter) . ')'; |
|
| 1307 | + $value = '('.implode(',', $parameter).')'; |
|
| 1308 | 1308 | } else { |
| 1309 | 1309 | $value = $parameter; |
| 1310 | 1310 | } |
| 1311 | - $additionalErrorInfos = str_replace(':' . $fieldName, var_export($value, true), $additionalErrorInfos); |
|
| 1311 | + $additionalErrorInfos = str_replace(':'.$fieldName, var_export($value, true), $additionalErrorInfos); |
|
| 1312 | 1312 | } |
| 1313 | 1313 | } |
| 1314 | 1314 | $additionalErrorInfos .= '.'; |
| 1315 | - 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); |
|
| 1315 | + 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); |
|
| 1316 | 1316 | } elseif ($count === 0) { |
| 1317 | 1317 | return null; |
| 1318 | 1318 | } |
@@ -1335,7 +1335,7 @@ discard block |
||
| 1335 | 1335 | */ |
| 1336 | 1336 | public function findObjectFromSql(string $mainTable, string $from, $filter, array $parameters, ?string $className, string $resultIteratorClass) : ?AbstractTDBMObject |
| 1337 | 1337 | { |
| 1338 | - assert(is_a($resultIteratorClass, ResultIterator::class, true), new TDBMInvalidArgumentException('$resultIteratorClass should be a `'. ResultIterator::class. '`. `' . $resultIteratorClass . '` provided.')); |
|
| 1338 | + assert(is_a($resultIteratorClass, ResultIterator::class, true), new TDBMInvalidArgumentException('$resultIteratorClass should be a `'.ResultIterator::class.'`. `'.$resultIteratorClass.'` provided.')); |
|
| 1339 | 1339 | $objects = $this->findObjectsFromSql($mainTable, $from, $filter, $parameters, null, self::MODE_ARRAY, $className, $resultIteratorClass); |
| 1340 | 1340 | return $this->getAtMostOneObjectOrFail($objects, $mainTable, $filter, $parameters); |
| 1341 | 1341 | } |
@@ -1356,7 +1356,7 @@ discard block |
||
| 1356 | 1356 | public function findObjectsFromRawSql(string $mainTable, string $sql, array $parameters, ?int $mode, ?string $className, ?string $sqlCount, string $resultIteratorClass): ResultIterator |
| 1357 | 1357 | { |
| 1358 | 1358 | if (!is_a($resultIteratorClass, ResultIterator::class, true)) { |
| 1359 | - throw new TDBMInvalidArgumentException('$resultIteratorClass should be a `'. ResultIterator::class. '`. `' . $resultIteratorClass . '` provided.'); |
|
| 1359 | + throw new TDBMInvalidArgumentException('$resultIteratorClass should be a `'.ResultIterator::class.'`. `'.$resultIteratorClass.'` provided.'); |
|
| 1360 | 1360 | } |
| 1361 | 1361 | // $mainTable is not secured in MagicJoin, let's add a bit of security to avoid SQL injection. |
| 1362 | 1362 | if (!preg_match('/^[a-zA-Z_][a-zA-Z0-9_]*$/', $mainTable)) { |
@@ -1386,7 +1386,7 @@ discard block |
||
| 1386 | 1386 | */ |
| 1387 | 1387 | public function findObjectOrFail(string $mainTable, $filter, array $parameters, array $additionalTablesFetch, string $className, string $resultIteratorClass): AbstractTDBMObject |
| 1388 | 1388 | { |
| 1389 | - assert(is_a($resultIteratorClass, ResultIterator::class, true), new TDBMInvalidArgumentException('$resultIteratorClass should be a `'. ResultIterator::class. '`. `' . $resultIteratorClass . '` provided.')); |
|
| 1389 | + assert(is_a($resultIteratorClass, ResultIterator::class, true), new TDBMInvalidArgumentException('$resultIteratorClass should be a `'.ResultIterator::class.'`. `'.$resultIteratorClass.'` provided.')); |
|
| 1390 | 1390 | $bean = $this->findObject($mainTable, $filter, $parameters, $additionalTablesFetch, $className, $resultIteratorClass); |
| 1391 | 1391 | if ($bean === null) { |
| 1392 | 1392 | throw NoBeanFoundException::missFilterRecord($mainTable); |
@@ -1496,7 +1496,7 @@ discard block |
||
| 1496 | 1496 | $table1 = $fks[0]->getForeignTableName(); |
| 1497 | 1497 | $table2 = $fks[1]->getForeignTableName(); |
| 1498 | 1498 | |
| 1499 | - $beanTables = array_map(function (DbRow $dbRow) { |
|
| 1499 | + $beanTables = array_map(function(DbRow $dbRow) { |
|
| 1500 | 1500 | return $dbRow->_getDbTableName(); |
| 1501 | 1501 | }, $bean->_getDbRows()); |
| 1502 | 1502 | |