From f08abe5ccb1ca6617f3c4086c464aefe4e518a5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Thu, 29 Sep 2022 00:52:49 +0200 Subject: [PATCH 1/2] fix: compatibility with PHP 8.2 --- src/GraphQl/Resolver/Stage/ReadStage.php | 2 +- src/GraphQl/Resolver/Stage/ReadStageInterface.php | 2 +- src/GraphQl/Resolver/Stage/SerializeStage.php | 2 +- src/GraphQl/Resolver/Stage/SerializeStageInterface.php | 2 +- src/State/CallableProvider.php | 2 +- src/State/ProviderInterface.php | 2 +- src/Symfony/Maker/Resources/skeleton/StateProvider.tpl.php | 2 +- tests/Fixtures/Symfony/Maker/CustomStateProvider.php | 2 +- tests/Fixtures/TestBundle/State/CustomOutputDtoProvider.php | 2 +- .../TestBundle/State/DummyExceptionToStatusProvider.php | 2 +- tests/Fixtures/TestBundle/State/FakeProvider.php | 2 +- tests/GraphQl/Resolver/Stage/ReadStageTest.php | 2 +- tests/GraphQl/Resolver/Stage/SerializeStageTest.php | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/GraphQl/Resolver/Stage/ReadStage.php b/src/GraphQl/Resolver/Stage/ReadStage.php index 8c0742f5b8e..b5c7d119030 100644 --- a/src/GraphQl/Resolver/Stage/ReadStage.php +++ b/src/GraphQl/Resolver/Stage/ReadStage.php @@ -43,7 +43,7 @@ public function __construct(private readonly IriConverterInterface $iriConverter /** * {@inheritdoc} */ - public function __invoke(?string $resourceClass, ?string $rootClass, Operation $operation, array $context): iterable|object|null + public function __invoke(?string $resourceClass, ?string $rootClass, Operation $operation, array $context): object|array|null { if (!($operation->canRead() ?? true)) { return $context['is_collection'] ? [] : null; diff --git a/src/GraphQl/Resolver/Stage/ReadStageInterface.php b/src/GraphQl/Resolver/Stage/ReadStageInterface.php index 76e8fcc0df0..fa0e941ea20 100644 --- a/src/GraphQl/Resolver/Stage/ReadStageInterface.php +++ b/src/GraphQl/Resolver/Stage/ReadStageInterface.php @@ -22,5 +22,5 @@ */ interface ReadStageInterface { - public function __invoke(?string $resourceClass, ?string $rootClass, Operation $operation, array $context): iterable|object|null; + public function __invoke(?string $resourceClass, ?string $rootClass, Operation $operation, array $context): object|array|null; } diff --git a/src/GraphQl/Resolver/Stage/SerializeStage.php b/src/GraphQl/Resolver/Stage/SerializeStage.php index a12307c1a18..aed1266a369 100644 --- a/src/GraphQl/Resolver/Stage/SerializeStage.php +++ b/src/GraphQl/Resolver/Stage/SerializeStage.php @@ -38,7 +38,7 @@ public function __construct(private readonly NormalizerInterface $normalizer, pr { } - public function __invoke(iterable|object|null $itemOrCollection, string $resourceClass, Operation $operation, array $context): ?array + public function __invoke(object|array|null $itemOrCollection, string $resourceClass, Operation $operation, array $context): ?array { $isCollection = $operation instanceof CollectionOperationInterface; $isMutation = $operation instanceof Mutation; diff --git a/src/GraphQl/Resolver/Stage/SerializeStageInterface.php b/src/GraphQl/Resolver/Stage/SerializeStageInterface.php index 274d5b0f96f..ac67e9b97f0 100644 --- a/src/GraphQl/Resolver/Stage/SerializeStageInterface.php +++ b/src/GraphQl/Resolver/Stage/SerializeStageInterface.php @@ -22,5 +22,5 @@ */ interface SerializeStageInterface { - public function __invoke(iterable|object|null $itemOrCollection, string $resourceClass, Operation $operation, array $context): ?array; + public function __invoke(object|array|null $itemOrCollection, string $resourceClass, Operation $operation, array $context): ?array; } diff --git a/src/State/CallableProvider.php b/src/State/CallableProvider.php index cac9ec0c344..4926e7e6797 100644 --- a/src/State/CallableProvider.php +++ b/src/State/CallableProvider.php @@ -26,7 +26,7 @@ public function __construct(private readonly ContainerInterface $locator) /** * {@inheritDoc} */ - public function provide(Operation $operation, array $uriVariables = [], array $context = []): object|iterable|null + public function provide(Operation $operation, array $uriVariables = [], array $context = []): object|array|null { if (\is_callable($provider = $operation->getProvider())) { return $provider($operation, $uriVariables, $context); diff --git a/src/State/ProviderInterface.php b/src/State/ProviderInterface.php index a45e7941552..ea72049c7f7 100644 --- a/src/State/ProviderInterface.php +++ b/src/State/ProviderInterface.php @@ -27,5 +27,5 @@ interface ProviderInterface /** * Provides data. */ - public function provide(Operation $operation, array $uriVariables = [], array $context = []): object|iterable|null; + public function provide(Operation $operation, array $uriVariables = [], array $context = []): object|array|null; } diff --git a/src/Symfony/Maker/Resources/skeleton/StateProvider.tpl.php b/src/Symfony/Maker/Resources/skeleton/StateProvider.tpl.php index c76b9746507..a6acb239f3a 100644 --- a/src/Symfony/Maker/Resources/skeleton/StateProvider.tpl.php +++ b/src/Symfony/Maker/Resources/skeleton/StateProvider.tpl.php @@ -8,7 +8,7 @@ class implements ProviderInterface { - public function provide(Operation $operation, array $uriVariables = [], array $context = []): object|iterable|null + public function provide(Operation $operation, array $uriVariables = [], array $context = []): object|array|null { // Retrieve the state from somewhere } diff --git a/tests/Fixtures/Symfony/Maker/CustomStateProvider.php b/tests/Fixtures/Symfony/Maker/CustomStateProvider.php index 584c8c77805..b4e25e12ea5 100644 --- a/tests/Fixtures/Symfony/Maker/CustomStateProvider.php +++ b/tests/Fixtures/Symfony/Maker/CustomStateProvider.php @@ -7,7 +7,7 @@ class CustomStateProvider implements ProviderInterface { - public function provide(Operation $operation, array $uriVariables = [], array $context = []): object|iterable|null + public function provide(Operation $operation, array $uriVariables = [], array $context = []): object|array|null { // Retrieve the state from somewhere } diff --git a/tests/Fixtures/TestBundle/State/CustomOutputDtoProvider.php b/tests/Fixtures/TestBundle/State/CustomOutputDtoProvider.php index a96c81b26af..13fcef1e1fd 100644 --- a/tests/Fixtures/TestBundle/State/CustomOutputDtoProvider.php +++ b/tests/Fixtures/TestBundle/State/CustomOutputDtoProvider.php @@ -27,7 +27,7 @@ public function __construct(private readonly ProviderInterface $itemProvider, pr /** * {@inheritDoc} */ - public function provide(Operation $operation, array $uriVariables = [], array $context = []): object|iterable|null + public function provide(Operation $operation, array $uriVariables = [], array $context = []): object|array|null { if ($operation instanceof CollectionOperationInterface) { $object = $this->collectionProvider->provide($operation, $uriVariables, $context); diff --git a/tests/Fixtures/TestBundle/State/DummyExceptionToStatusProvider.php b/tests/Fixtures/TestBundle/State/DummyExceptionToStatusProvider.php index 1a55ede9919..703f5ad2be1 100644 --- a/tests/Fixtures/TestBundle/State/DummyExceptionToStatusProvider.php +++ b/tests/Fixtures/TestBundle/State/DummyExceptionToStatusProvider.php @@ -19,7 +19,7 @@ class DummyExceptionToStatusProvider implements ProviderInterface { - public function provide(Operation $operation, array $uriVariables = [], array $context = []): iterable|object|null + public function provide(Operation $operation, array $uriVariables = [], array $context = []): object|array|null { throw new NotFoundException(); } diff --git a/tests/Fixtures/TestBundle/State/FakeProvider.php b/tests/Fixtures/TestBundle/State/FakeProvider.php index d0d6d8c89ac..7a954d89ad4 100644 --- a/tests/Fixtures/TestBundle/State/FakeProvider.php +++ b/tests/Fixtures/TestBundle/State/FakeProvider.php @@ -23,7 +23,7 @@ final class FakeProvider implements ProviderInterface * * @return array|object|null */ - public function provide(Operation $operation, array $uriVariables = [], array $context = []): iterable|object|null + public function provide(Operation $operation, array $uriVariables = [], array $context = []): object|array|null { $className = $operation->getClass(); $data = [ diff --git a/tests/GraphQl/Resolver/Stage/ReadStageTest.php b/tests/GraphQl/Resolver/Stage/ReadStageTest.php index 8c210cea81f..95c53841691 100644 --- a/tests/GraphQl/Resolver/Stage/ReadStageTest.php +++ b/tests/GraphQl/Resolver/Stage/ReadStageTest.php @@ -62,7 +62,7 @@ protected function setUp(): void /** * @dataProvider contextProvider */ - public function testApplyDisabled(array $context, iterable|object|null $expectedResult): void + public function testApplyDisabled(array $context, object|array|null $expectedResult): void { $resourceClass = 'myResource'; /** @var Operation $operation */ diff --git a/tests/GraphQl/Resolver/Stage/SerializeStageTest.php b/tests/GraphQl/Resolver/Stage/SerializeStageTest.php index dcc400f20f4..c9e77652727 100644 --- a/tests/GraphQl/Resolver/Stage/SerializeStageTest.php +++ b/tests/GraphQl/Resolver/Stage/SerializeStageTest.php @@ -80,7 +80,7 @@ public function applyDisabledProvider(): array /** * @dataProvider applyProvider */ - public function testApply(iterable|object $itemOrCollection, string $operationName, array $context, bool $paginationEnabled, ?array $expectedResult): void + public function testApply(object|array $itemOrCollection, string $operationName, array $context, bool $paginationEnabled, ?array $expectedResult): void { $resourceClass = 'myResource'; $operation = $context['is_mutation'] ? new Mutation() : new Query(); From bf34fcd135b5626b9a3ecbe57fd4973c62bdf5f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Thu, 29 Sep 2022 01:06:41 +0200 Subject: [PATCH 2/2] fix cs --- tests/Fixtures/TestBundle/State/FakeProvider.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/Fixtures/TestBundle/State/FakeProvider.php b/tests/Fixtures/TestBundle/State/FakeProvider.php index 7a954d89ad4..b38b8b3da71 100644 --- a/tests/Fixtures/TestBundle/State/FakeProvider.php +++ b/tests/Fixtures/TestBundle/State/FakeProvider.php @@ -18,11 +18,6 @@ final class FakeProvider implements ProviderInterface { - /** - * {@inheritDoc} - * - * @return array|object|null - */ public function provide(Operation $operation, array $uriVariables = [], array $context = []): object|array|null { $className = $operation->getClass();