@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | /** |
69 | 69 | * @inheritdoc |
70 | 70 | */ |
71 | - public function parseParameters(?array $parameters): array |
|
71 | + public function parseParameters(? array $parameters) : array |
|
72 | 72 | { |
73 | 73 | if ($parameters === null) { |
74 | 74 | return [0, $this->getDefaultPageSize()]; |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | 0, |
82 | 82 | PHP_INT_MAX |
83 | 83 | ); |
84 | - $size = $this->getValue( |
|
84 | + $size = $this->getValue( |
|
85 | 85 | $parameters, |
86 | 86 | static::PARAM_PAGING_SIZE, |
87 | 87 | $this->getDefaultPageSize(), |
@@ -208,12 +208,12 @@ |
||
208 | 208 | return [static::DATA => $data->getData()]; |
209 | 209 | } |
210 | 210 | |
211 | - $buildUrl = function ($offset) use ($data, $uri) { |
|
211 | + $buildUrl = function($offset) use ($data, $uri) { |
|
212 | 212 | $paramsWithPaging = [ |
213 | 213 | PaginationStrategyInterface::PARAM_PAGING_SKIP => $offset, |
214 | 214 | PaginationStrategyInterface::PARAM_PAGING_SIZE => $data->getLimit(), |
215 | 215 | ]; |
216 | - $fullUrl = $uri . '?' . http_build_query($paramsWithPaging); |
|
216 | + $fullUrl = $uri.'?'.http_build_query($paramsWithPaging); |
|
217 | 217 | |
218 | 218 | return $fullUrl; |
219 | 219 | }; |
@@ -108,8 +108,8 @@ |
||
108 | 108 | ); |
109 | 109 | assert(empty($validatorsFileMask) === false, "Invalid Validators file mask `$validatorsFileMask`."); |
110 | 110 | |
111 | - $schemesPath = $schemesFolder . DIRECTORY_SEPARATOR . $schemesFileMask; |
|
112 | - $validatorsPath = $validatorsFolder . DIRECTORY_SEPARATOR . $validatorsFileMask; |
|
111 | + $schemesPath = $schemesFolder.DIRECTORY_SEPARATOR.$schemesFileMask; |
|
112 | + $validatorsPath = $validatorsFolder.DIRECTORY_SEPARATOR.$validatorsFileMask; |
|
113 | 113 | |
114 | 114 | $requireUniqueTypes = $defaults[static::KEY_SCHEMES_REQUIRE_UNIQUE_TYPES] ?? true; |
115 | 115 |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | public function getMappedIncludes(): iterable |
246 | 246 | { |
247 | 247 | $fromScheme = $this->getRootScheme(); |
248 | - $getMappedRelLinks = function (iterable $links) use ($fromScheme) : iterable { |
|
248 | + $getMappedRelLinks = function(iterable $links) use ($fromScheme) : iterable { |
|
249 | 249 | foreach ($links as $link) { |
250 | 250 | assert(is_string($link)); |
251 | 251 | $fromSchemaClass = get_class($fromScheme); |
@@ -289,14 +289,14 @@ discard block |
||
289 | 289 | // ['rel2_name1', ], |
290 | 290 | // ['rel3_name1', 'rel3_name2', 'rel3_name3', ], |
291 | 291 | // ] |
292 | - $includeAsModelNames = function (iterable $relationships): iterable { |
|
292 | + $includeAsModelNames = function(iterable $relationships): iterable { |
|
293 | 293 | foreach ($relationships as $relationship) { |
294 | 294 | assert($relationship instanceof RelationshipInterface); |
295 | 295 | yield $relationship->getNameInModel(); |
296 | 296 | } |
297 | 297 | }; |
298 | - $mappedIncludes = $this->getMappedIncludes(); |
|
299 | - $getIncludes = function () use ($mappedIncludes, $includeAsModelNames) : iterable { |
|
298 | + $mappedIncludes = $this->getMappedIncludes(); |
|
299 | + $getIncludes = function() use ($mappedIncludes, $includeAsModelNames) : iterable { |
|
300 | 300 | foreach ($mappedIncludes as $relationships) { |
301 | 301 | yield $includeAsModelNames($relationships); |
302 | 302 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | public function __construct(array $parameters = [], array $messages = null) |
49 | 49 | { |
50 | 50 | $this->setParameters($parameters); |
51 | - $this->messages = $messages; |
|
51 | + $this->messages = $messages; |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -69,13 +69,13 @@ discard block |
||
69 | 69 | public function getIncludes(): iterable |
70 | 70 | { |
71 | 71 | if (array_key_exists(static::PARAM_INCLUDE, $this->getParameters()) === true) { |
72 | - $splitByDot = function (string $path): iterable { |
|
72 | + $splitByDot = function(string $path): iterable { |
|
73 | 73 | foreach ($this->splitStringAndCheckNoEmpties(static::PARAM_INCLUDE, $path, '.') as $link) { |
74 | 74 | yield $link; |
75 | 75 | } |
76 | 76 | }; |
77 | 77 | |
78 | - $includes = $this->getParameters()[static::PARAM_INCLUDE]; |
|
78 | + $includes = $this->getParameters()[static::PARAM_INCLUDE]; |
|
79 | 79 | foreach ($this->splitCommaSeparatedStringAndCheckNoEmpties(static::PARAM_INCLUDE, $includes) as $path) { |
80 | 80 | yield $path => $splitByDot($path); |
81 | 81 | } |
@@ -49,22 +49,22 @@ discard block |
||
49 | 49 | |
50 | 50 | $container[FactoryInterface::class] = $factory; |
51 | 51 | |
52 | - $container[JsonSchemesInterface::class] = function (PsrContainerInterface $container) use ($factory) { |
|
52 | + $container[JsonSchemesInterface::class] = function(PsrContainerInterface $container) use ($factory) { |
|
53 | 53 | $settings = $container->get(SettingsProviderInterface::class)->get(FluteSettings::class); |
54 | 54 | $modelSchemes = $container->get(ModelSchemeInfoInterface::class); |
55 | 55 | |
56 | 56 | return $factory->createJsonSchemes($settings[FluteSettings::KEY_MODEL_TO_SCHEME_MAP], $modelSchemes); |
57 | 57 | }; |
58 | 58 | |
59 | - $container[QueryParserInterface::class] = function (PsrContainerInterface $container) { |
|
59 | + $container[QueryParserInterface::class] = function(PsrContainerInterface $container) { |
|
60 | 60 | return new QueryParser($container->get(PaginationStrategyInterface::class)); |
61 | 61 | }; |
62 | 62 | |
63 | - $container[ParametersMapperInterface::class] = function (PsrContainerInterface $container) { |
|
63 | + $container[ParametersMapperInterface::class] = function(PsrContainerInterface $container) { |
|
64 | 64 | return new ParametersMapper($container->get(JsonSchemesInterface::class)); |
65 | 65 | }; |
66 | 66 | |
67 | - $container[EncoderInterface::class] = function (PsrContainerInterface $container) use ($factory) { |
|
67 | + $container[EncoderInterface::class] = function(PsrContainerInterface $container) use ($factory) { |
|
68 | 68 | /** @var JsonSchemesInterface $jsonSchemes */ |
69 | 69 | $jsonSchemes = $container->get(JsonSchemesInterface::class); |
70 | 70 | $settings = $container->get(SettingsProviderInterface::class)->get(FluteSettings::class); |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | return $encoder; |
80 | 80 | }; |
81 | 81 | |
82 | - $container[PaginationStrategyInterface::class] = function (PsrContainerInterface $container) { |
|
82 | + $container[PaginationStrategyInterface::class] = function(PsrContainerInterface $container) { |
|
83 | 83 | $settings = $container->get(SettingsProviderInterface::class)->get(FluteSettings::class); |
84 | 84 | |
85 | 85 | return new PaginationStrategy( |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | ); |
89 | 89 | }; |
90 | 90 | |
91 | - $container[JsonApiValidatorFactoryInterface::class] = function (PsrContainerInterface $container) { |
|
91 | + $container[JsonApiValidatorFactoryInterface::class] = function(PsrContainerInterface $container) { |
|
92 | 92 | $factory = new JsonApiValidatorFactory($container); |
93 | 93 | |
94 | 94 | return $factory; |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | */ |
117 | 117 | public static function configureExceptionHandler(LimoncelloContainerInterface $container) |
118 | 118 | { |
119 | - $container[ThrowableHandlerInterface::class] = function (PsrContainerInterface $container) { |
|
119 | + $container[ThrowableHandlerInterface::class] = function(PsrContainerInterface $container) { |
|
120 | 120 | $appSettings = $container->get(SettingsProviderInterface::class)->get(A::class); |
121 | 121 | $fluteSettings = $container->get(SettingsProviderInterface::class)->get(FluteSettings::class); |
122 | 122 |
@@ -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 |
@@ -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."); |
@@ -674,7 +674,7 @@ discard block |
||
674 | 674 | assert(is_string($pathPiece)); |
675 | 675 | $parent = $tmpPath; |
676 | 676 | $tmpPath = empty($tmpPath) === true ? |
677 | - $pathPiece : $tmpPath . static::PATH_SEPARATOR . $pathPiece; |
|
677 | + $pathPiece : $tmpPath.static::PATH_SEPARATOR.$pathPiece; |
|
678 | 678 | $normalizedPaths[$tmpPath] = [$parent, $pathPiece]; |
679 | 679 | $pathsDepths[$parent] = $parentDepth++; |
680 | 680 | } |
@@ -842,8 +842,7 @@ discard block |
||
842 | 842 | $filters = $this->getFilters(); |
843 | 843 | $sorts = $this->getSorts(); |
844 | 844 | $this->areFiltersWithAnd() ? |
845 | - $builder->addRelationshipFiltersAndSortsWithAnd($reverseRelName, $filters, $sorts) : |
|
846 | - $builder->addRelationshipFiltersAndSortsWithOr($reverseRelName, $filters, $sorts); |
|
845 | + $builder->addRelationshipFiltersAndSortsWithAnd($reverseRelName, $filters, $sorts) : $builder->addRelationshipFiltersAndSortsWithOr($reverseRelName, $filters, $sorts); |
|
847 | 846 | } |
848 | 847 | // ... and the input filters to actual data we select |
849 | 848 | if ($relationshipFilters !== null) { |
@@ -962,7 +961,7 @@ discard block |
||
962 | 961 | |
963 | 962 | $this->clearFetchParameters(); |
964 | 963 | |
965 | - return (int)$deleted; |
|
964 | + return (int) $deleted; |
|
966 | 965 | } |
967 | 966 | |
968 | 967 | /** |
@@ -991,7 +990,7 @@ discard block |
||
991 | 990 | |
992 | 991 | $this->clearBuilderParameters()->clearFetchParameters(); |
993 | 992 | |
994 | - $this->inTransaction(function () use ($saveMain, $toMany, &$index) { |
|
993 | + $this->inTransaction(function() use ($saveMain, $toMany, &$index) { |
|
995 | 994 | $saveMain->execute(); |
996 | 995 | |
997 | 996 | // if no index given will use last insert ID as index |
@@ -1007,7 +1006,7 @@ discard block |
||
1007 | 1006 | ->prepareCreateInToManyRelationship($relationshipName, $index, $secondaryIdBindName) |
1008 | 1007 | ); |
1009 | 1008 | foreach ($secondaryIds as $secondaryId) { |
1010 | - $inserted += (int)$saveToMany->setParameter($secondaryIdBindName, $secondaryId)->execute(); |
|
1009 | + $inserted += (int) $saveToMany->setParameter($secondaryIdBindName, $secondaryId)->execute(); |
|
1011 | 1010 | } |
1012 | 1011 | } |
1013 | 1012 | }); |
@@ -1036,12 +1035,12 @@ discard block |
||
1036 | 1035 | ->createBuilder($this->getModelClass()) |
1037 | 1036 | ->updateModels($allowedChanges) |
1038 | 1037 | ->addFiltersWithAndToTable($filters); |
1039 | - $saveMain = $this->builderSaveResourceOnUpdate($saveMain); |
|
1038 | + $saveMain = $this->builderSaveResourceOnUpdate($saveMain); |
|
1040 | 1039 | $saveMain->getSQL(); // prepare |
1041 | 1040 | |
1042 | 1041 | $this->clearBuilderParameters()->clearFetchParameters(); |
1043 | 1042 | |
1044 | - $this->inTransaction(function () use ($saveMain, $toMany, $index, &$updated) { |
|
1043 | + $this->inTransaction(function() use ($saveMain, $toMany, $index, &$updated) { |
|
1045 | 1044 | $updated = $saveMain->execute(); |
1046 | 1045 | |
1047 | 1046 | foreach ($toMany as $relationshipName => $secondaryIds) { |
@@ -1061,12 +1060,12 @@ discard block |
||
1061 | 1060 | ->prepareCreateInToManyRelationship($relationshipName, $index, $secondaryIdBindName) |
1062 | 1061 | ); |
1063 | 1062 | foreach ($secondaryIds as $secondaryId) { |
1064 | - $updated += (int)$saveToMany->setParameter($secondaryIdBindName, $secondaryId)->execute(); |
|
1063 | + $updated += (int) $saveToMany->setParameter($secondaryIdBindName, $secondaryId)->execute(); |
|
1065 | 1064 | } |
1066 | 1065 | } |
1067 | 1066 | }); |
1068 | 1067 | |
1069 | - return (int)$updated; |
|
1068 | + return (int) $updated; |
|
1070 | 1069 | } |
1071 | 1070 | |
1072 | 1071 | /** |
@@ -1150,7 +1149,7 @@ discard block |
||
1150 | 1149 | /** |
1151 | 1150 | * @inheritdoc |
1152 | 1151 | */ |
1153 | - public function fetchRow(QueryBuilder $builder, string $modelClass): ?array |
|
1152 | + public function fetchRow(QueryBuilder $builder, string $modelClass): ? array |
|
1154 | 1153 | { |
1155 | 1154 | $model = null; |
1156 | 1155 | |
@@ -1300,7 +1299,7 @@ discard block |
||
1300 | 1299 | * |
1301 | 1300 | * @return iterable |
1302 | 1301 | */ |
1303 | - protected function filterAttributesOnCreate(?string $index, iterable $attributes): iterable |
|
1302 | + protected function filterAttributesOnCreate(?string $index, iterable $attributes) : iterable |
|
1304 | 1303 | { |
1305 | 1304 | if ($index !== null) { |
1306 | 1305 | $pkName = $this->getModelSchemes()->getPrimaryKey($this->getModelClass()); |
@@ -1359,7 +1358,7 @@ discard block |
||
1359 | 1358 | $pkName = $this->getModelSchemes()->getPrimaryKey($parentClass); |
1360 | 1359 | |
1361 | 1360 | foreach ($childRelationships as $name) { |
1362 | - $childrenPath = $parentsPath !== static::ROOT_PATH ? $parentsPath . static::PATH_SEPARATOR . $name : $name; |
|
1361 | + $childrenPath = $parentsPath !== static::ROOT_PATH ? $parentsPath.static::PATH_SEPARATOR.$name : $name; |
|
1363 | 1362 | |
1364 | 1363 | $relationshipType = $this->getModelSchemes()->getRelationshipType($parentClass, $name); |
1365 | 1364 | list ($targetModelClass, $reverseRelName) = |
@@ -1380,7 +1379,7 @@ discard block |
||
1380 | 1379 | [$pkName => [FilterParameterInterface::OPERATION_EQUALS => [$parent->{$pkName}]]], |
1381 | 1380 | [] |
1382 | 1381 | ); |
1383 | - $child = $deDup->register($this->fetchResourceWithoutRelationships( |
|
1382 | + $child = $deDup->register($this->fetchResourceWithoutRelationships( |
|
1384 | 1383 | $clonedBuilder, |
1385 | 1384 | $clonedBuilder->getModelClass() |
1386 | 1385 | )); |
@@ -1401,7 +1400,7 @@ discard block |
||
1401 | 1400 | [$pkName => [FilterParameterInterface::OPERATION_EQUALS => [$parent->{$pkName}]]], |
1402 | 1401 | [] |
1403 | 1402 | ); |
1404 | - $children = $this->fetchPaginatedResourcesWithoutRelationships( |
|
1403 | + $children = $this->fetchPaginatedResourcesWithoutRelationships( |
|
1405 | 1404 | $clonedBuilder, |
1406 | 1405 | $clonedBuilder->getModelClass() |
1407 | 1406 | ); |