@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
184 | - * @param iterable $attributes |
|
184 | + * @param \Generator $attributes |
|
185 | 185 | * |
186 | 186 | * @return self |
187 | 187 | * |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | } |
204 | 204 | |
205 | 205 | /** |
206 | - * @param iterable $attributes |
|
206 | + * @param \Generator $attributes |
|
207 | 207 | * |
208 | 208 | * @return self |
209 | 209 | * |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | * @param string $modelClass |
227 | 227 | * @param iterable $attributes |
228 | 228 | * |
229 | - * @return iterable |
|
229 | + * @return \Generator |
|
230 | 230 | * |
231 | 231 | * @SuppressWarnings(PHPMD.StaticAccess) |
232 | 232 | * |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | } |
358 | 358 | |
359 | 359 | /** |
360 | - * @param iterable $filters |
|
360 | + * @param \Limoncello\Flute\Api\iterable|null $filters |
|
361 | 361 | * |
362 | 362 | * @return self |
363 | 363 | * |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | } |
374 | 374 | |
375 | 375 | /** |
376 | - * @param iterable $filters |
|
376 | + * @param \Limoncello\Flute\Api\iterable|null $filters |
|
377 | 377 | * |
378 | 378 | * @return self |
379 | 379 | * |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | } |
390 | 390 | |
391 | 391 | /** |
392 | - * @param iterable $filters |
|
392 | + * @param \Limoncello\Flute\Api\iterable|null $filters |
|
393 | 393 | * |
394 | 394 | * @return self |
395 | 395 | * |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | } |
439 | 439 | |
440 | 440 | /** |
441 | - * @param iterable $sortParameters |
|
441 | + * @param \Limoncello\Flute\Api\iterable|null $sortParameters |
|
442 | 442 | * |
443 | 443 | * @return self |
444 | 444 | */ |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | /** |
49 | 49 | * Condition joining method. |
50 | 50 | */ |
51 | - public const OR = self::AND + 1; |
|
51 | + public const OR = self:: AND + 1; |
|
52 | 52 | |
53 | 53 | /** |
54 | 54 | * @var string |
@@ -419,16 +419,16 @@ discard block |
||
419 | 419 | string $relationshipName, |
420 | 420 | ?iterable $relationshipFilters, |
421 | 421 | ?iterable $relationshipSorts, |
422 | - int $joinIndividuals = self::AND, |
|
423 | - int $joinRelationship = self::AND |
|
422 | + int $joinIndividuals = self:: AND , |
|
423 | + int $joinRelationship = self:: AND |
|
424 | 424 | ): self { |
425 | 425 | $targetAlias = $this->createRelationshipAlias($relationshipName); |
426 | 426 | |
427 | 427 | if ($relationshipFilters !== null) { |
428 | - $addWith = $joinIndividuals === self::AND ? $this->expr()->andX() : $this->expr()->orX(); |
|
428 | + $addWith = $joinIndividuals === self:: AND ? $this->expr()->andX() : $this->expr()->orX(); |
|
429 | 429 | $this->applyFilters($addWith, $targetAlias, $relationshipFilters); |
430 | 430 | if ($addWith->count() > 0) { |
431 | - $joinRelationship === self::AND ? $this->andWhere($addWith) : $this->orWhere($addWith); |
|
431 | + $joinRelationship === self:: AND ? $this->andWhere($addWith) : $this->orWhere($addWith); |
|
432 | 432 | } |
433 | 433 | } |
434 | 434 | |
@@ -551,7 +551,7 @@ discard block |
||
551 | 551 | foreach ($operationsWithArgs as $operation => $arguments) { |
552 | 552 | assert( |
553 | 553 | is_iterable($arguments) === true || is_array($arguments) === true, |
554 | - "Operation arguments are missing for `$columnName` column. " . |
|
554 | + "Operation arguments are missing for `$columnName` column. ". |
|
555 | 555 | 'Use an empty array as an empty argument list.' |
556 | 556 | ); |
557 | 557 | $expression->add($this->createFilterExpression($fullColumnName, $operation, $arguments)); |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | */ |
587 | 587 | public function buildColumnName(string $table, string $column): string |
588 | 588 | { |
589 | - return $this->quoteTableName($table) . '.' . $this->quoteColumnName($column); |
|
589 | + return $this->quoteTableName($table).'.'.$this->quoteColumnName($column); |
|
590 | 590 | } |
591 | 591 | |
592 | 592 | /** |
@@ -628,7 +628,7 @@ discard block |
||
628 | 628 | */ |
629 | 629 | public function createAlias(string $tableName): string |
630 | 630 | { |
631 | - $alias = $tableName . (++$this->aliasIdCounter); |
|
631 | + $alias = $tableName.(++$this->aliasIdCounter); |
|
632 | 632 | $this->knownAliases[$tableName] = $alias; |
633 | 633 | |
634 | 634 | return $alias; |
@@ -682,7 +682,7 @@ discard block |
||
682 | 682 | string $targetColumn |
683 | 683 | ): string { |
684 | 684 | $targetAlias = $this->createAlias($targetTable); |
685 | - $joinCondition = $this->buildColumnName($fromAlias, $fromColumn) . '=' . |
|
685 | + $joinCondition = $this->buildColumnName($fromAlias, $fromColumn).'='. |
|
686 | 686 | $this->buildColumnName($targetAlias, $targetColumn); |
687 | 687 | |
688 | 688 | $this->innerJoin( |
@@ -880,7 +880,7 @@ discard block |
||
880 | 880 | } else { |
881 | 881 | assert( |
882 | 882 | $value !== null, |
883 | - 'It seems you are trying to use `null` with =, >, <, or etc operator. ' . |
|
883 | + 'It seems you are trying to use `null` with =, >, <, or etc operator. '. |
|
884 | 884 | 'Use `is null` or `not null` instead.' |
885 | 885 | ); |
886 | 886 | assert(is_string($value), "Only strings, booleans and integers are supported."); |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | */ |
209 | 209 | public function withIndexesFilter(array $indexes): CrudInterface |
210 | 210 | { |
211 | - assert(call_user_func(function () use ($indexes) { |
|
211 | + assert(call_user_func(function() use ($indexes) { |
|
212 | 212 | $allOk = true; |
213 | 213 | |
214 | 214 | foreach ($indexes as $index) { |
@@ -760,7 +760,7 @@ discard block |
||
760 | 760 | $classAtPath = new ArrayObject(); |
761 | 761 | $idsAtPath = new ArrayObject(); |
762 | 762 | |
763 | - $registerModelAtRoot = function ($model) use ($modelStorage, $modelsAtPath, $idsAtPath): void { |
|
763 | + $registerModelAtRoot = function($model) use ($modelStorage, $modelsAtPath, $idsAtPath): void { |
|
764 | 764 | self::registerModelAtPath( |
765 | 765 | $model, |
766 | 766 | static::ROOT_PATH, |
@@ -848,7 +848,7 @@ discard block |
||
848 | 848 | assert(is_string($pathPiece)); |
849 | 849 | $parent = $tmpPath; |
850 | 850 | $tmpPath = empty($tmpPath) === true ? |
851 | - $pathPiece : $tmpPath . static::PATH_SEPARATOR . $pathPiece; |
|
851 | + $pathPiece : $tmpPath.static::PATH_SEPARATOR.$pathPiece; |
|
852 | 852 | $normalizedPaths[$tmpPath] = [$parent, $pathPiece]; |
853 | 853 | $pathsDepths[$parent] = $parentDepth++; |
854 | 854 | } |
@@ -1017,7 +1017,7 @@ discard block |
||
1017 | 1017 | ): ModelQueryBuilder { |
1018 | 1018 | assert( |
1019 | 1019 | $this->getModelSchemas()->hasRelationship($this->getModelClass(), $relationshipName), |
1020 | - "Relationship `$relationshipName` do not exist in model `" . $this->getModelClass() . '`' |
|
1020 | + "Relationship `$relationshipName` do not exist in model `".$this->getModelClass().'`' |
|
1021 | 1021 | ); |
1022 | 1022 | |
1023 | 1023 | // as we read data from a relationship our main table and model would be the table/model in the relationship |
@@ -1035,7 +1035,7 @@ discard block |
||
1035 | 1035 | if ($this->hasFilters() === true) { |
1036 | 1036 | $filters = $this->getFilters(); |
1037 | 1037 | $sorts = $this->getSorts(); |
1038 | - $joinCondition = $this->areFiltersWithAnd() === true ? ModelQueryBuilder::AND : ModelQueryBuilder::OR; |
|
1038 | + $joinCondition = $this->areFiltersWithAnd() === true ? ModelQueryBuilder:: AND : ModelQueryBuilder:: OR ; |
|
1039 | 1039 | $builder->addRelationshipFiltersAndSorts($reverseRelName, $filters, $sorts, $joinCondition); |
1040 | 1040 | } |
1041 | 1041 | // ... and the input filters to actual data we select |
@@ -1066,7 +1066,7 @@ discard block |
||
1066 | 1066 | ) { |
1067 | 1067 | assert( |
1068 | 1068 | $this->getModelSchemas()->hasRelationship($this->getModelClass(), $name), |
1069 | - "Relationship `$name` do not exist in model `" . $this->getModelClass() . '`' |
|
1069 | + "Relationship `$name` do not exist in model `".$this->getModelClass().'`' |
|
1070 | 1070 | ); |
1071 | 1071 | |
1072 | 1072 | // depending on the relationship type we expect the result to be either single resource or a collection |
@@ -1095,7 +1095,7 @@ discard block |
||
1095 | 1095 | ): array { |
1096 | 1096 | assert( |
1097 | 1097 | $this->getModelSchemas()->hasRelationship($this->getModelClass(), $name), |
1098 | - "Relationship `$name` do not exist in model `" . $this->getModelClass() . '`' |
|
1098 | + "Relationship `$name` do not exist in model `".$this->getModelClass().'`' |
|
1099 | 1099 | ); |
1100 | 1100 | |
1101 | 1101 | // depending on the relationship type we expect the result to be either single resource or a collection |
@@ -1171,7 +1171,7 @@ discard block |
||
1171 | 1171 | |
1172 | 1172 | $this->clearFetchParameters(); |
1173 | 1173 | |
1174 | - return (int)$deleted; |
|
1174 | + return (int) $deleted; |
|
1175 | 1175 | } |
1176 | 1176 | |
1177 | 1177 | /** |
@@ -1187,7 +1187,7 @@ discard block |
||
1187 | 1187 | |
1188 | 1188 | $this->clearFetchParameters(); |
1189 | 1189 | |
1190 | - return (int)$deleted > 0; |
|
1190 | + return (int) $deleted > 0; |
|
1191 | 1191 | } |
1192 | 1192 | |
1193 | 1193 | /** |
@@ -1212,7 +1212,7 @@ discard block |
||
1212 | 1212 | |
1213 | 1213 | $this->clearBuilderParameters()->clearFetchParameters(); |
1214 | 1214 | |
1215 | - $this->inTransaction(function () use ($saveMain, $toMany, &$index) { |
|
1215 | + $this->inTransaction(function() use ($saveMain, $toMany, &$index) { |
|
1216 | 1216 | $saveMain->execute(); |
1217 | 1217 | |
1218 | 1218 | // if no index given will use last insert ID as index |
@@ -1253,12 +1253,12 @@ discard block |
||
1253 | 1253 | ->createBuilder($this->getModelClass()) |
1254 | 1254 | ->updateModels($allowedChanges) |
1255 | 1255 | ->addFiltersWithAndToTable($filters); |
1256 | - $saveMain = $this->builderSaveResourceOnUpdate($saveMain); |
|
1256 | + $saveMain = $this->builderSaveResourceOnUpdate($saveMain); |
|
1257 | 1257 | $saveMain->getSQL(); // prepare |
1258 | 1258 | |
1259 | 1259 | $this->clearBuilderParameters()->clearFetchParameters(); |
1260 | 1260 | |
1261 | - $this->inTransaction(function () use ($saveMain, $toMany, $index, &$updated) { |
|
1261 | + $this->inTransaction(function() use ($saveMain, $toMany, $index, &$updated) { |
|
1262 | 1262 | $updated = $saveMain->execute(); |
1263 | 1263 | |
1264 | 1264 | $builderHook = Closure::fromCallable([$this, 'builderSaveRelationshipOnUpdate']); |
@@ -1274,7 +1274,7 @@ discard block |
||
1274 | 1274 | )->execute(); |
1275 | 1275 | |
1276 | 1276 | // add new ones |
1277 | - $updated += $this->addInToManyRelationship( |
|
1277 | + $updated += $this->addInToManyRelationship( |
|
1278 | 1278 | $connection, |
1279 | 1279 | $index, |
1280 | 1280 | $relationshipName, |
@@ -1284,7 +1284,7 @@ discard block |
||
1284 | 1284 | } |
1285 | 1285 | }); |
1286 | 1286 | |
1287 | - return (int)$updated; |
|
1287 | + return (int) $updated; |
|
1288 | 1288 | } |
1289 | 1289 | |
1290 | 1290 | /** |
@@ -1299,9 +1299,9 @@ discard block |
||
1299 | 1299 | public function createInBelongsToManyRelationship(string $parentId, string $name, iterable $childIds): int |
1300 | 1300 | { |
1301 | 1301 | // Check that relationship is `BelongsToMany` |
1302 | - assert(call_user_func(function () use ($name): bool { |
|
1302 | + assert(call_user_func(function() use ($name): bool { |
|
1303 | 1303 | $relType = $this->getModelSchemas()->getRelationshipType($this->getModelClass(), $name); |
1304 | - $errMsg = "Relationship `$name` of class `" . $this->getModelClass() . |
|
1304 | + $errMsg = "Relationship `$name` of class `".$this->getModelClass(). |
|
1305 | 1305 | '` either is not `belongsToMany` or do not exist in the class.'; |
1306 | 1306 | $isOk = $relType === RelationshipTypes::BELONGS_TO_MANY; |
1307 | 1307 | |
@@ -1323,9 +1323,9 @@ discard block |
||
1323 | 1323 | public function removeInBelongsToManyRelationship(string $parentId, string $name, iterable $childIds): int |
1324 | 1324 | { |
1325 | 1325 | // Check that relationship is `BelongsToMany` |
1326 | - assert(call_user_func(function () use ($name): bool { |
|
1326 | + assert(call_user_func(function() use ($name): bool { |
|
1327 | 1327 | $relType = $this->getModelSchemas()->getRelationshipType($this->getModelClass(), $name); |
1328 | - $errMsg = "Relationship `$name` of class `" . $this->getModelClass() . |
|
1328 | + $errMsg = "Relationship `$name` of class `".$this->getModelClass(). |
|
1329 | 1329 | '` either is not `belongsToMany` or do not exist in the class.'; |
1330 | 1330 | $isOk = $relType === RelationshipTypes::BELONGS_TO_MANY; |
1331 | 1331 | |
@@ -1493,7 +1493,7 @@ discard block |
||
1493 | 1493 | { |
1494 | 1494 | $countBuilder = $this->createBuilder($this->getModelClass()); |
1495 | 1495 | $countBuilder->setParameters($builder->getParameters()); |
1496 | - $countBuilder->select('COUNT(*)')->from('(' . $builder->getSQL() . ') AS RESULT'); |
|
1496 | + $countBuilder->select('COUNT(*)')->from('('.$builder->getSQL().') AS RESULT'); |
|
1497 | 1497 | |
1498 | 1498 | return $countBuilder; |
1499 | 1499 | } |
@@ -1525,7 +1525,7 @@ discard block |
||
1525 | 1525 | |
1526 | 1526 | foreach ($secondaryIdentities as $secondaryId) { |
1527 | 1527 | try { |
1528 | - $inserted += (int)$saveToMany->setParameter($secondaryIdBindName, $secondaryId)->execute(); |
|
1528 | + $inserted += (int) $saveToMany->setParameter($secondaryIdBindName, $secondaryId)->execute(); |
|
1529 | 1529 | } /** @noinspection PhpRedundantCatchClauseInspection */ catch (UcvException $exception) { |
1530 | 1530 | // Spec: If all of the specified resources can be added to, or are already present in, |
1531 | 1531 | // the relationship then the server MUST return a successful response. |
@@ -1772,7 +1772,7 @@ discard block |
||
1772 | 1772 | |
1773 | 1773 | $pkName = $this->getModelSchemas()->getPrimaryKey($parentClass); |
1774 | 1774 | |
1775 | - $registerModelAtPath = function ($model, string $path) use ($deDup, $modelsAtPath, $idsAtPath) { |
|
1775 | + $registerModelAtPath = function($model, string $path) use ($deDup, $modelsAtPath, $idsAtPath) { |
|
1776 | 1776 | return self::registerModelAtPath( |
1777 | 1777 | $model, |
1778 | 1778 | $path, |
@@ -1784,7 +1784,7 @@ discard block |
||
1784 | 1784 | }; |
1785 | 1785 | |
1786 | 1786 | foreach ($childRelationships as $name) { |
1787 | - $childrenPath = $parentsPath !== static::ROOT_PATH ? $parentsPath . static::PATH_SEPARATOR . $name : $name; |
|
1787 | + $childrenPath = $parentsPath !== static::ROOT_PATH ? $parentsPath.static::PATH_SEPARATOR.$name : $name; |
|
1788 | 1788 | |
1789 | 1789 | $relationshipType = $this->getModelSchemas()->getRelationshipType($parentClass, $name); |
1790 | 1790 | list ($targetModelClass, $reverseRelName) = |
@@ -1839,7 +1839,7 @@ discard block |
||
1839 | 1839 | [$pkName => [FilterParameterInterface::OPERATION_EQUALS => [$parent->{$pkName}]]], |
1840 | 1840 | [] |
1841 | 1841 | ); |
1842 | - $children = $this->fetchPaginatedResourcesWithoutRelationships( |
|
1842 | + $children = $this->fetchPaginatedResourcesWithoutRelationships( |
|
1843 | 1843 | $clonedBuilder, |
1844 | 1844 | $clonedBuilder->getModelClass() |
1845 | 1845 | ); |