From d7f7a62b585c54ef7973a30997d03e76c2ba0a8f Mon Sep 17 00:00:00 2001 From: Dawid Parafinski Date: Thu, 19 Dec 2024 15:38:55 +0100 Subject: [PATCH] Fixed phpstan issues after upgrading --- phpstan-baseline.neon | 6 ------ src/lib/ContentView/QueryResultsPagerFantaAdapter.php | 11 +++++++---- .../QueryResultsWithLocationPagerFantaAdapter.php | 11 +++++++---- src/lib/GraphQL/QueryFieldResolver.php | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index e068e8f..ce28a88 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -90,12 +90,6 @@ parameters: count: 1 path: src/lib/Persistence/Legacy/Content/FieldValue/Converter/QueryConverter.php - - - message: '#^Anonymous function should return Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Content but returns Ibexa\\Contracts\\Core\\Repository\\Values\\ValueObject\.$#' - identifier: return.type - count: 1 - path: src/lib/QueryFieldService.php - - message: '#^Method Ibexa\\FieldTypeQuery\\QueryFieldService\:\:isExpression\(\) has parameter \$expression with no type specified\.$#' identifier: missingType.parameter diff --git a/src/lib/ContentView/QueryResultsPagerFantaAdapter.php b/src/lib/ContentView/QueryResultsPagerFantaAdapter.php index c167b0b..09fe825 100644 --- a/src/lib/ContentView/QueryResultsPagerFantaAdapter.php +++ b/src/lib/ContentView/QueryResultsPagerFantaAdapter.php @@ -11,6 +11,9 @@ use Ibexa\Contracts\FieldTypeQuery\QueryFieldServiceInterface; use Pagerfanta\Adapter\AdapterInterface; +/** + * @implements AdapterInterface<\Ibexa\Contracts\Core\Repository\Values\Content\Content> + */ final class QueryResultsPagerFantaAdapter implements AdapterInterface { /** @var \Ibexa\Contracts\FieldTypeQuery\QueryFieldServiceInterface */ @@ -32,15 +35,15 @@ public function __construct( $this->fieldDefinitionIdentifier = $fieldDefinitionIdentifier; } - public function getNbResults() + public function getNbResults(): int { - return $this->queryFieldService->countContentItems( + return max($this->queryFieldService->countContentItems( $this->content, $this->fieldDefinitionIdentifier - ); + ), 0); } - public function getSlice($offset, $length) + public function getSlice($offset, $length): iterable { return $this->queryFieldService->loadContentItemsSlice( $this->content, diff --git a/src/lib/ContentView/QueryResultsWithLocationPagerFantaAdapter.php b/src/lib/ContentView/QueryResultsWithLocationPagerFantaAdapter.php index ad2dd5f..ad0ff48 100644 --- a/src/lib/ContentView/QueryResultsWithLocationPagerFantaAdapter.php +++ b/src/lib/ContentView/QueryResultsWithLocationPagerFantaAdapter.php @@ -11,6 +11,9 @@ use Ibexa\Contracts\FieldTypeQuery\QueryFieldLocationService; use Pagerfanta\Adapter\AdapterInterface; +/** + * @implements AdapterInterface<\Ibexa\Contracts\Core\Repository\Values\Content\Content> + */ final class QueryResultsWithLocationPagerFantaAdapter implements AdapterInterface { /** @var \Ibexa\Contracts\FieldTypeQuery\QueryFieldLocationService */ @@ -32,15 +35,15 @@ public function __construct( $this->fieldDefinitionIdentifier = $fieldDefinitionIdentifier; } - public function getNbResults() + public function getNbResults(): int { - return $this->queryFieldService->countContentItemsForLocation( + return max($this->queryFieldService->countContentItemsForLocation( $this->location, $this->fieldDefinitionIdentifier - ); + ), 0); } - public function getSlice($offset, $length) + public function getSlice($offset, $length): iterable { return $this->queryFieldService->loadContentItemsSliceForLocation( $this->location, diff --git a/src/lib/GraphQL/QueryFieldResolver.php b/src/lib/GraphQL/QueryFieldResolver.php index 35836cd..39b96cb 100644 --- a/src/lib/GraphQL/QueryFieldResolver.php +++ b/src/lib/GraphQL/QueryFieldResolver.php @@ -32,7 +32,7 @@ public function resolveQueryField(Field $field, Content $content): iterable } /** - * @return \GraphQL\Executor\Promise\Promise|\Overblog\GraphQLBundle\Relay\Connection\Output\Connection|null + * @return \GraphQL\Executor\Promise\Promise|\Overblog\GraphQLBundle\Relay\Connection\Output\Connection<\Ibexa\Contracts\Core\Repository\Values\Content\Content>|null */ public function resolveQueryFieldConnection(Argument $args, ?Field $field, Content $content) {