@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | |
| 126 | 126 | parse_str($this->getOriginalUri()->getQuery(), $queryParams); |
| 127 | 127 | |
| 128 | - return function ($offset) use ($pageSize, $queryParams) { |
|
| 128 | + return function($offset) use ($pageSize, $queryParams) { |
|
| 129 | 129 | $paramsWithPaging = array_merge($queryParams, [ |
| 130 | 130 | BaseQueryParserInterface::PARAM_PAGE => [ |
| 131 | 131 | JsonApiQueryValidatingParserInterface::PARAM_PAGING_OFFSET => $offset, |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | ], |
| 134 | 134 | ]); |
| 135 | 135 | $newUri = $this->getOriginalUri()->withQuery(http_build_query($paramsWithPaging)); |
| 136 | - $fullUrl = (string)$newUri; |
|
| 136 | + $fullUrl = (string) $newUri; |
|
| 137 | 137 | $link = $this->getFactory()->createLink($fullUrl, null, true); |
| 138 | 138 | |
| 139 | 139 | return $link; |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | ) { |
| 156 | 156 | assert( |
| 157 | 157 | in_array(JsonApiQueryRulesSerializerInterface::class, class_implements($serializerClass)), |
| 158 | - "`$serializerClass` should implement interface `" . JsonApiQueryRulesSerializerInterface::class . '`.' |
|
| 158 | + "`$serializerClass` should implement interface `".JsonApiQueryRulesSerializerInterface::class.'`.' |
|
| 159 | 159 | ); |
| 160 | 160 | |
| 161 | 161 | $parameters = []; |
@@ -571,7 +571,7 @@ discard block |
||
| 571 | 571 | { |
| 572 | 572 | // no validation rule means we should accept any input value |
| 573 | 573 | if ($ruleIndexes === null) { |
| 574 | - return is_numeric($value) === true ? (int)$value : 0; |
|
| 574 | + return is_numeric($value) === true ? (int) $value : 0; |
|
| 575 | 575 | } |
| 576 | 576 | |
| 577 | 577 | $ruleIndex = $this->serializerClass::readRuleMainIndex($ruleIndexes); |
@@ -582,7 +582,7 @@ discard block |
||
| 582 | 582 | |
| 583 | 583 | $validatedValue = $this->readSingleCapturedValue(); |
| 584 | 584 | |
| 585 | - return (int)$validatedValue; |
|
| 585 | + return (int) $validatedValue; |
|
| 586 | 586 | } |
| 587 | 587 | |
| 588 | 588 | /** |
@@ -448,7 +448,7 @@ discard block |
||
| 448 | 448 | } |
| 449 | 449 | |
| 450 | 450 | /** |
| 451 | - * @return iterable |
|
| 451 | + * @return Generator |
|
| 452 | 452 | * |
| 453 | 453 | * @SuppressWarnings(PHPMD.ElseExpression) |
| 454 | 454 | */ |
@@ -495,7 +495,7 @@ discard block |
||
| 495 | 495 | /** |
| 496 | 496 | * @param iterable $fieldsFromParent |
| 497 | 497 | * |
| 498 | - * @return iterable |
|
| 498 | + * @return Generator |
|
| 499 | 499 | * |
| 500 | 500 | * @SuppressWarnings(PHPMD.StaticAccess) |
| 501 | 501 | * @SuppressWarnings(PHPMD.ElseExpression) |
@@ -530,7 +530,7 @@ discard block |
||
| 530 | 530 | /** |
| 531 | 531 | * @param iterable $sortsFromParent |
| 532 | 532 | * |
| 533 | - * @return iterable |
|
| 533 | + * @return Generator |
|
| 534 | 534 | * |
| 535 | 535 | * @SuppressWarnings(PHPMD.StaticAccess) |
| 536 | 536 | * @SuppressWarnings(PHPMD.ElseExpression) |
@@ -562,7 +562,7 @@ discard block |
||
| 562 | 562 | /** |
| 563 | 563 | * @param iterable $includesFromParent |
| 564 | 564 | * |
| 565 | - * @return iterable |
|
| 565 | + * @return Generator |
|
| 566 | 566 | * |
| 567 | 567 | * @SuppressWarnings(PHPMD.StaticAccess) |
| 568 | 568 | * @SuppressWarnings(PHPMD.ElseExpression) |
@@ -592,7 +592,7 @@ discard block |
||
| 592 | 592 | } |
| 593 | 593 | |
| 594 | 594 | /** |
| 595 | - * @param iterable $iterable |
|
| 595 | + * @param Generator $iterable |
|
| 596 | 596 | * |
| 597 | 597 | * @return array |
| 598 | 598 | */ |
@@ -755,7 +755,7 @@ discard block |
||
| 755 | 755 | * @param int $ruleIndex |
| 756 | 756 | * @param iterable $values |
| 757 | 757 | * |
| 758 | - * @return iterable |
|
| 758 | + * @return Generator |
|
| 759 | 759 | */ |
| 760 | 760 | private function validateValues(int $ruleIndex, iterable $values): iterable |
| 761 | 761 | { |
@@ -770,9 +770,9 @@ discard block |
||
| 770 | 770 | |
| 771 | 771 | /** |
| 772 | 772 | * @param int $ruleIndex |
| 773 | - * @param iterable $opsAndArgs |
|
| 773 | + * @param Generator $opsAndArgs |
|
| 774 | 774 | * |
| 775 | - * @return iterable |
|
| 775 | + * @return Generator |
|
| 776 | 776 | */ |
| 777 | 777 | private function validateFilterArguments(int $ruleIndex, iterable $opsAndArgs): iterable |
| 778 | 778 | { |
@@ -936,7 +936,7 @@ discard block |
||
| 936 | 936 | * @param string $parameterName |
| 937 | 937 | * @param array $value |
| 938 | 938 | * |
| 939 | - * @return iterable |
|
| 939 | + * @return Generator |
|
| 940 | 940 | * |
| 941 | 941 | * @SuppressWarnings(PHPMD.ElseExpression) |
| 942 | 942 | */ |
@@ -212,12 +212,12 @@ |
||
| 212 | 212 | return [static::DATA => $data->getData()]; |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - $buildUrl = function ($offset) use ($data, $uri) { |
|
| 215 | + $buildUrl = function($offset) use ($data, $uri) { |
|
| 216 | 216 | $paramsWithPaging = [ |
| 217 | 217 | JsonApiQueryValidatingParserInterface::PARAM_PAGING_OFFSET => $offset, |
| 218 | 218 | JsonApiQueryValidatingParserInterface::PARAM_PAGING_LIMIT => $data->getLimit(), |
| 219 | 219 | ]; |
| 220 | - $fullUrl = $uri . '?' . http_build_query($paramsWithPaging); |
|
| 220 | + $fullUrl = $uri.'?'.http_build_query($paramsWithPaging); |
|
| 221 | 221 | |
| 222 | 222 | return $fullUrl; |
| 223 | 223 | }; |
@@ -269,7 +269,7 @@ |
||
| 269 | 269 | * @param FactoryInterface $errorFactory |
| 270 | 270 | * @param FormatterFactoryInterface $formatterFactory |
| 271 | 271 | * |
| 272 | - * @return ResponseInterface |
|
| 272 | + * @return string |
|
| 273 | 273 | */ |
| 274 | 274 | protected static function defaultCreate( |
| 275 | 275 | string $requestBody, |
@@ -792,7 +792,7 @@ discard block |
||
| 792 | 792 | */ |
| 793 | 793 | private static function assertClassValueDefined(?string $value): void |
| 794 | 794 | { |
| 795 | - assert(empty($value) === false, 'Value should be defined in `' . static::class . '`.'); |
|
| 795 | + assert(empty($value) === false, 'Value should be defined in `'.static::class.'`.'); |
|
| 796 | 796 | } |
| 797 | 797 | |
| 798 | 798 | /** |
@@ -805,7 +805,7 @@ discard block |
||
| 805 | 805 | { |
| 806 | 806 | assert( |
| 807 | 807 | array_key_exists($interface, class_implements($class)) === true, |
| 808 | - "Class `$class` should implement `" . $interface . '` interface.' |
|
| 808 | + "Class `$class` should implement `".$interface.'` interface.' |
|
| 809 | 809 | ); |
| 810 | 810 | } |
| 811 | 811 | } |
@@ -48,18 +48,18 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | $container[FactoryInterface::class] = $factory; |
| 50 | 50 | |
| 51 | - $container[JsonSchemasInterface::class] = function (PsrContainerInterface $container) use ($factory) { |
|
| 51 | + $container[JsonSchemasInterface::class] = function(PsrContainerInterface $container) use ($factory) { |
|
| 52 | 52 | $settings = $container->get(SettingsProviderInterface::class)->get(FluteSettings::class); |
| 53 | 53 | $modelSchemas = $container->get(ModelSchemaInfoInterface::class); |
| 54 | 54 | |
| 55 | 55 | return $factory->createJsonSchemas($settings[FluteSettings::KEY_MODEL_TO_SCHEMA_MAP], $modelSchemas); |
| 56 | 56 | }; |
| 57 | 57 | |
| 58 | - $container[ParametersMapperInterface::class] = function (PsrContainerInterface $container) { |
|
| 58 | + $container[ParametersMapperInterface::class] = function(PsrContainerInterface $container) { |
|
| 59 | 59 | return new ParametersMapper($container->get(JsonSchemasInterface::class)); |
| 60 | 60 | }; |
| 61 | 61 | |
| 62 | - $container[EncoderInterface::class] = function (PsrContainerInterface $container) use ($factory) { |
|
| 62 | + $container[EncoderInterface::class] = function(PsrContainerInterface $container) use ($factory) { |
|
| 63 | 63 | /** @var JsonSchemasInterface $jsonSchemas */ |
| 64 | 64 | $jsonSchemas = $container->get(JsonSchemasInterface::class); |
| 65 | 65 | $settings = $container->get(SettingsProviderInterface::class)->get(FluteSettings::class); |
@@ -74,19 +74,19 @@ discard block |
||
| 74 | 74 | return $encoder; |
| 75 | 75 | }; |
| 76 | 76 | |
| 77 | - $container[RelationshipPaginationStrategyInterface::class] = function (PsrContainerInterface $container) { |
|
| 77 | + $container[RelationshipPaginationStrategyInterface::class] = function(PsrContainerInterface $container) { |
|
| 78 | 78 | $settings = $container->get(SettingsProviderInterface::class)->get(FluteSettings::class); |
| 79 | 79 | |
| 80 | 80 | return new BasicRelationshipPaginationStrategy($settings[FluteSettings::KEY_DEFAULT_PAGING_SIZE]); |
| 81 | 81 | }; |
| 82 | 82 | |
| 83 | - $container[JsonApiParserFactoryInterface::class] = function (PsrContainerInterface $container) { |
|
| 83 | + $container[JsonApiParserFactoryInterface::class] = function(PsrContainerInterface $container) { |
|
| 84 | 84 | $factory = new JsonApiParserFactory($container); |
| 85 | 85 | |
| 86 | 86 | return $factory; |
| 87 | 87 | }; |
| 88 | 88 | |
| 89 | - $container[FormValidatorFactoryInterface::class] = function (PsrContainerInterface $container) { |
|
| 89 | + $container[FormValidatorFactoryInterface::class] = function(PsrContainerInterface $container) { |
|
| 90 | 90 | $factory = new FormValidatorFactory($container); |
| 91 | 91 | |
| 92 | 92 | return $factory; |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | */ |
| 105 | 105 | public static function configureExceptionHandler(LimoncelloContainerInterface $container) |
| 106 | 106 | { |
| 107 | - $container[ThrowableHandlerInterface::class] = function (PsrContainerInterface $container) { |
|
| 107 | + $container[ThrowableHandlerInterface::class] = function(PsrContainerInterface $container) { |
|
| 108 | 108 | /** @var CacheSettingsProviderInterface $provider */ |
| 109 | 109 | $provider = $container->get(CacheSettingsProviderInterface::class); |
| 110 | 110 | $appConfig = $provider->getApplicationConfiguration(); |
@@ -111,10 +111,10 @@ |
||
| 111 | 111 | ); |
| 112 | 112 | assert(empty($jsonQueryValFileMask) === false, "Invalid Query Validators file mask `$jsonQueryValFileMask`."); |
| 113 | 113 | |
| 114 | - $schemasPath = $schemasFolder . DIRECTORY_SEPARATOR . $schemasFileMask; |
|
| 115 | - $jsonDataValPath = $jsonDataValFolder . DIRECTORY_SEPARATOR . $jsonDataValFileMask; |
|
| 116 | - $formsValidatorsPath = $formsValFolder . DIRECTORY_SEPARATOR . $formsValFileMask; |
|
| 117 | - $jsonQueryValPath = $jsonQueryValFolder . DIRECTORY_SEPARATOR . $jsonQueryValFileMask; |
|
| 114 | + $schemasPath = $schemasFolder.DIRECTORY_SEPARATOR.$schemasFileMask; |
|
| 115 | + $jsonDataValPath = $jsonDataValFolder.DIRECTORY_SEPARATOR.$jsonDataValFileMask; |
|
| 116 | + $formsValidatorsPath = $formsValFolder.DIRECTORY_SEPARATOR.$formsValFileMask; |
|
| 117 | + $jsonQueryValPath = $jsonQueryValFolder.DIRECTORY_SEPARATOR.$jsonQueryValFileMask; |
|
| 118 | 118 | |
| 119 | 119 | $requireUniqueTypes = $defaults[static::KEY_SCHEMAS_REQUIRE_UNIQUE_TYPES] ?? true; |
| 120 | 120 | |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | static::assertClassValueDefined(static::SCHEMA_CLASS); |
| 209 | 209 | |
| 210 | 210 | $api = static::defaultCreateApi($container, static::API_CLASS); |
| 211 | - $handler = function () use ($api, $index, $modelRelName) { |
|
| 211 | + $handler = function() use ($api, $index, $modelRelName) { |
|
| 212 | 212 | return $api->readRelationship($index, $modelRelName); |
| 213 | 213 | }; |
| 214 | 214 | |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | static::assertClassValueDefined(static::SCHEMA_CLASS); |
| 249 | 249 | |
| 250 | 250 | $api = static::defaultCreateApi($container, static::API_CLASS); |
| 251 | - $handler = function () use ($api, $index, $modelRelName) { |
|
| 251 | + $handler = function() use ($api, $index, $modelRelName) { |
|
| 252 | 252 | return $api->readRelationship($index, $modelRelName); |
| 253 | 253 | }; |
| 254 | 254 | |
@@ -48,11 +48,11 @@ discard block |
||
| 48 | 48 | assert(class_exists($controllerClass) === true); |
| 49 | 49 | |
| 50 | 50 | $groupPrefix = $group->getUriPrefix(); |
| 51 | - $indexSlug = '/{' . JCI::ROUTE_KEY_INDEX . '}'; |
|
| 52 | - $params = function (string $method) use ($groupPrefix, $resourceName): array { |
|
| 51 | + $indexSlug = '/{'.JCI::ROUTE_KEY_INDEX.'}'; |
|
| 52 | + $params = function(string $method) use ($groupPrefix, $resourceName): array { |
|
| 53 | 53 | return [RouteInterface::PARAM_NAME => static::routeName($groupPrefix, $resourceName, $method)]; |
| 54 | 54 | }; |
| 55 | - $handler = function (string $method) use ($controllerClass): array { |
|
| 55 | + $handler = function(string $method) use ($controllerClass): array { |
|
| 56 | 56 | return [$controllerClass, $method]; |
| 57 | 57 | }; |
| 58 | 58 | |
@@ -65,13 +65,13 @@ discard block |
||
| 65 | 65 | $group->post($resourceName, $handler(JCI::METHOD_CREATE), $params(JCI::METHOD_CREATE)); |
| 66 | 66 | } |
| 67 | 67 | if (in_array(ControllerReadInterface::class, $classInterfaces) === true) { |
| 68 | - $group->get($resourceName . $indexSlug, $handler(JCI::METHOD_READ), $params(JCI::METHOD_READ)); |
|
| 68 | + $group->get($resourceName.$indexSlug, $handler(JCI::METHOD_READ), $params(JCI::METHOD_READ)); |
|
| 69 | 69 | } |
| 70 | 70 | if (in_array(ControllerUpdateInterface::class, $classInterfaces) === true) { |
| 71 | - $group->patch($resourceName . $indexSlug, $handler(JCI::METHOD_UPDATE), $params(JCI::METHOD_UPDATE)); |
|
| 71 | + $group->patch($resourceName.$indexSlug, $handler(JCI::METHOD_UPDATE), $params(JCI::METHOD_UPDATE)); |
|
| 72 | 72 | } |
| 73 | 73 | if (in_array(ControllerDeleteInterface::class, $classInterfaces) === true) { |
| 74 | - $group->delete($resourceName . $indexSlug, $handler(JCI::METHOD_DELETE), $params(JCI::METHOD_DELETE)); |
|
| 74 | + $group->delete($resourceName.$indexSlug, $handler(JCI::METHOD_DELETE), $params(JCI::METHOD_DELETE)); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | return $group; |
@@ -97,11 +97,11 @@ discard block |
||
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | $groupPrefix = $group->getUriPrefix(); |
| 100 | - $slugged = $subUri . '/{' . FCI::ROUTE_KEY_INDEX . '}'; |
|
| 101 | - $params = function (string $method) use ($groupPrefix, $subUri) : array { |
|
| 100 | + $slugged = $subUri.'/{'.FCI::ROUTE_KEY_INDEX.'}'; |
|
| 101 | + $params = function(string $method) use ($groupPrefix, $subUri) : array { |
|
| 102 | 102 | return [RouteInterface::PARAM_NAME => static::routeName($groupPrefix, $subUri, $method)]; |
| 103 | 103 | }; |
| 104 | - $handler = function (string $method) use ($controllerClass): array { |
|
| 104 | + $handler = function(string $method) use ($controllerClass): array { |
|
| 105 | 105 | return [$controllerClass, $method]; |
| 106 | 106 | }; |
| 107 | 107 | |
@@ -112,10 +112,10 @@ discard block |
||
| 112 | 112 | $group->get($subUri, $handler(FCI::METHOD_INDEX), $params(FCI::METHOD_INDEX)); |
| 113 | 113 | } |
| 114 | 114 | if (in_array(ControllerInstanceInterface::class, $classInterfaces) === true) { |
| 115 | - $group->get($subUri . $createSubUrl, $handler(FCI::METHOD_INSTANCE), $params(FCI::METHOD_INSTANCE)); |
|
| 115 | + $group->get($subUri.$createSubUrl, $handler(FCI::METHOD_INSTANCE), $params(FCI::METHOD_INSTANCE)); |
|
| 116 | 116 | } |
| 117 | 117 | if (in_array(ControllerCreateInterface::class, $classInterfaces) === true) { |
| 118 | - $group->post($subUri . $createSubUrl, $handler(FCI::METHOD_CREATE), $params(FCI::METHOD_CREATE)); |
|
| 118 | + $group->post($subUri.$createSubUrl, $handler(FCI::METHOD_CREATE), $params(FCI::METHOD_CREATE)); |
|
| 119 | 119 | } |
| 120 | 120 | if (in_array(ControllerReadInterface::class, $classInterfaces) === true) { |
| 121 | 121 | $group->get($slugged, $handler(FCI::METHOD_READ), $params(FCI::METHOD_READ)); |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | $group->post($slugged, $handler(FCI::METHOD_UPDATE), $params(FCI::METHOD_UPDATE)); |
| 125 | 125 | } |
| 126 | 126 | if (in_array(ControllerDeleteInterface::class, $classInterfaces) === true) { |
| 127 | - $deleteUri = $slugged . '/' . FCI::METHOD_DELETE; |
|
| 127 | + $deleteUri = $slugged.'/'.FCI::METHOD_DELETE; |
|
| 128 | 128 | $group->post($deleteUri, $handler(FCI::METHOD_DELETE), $params(FCI::METHOD_DELETE)); |
| 129 | 129 | } |
| 130 | 130 | |
@@ -150,14 +150,14 @@ discard block |
||
| 150 | 150 | /** @var string $controllerClass */ |
| 151 | 151 | /** @var string $schemaClass */ |
| 152 | 152 | |
| 153 | - $resourceIdUri = $resourceName . '/{' . JCI::ROUTE_KEY_INDEX . '}/'; |
|
| 154 | - $selfUri = $resourceIdUri . DocumentInterface::KEYWORD_RELATIONSHIPS . '/' . $relationshipName; |
|
| 153 | + $resourceIdUri = $resourceName.'/{'.JCI::ROUTE_KEY_INDEX.'}/'; |
|
| 154 | + $selfUri = $resourceIdUri.DocumentInterface::KEYWORD_RELATIONSHIPS.'/'.$relationshipName; |
|
| 155 | 155 | |
| 156 | 156 | return $group |
| 157 | 157 | // `self` |
| 158 | 158 | ->get($selfUri, [$controllerClass, $selfGetMethod]) |
| 159 | 159 | // `related` |
| 160 | - ->get($resourceIdUri . $relationshipName, [$controllerClass, $selfGetMethod]); |
|
| 160 | + ->get($resourceIdUri.$relationshipName, [$controllerClass, $selfGetMethod]); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | /** |
@@ -181,6 +181,6 @@ discard block |
||
| 181 | 181 | $subUri = substr($subUri, 0, -1); |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - return $prefix . $subUri . '::' . $method; |
|
| 184 | + return $prefix.$subUri.'::'.$method; |
|
| 185 | 185 | } |
| 186 | 186 | } |
@@ -71,8 +71,7 @@ |
||
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | $reply = $foundInvalidType === null ? |
| 74 | - static::createSuccessReply($indexes) : |
|
| 75 | - static::createErrorReply($context, $foundInvalidType, ErrorCodes::INVALID_RELATIONSHIP_TYPE); |
|
| 74 | + static::createSuccessReply($indexes) : static::createErrorReply($context, $foundInvalidType, ErrorCodes::INVALID_RELATIONSHIP_TYPE); |
|
| 76 | 75 | |
| 77 | 76 | return $reply; |
| 78 | 77 | } |