@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
131 | - * @param iterable $attributes |
|
131 | + * @param Generator $attributes |
|
132 | 132 | * |
133 | 133 | * @return self |
134 | 134 | * |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
151 | - * @param iterable $attributes |
|
151 | + * @param Generator $attributes |
|
152 | 152 | * |
153 | 153 | * @return self |
154 | 154 | * |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | * @param string $modelClass |
170 | 170 | * @param iterable $attributes |
171 | 171 | * |
172 | - * @return iterable |
|
172 | + * @return Generator |
|
173 | 173 | * |
174 | 174 | * @SuppressWarnings(PHPMD.StaticAccess) |
175 | 175 | */ |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | } |
250 | 250 | |
251 | 251 | /** |
252 | - * @param iterable $filters |
|
252 | + * @param \Limoncello\Flute\Api\iterable|null $filters |
|
253 | 253 | * |
254 | 254 | * @return self |
255 | 255 | */ |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | } |
260 | 260 | |
261 | 261 | /** |
262 | - * @param iterable $filters |
|
262 | + * @param \Limoncello\Flute\Api\iterable|null $filters |
|
263 | 263 | * |
264 | 264 | * @return self |
265 | 265 | */ |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | } |
270 | 270 | |
271 | 271 | /** |
272 | - * @param iterable $filters |
|
272 | + * @param \Limoncello\Flute\Api\iterable|null $filters |
|
273 | 273 | * |
274 | 274 | * @return self |
275 | 275 | */ |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | |
315 | 315 | /** |
316 | 316 | * @param string $relationshipName |
317 | - * @param iterable $relationshipFilters |
|
317 | + * @param \Limoncello\Flute\Api\iterable|null $relationshipFilters |
|
318 | 318 | * @param iterable|null $relationshipSorts |
319 | 319 | * |
320 | 320 | * @return self |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | } |
336 | 336 | |
337 | 337 | /** |
338 | - * @param iterable $sortParameters |
|
338 | + * @param \Limoncello\Flute\Api\iterable|null $sortParameters |
|
339 | 339 | * |
340 | 340 | * @return self |
341 | 341 | */ |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | string $relationshipName, |
290 | 290 | iterable $relationshipFilters, |
291 | 291 | ?iterable $relationshipSorts |
292 | - ): self { |
|
292 | + ) : self { |
|
293 | 293 | $joinWith = $this->expr()->andX(); |
294 | 294 | |
295 | 295 | return $this->addRelationshipFiltersAndSorts( |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | string $relationshipName, |
324 | 324 | iterable $relationshipFilters, |
325 | 325 | ?iterable $relationshipSorts |
326 | - ): self { |
|
326 | + ) : self { |
|
327 | 327 | $joinWith = $this->expr()->orX(); |
328 | 328 | |
329 | 329 | return $this->addRelationshipFiltersAndSorts( |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | CompositeExpression $filterLink, |
387 | 387 | iterable $relationshipFilters, |
388 | 388 | ?iterable $relationshipSorts |
389 | - ): self { |
|
389 | + ) : self { |
|
390 | 390 | $relationshipType = $this->getModelSchemes()->getRelationshipType($this->getModelClass(), $relationshipName); |
391 | 391 | switch ($relationshipType) { |
392 | 392 | case RelationshipTypes::BELONGS_TO: |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | CompositeExpression $filterLink, |
460 | 460 | iterable $relationshipFilters, |
461 | 461 | ?iterable $relationshipSorts |
462 | - ): self { |
|
462 | + ) : self { |
|
463 | 463 | $foreignKey = $this->getModelSchemes()->getForeignKey($this->getModelClass(), $relationshipName); |
464 | 464 | list($onePrimaryKey, $oneTable) = |
465 | 465 | $this->getModelSchemes()->getReversePrimaryKey($this->getModelClass(), $relationshipName); |
@@ -491,7 +491,7 @@ discard block |
||
491 | 491 | CompositeExpression $filterLink, |
492 | 492 | iterable $relationshipFilters, |
493 | 493 | ?iterable $relationshipSorts |
494 | - ): self { |
|
494 | + ) : self { |
|
495 | 495 | $primaryKey = $this->getModelSchemes()->getPrimaryKey($this->getModelClass()); |
496 | 496 | list($manyForeignKey, $manyTable) = |
497 | 497 | $this->getModelSchemes()->getReverseForeignKey($this->getModelClass(), $relationshipName); |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | CompositeExpression $targetFilterLink, |
524 | 524 | iterable $relationshipFilters, |
525 | 525 | ?iterable $relationshipSorts |
526 | - ): self { |
|
526 | + ) : self { |
|
527 | 527 | $primaryKey = $this->getModelSchemes()->getPrimaryKey($this->getModelClass()); |
528 | 528 | list ($intermediateTable, $intermediatePk, $intermediateFk) = |
529 | 529 | $this->getModelSchemes()->getBelongsToManyRelationship($this->getModelClass(), $relationshipName); |
@@ -571,9 +571,9 @@ discard block |
||
571 | 571 | ?CompositeExpression $targetFilterLink, |
572 | 572 | ?iterable $targetFilterParams, |
573 | 573 | ?iterable $relationshipSorts |
574 | - ): string { |
|
574 | + ) : string { |
|
575 | 575 | $targetAlias = $this->createAlias($targetTable); |
576 | - $joinCondition = $this->buildColumnName($fromAlias, $fromColumn) . '=' . |
|
576 | + $joinCondition = $this->buildColumnName($fromAlias, $fromColumn).'='. |
|
577 | 577 | $this->buildColumnName($targetAlias, $targetColumn); |
578 | 578 | |
579 | 579 | $this->innerJoin( |
@@ -632,7 +632,7 @@ discard block |
||
632 | 632 | ?CompositeExpression $targetFilterLink, |
633 | 633 | ?iterable $targetFilterParams, |
634 | 634 | ?iterable $targetSortParams |
635 | - ): string { |
|
635 | + ) : string { |
|
636 | 636 | $intNoSorting = null; |
637 | 637 | $intAlias = $this->innerJoinOneTable( |
638 | 638 | $fromAlias, |
@@ -643,7 +643,7 @@ discard block |
||
643 | 643 | $intFilterParams, |
644 | 644 | $intNoSorting |
645 | 645 | ); |
646 | - $targetAlias = $this->innerJoinOneTable( |
|
646 | + $targetAlias = $this->innerJoinOneTable( |
|
647 | 647 | $intAlias, |
648 | 648 | $intToTargetColumn, |
649 | 649 | $targetTable, |
@@ -663,7 +663,7 @@ discard block |
||
663 | 663 | */ |
664 | 664 | private function createAlias(string $tableName): string |
665 | 665 | { |
666 | - $alias = $tableName . (++$this->aliasIdCounter); |
|
666 | + $alias = $tableName.(++$this->aliasIdCounter); |
|
667 | 667 | $this->knownAliases[$tableName] = $alias; |
668 | 668 | |
669 | 669 | return $alias; |
@@ -827,7 +827,7 @@ discard block |
||
827 | 827 | } else { |
828 | 828 | assert( |
829 | 829 | $value !== null, |
830 | - 'It seems you are trying to use `null` with =, >, <, or etc operator. ' . |
|
830 | + 'It seems you are trying to use `null` with =, >, <, or etc operator. '. |
|
831 | 831 | 'Use `is null` or `not null` instead.' |
832 | 832 | ); |
833 | 833 | assert(is_string($value), "Only strings, booleans and integers are supported."); |
@@ -616,9 +616,9 @@ discard block |
||
616 | 616 | } |
617 | 617 | |
618 | 618 | /** |
619 | - * @param iterable $paths (string[]) |
|
619 | + * @param iterable|null $paths (string[]) |
|
620 | 620 | * |
621 | - * @return iterable |
|
621 | + * @return Generator |
|
622 | 622 | */ |
623 | 623 | private static function getPaths(iterable $paths): iterable |
624 | 624 | { |
@@ -1230,7 +1230,7 @@ discard block |
||
1230 | 1230 | * @param null|string $index |
1231 | 1231 | * @param iterable $attributes |
1232 | 1232 | * |
1233 | - * @return iterable |
|
1233 | + * @return Generator |
|
1234 | 1234 | */ |
1235 | 1235 | protected function filterAttributesOnCreate(?string $index, iterable $attributes): iterable |
1236 | 1236 | { |
@@ -1250,7 +1250,7 @@ discard block |
||
1250 | 1250 | /** |
1251 | 1251 | * @param iterable $attributes |
1252 | 1252 | * |
1253 | - * @return iterable |
|
1253 | + * @return Generator |
|
1254 | 1254 | */ |
1255 | 1255 | protected function filterAttributesOnUpdate(iterable $attributes): iterable |
1256 | 1256 | { |
@@ -1422,10 +1422,10 @@ discard block |
||
1422 | 1422 | |
1423 | 1423 | /** |
1424 | 1424 | * @param iterable $attributes |
1425 | - * @param array $typeNames |
|
1425 | + * @param Type[] $typeNames |
|
1426 | 1426 | * @param AbstractPlatform $platform |
1427 | 1427 | * |
1428 | - * @return iterable |
|
1428 | + * @return Generator |
|
1429 | 1429 | */ |
1430 | 1430 | private function readTypedAttributes(iterable $attributes, array $typeNames, AbstractPlatform $platform): iterable |
1431 | 1431 | { |
@@ -636,7 +636,7 @@ discard block |
||
636 | 636 | assert(is_string($pathPiece)); |
637 | 637 | $parent = $tmpPath; |
638 | 638 | $tmpPath = empty($tmpPath) === true ? |
639 | - $pathPiece : $tmpPath . static::PATH_SEPARATOR . $pathPiece; |
|
639 | + $pathPiece : $tmpPath.static::PATH_SEPARATOR.$pathPiece; |
|
640 | 640 | $normalizedPaths[$tmpPath] = [$parent, $pathPiece]; |
641 | 641 | $pathsDepths[$parent] = $parentDepth++; |
642 | 642 | } |
@@ -804,8 +804,7 @@ discard block |
||
804 | 804 | $filters = $this->getFilters(); |
805 | 805 | $sorts = $this->getSorts(); |
806 | 806 | $this->areFiltersWithAnd() ? |
807 | - $builder->addRelationshipFiltersAndSortsWithAnd($reverseRelName, $filters, $sorts) : |
|
808 | - $builder->addRelationshipFiltersAndSortsWithOr($reverseRelName, $filters, $sorts); |
|
807 | + $builder->addRelationshipFiltersAndSortsWithAnd($reverseRelName, $filters, $sorts) : $builder->addRelationshipFiltersAndSortsWithOr($reverseRelName, $filters, $sorts); |
|
809 | 808 | } |
810 | 809 | // ... and the input filters to actual data we select |
811 | 810 | if ($relationshipFilters !== null) { |
@@ -924,7 +923,7 @@ discard block |
||
924 | 923 | |
925 | 924 | $this->clearFetchParameters(); |
926 | 925 | |
927 | - return (int)$deleted; |
|
926 | + return (int) $deleted; |
|
928 | 927 | } |
929 | 928 | |
930 | 929 | /** |
@@ -953,7 +952,7 @@ discard block |
||
953 | 952 | |
954 | 953 | $this->clearBuilderParameters()->clearFetchParameters(); |
955 | 954 | |
956 | - $this->inTransaction(function () use ($saveMain, $toMany, &$index) { |
|
955 | + $this->inTransaction(function() use ($saveMain, $toMany, &$index) { |
|
957 | 956 | $saveMain->execute(); |
958 | 957 | |
959 | 958 | // if no index given will use last insert ID as index |
@@ -969,7 +968,7 @@ discard block |
||
969 | 968 | ->prepareCreateInToManyRelationship($relationshipName, $index, $secondaryIdBindName) |
970 | 969 | ); |
971 | 970 | foreach ($secondaryIds as $secondaryId) { |
972 | - $inserted += (int)$saveToMany->setParameter($secondaryIdBindName, $secondaryId)->execute(); |
|
971 | + $inserted += (int) $saveToMany->setParameter($secondaryIdBindName, $secondaryId)->execute(); |
|
973 | 972 | } |
974 | 973 | } |
975 | 974 | }); |
@@ -998,12 +997,12 @@ discard block |
||
998 | 997 | ->createBuilder($this->getModelClass()) |
999 | 998 | ->updateModels($allowedChanges) |
1000 | 999 | ->addFiltersWithAndToTable($filters); |
1001 | - $saveMain = $this->builderSaveResourceOnUpdate($saveMain); |
|
1000 | + $saveMain = $this->builderSaveResourceOnUpdate($saveMain); |
|
1002 | 1001 | $saveMain->getSQL(); // prepare |
1003 | 1002 | |
1004 | 1003 | $this->clearBuilderParameters()->clearFetchParameters(); |
1005 | 1004 | |
1006 | - $this->inTransaction(function () use ($saveMain, $toMany, $index, &$updated) { |
|
1005 | + $this->inTransaction(function() use ($saveMain, $toMany, $index, &$updated) { |
|
1007 | 1006 | $updated = $saveMain->execute(); |
1008 | 1007 | |
1009 | 1008 | foreach ($toMany as $relationshipName => $secondaryIds) { |
@@ -1023,12 +1022,12 @@ discard block |
||
1023 | 1022 | ->prepareCreateInToManyRelationship($relationshipName, $index, $secondaryIdBindName) |
1024 | 1023 | ); |
1025 | 1024 | foreach ($secondaryIds as $secondaryId) { |
1026 | - $updated += (int)$saveToMany->setParameter($secondaryIdBindName, $secondaryId)->execute(); |
|
1025 | + $updated += (int) $saveToMany->setParameter($secondaryIdBindName, $secondaryId)->execute(); |
|
1027 | 1026 | } |
1028 | 1027 | } |
1029 | 1028 | }); |
1030 | 1029 | |
1031 | - return (int)$updated; |
|
1030 | + return (int) $updated; |
|
1032 | 1031 | } |
1033 | 1032 | |
1034 | 1033 | /** |
@@ -1114,7 +1113,7 @@ discard block |
||
1114 | 1113 | /** |
1115 | 1114 | * @inheritdoc |
1116 | 1115 | */ |
1117 | - public function fetchRow(QueryBuilder $builder, string $modelClass): ?array |
|
1116 | + public function fetchRow(QueryBuilder $builder, string $modelClass): ? array |
|
1118 | 1117 | { |
1119 | 1118 | $statement = $builder->execute(); |
1120 | 1119 | $statement->setFetchMode(PDOConnection::FETCH_ASSOC); |
@@ -1232,7 +1231,7 @@ discard block |
||
1232 | 1231 | * |
1233 | 1232 | * @return iterable |
1234 | 1233 | */ |
1235 | - protected function filterAttributesOnCreate(?string $index, iterable $attributes): iterable |
|
1234 | + protected function filterAttributesOnCreate(?string $index, iterable $attributes) : iterable |
|
1236 | 1235 | { |
1237 | 1236 | if ($index !== null) { |
1238 | 1237 | $pkName = $this->getModelSchemes()->getPrimaryKey($this->getModelClass()); |
@@ -1291,7 +1290,7 @@ discard block |
||
1291 | 1290 | $pkName = $this->getModelSchemes()->getPrimaryKey($parentClass); |
1292 | 1291 | |
1293 | 1292 | foreach ($childRelationships as $name) { |
1294 | - $childrenPath = $parentsPath !== static::ROOT_PATH ? $parentsPath . static::PATH_SEPARATOR . $name : $name; |
|
1293 | + $childrenPath = $parentsPath !== static::ROOT_PATH ? $parentsPath.static::PATH_SEPARATOR.$name : $name; |
|
1295 | 1294 | |
1296 | 1295 | $relationshipType = $this->getModelSchemes()->getRelationshipType($parentClass, $name); |
1297 | 1296 | list ($targetModelClass, $reverseRelName) = |
@@ -1312,7 +1311,7 @@ discard block |
||
1312 | 1311 | [$pkName => [FilterParameterInterface::OPERATION_EQUALS => [$parent->{$pkName}]]], |
1313 | 1312 | [] |
1314 | 1313 | ); |
1315 | - $child = $deDup->register($this->fetchResourceWithoutRelationships( |
|
1314 | + $child = $deDup->register($this->fetchResourceWithoutRelationships( |
|
1316 | 1315 | $clonedBuilder, |
1317 | 1316 | $clonedBuilder->getModelClass() |
1318 | 1317 | )); |
@@ -1333,7 +1332,7 @@ discard block |
||
1333 | 1332 | [$pkName => [FilterParameterInterface::OPERATION_EQUALS => [$parent->{$pkName}]]], |
1334 | 1333 | [] |
1335 | 1334 | ); |
1336 | - $children = $this->fetchPaginatedResourcesWithoutRelationships( |
|
1335 | + $children = $this->fetchPaginatedResourcesWithoutRelationships( |
|
1337 | 1336 | $clonedBuilder, |
1338 | 1337 | $clonedBuilder->getModelClass() |
1339 | 1338 | ); |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | public function fetchResources(QueryBuilder $builder, string $modelClass): PaginatedDataInterface; |
109 | 109 | |
110 | 110 | /** |
111 | - * @param QueryBuilder|null $builder |
|
111 | + * @param QueryBuilder $builder |
|
112 | 112 | * @param string|null $modelClass |
113 | 113 | * |
114 | 114 | * @return PaginatedDataInterface |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * @param string $modelClass |
129 | 129 | * @param string $columnName |
130 | 130 | * |
131 | - * @return iterable |
|
131 | + * @return \Generator |
|
132 | 132 | */ |
133 | 133 | public function fetchColumn(QueryBuilder $builder, string $modelClass, string $columnName): iterable; |
134 | 134 | |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | ): array; |
212 | 212 | |
213 | 213 | /** |
214 | - * @param int|string $index |
|
214 | + * @param string $index |
|
215 | 215 | * @param string $name |
216 | 216 | * @param iterable|null $relationshipFilters |
217 | 217 | * @param iterable|null $relationshipSorts |
@@ -121,7 +121,7 @@ |
||
121 | 121 | * |
122 | 122 | * @return array|null |
123 | 123 | */ |
124 | - public function fetchRow(QueryBuilder $builder, string $modelClass): ?array; |
|
124 | + public function fetchRow(QueryBuilder $builder, string $modelClass): ? array; |
|
125 | 125 | |
126 | 126 | /** |
127 | 127 | * @param QueryBuilder $builder |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | ): ResponseInterface { |
93 | 93 | list ($index, $api) = static::createImpl($container, $request); |
94 | 94 | |
95 | - $data = $api->read($index)->getData(); |
|
95 | + $data = $api->read($index)->getData(); |
|
96 | 96 | |
97 | 97 | $response = static::createResponses($container, $request)->getCreatedResponse($data); |
98 | 98 | |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | */ |
238 | 238 | protected static function readJsonFromRequest(ContainerInterface $container, ServerRequestInterface $request): array |
239 | 239 | { |
240 | - $body = (string)$request->getBody(); |
|
240 | + $body = (string) $request->getBody(); |
|
241 | 241 | if (empty($body) === true || ($json = json_decode($body, true)) === null) { |
242 | 242 | /** @var FactoryInterface $factory */ |
243 | 243 | $factory = $container->get(FactoryInterface::class); |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | { |
379 | 379 | assert( |
380 | 380 | empty(static::ON_CREATE_VALIDATION_RULES_SET_CLASS) === false, |
381 | - 'Validation rules set should be defined for class ' . static::class . '.' |
|
381 | + 'Validation rules set should be defined for class '.static::class.'.' |
|
382 | 382 | ); |
383 | 383 | |
384 | 384 | return static::createJsonApiValidator($container, static::ON_CREATE_VALIDATION_RULES_SET_CLASS); |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | { |
394 | 394 | assert( |
395 | 395 | empty(static::ON_UPDATE_VALIDATION_RULES_SET_CLASS) === false, |
396 | - 'Validation rules set should be defined for class ' . static::class . '.' |
|
396 | + 'Validation rules set should be defined for class '.static::class.'.' |
|
397 | 397 | ); |
398 | 398 | |
399 | 399 | return static::createJsonApiValidator($container, static::ON_UPDATE_VALIDATION_RULES_SET_CLASS); |
@@ -601,7 +601,7 @@ discard block |
||
601 | 601 | ContainerInterface $container, |
602 | 602 | ServerRequestInterface $request |
603 | 603 | ): array { |
604 | - $jsonData = static::normalizeIndexValueOnUpdate( |
|
604 | + $jsonData = static::normalizeIndexValueOnUpdate( |
|
605 | 605 | $routeParams, |
606 | 606 | $container, |
607 | 607 | static::readJsonFromRequest($container, $request) |