@@ -408,7 +408,7 @@ |
||
| 408 | 408 | * @param string $parameterName |
| 409 | 409 | * @param iterable $value |
| 410 | 410 | * |
| 411 | - * @return iterable |
|
| 411 | + * @return Generator |
|
| 412 | 412 | */ |
| 413 | 413 | private function parseOperationsAndArguments(string $parameterName, iterable $value): iterable |
| 414 | 414 | { |
@@ -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 | } |
@@ -264,7 +264,7 @@ |
||
| 264 | 264 | * @param string $parameterName |
| 265 | 265 | * @param array $value |
| 266 | 266 | * |
| 267 | - * @return iterable |
|
| 267 | + * @return Generator |
|
| 268 | 268 | */ |
| 269 | 269 | private function parseOperationsAndArguments(string $parameterName, array $value): iterable |
| 270 | 270 | { |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | { |
| 93 | 93 | // debug check all fields are strings |
| 94 | 94 | assert( |
| 95 | - (function () use ($fields) { |
|
| 95 | + (function() use ($fields) { |
|
| 96 | 96 | $allAreStrings = !empty($fields); |
| 97 | 97 | foreach ($fields as $field) { |
| 98 | 98 | $allAreStrings = $allAreStrings === true && is_string($field) === true && empty($field) === false; |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | { |
| 135 | 135 | // debug check all fields are strings |
| 136 | 136 | assert( |
| 137 | - (function () use ($fields) { |
|
| 137 | + (function() use ($fields) { |
|
| 138 | 138 | $allAreStrings = !empty($fields); |
| 139 | 139 | foreach ($fields as $field) { |
| 140 | 140 | $allAreStrings = $allAreStrings === true && is_string($field) === true && empty($field) === false; |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | { |
| 177 | 177 | // debug check all fields are strings |
| 178 | 178 | assert( |
| 179 | - (function () use ($paths) { |
|
| 179 | + (function() use ($paths) { |
|
| 180 | 180 | $allAreStrings = !empty($paths); |
| 181 | 181 | foreach ($paths as $path) { |
| 182 | 182 | $allAreStrings = $allAreStrings === true && is_string($path) === true && empty($path) === false; |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | /** |
| 131 | - * @param iterable $attributes |
|
| 131 | + * @param Generator $attributes |
|
| 132 | 132 | * |
| 133 | 133 | * @return self |
| 134 | 134 | * |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
| 151 | - * @param iterable $attributes |
|
| 151 | + * @param Generator $attributes |
|
| 152 | 152 | * |
| 153 | 153 | * @return self |
| 154 | 154 | * |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | * @param string $modelClass |
| 170 | 170 | * @param iterable $attributes |
| 171 | 171 | * |
| 172 | - * @return iterable |
|
| 172 | + * @return Generator |
|
| 173 | 173 | * |
| 174 | 174 | * @SuppressWarnings(PHPMD.StaticAccess) |
| 175 | 175 | */ |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | /** |
| 252 | - * @param iterable $filters |
|
| 252 | + * @param \Limoncello\Flute\Api\iterable|null $filters |
|
| 253 | 253 | * |
| 254 | 254 | * @return self |
| 255 | 255 | */ |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | /** |
| 262 | - * @param iterable $filters |
|
| 262 | + * @param \Limoncello\Flute\Api\iterable|null $filters |
|
| 263 | 263 | * |
| 264 | 264 | * @return self |
| 265 | 265 | */ |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | /** |
| 272 | - * @param iterable $filters |
|
| 272 | + * @param \Limoncello\Flute\Api\iterable|null $filters |
|
| 273 | 273 | * |
| 274 | 274 | * @return self |
| 275 | 275 | */ |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | |
| 315 | 315 | /** |
| 316 | 316 | * @param string $relationshipName |
| 317 | - * @param iterable $relationshipFilters |
|
| 317 | + * @param \Limoncello\Flute\Api\iterable|null $relationshipFilters |
|
| 318 | 318 | * @param iterable|null $relationshipSorts |
| 319 | 319 | * |
| 320 | 320 | * @return self |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | /** |
| 338 | - * @param iterable $sortParameters |
|
| 338 | + * @param \Limoncello\Flute\Api\iterable|null $sortParameters |
|
| 339 | 339 | * |
| 340 | 340 | * @return self |
| 341 | 341 | */ |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | string $relationshipName, |
| 321 | 321 | iterable $relationshipFilters, |
| 322 | 322 | ?iterable $relationshipSorts |
| 323 | - ): self { |
|
| 323 | + ) : self { |
|
| 324 | 324 | $joinWith = $this->expr()->andX(); |
| 325 | 325 | |
| 326 | 326 | return $this->addRelationshipFiltersAndSorts( |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | string $relationshipName, |
| 355 | 355 | iterable $relationshipFilters, |
| 356 | 356 | ?iterable $relationshipSorts |
| 357 | - ): self { |
|
| 357 | + ) : self { |
|
| 358 | 358 | $joinWith = $this->expr()->orX(); |
| 359 | 359 | |
| 360 | 360 | return $this->addRelationshipFiltersAndSorts( |
@@ -415,7 +415,7 @@ discard block |
||
| 415 | 415 | CompositeExpression $filterLink, |
| 416 | 416 | iterable $relationshipFilters, |
| 417 | 417 | ?iterable $relationshipSorts |
| 418 | - ): self { |
|
| 418 | + ) : self { |
|
| 419 | 419 | $relationshipType = $this->getModelSchemes()->getRelationshipType($this->getModelClass(), $relationshipName); |
| 420 | 420 | switch ($relationshipType) { |
| 421 | 421 | case RelationshipTypes::BELONGS_TO: |
@@ -488,7 +488,7 @@ discard block |
||
| 488 | 488 | CompositeExpression $filterLink, |
| 489 | 489 | iterable $relationshipFilters, |
| 490 | 490 | ?iterable $relationshipSorts |
| 491 | - ): self { |
|
| 491 | + ) : self { |
|
| 492 | 492 | $foreignKey = $this->getModelSchemes()->getForeignKey($this->getModelClass(), $relationshipName); |
| 493 | 493 | list($onePrimaryKey, $oneTable) = |
| 494 | 494 | $this->getModelSchemes()->getReversePrimaryKey($this->getModelClass(), $relationshipName); |
@@ -522,7 +522,7 @@ discard block |
||
| 522 | 522 | CompositeExpression $filterLink, |
| 523 | 523 | iterable $relationshipFilters, |
| 524 | 524 | ?iterable $relationshipSorts |
| 525 | - ): self { |
|
| 525 | + ) : self { |
|
| 526 | 526 | $primaryKey = $this->getModelSchemes()->getPrimaryKey($this->getModelClass()); |
| 527 | 527 | list($manyForeignKey, $manyTable) = |
| 528 | 528 | $this->getModelSchemes()->getReverseForeignKey($this->getModelClass(), $relationshipName); |
@@ -556,7 +556,7 @@ discard block |
||
| 556 | 556 | CompositeExpression $targetFilterLink, |
| 557 | 557 | iterable $relationshipFilters, |
| 558 | 558 | ?iterable $relationshipSorts |
| 559 | - ): self { |
|
| 559 | + ) : self { |
|
| 560 | 560 | $primaryKey = $this->getModelSchemes()->getPrimaryKey($this->getModelClass()); |
| 561 | 561 | list ($intermediateTable, $intermediatePk, $intermediateFk) = |
| 562 | 562 | $this->getModelSchemes()->getBelongsToManyRelationship($this->getModelClass(), $relationshipName); |
@@ -606,9 +606,9 @@ discard block |
||
| 606 | 606 | ?CompositeExpression $targetFilterLink, |
| 607 | 607 | ?iterable $targetFilterParams, |
| 608 | 608 | ?iterable $relationshipSorts |
| 609 | - ): string { |
|
| 609 | + ) : string { |
|
| 610 | 610 | $targetAlias = $this->createAlias($targetTable); |
| 611 | - $joinCondition = $this->buildColumnName($fromAlias, $fromColumn) . '=' . |
|
| 611 | + $joinCondition = $this->buildColumnName($fromAlias, $fromColumn).'='. |
|
| 612 | 612 | $this->buildColumnName($targetAlias, $targetColumn); |
| 613 | 613 | |
| 614 | 614 | $this->innerJoin( |
@@ -667,7 +667,7 @@ discard block |
||
| 667 | 667 | ?CompositeExpression $targetFilterLink, |
| 668 | 668 | ?iterable $targetFilterParams, |
| 669 | 669 | ?iterable $targetSortParams |
| 670 | - ): string { |
|
| 670 | + ) : string { |
|
| 671 | 671 | $intNoSorting = null; |
| 672 | 672 | $intAlias = $this->innerJoinOneTable( |
| 673 | 673 | $fromAlias, |
@@ -678,7 +678,7 @@ discard block |
||
| 678 | 678 | $intFilterParams, |
| 679 | 679 | $intNoSorting |
| 680 | 680 | ); |
| 681 | - $targetAlias = $this->innerJoinOneTable( |
|
| 681 | + $targetAlias = $this->innerJoinOneTable( |
|
| 682 | 682 | $intAlias, |
| 683 | 683 | $intToTargetColumn, |
| 684 | 684 | $targetTable, |
@@ -698,7 +698,7 @@ discard block |
||
| 698 | 698 | */ |
| 699 | 699 | private function createAlias(string $tableName): string |
| 700 | 700 | { |
| 701 | - $alias = $tableName . (++$this->aliasIdCounter); |
|
| 701 | + $alias = $tableName.(++$this->aliasIdCounter); |
|
| 702 | 702 | $this->knownAliases[$tableName] = $alias; |
| 703 | 703 | |
| 704 | 704 | return $alias; |
@@ -876,7 +876,7 @@ discard block |
||
| 876 | 876 | if ($this->dtToDbConverter === null) { |
| 877 | 877 | $type = Type::getType(DateTimeType::DATETIME); |
| 878 | 878 | $platform = $this->getConnection()->getDatabasePlatform(); |
| 879 | - $this->dtToDbConverter = function (DateTimeInterface $dateTime) use ($type, $platform) : string { |
|
| 879 | + $this->dtToDbConverter = function(DateTimeInterface $dateTime) use ($type, $platform) : string { |
|
| 880 | 880 | return $type->convertToDatabaseValue($dateTime, $platform); |
| 881 | 881 | }; |
| 882 | 882 | } |
@@ -902,7 +902,7 @@ discard block |
||
| 902 | 902 | } else { |
| 903 | 903 | assert( |
| 904 | 904 | $value !== null, |
| 905 | - 'It seems you are trying to use `null` with =, >, <, or etc operator. ' . |
|
| 905 | + 'It seems you are trying to use `null` with =, >, <, or etc operator. '. |
|
| 906 | 906 | 'Use `is null` or `not null` instead.' |
| 907 | 907 | ); |
| 908 | 908 | assert(is_string($value), "Only strings, booleans and integers are supported."); |
@@ -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 |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | public function fetchResources(QueryBuilder $builder, string $modelClass): PaginatedDataInterface; |
| 109 | 109 | |
| 110 | 110 | /** |
| 111 | - * @param QueryBuilder|null $builder |
|
| 111 | + * @param QueryBuilder $builder |
|
| 112 | 112 | * @param string|null $modelClass |
| 113 | 113 | * |
| 114 | 114 | * @return mixed|null |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | * @param string $modelClass |
| 129 | 129 | * @param string $columnName |
| 130 | 130 | * |
| 131 | - * @return iterable |
|
| 131 | + * @return \Generator |
|
| 132 | 132 | */ |
| 133 | 133 | public function fetchColumn(QueryBuilder $builder, string $modelClass, string $columnName): iterable; |
| 134 | 134 | |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | ): array; |
| 212 | 212 | |
| 213 | 213 | /** |
| 214 | - * @param int|string $index |
|
| 214 | + * @param string $index |
|
| 215 | 215 | * @param string $name |
| 216 | 216 | * @param iterable|null $relationshipFilters |
| 217 | 217 | * @param iterable|null $relationshipSorts |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | */ |
| 241 | 241 | protected static function readJsonFromRequest(ContainerInterface $container, ServerRequestInterface $request): array |
| 242 | 242 | { |
| 243 | - $body = (string)$request->getBody(); |
|
| 243 | + $body = (string) $request->getBody(); |
|
| 244 | 244 | if (empty($body) === true || ($json = json_decode($body, true)) === null) { |
| 245 | 245 | /** @var FactoryInterface $factory */ |
| 246 | 246 | $factory = $container->get(FactoryInterface::class); |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | { |
| 384 | 384 | assert( |
| 385 | 385 | empty(static::ON_CREATE_VALIDATION_RULES_SET_CLASS) === false, |
| 386 | - 'Validation rules set should be defined for class ' . static::class . '.' |
|
| 386 | + 'Validation rules set should be defined for class '.static::class.'.' |
|
| 387 | 387 | ); |
| 388 | 388 | |
| 389 | 389 | return static::createJsonApiValidator($container, static::ON_CREATE_VALIDATION_RULES_SET_CLASS); |
@@ -398,7 +398,7 @@ discard block |
||
| 398 | 398 | { |
| 399 | 399 | assert( |
| 400 | 400 | empty(static::ON_UPDATE_VALIDATION_RULES_SET_CLASS) === false, |
| 401 | - 'Validation rules set should be defined for class ' . static::class . '.' |
|
| 401 | + 'Validation rules set should be defined for class '.static::class.'.' |
|
| 402 | 402 | ); |
| 403 | 403 | |
| 404 | 404 | return static::createJsonApiValidator($container, static::ON_UPDATE_VALIDATION_RULES_SET_CLASS); |
@@ -606,7 +606,7 @@ discard block |
||
| 606 | 606 | ContainerInterface $container, |
| 607 | 607 | ServerRequestInterface $request |
| 608 | 608 | ): array { |
| 609 | - $jsonData = static::normalizeIndexValueOnUpdate( |
|
| 609 | + $jsonData = static::normalizeIndexValueOnUpdate( |
|
| 610 | 610 | $routeParams, |
| 611 | 611 | $container, |
| 612 | 612 | static::readJsonFromRequest($container, $request) |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | * @param string $name |
| 271 | 271 | * @param iterable $operationsAndArgs |
| 272 | 272 | * |
| 273 | - * @return iterable |
|
| 273 | + * @return \Generator |
|
| 274 | 274 | */ |
| 275 | 275 | private function getValidatedOperationsAndArguments( |
| 276 | 276 | int $blockIndex, |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | * @param string $name |
| 288 | 288 | * @param iterable $arguments |
| 289 | 289 | * |
| 290 | - * @return iterable |
|
| 290 | + * @return \Generator |
|
| 291 | 291 | */ |
| 292 | 292 | private function getValidatedArguments(int $blockIndex, string $name, iterable $arguments): iterable |
| 293 | 293 | { |
@@ -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 | } |
@@ -162,7 +162,7 @@ |
||
| 162 | 162 | protected function setWrapperErrors(array $wrapperErrors): self |
| 163 | 163 | { |
| 164 | 164 | if (empty($wrapperErrors) === false) { |
| 165 | - assert(call_user_func(function () use ($wrapperErrors) : bool { |
|
| 165 | + assert(call_user_func(function() use ($wrapperErrors) : bool { |
|
| 166 | 166 | $allAreErrors = true; |
| 167 | 167 | |
| 168 | 168 | foreach ($wrapperErrors as $error) { |
@@ -105,8 +105,7 @@ |
||
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | $reply = $count > 0 ? |
| 108 | - BlockReplies::createSuccessReply($values) : |
|
| 109 | - BlockReplies::createErrorReply($context, $values, ErrorCodes::EXIST_IN_DATABASE_MULTIPLE); |
|
| 108 | + BlockReplies::createSuccessReply($values) : BlockReplies::createErrorReply($context, $values, ErrorCodes::EXIST_IN_DATABASE_MULTIPLE); |
|
| 110 | 109 | |
| 111 | 110 | return $reply; |
| 112 | 111 | } |
@@ -86,8 +86,7 @@ |
||
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | $reply = $foundInvalidType === null ? |
| 89 | - BlockReplies::createSuccessReply($indexes) : |
|
| 90 | - BlockReplies::createErrorReply($context, $foundInvalidType, ErrorCodes::INVALID_RELATIONSHIP_TYPE); |
|
| 89 | + BlockReplies::createSuccessReply($indexes) : BlockReplies::createErrorReply($context, $foundInvalidType, ErrorCodes::INVALID_RELATIONSHIP_TYPE); |
|
| 91 | 90 | |
| 92 | 91 | return $reply; |
| 93 | 92 | } |