Skip to content

fix: compatibility with PHP 8.2 #5024

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/GraphQl/Resolver/Stage/ReadStage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/GraphQl/Resolver/Stage/ReadStageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion src/GraphQl/Resolver/Stage/SerializeStage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/GraphQl/Resolver/Stage/SerializeStageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion src/State/CallableProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/State/ProviderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion src/Symfony/Maker/Resources/skeleton/StateProvider.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class <?php echo $class_name; ?> 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
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/Symfony/Maker/CustomStateProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
7 changes: 1 addition & 6 deletions tests/Fixtures/TestBundle/State/FakeProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,7 @@

final class FakeProvider implements ProviderInterface
{
/**
* {@inheritDoc}
*
* @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 = [
Expand Down
2 changes: 1 addition & 1 deletion tests/GraphQl/Resolver/Stage/ReadStageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion tests/GraphQl/Resolver/Stage/SerializeStageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down