@@ -212,12 +212,12 @@ |
||
212 | 212 | return [static::DATA => $data->getData()]; |
213 | 213 | } |
214 | 214 | |
215 | - $buildUrl = function ($offset) use ($data, $uri) { |
|
215 | + $buildUrl = function($offset) use ($data, $uri) { |
|
216 | 216 | $paramsWithPaging = [ |
217 | 217 | PaginationStrategyInterface::PARAM_PAGING_OFFSET => $offset, |
218 | 218 | PaginationStrategyInterface::PARAM_PAGING_LIMIT => $data->getLimit(), |
219 | 219 | ]; |
220 | - $fullUrl = $uri . '?' . http_build_query($paramsWithPaging); |
|
220 | + $fullUrl = $uri.'?'.http_build_query($paramsWithPaging); |
|
221 | 221 | |
222 | 222 | return $fullUrl; |
223 | 223 | }; |
@@ -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."); |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | $classAtPath = new ArrayObject(); |
688 | 688 | $idsAtPath = new ArrayObject(); |
689 | 689 | |
690 | - $registerModelAtRoot = function ($model) use ($modelStorage, $modelsAtPath, $idsAtPath): void { |
|
690 | + $registerModelAtRoot = function($model) use ($modelStorage, $modelsAtPath, $idsAtPath): void { |
|
691 | 691 | self::registerModelAtPath( |
692 | 692 | $model, |
693 | 693 | static::ROOT_PATH, |
@@ -775,7 +775,7 @@ discard block |
||
775 | 775 | assert(is_string($pathPiece)); |
776 | 776 | $parent = $tmpPath; |
777 | 777 | $tmpPath = empty($tmpPath) === true ? |
778 | - $pathPiece : $tmpPath . static::PATH_SEPARATOR . $pathPiece; |
|
778 | + $pathPiece : $tmpPath.static::PATH_SEPARATOR.$pathPiece; |
|
779 | 779 | $normalizedPaths[$tmpPath] = [$parent, $pathPiece]; |
780 | 780 | $pathsDepths[$parent] = $parentDepth++; |
781 | 781 | } |
@@ -930,7 +930,7 @@ discard block |
||
930 | 930 | $countBuilder = $this->getConnection()->createQueryBuilder(); |
931 | 931 | $countBuilder->setParameters($builder->getParameters()); |
932 | 932 | |
933 | - $countBuilder->select('COUNT(*)')->from('(' . $builder->getSQL() . ') AS RESULT'); |
|
933 | + $countBuilder->select('COUNT(*)')->from('('.$builder->getSQL().') AS RESULT'); |
|
934 | 934 | |
935 | 935 | $builder = $countBuilder; |
936 | 936 | } |
@@ -960,7 +960,7 @@ discard block |
||
960 | 960 | ): ModelQueryBuilder { |
961 | 961 | assert( |
962 | 962 | $this->getModelSchemes()->hasRelationship($this->getModelClass(), $relationshipName), |
963 | - "Relationship `$relationshipName` do not exist in model `" . $this->getModelClass() . '`' |
|
963 | + "Relationship `$relationshipName` do not exist in model `".$this->getModelClass().'`' |
|
964 | 964 | ); |
965 | 965 | |
966 | 966 | // as we read data from a relationship our main table and model would be the table/model in the relationship |
@@ -979,8 +979,7 @@ discard block |
||
979 | 979 | $filters = $this->getFilters(); |
980 | 980 | $sorts = $this->getSorts(); |
981 | 981 | $this->areFiltersWithAnd() ? |
982 | - $builder->addRelationshipFiltersAndSortsWithAnd($reverseRelName, $filters, $sorts) : |
|
983 | - $builder->addRelationshipFiltersAndSortsWithOr($reverseRelName, $filters, $sorts); |
|
982 | + $builder->addRelationshipFiltersAndSortsWithAnd($reverseRelName, $filters, $sorts) : $builder->addRelationshipFiltersAndSortsWithOr($reverseRelName, $filters, $sorts); |
|
984 | 983 | } |
985 | 984 | // ... and the input filters to actual data we select |
986 | 985 | if ($relationshipFilters !== null) { |
@@ -1008,7 +1007,7 @@ discard block |
||
1008 | 1007 | ) { |
1009 | 1008 | assert( |
1010 | 1009 | $this->getModelSchemes()->hasRelationship($this->getModelClass(), $name), |
1011 | - "Relationship `$name` do not exist in model `" . $this->getModelClass() . '`' |
|
1010 | + "Relationship `$name` do not exist in model `".$this->getModelClass().'`' |
|
1012 | 1011 | ); |
1013 | 1012 | |
1014 | 1013 | // depending on the relationship type we expect the result to be either single resource or a collection |
@@ -1035,7 +1034,7 @@ discard block |
||
1035 | 1034 | ): array { |
1036 | 1035 | assert( |
1037 | 1036 | $this->getModelSchemes()->hasRelationship($this->getModelClass(), $name), |
1038 | - "Relationship `$name` do not exist in model `" . $this->getModelClass() . '`' |
|
1037 | + "Relationship `$name` do not exist in model `".$this->getModelClass().'`' |
|
1039 | 1038 | ); |
1040 | 1039 | |
1041 | 1040 | // depending on the relationship type we expect the result to be either single resource or a collection |
@@ -1109,7 +1108,7 @@ discard block |
||
1109 | 1108 | |
1110 | 1109 | $this->clearFetchParameters(); |
1111 | 1110 | |
1112 | - return (int)$deleted; |
|
1111 | + return (int) $deleted; |
|
1113 | 1112 | } |
1114 | 1113 | |
1115 | 1114 | /** |
@@ -1123,7 +1122,7 @@ discard block |
||
1123 | 1122 | |
1124 | 1123 | $this->clearFetchParameters(); |
1125 | 1124 | |
1126 | - return (int)$deleted > 0; |
|
1125 | + return (int) $deleted > 0; |
|
1127 | 1126 | } |
1128 | 1127 | |
1129 | 1128 | /** |
@@ -1144,7 +1143,7 @@ discard block |
||
1144 | 1143 | |
1145 | 1144 | $this->clearBuilderParameters()->clearFetchParameters(); |
1146 | 1145 | |
1147 | - $this->inTransaction(function () use ($saveMain, $toMany, &$index) { |
|
1146 | + $this->inTransaction(function() use ($saveMain, $toMany, &$index) { |
|
1148 | 1147 | $saveMain->execute(); |
1149 | 1148 | |
1150 | 1149 | // if no index given will use last insert ID as index |
@@ -1160,7 +1159,7 @@ discard block |
||
1160 | 1159 | ->prepareCreateInToManyRelationship($relationshipName, $index, $secondaryIdBindName) |
1161 | 1160 | ); |
1162 | 1161 | foreach ($secondaryIds as $secondaryId) { |
1163 | - $inserted += (int)$saveToMany->setParameter($secondaryIdBindName, $secondaryId)->execute(); |
|
1162 | + $inserted += (int) $saveToMany->setParameter($secondaryIdBindName, $secondaryId)->execute(); |
|
1164 | 1163 | } |
1165 | 1164 | } |
1166 | 1165 | }); |
@@ -1189,12 +1188,12 @@ discard block |
||
1189 | 1188 | ->createBuilder($this->getModelClass()) |
1190 | 1189 | ->updateModels($allowedChanges) |
1191 | 1190 | ->addFiltersWithAndToTable($filters); |
1192 | - $saveMain = $this->builderSaveResourceOnUpdate($saveMain); |
|
1191 | + $saveMain = $this->builderSaveResourceOnUpdate($saveMain); |
|
1193 | 1192 | $saveMain->getSQL(); // prepare |
1194 | 1193 | |
1195 | 1194 | $this->clearBuilderParameters()->clearFetchParameters(); |
1196 | 1195 | |
1197 | - $this->inTransaction(function () use ($saveMain, $toMany, $index, &$updated) { |
|
1196 | + $this->inTransaction(function() use ($saveMain, $toMany, $index, &$updated) { |
|
1198 | 1197 | $updated = $saveMain->execute(); |
1199 | 1198 | |
1200 | 1199 | foreach ($toMany as $relationshipName => $secondaryIds) { |
@@ -1214,12 +1213,12 @@ discard block |
||
1214 | 1213 | ->prepareCreateInToManyRelationship($relationshipName, $index, $secondaryIdBindName) |
1215 | 1214 | ); |
1216 | 1215 | foreach ($secondaryIds as $secondaryId) { |
1217 | - $updated += (int)$saveToMany->setParameter($secondaryIdBindName, $secondaryId)->execute(); |
|
1216 | + $updated += (int) $saveToMany->setParameter($secondaryIdBindName, $secondaryId)->execute(); |
|
1218 | 1217 | } |
1219 | 1218 | } |
1220 | 1219 | }); |
1221 | 1220 | |
1222 | - return (int)$updated; |
|
1221 | + return (int) $updated; |
|
1223 | 1222 | } |
1224 | 1223 | |
1225 | 1224 | /** |
@@ -1555,7 +1554,7 @@ discard block |
||
1555 | 1554 | |
1556 | 1555 | $pkName = $this->getModelSchemes()->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->getModelSchemes()->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 | ); |
@@ -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 | */ |
@@ -75,7 +75,7 @@ |
||
75 | 75 | 0, |
76 | 76 | PHP_INT_MAX |
77 | 77 | ); |
78 | - $size = $this->getValue( |
|
78 | + $size = $this->getValue( |
|
79 | 79 | $parameters, |
80 | 80 | static::PARAM_PAGING_LIMIT, |
81 | 81 | $this->getDefaultPageSize(), |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | |
126 | 126 | parse_str($this->getOriginalUri()->getQuery(), $queryParams); |
127 | 127 | |
128 | - return function ($offset) use ($pageSize, $queryParams) { |
|
128 | + return function($offset) use ($pageSize, $queryParams) { |
|
129 | 129 | $paramsWithPaging = array_merge($queryParams, [ |
130 | 130 | BaseQueryParserInterface::PARAM_PAGE => [ |
131 | 131 | PaginationStrategyInterface::PARAM_PAGING_OFFSET => $offset, |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | ], |
134 | 134 | ]); |
135 | 135 | $newUri = $this->getOriginalUri()->withQuery(http_build_query($paramsWithPaging)); |
136 | - $fullUrl = (string)$newUri; |
|
136 | + $fullUrl = (string) $newUri; |
|
137 | 137 | $link = $this->getFactory()->createLink($fullUrl, null, true); |
138 | 138 | |
139 | 139 | return $link; |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | ContainerInterface $container, |
184 | 184 | ServerRequestInterface $request |
185 | 185 | ): ResponseInterface { |
186 | - $apiHandler = function (CrudInterface $crud) use ($index, $relationshipName) { |
|
186 | + $apiHandler = function(CrudInterface $crud) use ($index, $relationshipName) { |
|
187 | 187 | return $crud->readRelationship($index, $relationshipName); |
188 | 188 | }; |
189 | 189 | |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | ContainerInterface $container, |
208 | 208 | ServerRequestInterface $request |
209 | 209 | ): ResponseInterface { |
210 | - $apiHandler = function (CrudInterface $crud) use ($index, $relationshipName) { |
|
210 | + $apiHandler = function(CrudInterface $crud) use ($index, $relationshipName) { |
|
211 | 211 | return $crud->readRelationship($index, $relationshipName); |
212 | 212 | }; |
213 | 213 | |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | */ |
312 | 312 | protected static function readJsonFromRequest(ContainerInterface $container, ServerRequestInterface $request): array |
313 | 313 | { |
314 | - $body = (string)$request->getBody(); |
|
314 | + $body = (string) $request->getBody(); |
|
315 | 315 | if (empty($body) === true || ($json = json_decode($body, true)) === null) { |
316 | 316 | /** @var FactoryInterface $factory */ |
317 | 317 | $factory = $container->get(FactoryInterface::class); |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | { |
465 | 465 | assert( |
466 | 466 | empty(static::ON_CREATE_VALIDATION_RULES_SET_CLASS) === false, |
467 | - 'Validation rules set should be defined for class ' . static::class . '.' |
|
467 | + 'Validation rules set should be defined for class '.static::class.'.' |
|
468 | 468 | ); |
469 | 469 | |
470 | 470 | return static::createJsonApiValidator($container, static::ON_CREATE_VALIDATION_RULES_SET_CLASS); |
@@ -482,7 +482,7 @@ discard block |
||
482 | 482 | { |
483 | 483 | assert( |
484 | 484 | empty(static::ON_UPDATE_VALIDATION_RULES_SET_CLASS) === false, |
485 | - 'Validation rules set should be defined for class ' . static::class . '.' |
|
485 | + 'Validation rules set should be defined for class '.static::class.'.' |
|
486 | 486 | ); |
487 | 487 | |
488 | 488 | return static::createJsonApiValidator($container, static::ON_UPDATE_VALIDATION_RULES_SET_CLASS); |
@@ -683,7 +683,7 @@ discard block |
||
683 | 683 | ContainerInterface $container, |
684 | 684 | ServerRequestInterface $request |
685 | 685 | ): array { |
686 | - $jsonData = static::normalizeIndexValueOnUpdate( |
|
686 | + $jsonData = static::normalizeIndexValueOnUpdate( |
|
687 | 687 | $routeParams, |
688 | 688 | $container, |
689 | 689 | static::readJsonFromRequest($container, $request) |
@@ -86,10 +86,10 @@ |
||
86 | 86 | ); |
87 | 87 | assert(empty($queryValFileMask) === false, "Invalid Query Validators file mask `$queryValFileMask`."); |
88 | 88 | |
89 | - $schemesPath = $schemesFolder . DIRECTORY_SEPARATOR . $schemesFileMask; |
|
90 | - $jsonValidatorsPath = $jsonValFolder . DIRECTORY_SEPARATOR . $jsonValFileMask; |
|
91 | - $formsValidatorsPath = $formsValFolder . DIRECTORY_SEPARATOR . $formsValFileMask; |
|
92 | - $queryValidatorsPath = $queryValFolder . DIRECTORY_SEPARATOR . $queryValFileMask; |
|
89 | + $schemesPath = $schemesFolder.DIRECTORY_SEPARATOR.$schemesFileMask; |
|
90 | + $jsonValidatorsPath = $jsonValFolder.DIRECTORY_SEPARATOR.$jsonValFileMask; |
|
91 | + $formsValidatorsPath = $formsValFolder.DIRECTORY_SEPARATOR.$formsValFileMask; |
|
92 | + $queryValidatorsPath = $queryValFolder.DIRECTORY_SEPARATOR.$queryValFileMask; |
|
93 | 93 | |
94 | 94 | $requireUniqueTypes = $defaults[static::KEY_SCHEMAS_REQUIRE_UNIQUE_TYPES] ?? true; |
95 | 95 |