@@ -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 |
@@ -1,4 +1,4 @@ |
||
1 | -<?php declare (strict_types = 1); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace Limoncello\Flute\Contracts\Http\Query; |
4 | 4 |
@@ -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 | */ |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare (strict_types = 1); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace Limoncello\Flute\Api; |
4 | 4 | |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | throw new InvalidArgumentException($this->getMessage(Messages::MSG_ERR_INVALID_ARGUMENT)); |
210 | 210 | } |
211 | 211 | |
212 | - assert(call_user_func(function () use ($indexes) { |
|
212 | + assert(call_user_func(function() use ($indexes) { |
|
213 | 213 | $allOk = true; |
214 | 214 | |
215 | 215 | foreach ($indexes as $index) { |
@@ -763,7 +763,7 @@ discard block |
||
763 | 763 | $classAtPath = new ArrayObject(); |
764 | 764 | $idsAtPath = new ArrayObject(); |
765 | 765 | |
766 | - $registerModelAtRoot = function ($model) use ($modelStorage, $modelsAtPath, $idsAtPath): void { |
|
766 | + $registerModelAtRoot = function($model) use ($modelStorage, $modelsAtPath, $idsAtPath): void { |
|
767 | 767 | self::registerModelAtPath( |
768 | 768 | $model, |
769 | 769 | static::ROOT_PATH, |
@@ -851,7 +851,7 @@ discard block |
||
851 | 851 | assert(is_string($pathPiece)); |
852 | 852 | $parent = $tmpPath; |
853 | 853 | $tmpPath = empty($tmpPath) === true ? |
854 | - $pathPiece : $tmpPath . static::PATH_SEPARATOR . $pathPiece; |
|
854 | + $pathPiece : $tmpPath.static::PATH_SEPARATOR.$pathPiece; |
|
855 | 855 | $normalizedPaths[$tmpPath] = [$parent, $pathPiece]; |
856 | 856 | $pathsDepths[$parent] = $parentDepth++; |
857 | 857 | } |
@@ -999,7 +999,7 @@ discard block |
||
999 | 999 | $this->createCountBuilderFromBuilder($this->createIndexModelBuilder()) |
1000 | 1000 | )->execute()->fetchColumn(); |
1001 | 1001 | |
1002 | - return $result === false ? null : (int)$result; |
|
1002 | + return $result === false ? null : (int) $result; |
|
1003 | 1003 | } |
1004 | 1004 | |
1005 | 1005 | /** |
@@ -1020,7 +1020,7 @@ discard block |
||
1020 | 1020 | ): ModelQueryBuilder { |
1021 | 1021 | assert( |
1022 | 1022 | $this->getModelSchemas()->hasRelationship($this->getModelClass(), $relationshipName), |
1023 | - "Relationship `$relationshipName` do not exist in model `" . $this->getModelClass() . '`' |
|
1023 | + "Relationship `$relationshipName` do not exist in model `".$this->getModelClass().'`' |
|
1024 | 1024 | ); |
1025 | 1025 | |
1026 | 1026 | // as we read data from a relationship our main table and model would be the table/model in the relationship |
@@ -1038,7 +1038,7 @@ discard block |
||
1038 | 1038 | if ($this->hasFilters() === true) { |
1039 | 1039 | $filters = $this->getFilters(); |
1040 | 1040 | $sorts = $this->getSorts(); |
1041 | - $joinCondition = $this->areFiltersWithAnd() === true ? ModelQueryBuilder::AND : ModelQueryBuilder::OR; |
|
1041 | + $joinCondition = $this->areFiltersWithAnd() === true ? ModelQueryBuilder:: AND : ModelQueryBuilder:: OR ; |
|
1042 | 1042 | $builder->addRelationshipFiltersAndSorts($reverseRelName, $filters, $sorts, $joinCondition); |
1043 | 1043 | } |
1044 | 1044 | // ... and the input filters to actual data we select |
@@ -1069,7 +1069,7 @@ discard block |
||
1069 | 1069 | ) { |
1070 | 1070 | assert( |
1071 | 1071 | $this->getModelSchemas()->hasRelationship($this->getModelClass(), $name), |
1072 | - "Relationship `$name` do not exist in model `" . $this->getModelClass() . '`' |
|
1072 | + "Relationship `$name` do not exist in model `".$this->getModelClass().'`' |
|
1073 | 1073 | ); |
1074 | 1074 | |
1075 | 1075 | // depending on the relationship type we expect the result to be either single resource or a collection |
@@ -1098,7 +1098,7 @@ discard block |
||
1098 | 1098 | ): array { |
1099 | 1099 | assert( |
1100 | 1100 | $this->getModelSchemas()->hasRelationship($this->getModelClass(), $name), |
1101 | - "Relationship `$name` do not exist in model `" . $this->getModelClass() . '`' |
|
1101 | + "Relationship `$name` do not exist in model `".$this->getModelClass().'`' |
|
1102 | 1102 | ); |
1103 | 1103 | |
1104 | 1104 | // depending on the relationship type we expect the result to be either single resource or a collection |
@@ -1167,7 +1167,7 @@ discard block |
||
1167 | 1167 | |
1168 | 1168 | $this->clearFetchParameters(); |
1169 | 1169 | |
1170 | - return (int)$deleted; |
|
1170 | + return (int) $deleted; |
|
1171 | 1171 | } |
1172 | 1172 | |
1173 | 1173 | /** |
@@ -1183,7 +1183,7 @@ discard block |
||
1183 | 1183 | |
1184 | 1184 | $this->clearFetchParameters(); |
1185 | 1185 | |
1186 | - return (int)$deleted > 0; |
|
1186 | + return (int) $deleted > 0; |
|
1187 | 1187 | } |
1188 | 1188 | |
1189 | 1189 | /** |
@@ -1204,7 +1204,7 @@ discard block |
||
1204 | 1204 | |
1205 | 1205 | $this->clearBuilderParameters()->clearFetchParameters(); |
1206 | 1206 | |
1207 | - $this->inTransaction(function () use ($saveMain, $toMany, &$index) { |
|
1207 | + $this->inTransaction(function() use ($saveMain, $toMany, &$index) { |
|
1208 | 1208 | $saveMain->execute(); |
1209 | 1209 | |
1210 | 1210 | // if no index given will use last insert ID as index |
@@ -1241,12 +1241,12 @@ discard block |
||
1241 | 1241 | ->createBuilder($this->getModelClass()) |
1242 | 1242 | ->updateModels($allowedChanges) |
1243 | 1243 | ->addFiltersWithAndToTable($filters); |
1244 | - $saveMain = $this->builderSaveResourceOnUpdate($saveMain); |
|
1244 | + $saveMain = $this->builderSaveResourceOnUpdate($saveMain); |
|
1245 | 1245 | $saveMain->getSQL(); // prepare |
1246 | 1246 | |
1247 | 1247 | $this->clearBuilderParameters()->clearFetchParameters(); |
1248 | 1248 | |
1249 | - $this->inTransaction(function () use ($saveMain, $toMany, $index, &$updated) { |
|
1249 | + $this->inTransaction(function() use ($saveMain, $toMany, $index, &$updated) { |
|
1250 | 1250 | $updated = $saveMain->execute(); |
1251 | 1251 | |
1252 | 1252 | $builderHook = Closure::fromCallable([$this, 'builderSaveRelationshipOnUpdate']); |
@@ -1262,7 +1262,7 @@ discard block |
||
1262 | 1262 | )->execute(); |
1263 | 1263 | |
1264 | 1264 | // add new ones |
1265 | - $updated += $this->addInToManyRelationship( |
|
1265 | + $updated += $this->addInToManyRelationship( |
|
1266 | 1266 | $connection, |
1267 | 1267 | $index, |
1268 | 1268 | $relationshipName, |
@@ -1272,7 +1272,7 @@ discard block |
||
1272 | 1272 | } |
1273 | 1273 | }); |
1274 | 1274 | |
1275 | - return (int)$updated; |
|
1275 | + return (int) $updated; |
|
1276 | 1276 | } |
1277 | 1277 | |
1278 | 1278 | /** |
@@ -1289,9 +1289,9 @@ discard block |
||
1289 | 1289 | public function createInBelongsToManyRelationship(string $parentId, string $name, iterable $childIds): int |
1290 | 1290 | { |
1291 | 1291 | // Check that relationship is `BelongsToMany` |
1292 | - assert(call_user_func(function () use ($name): bool { |
|
1292 | + assert(call_user_func(function() use ($name): bool { |
|
1293 | 1293 | $relType = $this->getModelSchemas()->getRelationshipType($this->getModelClass(), $name); |
1294 | - $errMsg = "Relationship `$name` of class `" . $this->getModelClass() . |
|
1294 | + $errMsg = "Relationship `$name` of class `".$this->getModelClass(). |
|
1295 | 1295 | '` either is not `belongsToMany` or do not exist in the class.'; |
1296 | 1296 | $isOk = $relType === RelationshipTypes::BELONGS_TO_MANY; |
1297 | 1297 | |
@@ -1313,9 +1313,9 @@ discard block |
||
1313 | 1313 | public function removeInBelongsToManyRelationship(string $parentId, string $name, iterable $childIds): int |
1314 | 1314 | { |
1315 | 1315 | // Check that relationship is `BelongsToMany` |
1316 | - assert(call_user_func(function () use ($name): bool { |
|
1316 | + assert(call_user_func(function() use ($name): bool { |
|
1317 | 1317 | $relType = $this->getModelSchemas()->getRelationshipType($this->getModelClass(), $name); |
1318 | - $errMsg = "Relationship `$name` of class `" . $this->getModelClass() . |
|
1318 | + $errMsg = "Relationship `$name` of class `".$this->getModelClass(). |
|
1319 | 1319 | '` either is not `belongsToMany` or do not exist in the class.'; |
1320 | 1320 | $isOk = $relType === RelationshipTypes::BELONGS_TO_MANY; |
1321 | 1321 | |
@@ -1483,7 +1483,7 @@ discard block |
||
1483 | 1483 | { |
1484 | 1484 | $countBuilder = $this->createBuilder($this->getModelClass()); |
1485 | 1485 | $countBuilder->setParameters($builder->getParameters()); |
1486 | - $countBuilder->select('COUNT(*)')->from('(' . $builder->getSQL() . ') AS RESULT'); |
|
1486 | + $countBuilder->select('COUNT(*)')->from('('.$builder->getSQL().') AS RESULT'); |
|
1487 | 1487 | |
1488 | 1488 | return $countBuilder; |
1489 | 1489 | } |
@@ -1517,7 +1517,7 @@ discard block |
||
1517 | 1517 | |
1518 | 1518 | foreach ($secondaryIdentities as $secondaryId) { |
1519 | 1519 | try { |
1520 | - $inserted += (int)$saveToMany->setParameter($secondaryIdBindName, $secondaryId)->execute(); |
|
1520 | + $inserted += (int) $saveToMany->setParameter($secondaryIdBindName, $secondaryId)->execute(); |
|
1521 | 1521 | } /** @noinspection PhpRedundantCatchClauseInspection */ catch (UcvException $exception) { |
1522 | 1522 | // Spec: If all of the specified resources can be added to, or are already present in, |
1523 | 1523 | // the relationship then the server MUST return a successful response. |
@@ -1764,7 +1764,7 @@ discard block |
||
1764 | 1764 | |
1765 | 1765 | $pkName = $this->getModelSchemas()->getPrimaryKey($parentClass); |
1766 | 1766 | |
1767 | - $registerModelAtPath = function ($model, string $path) use ($deDup, $modelsAtPath, $idsAtPath) { |
|
1767 | + $registerModelAtPath = function($model, string $path) use ($deDup, $modelsAtPath, $idsAtPath) { |
|
1768 | 1768 | return self::registerModelAtPath( |
1769 | 1769 | $model, |
1770 | 1770 | $path, |
@@ -1776,7 +1776,7 @@ discard block |
||
1776 | 1776 | }; |
1777 | 1777 | |
1778 | 1778 | foreach ($childRelationships as $name) { |
1779 | - $childrenPath = $parentsPath !== static::ROOT_PATH ? $parentsPath . static::PATH_SEPARATOR . $name : $name; |
|
1779 | + $childrenPath = $parentsPath !== static::ROOT_PATH ? $parentsPath.static::PATH_SEPARATOR.$name : $name; |
|
1780 | 1780 | |
1781 | 1781 | $relationshipType = $this->getModelSchemas()->getRelationshipType($parentClass, $name); |
1782 | 1782 | list ($targetModelClass, $reverseRelName) = |
@@ -1831,7 +1831,7 @@ discard block |
||
1831 | 1831 | [$pkName => [FilterParameterInterface::OPERATION_EQUALS => [$parent->{$pkName}]]], |
1832 | 1832 | [] |
1833 | 1833 | ); |
1834 | - $children = $this->fetchPaginatedResourcesWithoutRelationships( |
|
1834 | + $children = $this->fetchPaginatedResourcesWithoutRelationships( |
|
1835 | 1835 | $clonedBuilder, |
1836 | 1836 | $clonedBuilder->getModelClass() |
1837 | 1837 | ); |
@@ -409,7 +409,7 @@ |
||
409 | 409 | * @param string $parameterName |
410 | 410 | * @param iterable $value |
411 | 411 | * |
412 | - * @return iterable |
|
412 | + * @return Generator |
|
413 | 413 | * |
414 | 414 | * @SuppressWarnings(PHPMD.CyclomaticComplexity) |
415 | 415 | */ |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare (strict_types = 1); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace Limoncello\Flute\Http\Query; |
4 | 4 | |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | public function getMappedIncludes(): iterable |
250 | 250 | { |
251 | 251 | $fromSchema = $this->getRootSchema(); |
252 | - $getMappedRelLinks = function (iterable $links) use ($fromSchema) : iterable { |
|
252 | + $getMappedRelLinks = function(iterable $links) use ($fromSchema) : iterable { |
|
253 | 253 | foreach ($links as $link) { |
254 | 254 | assert(is_string($link)); |
255 | 255 | $fromSchemaClass = get_class($fromSchema); |
@@ -299,14 +299,14 @@ discard block |
||
299 | 299 | // ['rel2_name1', ], |
300 | 300 | // ['rel3_name1', 'rel3_name2', 'rel3_name3', ], |
301 | 301 | // ] |
302 | - $includeAsModelNames = function (iterable $relationships): iterable { |
|
302 | + $includeAsModelNames = function(iterable $relationships): iterable { |
|
303 | 303 | foreach ($relationships as $relationship) { |
304 | 304 | assert($relationship instanceof RelationshipInterface); |
305 | 305 | yield $relationship->getNameInModel(); |
306 | 306 | } |
307 | 307 | }; |
308 | 308 | $mappedIncludes = $this->getMappedIncludes(); |
309 | - $getIncludes = function () use ($mappedIncludes, $includeAsModelNames) : iterable { |
|
309 | + $getIncludes = function() use ($mappedIncludes, $includeAsModelNames) : iterable { |
|
310 | 310 | foreach ($mappedIncludes as $relationships) { |
311 | 311 | yield $includeAsModelNames($relationships); |
312 | 312 | } |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | } |
380 | 380 | |
381 | 381 | /** |
382 | - * @return iterable |
|
382 | + * @return Generator |
|
383 | 383 | * |
384 | 384 | * @SuppressWarnings(PHPMD.ElseExpression) |
385 | 385 | */ |
@@ -421,9 +421,9 @@ discard block |
||
421 | 421 | } |
422 | 422 | |
423 | 423 | /** |
424 | - * @param iterable $fieldsFromParent |
|
424 | + * @param Generator $fieldsFromParent |
|
425 | 425 | * |
426 | - * @return iterable |
|
426 | + * @return Generator |
|
427 | 427 | * |
428 | 428 | * @SuppressWarnings(PHPMD.StaticAccess) |
429 | 429 | * @SuppressWarnings(PHPMD.ElseExpression) |
@@ -456,9 +456,9 @@ discard block |
||
456 | 456 | } |
457 | 457 | |
458 | 458 | /** |
459 | - * @param iterable $sortsFromParent |
|
459 | + * @param Generator $sortsFromParent |
|
460 | 460 | * |
461 | - * @return iterable |
|
461 | + * @return Generator |
|
462 | 462 | * |
463 | 463 | * @SuppressWarnings(PHPMD.StaticAccess) |
464 | 464 | * @SuppressWarnings(PHPMD.ElseExpression) |
@@ -488,9 +488,9 @@ discard block |
||
488 | 488 | } |
489 | 489 | |
490 | 490 | /** |
491 | - * @param iterable $includesFromParent |
|
491 | + * @param Generator $includesFromParent |
|
492 | 492 | * |
493 | - * @return iterable |
|
493 | + * @return Generator |
|
494 | 494 | * |
495 | 495 | * @SuppressWarnings(PHPMD.StaticAccess) |
496 | 496 | * @SuppressWarnings(PHPMD.ElseExpression) |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | } |
521 | 521 | |
522 | 522 | /** |
523 | - * @param iterable $iterable |
|
523 | + * @param Generator $iterable |
|
524 | 524 | * |
525 | 525 | * @return array |
526 | 526 | */ |
@@ -683,7 +683,7 @@ discard block |
||
683 | 683 | * @param int $ruleIndex |
684 | 684 | * @param iterable $values |
685 | 685 | * |
686 | - * @return iterable |
|
686 | + * @return Generator |
|
687 | 687 | */ |
688 | 688 | private function validateValues(int $ruleIndex, iterable $values): iterable |
689 | 689 | { |
@@ -698,9 +698,9 @@ discard block |
||
698 | 698 | |
699 | 699 | /** |
700 | 700 | * @param int $ruleIndex |
701 | - * @param iterable $opsAndArgs |
|
701 | + * @param Generator $opsAndArgs |
|
702 | 702 | * |
703 | - * @return iterable |
|
703 | + * @return Generator |
|
704 | 704 | */ |
705 | 705 | private function validateFilterArguments(int $ruleIndex, iterable $opsAndArgs): iterable |
706 | 706 | { |
@@ -858,7 +858,7 @@ discard block |
||
858 | 858 | * @param string $parameterName |
859 | 859 | * @param array $value |
860 | 860 | * |
861 | - * @return iterable |
|
861 | + * @return Generator |
|
862 | 862 | * |
863 | 863 | * @SuppressWarnings(PHPMD.ElseExpression) |
864 | 864 | */ |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare (strict_types = 1); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace Limoncello\Flute\Validation\JsonApi; |
4 | 4 | |
@@ -714,7 +714,7 @@ discard block |
||
714 | 714 | { |
715 | 715 | // no validation rule means we should accept any input value |
716 | 716 | if ($ruleIndexes === null) { |
717 | - return is_numeric($value) === true ? (int)$value : 0; |
|
717 | + return is_numeric($value) === true ? (int) $value : 0; |
|
718 | 718 | } |
719 | 719 | |
720 | 720 | $ruleIndex = $this->serializerClass::readRuleMainIndex($ruleIndexes); |
@@ -725,7 +725,7 @@ discard block |
||
725 | 725 | |
726 | 726 | $validatedValue = $this->readSingleCapturedValue(); |
727 | 727 | |
728 | - return (int)$validatedValue; |
|
728 | + return (int) $validatedValue; |
|
729 | 729 | } |
730 | 730 | |
731 | 731 | /** |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | public function fetchResources(QueryBuilder $builder, string $modelClass): PaginatedDataInterface; |
121 | 121 | |
122 | 122 | /** |
123 | - * @param QueryBuilder|null $builder |
|
123 | + * @param QueryBuilder $builder |
|
124 | 124 | * @param string|null $modelClass |
125 | 125 | * |
126 | 126 | * @return mixed|null |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @param string $modelClass |
141 | 141 | * @param string $columnName |
142 | 142 | * |
143 | - * @return iterable |
|
143 | + * @return \Generator |
|
144 | 144 | */ |
145 | 145 | public function fetchColumn(QueryBuilder $builder, string $modelClass, string $columnName): iterable; |
146 | 146 |
@@ -1,4 +1,4 @@ |
||
1 | -<?php declare (strict_types = 1); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace Limoncello\Flute\Contracts\Api; |
4 | 4 |
@@ -161,7 +161,7 @@ |
||
161 | 161 | public static function readRulesEndIndexes(array $arrayRuleIndexes): array; |
162 | 162 | |
163 | 163 | /** |
164 | - * @param array $arrayRuleIndexes |
|
164 | + * @param integer[] $arrayRuleIndexes |
|
165 | 165 | * @param string $name |
166 | 166 | * |
167 | 167 | * @return array |
@@ -1,4 +1,4 @@ |
||
1 | -<?php declare (strict_types = 1); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace Limoncello\Flute\Contracts\Validation; |
4 | 4 |
@@ -251,7 +251,7 @@ |
||
251 | 251 | * @param FactoryInterface $errorFactory |
252 | 252 | * @param FormatterFactoryInterface $formatterFactory |
253 | 253 | * |
254 | - * @return ResponseInterface |
|
254 | + * @return string |
|
255 | 255 | */ |
256 | 256 | protected static function defaultCreate( |
257 | 257 | string $requestBody, |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare (strict_types = 1); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace Limoncello\Flute\Http\Traits; |
4 | 4 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | EncoderInterface $encoder |
111 | 111 | ): ResponseInterface { |
112 | 112 | $queryParser->parse($index, $queryParams); |
113 | - $validatedIndex = (string)$queryParser->getIdentity(); |
|
113 | + $validatedIndex = (string) $queryParser->getIdentity(); |
|
114 | 114 | |
115 | 115 | $model = $mapper->applyQueryParameters($queryParser, $crud)->read($validatedIndex); |
116 | 116 | assert(!($model instanceof PaginatedDataInterface)); |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | $title = $formatter->formatMessage(Messages::MSG_ERR_CANNOT_CREATE_NON_UNIQUE_RESOURCE); |
281 | 281 | $details = null; |
282 | 282 | $errorCode = JsonApiResponse::HTTP_CONFLICT; |
283 | - $errors->addDataError($title, $details, (string)$errorCode); |
|
283 | + $errors->addDataError($title, $details, (string) $errorCode); |
|
284 | 284 | |
285 | 285 | throw new JsonApiException($errors); |
286 | 286 | } |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | list ($index, $attributes, $toMany) = static::mapSchemaDataToModelData($captures, $schemaClass, $schemaInfo); |
410 | 410 | |
411 | 411 | try { |
412 | - $updated = $crud->update((string)$index, $attributes, $toMany); |
|
412 | + $updated = $crud->update((string) $index, $attributes, $toMany); |
|
413 | 413 | } /** @noinspection PhpRedundantCatchClauseInspection */ catch (UniqueConstraintViolationException $exception) { |
414 | 414 | $errors = $errorFactory->createErrorCollection(); |
415 | 415 | $formatter = $formatterFactory->createFormatter(Messages::NAMESPACE_NAME); |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | ->formatMessage(Messages::MSG_ERR_CANNOT_UPDATE_WITH_UNIQUE_CONSTRAINT_VIOLATION); |
418 | 418 | $details = null; |
419 | 419 | $errorCode = JsonApiResponse::HTTP_CONFLICT; |
420 | - $errors->addDataError($title, $details, (string)$errorCode); |
|
420 | + $errors->addDataError($title, $details, (string) $errorCode); |
|
421 | 421 | |
422 | 422 | throw new JsonApiException($errors); |
423 | 423 | } |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | CrudInterface $crud, |
471 | 471 | EncoderInterface $encoder |
472 | 472 | ): ResponseInterface { |
473 | - $validatedIndex = (string)$queryParser->parse($index)->getIdentity(); |
|
473 | + $validatedIndex = (string) $queryParser->parse($index)->getIdentity(); |
|
474 | 474 | $crud->remove($validatedIndex); |
475 | 475 | |
476 | 476 | $responses = static::defaultCreateResponses($requestUri, $encoder); |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | $captures = $dataValidator->assertRelationship($index, $jsonRelName, $jsonData)->getCaptures(); |
524 | 524 | $relIds = $captures[$jsonRelName]; |
525 | 525 | |
526 | - $validatedIndex = (string)$queryParser->parse($index)->getIdentity(); |
|
526 | + $validatedIndex = (string) $queryParser->parse($index)->getIdentity(); |
|
527 | 527 | $parentCrud->createInBelongsToManyRelationship($validatedIndex, $modelRelName, $relIds); |
528 | 528 | |
529 | 529 | $responses = static::defaultCreateResponses($requestUri, $encoder); |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | $captures = $dataValidator->assertRelationship($index, $jsonRelName, $jsonData)->getCaptures(); |
577 | 577 | $relIds = $captures[$jsonRelName]; |
578 | 578 | |
579 | - $validatedIndex = (string)$queryParser->parse($index)->getIdentity(); |
|
579 | + $validatedIndex = (string) $queryParser->parse($index)->getIdentity(); |
|
580 | 580 | $parentCrud->removeInBelongsToManyRelationship($validatedIndex, $modelRelName, $relIds); |
581 | 581 | |
582 | 582 | $responses = static::defaultCreateResponses($requestUri, $encoder); |
@@ -624,7 +624,7 @@ discard block |
||
624 | 624 | $modelClass = $schemaClass::MODEL; |
625 | 625 | assert($schemaInfo->hasRelationship($modelClass, $modelRelName)); |
626 | 626 | assert( |
627 | - ($type =$schemaInfo->getRelationshipType($modelClass, $modelRelName)) === RelationshipTypes::BELONGS_TO || |
|
627 | + ($type = $schemaInfo->getRelationshipType($modelClass, $modelRelName)) === RelationshipTypes::BELONGS_TO || |
|
628 | 628 | $type === RelationshipTypes::BELONGS_TO_MANY |
629 | 629 | ); |
630 | 630 | |
@@ -633,7 +633,7 @@ discard block |
||
633 | 633 | |
634 | 634 | // If we are here then we have something in 'data' section. |
635 | 635 | |
636 | - $validatedIndex = (string)$queryParser->parse($index)->getIdentity(); |
|
636 | + $validatedIndex = (string) $queryParser->parse($index)->getIdentity(); |
|
637 | 637 | list (, $attributes, $toMany) = static::mapSchemaDataToModelData($captures, $schemaClass, $schemaInfo); |
638 | 638 | |
639 | 639 | $updated = $crud->update($validatedIndex, $attributes, $toMany); |
@@ -875,7 +875,7 @@ discard block |
||
875 | 875 | ): string { |
876 | 876 | $schema = $jsonSchemas->getSchema($model); |
877 | 877 | $selfLink = $schema->getSelfLink($model); |
878 | - $urlPrefix = (string)$requestUri->withPath('')->withQuery('')->withFragment(''); |
|
878 | + $urlPrefix = (string) $requestUri->withPath('')->withQuery('')->withFragment(''); |
|
879 | 879 | $fullUrl = $selfLink->getStringRepresentation($urlPrefix); |
880 | 880 | |
881 | 881 | return $fullUrl; |
@@ -888,7 +888,7 @@ discard block |
||
888 | 888 | */ |
889 | 889 | private static function assertClassValueDefined(?string $value): void |
890 | 890 | { |
891 | - assert(empty($value) === false, 'Value should be defined in `' . static::class . '`.'); |
|
891 | + assert(empty($value) === false, 'Value should be defined in `'.static::class.'`.'); |
|
892 | 892 | } |
893 | 893 | |
894 | 894 | /** |
@@ -901,7 +901,7 @@ discard block |
||
901 | 901 | { |
902 | 902 | assert( |
903 | 903 | array_key_exists($interface, class_implements($class)) === true, |
904 | - "Class `$class` should implement `" . $interface . '` interface.' |
|
904 | + "Class `$class` should implement `".$interface.'` interface.' |
|
905 | 905 | ); |
906 | 906 | } |
907 | 907 | } |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare (strict_types = 1); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace Limoncello\Flute\Http\ThrowableHandlers; |
4 | 4 | |
@@ -132,9 +132,9 @@ discard block |
||
132 | 132 | $details = null; |
133 | 133 | if ($this->isDebug === true) { |
134 | 134 | $message = $throwable->getMessage(); |
135 | - $details = (string)$throwable; |
|
135 | + $details = (string) $throwable; |
|
136 | 136 | } |
137 | - $errors->add(new Error(null, null, null, (string)$httpCode, null, $message, $details)); |
|
137 | + $errors->add(new Error(null, null, null, (string) $httpCode, null, $message, $details)); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | // encode the error and send to client |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare (strict_types = 1); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace Limoncello\Flute\Http; |
4 | 4 | |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | |
93 | 93 | $response = static::defaultCreateHandler( |
94 | 94 | $request->getUri(), |
95 | - (string)$request->getBody(), |
|
95 | + (string) $request->getBody(), |
|
96 | 96 | static::SCHEMA_CLASS, |
97 | 97 | $container->get(ModelSchemaInfoInterface::class), |
98 | 98 | static::defaultCreateDataParser($container, static::ON_CREATE_DATA_VALIDATION_RULES_CLASS), |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | static::assertClassValueDefined(static::ON_READ_QUERY_VALIDATION_RULES_CLASS); |
120 | 120 | |
121 | 121 | return static::defaultReadHandler( |
122 | - (string)$routeParams[static::ROUTE_KEY_INDEX], |
|
122 | + (string) $routeParams[static::ROUTE_KEY_INDEX], |
|
123 | 123 | $request->getQueryParams(), |
124 | 124 | $request->getUri(), |
125 | 125 | static::defaultCreateQueryParser($container, static::ON_READ_QUERY_VALIDATION_RULES_CLASS), |
@@ -142,9 +142,9 @@ discard block |
||
142 | 142 | static::assertClassValueDefined(static::ON_UPDATE_DATA_VALIDATION_RULES_CLASS); |
143 | 143 | |
144 | 144 | $response = static::defaultUpdateHandler( |
145 | - (string)$routeParams[static::ROUTE_KEY_INDEX], |
|
145 | + (string) $routeParams[static::ROUTE_KEY_INDEX], |
|
146 | 146 | $request->getUri(), |
147 | - (string)$request->getBody(), |
|
147 | + (string) $request->getBody(), |
|
148 | 148 | static::SCHEMA_CLASS, |
149 | 149 | $container->get(ModelSchemaInfoInterface::class), |
150 | 150 | static::defaultCreateDataParser($container, static::ON_UPDATE_DATA_VALIDATION_RULES_CLASS), |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | static::assertClassValueDefined(static::API_CLASS); |
169 | 169 | |
170 | 170 | $response = static::defaultDeleteHandler( |
171 | - (string)$routeParams[static::ROUTE_KEY_INDEX], |
|
171 | + (string) $routeParams[static::ROUTE_KEY_INDEX], |
|
172 | 172 | $request->getUri(), |
173 | 173 | static::defaultCreateQueryParser($container, static::ON_READ_QUERY_VALIDATION_RULES_CLASS), |
174 | 174 | static::defaultCreateApi($container, static::API_CLASS), |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | static::assertClassValueDefined(static::SCHEMA_CLASS); |
202 | 202 | |
203 | 203 | $api = static::defaultCreateApi($container, static::API_CLASS); |
204 | - $handler = function () use ($api, $index, $modelRelName) { |
|
204 | + $handler = function() use ($api, $index, $modelRelName) { |
|
205 | 205 | return $api->readRelationship($index, $modelRelName); |
206 | 206 | }; |
207 | 207 | |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | static::assertClassValueDefined(static::SCHEMA_CLASS); |
241 | 241 | |
242 | 242 | $api = static::defaultCreateApi($container, static::API_CLASS); |
243 | - $handler = function () use ($api, $index, $modelRelName) { |
|
243 | + $handler = function() use ($api, $index, $modelRelName) { |
|
244 | 244 | return $api->readRelationship($index, $modelRelName); |
245 | 245 | }; |
246 | 246 |