@@ -77,8 +77,7 @@ |
||
77 | 77 | assert(is_scalar($index) === true && is_scalar($type) === true); |
78 | 78 | $expectedType = $context->getProperties()->getProperty(self::PROPERTY_RESOURCE_TYPE); |
79 | 79 | $reply = $type === $expectedType ? |
80 | - BlockReplies::createSuccessReply($index) : |
|
81 | - BlockReplies::createErrorReply($context, $type, ErrorCodes::INVALID_RELATIONSHIP_TYPE); |
|
80 | + BlockReplies::createSuccessReply($index) : BlockReplies::createErrorReply($context, $type, ErrorCodes::INVALID_RELATIONSHIP_TYPE); |
|
82 | 81 | |
83 | 82 | return $reply; |
84 | 83 | } |
@@ -101,8 +101,7 @@ |
||
101 | 101 | } |
102 | 102 | |
103 | 103 | $reply = $count <= 0 ? |
104 | - BlockReplies::createSuccessReply($value) : |
|
105 | - BlockReplies::createErrorReply($context, $value, ErrorCodes::UNIQUE_IN_DATABASE_SINGLE); |
|
104 | + BlockReplies::createSuccessReply($value) : BlockReplies::createErrorReply($context, $value, ErrorCodes::UNIQUE_IN_DATABASE_SINGLE); |
|
106 | 105 | |
107 | 106 | return $reply; |
108 | 107 | } |
@@ -101,8 +101,7 @@ |
||
101 | 101 | } |
102 | 102 | |
103 | 103 | $reply = $count > 0 ? |
104 | - BlockReplies::createSuccessReply($value) : |
|
105 | - BlockReplies::createErrorReply($context, $value, ErrorCodes::EXIST_IN_DATABASE_SINGLE); |
|
104 | + BlockReplies::createSuccessReply($value) : BlockReplies::createErrorReply($context, $value, ErrorCodes::EXIST_IN_DATABASE_SINGLE); |
|
106 | 105 | |
107 | 106 | return $reply; |
108 | 107 | } |
@@ -378,7 +378,7 @@ |
||
378 | 378 | /** |
379 | 379 | * @return int[]|null |
380 | 380 | */ |
381 | - private function getAttributeRules(): ?array |
|
381 | + private function getAttributeRules(): ? array |
|
382 | 382 | { |
383 | 383 | return $this->attributeRules; |
384 | 384 | } |
@@ -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 | 298 | $mappedIncludes = $this->getMappedIncludes(); |
299 | - $getIncludes = function () use ($mappedIncludes, $includeAsModelNames) : iterable { |
|
299 | + $getIncludes = function() use ($mappedIncludes, $includeAsModelNames) : iterable { |
|
300 | 300 | foreach ($mappedIncludes as $relationships) { |
301 | 301 | yield $includeAsModelNames($relationships); |
302 | 302 | } |
@@ -54,22 +54,22 @@ discard block |
||
54 | 54 | |
55 | 55 | $container[FactoryInterface::class] = $factory; |
56 | 56 | |
57 | - $container[JsonSchemesInterface::class] = function (PsrContainerInterface $container) use ($factory) { |
|
57 | + $container[JsonSchemesInterface::class] = function(PsrContainerInterface $container) use ($factory) { |
|
58 | 58 | $settings = $container->get(SettingsProviderInterface::class)->get(FluteSettings::class); |
59 | 59 | $modelSchemes = $container->get(ModelSchemeInfoInterface::class); |
60 | 60 | |
61 | 61 | return $factory->createJsonSchemes($settings[FluteSettings::KEY_MODEL_TO_SCHEME_MAP], $modelSchemes); |
62 | 62 | }; |
63 | 63 | |
64 | - $container[QueryParserInterface::class] = function (PsrContainerInterface $container) { |
|
64 | + $container[QueryParserInterface::class] = function(PsrContainerInterface $container) { |
|
65 | 65 | return new QueryParser($container->get(PaginationStrategyInterface::class)); |
66 | 66 | }; |
67 | 67 | |
68 | - $container[ParametersMapperInterface::class] = function (PsrContainerInterface $container) { |
|
68 | + $container[ParametersMapperInterface::class] = function(PsrContainerInterface $container) { |
|
69 | 69 | return new ParametersMapper($container->get(JsonSchemesInterface::class)); |
70 | 70 | }; |
71 | 71 | |
72 | - $container[EncoderInterface::class] = function (PsrContainerInterface $container) use ($factory) { |
|
72 | + $container[EncoderInterface::class] = function(PsrContainerInterface $container) use ($factory) { |
|
73 | 73 | /** @var JsonSchemesInterface $jsonSchemes */ |
74 | 74 | $jsonSchemes = $container->get(JsonSchemesInterface::class); |
75 | 75 | $settings = $container->get(SettingsProviderInterface::class)->get(FluteSettings::class); |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | return $encoder; |
85 | 85 | }; |
86 | 86 | |
87 | - $container[PaginationStrategyInterface::class] = function (PsrContainerInterface $container) { |
|
87 | + $container[PaginationStrategyInterface::class] = function(PsrContainerInterface $container) { |
|
88 | 88 | $settings = $container->get(SettingsProviderInterface::class)->get(FluteSettings::class); |
89 | 89 | |
90 | 90 | return new PaginationStrategy( |
@@ -93,19 +93,19 @@ discard block |
||
93 | 93 | ); |
94 | 94 | }; |
95 | 95 | |
96 | - $container[JsonApiValidatorFactoryInterface::class] = function (PsrContainerInterface $container) { |
|
96 | + $container[JsonApiValidatorFactoryInterface::class] = function(PsrContainerInterface $container) { |
|
97 | 97 | $factory = new JsonApiValidatorFactory($container); |
98 | 98 | |
99 | 99 | return $factory; |
100 | 100 | }; |
101 | 101 | |
102 | - $container[FormValidatorFactoryInterface::class] = function (PsrContainerInterface $container) { |
|
102 | + $container[FormValidatorFactoryInterface::class] = function(PsrContainerInterface $container) { |
|
103 | 103 | $factory = new FormValidatorFactory($container); |
104 | 104 | |
105 | 105 | return $factory; |
106 | 106 | }; |
107 | 107 | |
108 | - $container[QueryValidatorFactoryInterface::class] = function (PsrContainerInterface $container) { |
|
108 | + $container[QueryValidatorFactoryInterface::class] = function(PsrContainerInterface $container) { |
|
109 | 109 | /** @var PaginationStrategyInterface $paginationStrategy */ |
110 | 110 | $paginationStrategy = $container->get(PaginationStrategyInterface::class); |
111 | 111 | $settings = $container->get(SettingsProviderInterface::class)->get(FluteSettings::class); |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | */ |
138 | 138 | public static function configureExceptionHandler(LimoncelloContainerInterface $container) |
139 | 139 | { |
140 | - $container[ThrowableHandlerInterface::class] = function (PsrContainerInterface $container) { |
|
140 | + $container[ThrowableHandlerInterface::class] = function(PsrContainerInterface $container) { |
|
141 | 141 | /** @var CacheSettingsProviderInterface $provider */ |
142 | 142 | $provider = $container->get(CacheSettingsProviderInterface::class); |
143 | 143 | $appConfig = $provider->getApplicationConfiguration(); |
@@ -147,10 +147,10 @@ |
||
147 | 147 | ); |
148 | 148 | assert(empty($queryValFileMask) === false, "Invalid Query Validators file mask `$queryValFileMask`."); |
149 | 149 | |
150 | - $schemesPath = $schemesFolder . DIRECTORY_SEPARATOR . $schemesFileMask; |
|
151 | - $jsonValidatorsPath = $jsonValFolder . DIRECTORY_SEPARATOR . $jsonValFileMask; |
|
152 | - $formsValidatorsPath = $formsValFolder . DIRECTORY_SEPARATOR . $formsValFileMask; |
|
153 | - $queryValidatorsPath = $queryValFolder . DIRECTORY_SEPARATOR . $queryValFileMask; |
|
150 | + $schemesPath = $schemesFolder.DIRECTORY_SEPARATOR.$schemesFileMask; |
|
151 | + $jsonValidatorsPath = $jsonValFolder.DIRECTORY_SEPARATOR.$jsonValFileMask; |
|
152 | + $formsValidatorsPath = $formsValFolder.DIRECTORY_SEPARATOR.$formsValFileMask; |
|
153 | + $queryValidatorsPath = $queryValFolder.DIRECTORY_SEPARATOR.$queryValFileMask; |
|
154 | 154 | |
155 | 155 | $requireUniqueTypes = $defaults[static::KEY_SCHEMES_REQUIRE_UNIQUE_TYPES] ?? true; |
156 | 156 |
@@ -673,7 +673,7 @@ discard block |
||
673 | 673 | $classAtPath = new ArrayObject(); |
674 | 674 | $idsAtPath = new ArrayObject(); |
675 | 675 | |
676 | - $registerModelAtRoot = function ($model) use ($modelStorage, $modelsAtPath, $idsAtPath): void { |
|
676 | + $registerModelAtRoot = function($model) use ($modelStorage, $modelsAtPath, $idsAtPath): void { |
|
677 | 677 | self::registerModelAtPath( |
678 | 678 | $model, |
679 | 679 | static::ROOT_PATH, |
@@ -761,7 +761,7 @@ discard block |
||
761 | 761 | assert(is_string($pathPiece)); |
762 | 762 | $parent = $tmpPath; |
763 | 763 | $tmpPath = empty($tmpPath) === true ? |
764 | - $pathPiece : $tmpPath . static::PATH_SEPARATOR . $pathPiece; |
|
764 | + $pathPiece : $tmpPath.static::PATH_SEPARATOR.$pathPiece; |
|
765 | 765 | $normalizedPaths[$tmpPath] = [$parent, $pathPiece]; |
766 | 766 | $pathsDepths[$parent] = $parentDepth++; |
767 | 767 | } |
@@ -933,8 +933,7 @@ discard block |
||
933 | 933 | $filters = $this->getFilters(); |
934 | 934 | $sorts = $this->getSorts(); |
935 | 935 | $this->areFiltersWithAnd() ? |
936 | - $builder->addRelationshipFiltersAndSortsWithAnd($reverseRelName, $filters, $sorts) : |
|
937 | - $builder->addRelationshipFiltersAndSortsWithOr($reverseRelName, $filters, $sorts); |
|
936 | + $builder->addRelationshipFiltersAndSortsWithAnd($reverseRelName, $filters, $sorts) : $builder->addRelationshipFiltersAndSortsWithOr($reverseRelName, $filters, $sorts); |
|
938 | 937 | } |
939 | 938 | // ... and the input filters to actual data we select |
940 | 939 | if ($relationshipFilters !== null) { |
@@ -1053,7 +1052,7 @@ discard block |
||
1053 | 1052 | |
1054 | 1053 | $this->clearFetchParameters(); |
1055 | 1054 | |
1056 | - return (int)$deleted; |
|
1055 | + return (int) $deleted; |
|
1057 | 1056 | } |
1058 | 1057 | |
1059 | 1058 | /** |
@@ -1067,7 +1066,7 @@ discard block |
||
1067 | 1066 | |
1068 | 1067 | $this->clearFetchParameters(); |
1069 | 1068 | |
1070 | - return (int)$deleted > 0; |
|
1069 | + return (int) $deleted > 0; |
|
1071 | 1070 | } |
1072 | 1071 | |
1073 | 1072 | /** |
@@ -1088,7 +1087,7 @@ discard block |
||
1088 | 1087 | |
1089 | 1088 | $this->clearBuilderParameters()->clearFetchParameters(); |
1090 | 1089 | |
1091 | - $this->inTransaction(function () use ($saveMain, $toMany, &$index) { |
|
1090 | + $this->inTransaction(function() use ($saveMain, $toMany, &$index) { |
|
1092 | 1091 | $saveMain->execute(); |
1093 | 1092 | |
1094 | 1093 | // if no index given will use last insert ID as index |
@@ -1104,7 +1103,7 @@ discard block |
||
1104 | 1103 | ->prepareCreateInToManyRelationship($relationshipName, $index, $secondaryIdBindName) |
1105 | 1104 | ); |
1106 | 1105 | foreach ($secondaryIds as $secondaryId) { |
1107 | - $inserted += (int)$saveToMany->setParameter($secondaryIdBindName, $secondaryId)->execute(); |
|
1106 | + $inserted += (int) $saveToMany->setParameter($secondaryIdBindName, $secondaryId)->execute(); |
|
1108 | 1107 | } |
1109 | 1108 | } |
1110 | 1109 | }); |
@@ -1133,12 +1132,12 @@ discard block |
||
1133 | 1132 | ->createBuilder($this->getModelClass()) |
1134 | 1133 | ->updateModels($allowedChanges) |
1135 | 1134 | ->addFiltersWithAndToTable($filters); |
1136 | - $saveMain = $this->builderSaveResourceOnUpdate($saveMain); |
|
1135 | + $saveMain = $this->builderSaveResourceOnUpdate($saveMain); |
|
1137 | 1136 | $saveMain->getSQL(); // prepare |
1138 | 1137 | |
1139 | 1138 | $this->clearBuilderParameters()->clearFetchParameters(); |
1140 | 1139 | |
1141 | - $this->inTransaction(function () use ($saveMain, $toMany, $index, &$updated) { |
|
1140 | + $this->inTransaction(function() use ($saveMain, $toMany, $index, &$updated) { |
|
1142 | 1141 | $updated = $saveMain->execute(); |
1143 | 1142 | |
1144 | 1143 | foreach ($toMany as $relationshipName => $secondaryIds) { |
@@ -1158,12 +1157,12 @@ discard block |
||
1158 | 1157 | ->prepareCreateInToManyRelationship($relationshipName, $index, $secondaryIdBindName) |
1159 | 1158 | ); |
1160 | 1159 | foreach ($secondaryIds as $secondaryId) { |
1161 | - $updated += (int)$saveToMany->setParameter($secondaryIdBindName, $secondaryId)->execute(); |
|
1160 | + $updated += (int) $saveToMany->setParameter($secondaryIdBindName, $secondaryId)->execute(); |
|
1162 | 1161 | } |
1163 | 1162 | } |
1164 | 1163 | }); |
1165 | 1164 | |
1166 | - return (int)$updated; |
|
1165 | + return (int) $updated; |
|
1167 | 1166 | } |
1168 | 1167 | |
1169 | 1168 | /** |
@@ -1247,7 +1246,7 @@ discard block |
||
1247 | 1246 | /** |
1248 | 1247 | * @inheritdoc |
1249 | 1248 | */ |
1250 | - public function fetchRow(QueryBuilder $builder, string $modelClass): ?array |
|
1249 | + public function fetchRow(QueryBuilder $builder, string $modelClass): ? array |
|
1251 | 1250 | { |
1252 | 1251 | $model = null; |
1253 | 1252 | |
@@ -1427,7 +1426,7 @@ discard block |
||
1427 | 1426 | * |
1428 | 1427 | * @return iterable |
1429 | 1428 | */ |
1430 | - protected function filterAttributesOnCreate(?string $index, iterable $attributes): iterable |
|
1429 | + protected function filterAttributesOnCreate(?string $index, iterable $attributes) : iterable |
|
1431 | 1430 | { |
1432 | 1431 | if ($index !== null) { |
1433 | 1432 | $pkName = $this->getModelSchemes()->getPrimaryKey($this->getModelClass()); |
@@ -1487,7 +1486,7 @@ discard block |
||
1487 | 1486 | |
1488 | 1487 | $pkName = $this->getModelSchemes()->getPrimaryKey($parentClass); |
1489 | 1488 | |
1490 | - $registerModelAtPath = function ($model, string $path) use ($deDup, $modelsAtPath, $idsAtPath) { |
|
1489 | + $registerModelAtPath = function($model, string $path) use ($deDup, $modelsAtPath, $idsAtPath) { |
|
1491 | 1490 | return self::registerModelAtPath( |
1492 | 1491 | $model, |
1493 | 1492 | $path, |
@@ -1499,7 +1498,7 @@ discard block |
||
1499 | 1498 | }; |
1500 | 1499 | |
1501 | 1500 | foreach ($childRelationships as $name) { |
1502 | - $childrenPath = $parentsPath !== static::ROOT_PATH ? $parentsPath . static::PATH_SEPARATOR . $name : $name; |
|
1501 | + $childrenPath = $parentsPath !== static::ROOT_PATH ? $parentsPath.static::PATH_SEPARATOR.$name : $name; |
|
1503 | 1502 | |
1504 | 1503 | $relationshipType = $this->getModelSchemes()->getRelationshipType($parentClass, $name); |
1505 | 1504 | list ($targetModelClass, $reverseRelName) = |
@@ -1549,7 +1548,7 @@ discard block |
||
1549 | 1548 | [$pkName => [FilterParameterInterface::OPERATION_EQUALS => [$parent->{$pkName}]]], |
1550 | 1549 | [] |
1551 | 1550 | ); |
1552 | - $children = $this->fetchPaginatedResourcesWithoutRelationships( |
|
1551 | + $children = $this->fetchPaginatedResourcesWithoutRelationships( |
|
1553 | 1552 | $clonedBuilder, |
1554 | 1553 | $clonedBuilder->getModelClass() |
1555 | 1554 | ); |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | /** |
63 | 63 | * @inheritdoc |
64 | 64 | */ |
65 | - public function parseParameters(?array $parameters): array |
|
65 | + public function parseParameters(? array $parameters) : array |
|
66 | 66 | { |
67 | 67 | if ($parameters === null) { |
68 | 68 | return [0, $this->getDefaultPageSize()]; |
@@ -75,7 +75,7 @@ discard block |
||
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(), |