@@ -83,13 +83,12 @@ |
||
| 83 | 83 | ->where($builder->expr()->in($primaryName, $placeholders)) |
| 84 | 84 | ->execute(); |
| 85 | 85 | |
| 86 | - $count = (int)$statement->fetchColumn(); |
|
| 86 | + $count = (int) $statement->fetchColumn(); |
|
| 87 | 87 | $result = $count === count($values); |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | $reply = $result === true ? |
| 91 | - static::createSuccessReply($values) : |
|
| 92 | - static::createErrorReply($context, $values, ErrorCodes::EXIST_IN_DATABASE_MULTIPLE); |
|
| 91 | + static::createSuccessReply($values) : static::createErrorReply($context, $values, ErrorCodes::EXIST_IN_DATABASE_MULTIPLE); |
|
| 93 | 92 | |
| 94 | 93 | return $reply; |
| 95 | 94 | } |
@@ -242,12 +242,11 @@ discard block |
||
| 242 | 242 | $this->executeStarts($this->getSerializer()::readRuleStartIndexes($ruleIndexes)); |
| 243 | 243 | $ruleIndex = $this->getSerializer()::readRuleIndex($ruleIndexes); |
| 244 | 244 | $isFoundInToOne === true ? |
| 245 | - $this->validateAsToOneRelationship($ruleIndex, $name, $jsonData) : |
|
| 246 | - $this->validateAsToManyRelationship($ruleIndex, $name, $jsonData); |
|
| 245 | + $this->validateAsToOneRelationship($ruleIndex, $name, $jsonData) : $this->validateAsToManyRelationship($ruleIndex, $name, $jsonData); |
|
| 247 | 246 | $this->executeEnds($this->getSerializer()::readRuleEndIndexes($ruleIndexes)); |
| 248 | 247 | |
| 249 | 248 | if (count($this->getErrorAggregator()) > 0) { |
| 250 | - $status = JsonApiResponse::HTTP_CONFLICT; |
|
| 249 | + $status = JsonApiResponse::HTTP_CONFLICT; |
|
| 251 | 250 | foreach ($this->getErrorAggregator()->get() as $error) { |
| 252 | 251 | $this->getJsonApiErrorCollection()->addValidationRelationshipError($error, $status); |
| 253 | 252 | $this->addErrorStatus($status); |
@@ -362,7 +361,7 @@ discard block |
||
| 362 | 361 | |
| 363 | 362 | if (count($this->getErrorAggregator()) > 0) { |
| 364 | 363 | $title = $this->formatMessage(ErrorCodes::INVALID_VALUE); |
| 365 | - $status = JsonApiResponse::HTTP_CONFLICT; |
|
| 364 | + $status = JsonApiResponse::HTTP_CONFLICT; |
|
| 366 | 365 | foreach ($this->getErrorAggregator()->get() as $error) { |
| 367 | 366 | $details = $this->getMessage($error); |
| 368 | 367 | $this->getJsonApiErrorCollection()->addDataTypeError($title, $details, $status); |
@@ -453,7 +452,7 @@ discard block |
||
| 453 | 452 | $this->executeEnds($this->getSerializer()::readRulesEndIndexes($this->getAttributeRules())); |
| 454 | 453 | |
| 455 | 454 | if (count($this->getErrorAggregator()) > 0) { |
| 456 | - $status = JsonApiResponse::HTTP_UNPROCESSABLE_ENTITY; |
|
| 455 | + $status = JsonApiResponse::HTTP_UNPROCESSABLE_ENTITY; |
|
| 457 | 456 | foreach ($this->getErrorAggregator()->get() as $error) { |
| 458 | 457 | $this->getJsonApiErrorCollection()->addValidationAttributeError($error, $status); |
| 459 | 458 | } |
@@ -520,7 +519,7 @@ discard block |
||
| 520 | 519 | )); |
| 521 | 520 | |
| 522 | 521 | if (count($this->getErrorAggregator()) > 0) { |
| 523 | - $status = JsonApiResponse::HTTP_CONFLICT; |
|
| 522 | + $status = JsonApiResponse::HTTP_CONFLICT; |
|
| 524 | 523 | foreach ($this->getErrorAggregator()->get() as $error) { |
| 525 | 524 | $this->getJsonApiErrorCollection()->addValidationRelationshipError($error, $status); |
| 526 | 525 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | $container[FactoryInterface::class] = $factory; |
| 55 | 55 | |
| 56 | - $container[JsonSchemasInterface::class] = function (PsrContainerInterface $container) use ($factory) { |
|
| 56 | + $container[JsonSchemasInterface::class] = function(PsrContainerInterface $container) use ($factory) { |
|
| 57 | 57 | $settings = $container->get(SettingsProviderInterface::class)->get(FluteSettings::class); |
| 58 | 58 | $modelSchemas = $container->get(ModelSchemaInfoInterface::class); |
| 59 | 59 | |
@@ -64,11 +64,11 @@ discard block |
||
| 64 | 64 | ); |
| 65 | 65 | }; |
| 66 | 66 | |
| 67 | - $container[ParametersMapperInterface::class] = function (PsrContainerInterface $container) { |
|
| 67 | + $container[ParametersMapperInterface::class] = function(PsrContainerInterface $container) { |
|
| 68 | 68 | return new ParametersMapper($container->get(JsonSchemasInterface::class)); |
| 69 | 69 | }; |
| 70 | 70 | |
| 71 | - $container[EncoderInterface::class] = function (PsrContainerInterface $container) use ($factory) { |
|
| 71 | + $container[EncoderInterface::class] = function(PsrContainerInterface $container) use ($factory) { |
|
| 72 | 72 | /** @var JsonSchemasInterface $jsonSchemas */ |
| 73 | 73 | $jsonSchemas = $container->get(JsonSchemasInterface::class); |
| 74 | 74 | $settings = $container->get(SettingsProviderInterface::class)->get(FluteSettings::class); |
@@ -84,19 +84,19 @@ discard block |
||
| 84 | 84 | return $encoder; |
| 85 | 85 | }; |
| 86 | 86 | |
| 87 | - $container[RelationshipPaginationStrategyInterface::class] = function (PsrContainerInterface $container) { |
|
| 87 | + $container[RelationshipPaginationStrategyInterface::class] = function(PsrContainerInterface $container) { |
|
| 88 | 88 | $settings = $container->get(SettingsProviderInterface::class)->get(FluteSettings::class); |
| 89 | 89 | |
| 90 | 90 | return new BasicRelationshipPaginationStrategy($settings[FluteSettings::KEY_DEFAULT_PAGING_SIZE]); |
| 91 | 91 | }; |
| 92 | 92 | |
| 93 | - $container[JsonApiParserFactoryInterface::class] = function (PsrContainerInterface $container) { |
|
| 93 | + $container[JsonApiParserFactoryInterface::class] = function(PsrContainerInterface $container) { |
|
| 94 | 94 | $factory = new JsonApiParserFactory($container); |
| 95 | 95 | |
| 96 | 96 | return $factory; |
| 97 | 97 | }; |
| 98 | 98 | |
| 99 | - $container[FormValidatorFactoryInterface::class] = function (PsrContainerInterface $container) { |
|
| 99 | + $container[FormValidatorFactoryInterface::class] = function(PsrContainerInterface $container) { |
|
| 100 | 100 | $factory = new FormValidatorFactory($container); |
| 101 | 101 | |
| 102 | 102 | return $factory; |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | */ |
| 115 | 115 | public static function configureExceptionHandler(LimoncelloContainerInterface $container) |
| 116 | 116 | { |
| 117 | - $container[ThrowableHandlerInterface::class] = function (PsrContainerInterface $container) { |
|
| 117 | + $container[ThrowableHandlerInterface::class] = function(PsrContainerInterface $container) { |
|
| 118 | 118 | /** @var CacheSettingsProviderInterface $provider */ |
| 119 | 119 | $provider = $container->get(CacheSettingsProviderInterface::class); |
| 120 | 120 | $appConfig = $provider->getApplicationConfiguration(); |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | |
| 125 | 125 | parse_str($this->getOriginalUri()->getQuery(), $queryParams); |
| 126 | 126 | |
| 127 | - return function ($offset) use ($pageSize, $queryParams) { |
|
| 127 | + return function($offset) use ($pageSize, $queryParams) { |
|
| 128 | 128 | $paramsWithPaging = array_merge($queryParams, [ |
| 129 | 129 | BaseQueryParserInterface::PARAM_PAGE => [ |
| 130 | 130 | JsonApiQueryParserInterface::PARAM_PAGING_OFFSET => $offset, |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | ], |
| 133 | 133 | ]); |
| 134 | 134 | $newUri = $this->getOriginalUri()->withQuery(http_build_query($paramsWithPaging)); |
| 135 | - $fullUrl = (string)$newUri; |
|
| 135 | + $fullUrl = (string) $newUri; |
|
| 136 | 136 | $link = $this->getFactory()->createLink(false, $fullUrl, false); |
| 137 | 137 | |
| 138 | 138 | return $link; |
@@ -130,7 +130,7 @@ |
||
| 130 | 130 | $details = null; |
| 131 | 131 | if ($this->isDebug === true) { |
| 132 | 132 | $message = $throwable->getMessage(); |
| 133 | - $details = (string)$throwable; |
|
| 133 | + $details = (string) $throwable; |
|
| 134 | 134 | } |
| 135 | 135 | $errors->add(new Error(null, null, null, $httpCode, null, $message, $details)); |
| 136 | 136 | } |
@@ -235,14 +235,14 @@ discard block |
||
| 235 | 235 | // if we are here then relationship contains paginated data, so we have to add pagination links |
| 236 | 236 | $offset = $relationshipData->getOffset(); |
| 237 | 237 | $limit = $relationshipData->getLimit(); |
| 238 | - $urlPrefix = $this->getRelationshipSelfSubUrl($model, $jsonRelName) . '?'; |
|
| 239 | - $buildLink = function (int $offset, int $limit) use ($urlPrefix) : LinkInterface { |
|
| 238 | + $urlPrefix = $this->getRelationshipSelfSubUrl($model, $jsonRelName).'?'; |
|
| 239 | + $buildLink = function(int $offset, int $limit) use ($urlPrefix) : LinkInterface { |
|
| 240 | 240 | $paramsWithPaging = [ |
| 241 | 241 | JsonApiQueryParserInterface::PARAM_PAGING_OFFSET => $offset, |
| 242 | 242 | JsonApiQueryParserInterface::PARAM_PAGING_LIMIT => $limit, |
| 243 | 243 | ]; |
| 244 | 244 | |
| 245 | - $subUrl = $urlPrefix . http_build_query($paramsWithPaging); |
|
| 245 | + $subUrl = $urlPrefix.http_build_query($paramsWithPaging); |
|
| 246 | 246 | |
| 247 | 247 | return $this->getFactory()->createLink(true, $subUrl, false); |
| 248 | 248 | }; |
@@ -341,6 +341,6 @@ discard block |
||
| 341 | 341 | */ |
| 342 | 342 | private function getRelationshipSelfSubUrl(ModelInterface $model, string $jsonRelName): string |
| 343 | 343 | { |
| 344 | - return $this->getSelfSubUrl($model) . '/relationships/' . $jsonRelName; |
|
| 344 | + return $this->getSelfSubUrl($model).'/relationships/'.$jsonRelName; |
|
| 345 | 345 | } |
| 346 | 346 | } |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | /** |
| 220 | - * @param iterable $attributes |
|
| 220 | + * @param \Generator $attributes |
|
| 221 | 221 | * |
| 222 | 222 | * @return self |
| 223 | 223 | * |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | /** |
| 242 | - * @param iterable $attributes |
|
| 242 | + * @param \Generator $attributes |
|
| 243 | 243 | * |
| 244 | 244 | * @return self |
| 245 | 245 | * |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | * @param string $modelClass |
| 263 | 263 | * @param iterable $attributes |
| 264 | 264 | * |
| 265 | - * @return iterable |
|
| 265 | + * @return \Generator |
|
| 266 | 266 | * |
| 267 | 267 | * @SuppressWarnings(PHPMD.StaticAccess) |
| 268 | 268 | * |
@@ -397,7 +397,7 @@ discard block |
||
| 397 | 397 | } |
| 398 | 398 | |
| 399 | 399 | /** |
| 400 | - * @param iterable $filters |
|
| 400 | + * @param \Limoncello\Flute\Api\iterable|null $filters |
|
| 401 | 401 | * |
| 402 | 402 | * @return self |
| 403 | 403 | * |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | } |
| 414 | 414 | |
| 415 | 415 | /** |
| 416 | - * @param iterable $filters |
|
| 416 | + * @param \Limoncello\Flute\Api\iterable|null $filters |
|
| 417 | 417 | * |
| 418 | 418 | * @return self |
| 419 | 419 | * |
@@ -429,7 +429,7 @@ discard block |
||
| 429 | 429 | } |
| 430 | 430 | |
| 431 | 431 | /** |
| 432 | - * @param iterable $filters |
|
| 432 | + * @param \Limoncello\Flute\Api\iterable|null $filters |
|
| 433 | 433 | * |
| 434 | 434 | * @return self |
| 435 | 435 | * |
@@ -523,7 +523,7 @@ discard block |
||
| 523 | 523 | } |
| 524 | 524 | |
| 525 | 525 | /** |
| 526 | - * @param iterable $sortParameters |
|
| 526 | + * @param \Limoncello\Flute\Api\iterable|null $sortParameters |
|
| 527 | 527 | * |
| 528 | 528 | * @return self |
| 529 | 529 | * |
@@ -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 |
@@ -463,8 +463,8 @@ discard block |
||
| 463 | 463 | string $relationshipName, |
| 464 | 464 | ?iterable $relationshipFilters, |
| 465 | 465 | ?iterable $relationshipSorts, |
| 466 | - int $joinIndividuals = self::AND, |
|
| 467 | - int $joinRelationship = self::AND |
|
| 466 | + int $joinIndividuals = self:: AND , |
|
| 467 | + int $joinRelationship = self:: AND |
|
| 468 | 468 | ): self { |
| 469 | 469 | $targetAlias = null; |
| 470 | 470 | |
@@ -476,7 +476,7 @@ discard block |
||
| 476 | 476 | $reversePk = $isBelongsTo === true ? |
| 477 | 477 | $this->getModelSchemas()->getReversePrimaryKey($this->getModelClass(), $relationshipName)[0] : null; |
| 478 | 478 | |
| 479 | - $addWith = $joinIndividuals === self::AND ? $this->expr()->andX() : $this->expr()->orX(); |
|
| 479 | + $addWith = $joinIndividuals === self:: AND ? $this->expr()->andX() : $this->expr()->orX(); |
|
| 480 | 480 | |
| 481 | 481 | foreach ($relationshipFilters as $columnName => $operationsWithArgs) { |
| 482 | 482 | if ($columnName === $reversePk) { |
@@ -496,14 +496,14 @@ discard block |
||
| 496 | 496 | foreach ($operationsWithArgs as $operation => $arguments) { |
| 497 | 497 | assert( |
| 498 | 498 | is_iterable($arguments) === true || is_array($arguments) === true, |
| 499 | - "Operation arguments are missing for `$columnName` column. " . |
|
| 499 | + "Operation arguments are missing for `$columnName` column. ". |
|
| 500 | 500 | 'Use an empty array as an empty argument list.' |
| 501 | 501 | ); |
| 502 | 502 | $addWith->add($this->createFilterExpression($fullColumnName, $operation, $arguments)); |
| 503 | 503 | } |
| 504 | 504 | |
| 505 | 505 | if ($addWith->count() > 0) { |
| 506 | - $joinRelationship === self::AND ? $this->andWhere($addWith) : $this->orWhere($addWith); |
|
| 506 | + $joinRelationship === self:: AND ? $this->andWhere($addWith) : $this->orWhere($addWith); |
|
| 507 | 507 | } |
| 508 | 508 | } |
| 509 | 509 | } |
@@ -644,7 +644,7 @@ discard block |
||
| 644 | 644 | foreach ($operationsWithArgs as $operation => $arguments) { |
| 645 | 645 | assert( |
| 646 | 646 | is_iterable($arguments) === true || is_array($arguments) === true, |
| 647 | - "Operation arguments are missing for `$columnName` column. " . |
|
| 647 | + "Operation arguments are missing for `$columnName` column. ". |
|
| 648 | 648 | 'Use an empty array as an empty argument list.' |
| 649 | 649 | ); |
| 650 | 650 | $expression->add($this->createFilterExpression($fullColumnName, $operation, $arguments)); |
@@ -697,7 +697,7 @@ discard block |
||
| 697 | 697 | { |
| 698 | 698 | $platform = $this->getConnection()->getDatabasePlatform(); |
| 699 | 699 | |
| 700 | - return $platform->quoteSingleIdentifier($tableOrAlias) . '.' . $platform->quoteSingleIdentifier($column); |
|
| 700 | + return $platform->quoteSingleIdentifier($tableOrAlias).'.'.$platform->quoteSingleIdentifier($column); |
|
| 701 | 701 | } |
| 702 | 702 | |
| 703 | 703 | /** |
@@ -739,7 +739,7 @@ discard block |
||
| 739 | 739 | */ |
| 740 | 740 | public function createAlias(string $tableName): string |
| 741 | 741 | { |
| 742 | - $alias = $tableName . (++$this->aliasIdCounter); |
|
| 742 | + $alias = $tableName.(++$this->aliasIdCounter); |
|
| 743 | 743 | $this->knownAliases[$tableName] = $alias; |
| 744 | 744 | |
| 745 | 745 | return $alias; |
@@ -762,7 +762,7 @@ discard block |
||
| 762 | 762 | string $targetColumn |
| 763 | 763 | ): string { |
| 764 | 764 | $targetAlias = $this->createAlias($targetTable); |
| 765 | - $joinCondition = $this->quoteDoubleIdentifier($fromAlias, $fromColumn) . '=' . |
|
| 765 | + $joinCondition = $this->quoteDoubleIdentifier($fromAlias, $fromColumn).'='. |
|
| 766 | 766 | $this->quoteDoubleIdentifier($targetAlias, $targetColumn); |
| 767 | 767 | |
| 768 | 768 | $this->innerJoin( |
@@ -975,7 +975,7 @@ discard block |
||
| 975 | 975 | } else { |
| 976 | 976 | assert( |
| 977 | 977 | $value !== null, |
| 978 | - 'It seems you are trying to use `null` with =, >, <, or etc operator. ' . |
|
| 978 | + 'It seems you are trying to use `null` with =, >, <, or etc operator. '. |
|
| 979 | 979 | 'Use `is null` or `not null` instead.' |
| 980 | 980 | ); |
| 981 | 981 | assert(is_string($value), "Only strings, booleans and integers are supported."); |