@@ -99,7 +99,7 @@ |
||
| 99 | 99 | $details = null; |
| 100 | 100 | if ($this->isDebug === true) { |
| 101 | 101 | $message = $throwable->getMessage(); |
| 102 | - $details = (string)$throwable; |
|
| 102 | + $details = (string) $throwable; |
|
| 103 | 103 | } |
| 104 | 104 | $errors->add(new Error(null, null, $httpCode, null, $message, $details)); |
| 105 | 105 | } |
@@ -52,17 +52,17 @@ |
||
| 52 | 52 | public function withIncludes(iterable $includes): self; |
| 53 | 53 | |
| 54 | 54 | /** |
| 55 | - * @return iterable |
|
| 55 | + * @return \Generator |
|
| 56 | 56 | */ |
| 57 | 57 | public function getMappedFilters(): iterable; |
| 58 | 58 | |
| 59 | 59 | /** |
| 60 | - * @return iterable |
|
| 60 | + * @return \Generator |
|
| 61 | 61 | */ |
| 62 | 62 | public function getMappedSorts(): iterable; |
| 63 | 63 | |
| 64 | 64 | /** |
| 65 | - * @return iterable |
|
| 65 | + * @return \Generator |
|
| 66 | 66 | */ |
| 67 | 67 | public function getMappedIncludes(): iterable; |
| 68 | 68 | |
@@ -105,8 +105,7 @@ |
||
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | $reply = $count > 0 ? |
| 108 | - BlockReplies::createSuccessReply($values) : |
|
| 109 | - BlockReplies::createErrorReply($context, $values, ErrorCodes::EXIST_IN_DATABASE_MULTIPLE); |
|
| 108 | + BlockReplies::createSuccessReply($values) : BlockReplies::createErrorReply($context, $values, ErrorCodes::EXIST_IN_DATABASE_MULTIPLE); |
|
| 110 | 109 | |
| 111 | 110 | return $reply; |
| 112 | 111 | } |
@@ -86,8 +86,7 @@ |
||
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | $reply = $foundInvalidType === null ? |
| 89 | - BlockReplies::createSuccessReply($indexes) : |
|
| 90 | - BlockReplies::createErrorReply($context, $foundInvalidType, ErrorCodes::INVALID_RELATIONSHIP_TYPE); |
|
| 89 | + BlockReplies::createSuccessReply($indexes) : BlockReplies::createErrorReply($context, $foundInvalidType, ErrorCodes::INVALID_RELATIONSHIP_TYPE); |
|
| 91 | 90 | |
| 92 | 91 | return $reply; |
| 93 | 92 | } |
@@ -77,8 +77,7 @@ |
||
| 77 | 77 | assert(is_scalar($index) === true && is_scalar($type) === true); |
| 78 | 78 | $expectedType = $context->getProperties()->getProperty(self::PROPERTY_RESOURCE_TYPE); |
| 79 | 79 | $reply = $type === $expectedType ? |
| 80 | - BlockReplies::createSuccessReply($index) : |
|
| 81 | - BlockReplies::createErrorReply($context, $type, ErrorCodes::INVALID_RELATIONSHIP_TYPE); |
|
| 80 | + BlockReplies::createSuccessReply($index) : BlockReplies::createErrorReply($context, $type, ErrorCodes::INVALID_RELATIONSHIP_TYPE); |
|
| 82 | 81 | |
| 83 | 82 | return $reply; |
| 84 | 83 | } |
@@ -101,8 +101,7 @@ |
||
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | $reply = $count <= 0 ? |
| 104 | - BlockReplies::createSuccessReply($value) : |
|
| 105 | - BlockReplies::createErrorReply($context, $value, ErrorCodes::UNIQUE_IN_DATABASE_SINGLE); |
|
| 104 | + BlockReplies::createSuccessReply($value) : BlockReplies::createErrorReply($context, $value, ErrorCodes::UNIQUE_IN_DATABASE_SINGLE); |
|
| 106 | 105 | |
| 107 | 106 | return $reply; |
| 108 | 107 | } |
@@ -101,8 +101,7 @@ |
||
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | $reply = $count > 0 ? |
| 104 | - BlockReplies::createSuccessReply($value) : |
|
| 105 | - BlockReplies::createErrorReply($context, $value, ErrorCodes::EXIST_IN_DATABASE_SINGLE); |
|
| 104 | + BlockReplies::createSuccessReply($value) : BlockReplies::createErrorReply($context, $value, ErrorCodes::EXIST_IN_DATABASE_SINGLE); |
|
| 106 | 105 | |
| 107 | 106 | return $reply; |
| 108 | 107 | } |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | /** |
| 174 | - * @param iterable $attributes |
|
| 174 | + * @param \Generator $attributes |
|
| 175 | 175 | * |
| 176 | 176 | * @return self |
| 177 | 177 | * |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | /** |
| 196 | - * @param iterable $attributes |
|
| 196 | + * @param \Generator $attributes |
|
| 197 | 197 | * |
| 198 | 198 | * @return self |
| 199 | 199 | * |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | * @param string $modelClass |
| 217 | 217 | * @param iterable $attributes |
| 218 | 218 | * |
| 219 | - * @return iterable |
|
| 219 | + * @return \Generator |
|
| 220 | 220 | * |
| 221 | 221 | * @SuppressWarnings(PHPMD.StaticAccess) |
| 222 | 222 | * |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | /** |
| 318 | - * @param iterable $filters |
|
| 318 | + * @param \Limoncello\Flute\Api\iterable|null $filters |
|
| 319 | 319 | * |
| 320 | 320 | * @return self |
| 321 | 321 | * |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | /** |
| 334 | - * @param iterable $filters |
|
| 334 | + * @param \Limoncello\Flute\Api\iterable|null $filters |
|
| 335 | 335 | * |
| 336 | 336 | * @return self |
| 337 | 337 | * |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | /** |
| 350 | - * @param iterable $filters |
|
| 350 | + * @param \Limoncello\Flute\Api\iterable|null $filters |
|
| 351 | 351 | * |
| 352 | 352 | * @return self |
| 353 | 353 | * |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | |
| 392 | 392 | /** |
| 393 | 393 | * @param string $relationshipName |
| 394 | - * @param iterable $relationshipFilters |
|
| 394 | + * @param \Limoncello\Flute\Api\iterable|null $relationshipFilters |
|
| 395 | 395 | * @param iterable|null $relationshipSorts |
| 396 | 396 | * |
| 397 | 397 | * @return self |
@@ -417,7 +417,7 @@ discard block |
||
| 417 | 417 | } |
| 418 | 418 | |
| 419 | 419 | /** |
| 420 | - * @param iterable $sortParameters |
|
| 420 | + * @param \Limoncello\Flute\Api\iterable|null $sortParameters |
|
| 421 | 421 | * |
| 422 | 422 | * @return self |
| 423 | 423 | */ |
@@ -639,7 +639,7 @@ discard block |
||
| 639 | 639 | string $targetColumn |
| 640 | 640 | ): string { |
| 641 | 641 | $targetAlias = $this->createAlias($targetTable); |
| 642 | - $joinCondition = $this->buildColumnName($fromAlias, $fromColumn) . '=' . |
|
| 642 | + $joinCondition = $this->buildColumnName($fromAlias, $fromColumn).'='. |
|
| 643 | 643 | $this->buildColumnName($targetAlias, $targetColumn); |
| 644 | 644 | |
| 645 | 645 | $this->innerJoin( |
@@ -685,7 +685,7 @@ discard block |
||
| 685 | 685 | */ |
| 686 | 686 | private function createAlias(string $tableName): string |
| 687 | 687 | { |
| 688 | - $alias = $tableName . (++$this->aliasIdCounter); |
|
| 688 | + $alias = $tableName.(++$this->aliasIdCounter); |
|
| 689 | 689 | $this->knownAliases[$tableName] = $alias; |
| 690 | 690 | |
| 691 | 691 | return $alias; |
@@ -850,7 +850,7 @@ discard block |
||
| 850 | 850 | } else { |
| 851 | 851 | assert( |
| 852 | 852 | $value !== null, |
| 853 | - 'It seems you are trying to use `null` with =, >, <, or etc operator. ' . |
|
| 853 | + 'It seems you are trying to use `null` with =, >, <, or etc operator. '. |
|
| 854 | 854 | 'Use `is null` or `not null` instead.' |
| 855 | 855 | ); |
| 856 | 856 | assert(is_string($value), "Only strings, booleans and integers are supported."); |
@@ -756,9 +756,9 @@ discard block |
||
| 756 | 756 | } |
| 757 | 757 | |
| 758 | 758 | /** |
| 759 | - * @param iterable $paths (string[]) |
|
| 759 | + * @param iterable|null $paths (string[]) |
|
| 760 | 760 | * |
| 761 | - * @return iterable |
|
| 761 | + * @return Generator |
|
| 762 | 762 | */ |
| 763 | 763 | private static function getPaths(iterable $paths): iterable |
| 764 | 764 | { |
@@ -1399,7 +1399,7 @@ discard block |
||
| 1399 | 1399 | * @param string $modelClass |
| 1400 | 1400 | * @param string $keyColumnName |
| 1401 | 1401 | * |
| 1402 | - * @return iterable |
|
| 1402 | + * @return Generator |
|
| 1403 | 1403 | * |
| 1404 | 1404 | * @throws DBALException |
| 1405 | 1405 | * |
@@ -1503,7 +1503,7 @@ discard block |
||
| 1503 | 1503 | * @param null|string $index |
| 1504 | 1504 | * @param iterable $attributes |
| 1505 | 1505 | * |
| 1506 | - * @return iterable |
|
| 1506 | + * @return Generator |
|
| 1507 | 1507 | */ |
| 1508 | 1508 | protected function filterAttributesOnCreate(?string $index, iterable $attributes): iterable |
| 1509 | 1509 | { |
@@ -1523,7 +1523,7 @@ discard block |
||
| 1523 | 1523 | /** |
| 1524 | 1524 | * @param iterable $attributes |
| 1525 | 1525 | * |
| 1526 | - * @return iterable |
|
| 1526 | + * @return Generator |
|
| 1527 | 1527 | */ |
| 1528 | 1528 | protected function filterAttributesOnUpdate(iterable $attributes): iterable |
| 1529 | 1529 | { |
@@ -1722,10 +1722,10 @@ discard block |
||
| 1722 | 1722 | |
| 1723 | 1723 | /** |
| 1724 | 1724 | * @param iterable $attributes |
| 1725 | - * @param array $typeNames |
|
| 1725 | + * @param Type[] $typeNames |
|
| 1726 | 1726 | * @param AbstractPlatform $platform |
| 1727 | 1727 | * |
| 1728 | - * @return iterable |
|
| 1728 | + * @return Generator |
|
| 1729 | 1729 | * |
| 1730 | 1730 | * @throws DBALException |
| 1731 | 1731 | */ |
@@ -689,7 +689,7 @@ discard block |
||
| 689 | 689 | $classAtPath = new ArrayObject(); |
| 690 | 690 | $idsAtPath = new ArrayObject(); |
| 691 | 691 | |
| 692 | - $registerModelAtRoot = function ($model) use ($modelStorage, $modelsAtPath, $idsAtPath): void { |
|
| 692 | + $registerModelAtRoot = function($model) use ($modelStorage, $modelsAtPath, $idsAtPath): void { |
|
| 693 | 693 | self::registerModelAtPath( |
| 694 | 694 | $model, |
| 695 | 695 | static::ROOT_PATH, |
@@ -777,7 +777,7 @@ discard block |
||
| 777 | 777 | assert(is_string($pathPiece)); |
| 778 | 778 | $parent = $tmpPath; |
| 779 | 779 | $tmpPath = empty($tmpPath) === true ? |
| 780 | - $pathPiece : $tmpPath . static::PATH_SEPARATOR . $pathPiece; |
|
| 780 | + $pathPiece : $tmpPath.static::PATH_SEPARATOR.$pathPiece; |
|
| 781 | 781 | $normalizedPaths[$tmpPath] = [$parent, $pathPiece]; |
| 782 | 782 | $pathsDepths[$parent] = $parentDepth++; |
| 783 | 783 | } |
@@ -934,7 +934,7 @@ discard block |
||
| 934 | 934 | ): ModelQueryBuilder { |
| 935 | 935 | assert( |
| 936 | 936 | $this->getModelSchemas()->hasRelationship($this->getModelClass(), $relationshipName), |
| 937 | - "Relationship `$relationshipName` do not exist in model `" . $this->getModelClass() . '`' |
|
| 937 | + "Relationship `$relationshipName` do not exist in model `".$this->getModelClass().'`' |
|
| 938 | 938 | ); |
| 939 | 939 | |
| 940 | 940 | // as we read data from a relationship our main table and model would be the table/model in the relationship |
@@ -953,8 +953,7 @@ discard block |
||
| 953 | 953 | $filters = $this->getFilters(); |
| 954 | 954 | $sorts = $this->getSorts(); |
| 955 | 955 | $this->areFiltersWithAnd() ? |
| 956 | - $builder->addRelationshipFiltersAndSortsWithAnd($reverseRelName, $filters, $sorts) : |
|
| 957 | - $builder->addRelationshipFiltersAndSortsWithOr($reverseRelName, $filters, $sorts); |
|
| 956 | + $builder->addRelationshipFiltersAndSortsWithAnd($reverseRelName, $filters, $sorts) : $builder->addRelationshipFiltersAndSortsWithOr($reverseRelName, $filters, $sorts); |
|
| 958 | 957 | } |
| 959 | 958 | // ... and the input filters to actual data we select |
| 960 | 959 | if ($relationshipFilters !== null) { |
@@ -982,7 +981,7 @@ discard block |
||
| 982 | 981 | ) { |
| 983 | 982 | assert( |
| 984 | 983 | $this->getModelSchemas()->hasRelationship($this->getModelClass(), $name), |
| 985 | - "Relationship `$name` do not exist in model `" . $this->getModelClass() . '`' |
|
| 984 | + "Relationship `$name` do not exist in model `".$this->getModelClass().'`' |
|
| 986 | 985 | ); |
| 987 | 986 | |
| 988 | 987 | // depending on the relationship type we expect the result to be either single resource or a collection |
@@ -1009,7 +1008,7 @@ discard block |
||
| 1009 | 1008 | ): array { |
| 1010 | 1009 | assert( |
| 1011 | 1010 | $this->getModelSchemas()->hasRelationship($this->getModelClass(), $name), |
| 1012 | - "Relationship `$name` do not exist in model `" . $this->getModelClass() . '`' |
|
| 1011 | + "Relationship `$name` do not exist in model `".$this->getModelClass().'`' |
|
| 1013 | 1012 | ); |
| 1014 | 1013 | |
| 1015 | 1014 | // depending on the relationship type we expect the result to be either single resource or a collection |
@@ -1083,7 +1082,7 @@ discard block |
||
| 1083 | 1082 | |
| 1084 | 1083 | $this->clearFetchParameters(); |
| 1085 | 1084 | |
| 1086 | - return (int)$deleted; |
|
| 1085 | + return (int) $deleted; |
|
| 1087 | 1086 | } |
| 1088 | 1087 | |
| 1089 | 1088 | /** |
@@ -1097,7 +1096,7 @@ discard block |
||
| 1097 | 1096 | |
| 1098 | 1097 | $this->clearFetchParameters(); |
| 1099 | 1098 | |
| 1100 | - return (int)$deleted > 0; |
|
| 1099 | + return (int) $deleted > 0; |
|
| 1101 | 1100 | } |
| 1102 | 1101 | |
| 1103 | 1102 | /** |
@@ -1118,7 +1117,7 @@ discard block |
||
| 1118 | 1117 | |
| 1119 | 1118 | $this->clearBuilderParameters()->clearFetchParameters(); |
| 1120 | 1119 | |
| 1121 | - $this->inTransaction(function () use ($saveMain, $toMany, &$index) { |
|
| 1120 | + $this->inTransaction(function() use ($saveMain, $toMany, &$index) { |
|
| 1122 | 1121 | $saveMain->execute(); |
| 1123 | 1122 | |
| 1124 | 1123 | // if no index given will use last insert ID as index |
@@ -1134,7 +1133,7 @@ discard block |
||
| 1134 | 1133 | ->prepareCreateInToManyRelationship($relationshipName, $index, $secondaryIdBindName) |
| 1135 | 1134 | ); |
| 1136 | 1135 | foreach ($secondaryIds as $secondaryId) { |
| 1137 | - $inserted += (int)$saveToMany->setParameter($secondaryIdBindName, $secondaryId)->execute(); |
|
| 1136 | + $inserted += (int) $saveToMany->setParameter($secondaryIdBindName, $secondaryId)->execute(); |
|
| 1138 | 1137 | } |
| 1139 | 1138 | } |
| 1140 | 1139 | }); |
@@ -1163,12 +1162,12 @@ discard block |
||
| 1163 | 1162 | ->createBuilder($this->getModelClass()) |
| 1164 | 1163 | ->updateModels($allowedChanges) |
| 1165 | 1164 | ->addFiltersWithAndToTable($filters); |
| 1166 | - $saveMain = $this->builderSaveResourceOnUpdate($saveMain); |
|
| 1165 | + $saveMain = $this->builderSaveResourceOnUpdate($saveMain); |
|
| 1167 | 1166 | $saveMain->getSQL(); // prepare |
| 1168 | 1167 | |
| 1169 | 1168 | $this->clearBuilderParameters()->clearFetchParameters(); |
| 1170 | 1169 | |
| 1171 | - $this->inTransaction(function () use ($saveMain, $toMany, $index, &$updated) { |
|
| 1170 | + $this->inTransaction(function() use ($saveMain, $toMany, $index, &$updated) { |
|
| 1172 | 1171 | $updated = $saveMain->execute(); |
| 1173 | 1172 | |
| 1174 | 1173 | foreach ($toMany as $relationshipName => $secondaryIds) { |
@@ -1188,12 +1187,12 @@ discard block |
||
| 1188 | 1187 | ->prepareCreateInToManyRelationship($relationshipName, $index, $secondaryIdBindName) |
| 1189 | 1188 | ); |
| 1190 | 1189 | foreach ($secondaryIds as $secondaryId) { |
| 1191 | - $updated += (int)$saveToMany->setParameter($secondaryIdBindName, $secondaryId)->execute(); |
|
| 1190 | + $updated += (int) $saveToMany->setParameter($secondaryIdBindName, $secondaryId)->execute(); |
|
| 1192 | 1191 | } |
| 1193 | 1192 | } |
| 1194 | 1193 | }); |
| 1195 | 1194 | |
| 1196 | - return (int)$updated; |
|
| 1195 | + return (int) $updated; |
|
| 1197 | 1196 | } |
| 1198 | 1197 | |
| 1199 | 1198 | /** |
@@ -1344,7 +1343,7 @@ discard block |
||
| 1344 | 1343 | { |
| 1345 | 1344 | $countBuilder = $this->createBuilder($this->getModelClass()); |
| 1346 | 1345 | $countBuilder->setParameters($builder->getParameters()); |
| 1347 | - $countBuilder->select('COUNT(*)')->from('(' . $builder->getSQL() . ') AS RESULT'); |
|
| 1346 | + $countBuilder->select('COUNT(*)')->from('('.$builder->getSQL().') AS RESULT'); |
|
| 1348 | 1347 | |
| 1349 | 1348 | return $countBuilder; |
| 1350 | 1349 | } |
@@ -1555,7 +1554,7 @@ discard block |
||
| 1555 | 1554 | |
| 1556 | 1555 | $pkName = $this->getModelSchemas()->getPrimaryKey($parentClass); |
| 1557 | 1556 | |
| 1558 | - $registerModelAtPath = function ($model, string $path) use ($deDup, $modelsAtPath, $idsAtPath) { |
|
| 1557 | + $registerModelAtPath = function($model, string $path) use ($deDup, $modelsAtPath, $idsAtPath) { |
|
| 1559 | 1558 | return self::registerModelAtPath( |
| 1560 | 1559 | $model, |
| 1561 | 1560 | $path, |
@@ -1567,7 +1566,7 @@ discard block |
||
| 1567 | 1566 | }; |
| 1568 | 1567 | |
| 1569 | 1568 | foreach ($childRelationships as $name) { |
| 1570 | - $childrenPath = $parentsPath !== static::ROOT_PATH ? $parentsPath . static::PATH_SEPARATOR . $name : $name; |
|
| 1569 | + $childrenPath = $parentsPath !== static::ROOT_PATH ? $parentsPath.static::PATH_SEPARATOR.$name : $name; |
|
| 1571 | 1570 | |
| 1572 | 1571 | $relationshipType = $this->getModelSchemas()->getRelationshipType($parentClass, $name); |
| 1573 | 1572 | list ($targetModelClass, $reverseRelName) = |
@@ -1617,7 +1616,7 @@ discard block |
||
| 1617 | 1616 | [$pkName => [FilterParameterInterface::OPERATION_EQUALS => [$parent->{$pkName}]]], |
| 1618 | 1617 | [] |
| 1619 | 1618 | ); |
| 1620 | - $children = $this->fetchPaginatedResourcesWithoutRelationships( |
|
| 1619 | + $children = $this->fetchPaginatedResourcesWithoutRelationships( |
|
| 1621 | 1620 | $clonedBuilder, |
| 1622 | 1621 | $clonedBuilder->getModelClass() |
| 1623 | 1622 | ); |