diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 97d9b749f..063e23647 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,6 +20,7 @@ jobs: - '8.1' - '8.2' - '8.3' + - '8.4' symfony-version: - '5.4.*' - '6.0.*' @@ -45,6 +46,8 @@ jobs: symfony-version: '7.0.*' - php-version: '8.1' symfony-version: '7.1.*' + - php-version: '8.4' + dependencies: 'lowest' include: - php-version: '8.0' symfony-version: '5.4.*' diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 8e9b5364a..bbb3b0d9b 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -35,6 +35,7 @@ 'single_line_comment_style' => false, 'phpdoc_no_alias_tag' => ['replacements' => ['type' => 'var']], 'no_mixed_echo_print' => ['use' => 'echo'], + 'nullable_type_declaration_for_default_null_value' => true, ] ) ->setFinder($finder) diff --git a/src/Annotation/Builder.php b/src/Annotation/Builder.php index beeb1d066..cb5003f4f 100644 --- a/src/Annotation/Builder.php +++ b/src/Annotation/Builder.php @@ -20,7 +20,7 @@ abstract class Builder extends Annotation /** * Builder name. */ - public string $name; + public ?string $name; /** * The builder config. @@ -31,7 +31,7 @@ abstract class Builder extends Annotation * @param string|null $name The name of the builder * @param array $config The builder configuration array */ - public function __construct(string $name = null, array $config = []) + public function __construct(?string $name = null, array $config = []) { $this->name = $name; $this->config = $config; diff --git a/src/Annotation/Input.php b/src/Annotation/Input.php index cdbf0e936..9b18f8b94 100644 --- a/src/Annotation/Input.php +++ b/src/Annotation/Input.php @@ -27,7 +27,7 @@ final class Input extends Annotation */ public bool $isRelay = false; - public function __construct(string $name = null, bool $isRelay = false) + public function __construct(?string $name = null, bool $isRelay = false) { $this->name = $name; $this->isRelay = $isRelay; diff --git a/src/Annotation/Provider.php b/src/Annotation/Provider.php index 6afd4a618..156b65d6c 100644 --- a/src/Annotation/Provider.php +++ b/src/Annotation/Provider.php @@ -37,11 +37,11 @@ final class Provider extends Annotation public ?array $targetMutationTypes; /** - * @param string $prefix A prefix to apply to the name of fields generated by this provider + * @param string|null $prefix A prefix to apply to the name of fields generated by this provider * @param string|string[]|null $targetQueryTypes A list of GraphQL types to add the resolver queries to * @param string|string[]|null $targetMutationTypes A list of GraphQL types to add the resolver mutations to */ - public function __construct(string $prefix = null, $targetQueryTypes = null, $targetMutationTypes = null) + public function __construct(?string $prefix = null, $targetQueryTypes = null, $targetMutationTypes = null) { $this->prefix = $prefix; $this->targetQueryTypes = is_string($targetQueryTypes) ? [$targetQueryTypes] : $targetQueryTypes; diff --git a/src/Annotation/Relay/Connection.php b/src/Annotation/Relay/Connection.php index e97174b13..4d20c0143 100644 --- a/src/Annotation/Relay/Connection.php +++ b/src/Annotation/Relay/Connection.php @@ -29,7 +29,7 @@ final class Connection extends Type */ public ?string $node; - public function __construct(string $edge = null, string $node = null) + public function __construct(?string $edge = null, ?string $node = null) { $this->edge = $edge; $this->node = $node; diff --git a/src/Annotation/Scalar.php b/src/Annotation/Scalar.php index 13c2db6ca..6c2e7175c 100644 --- a/src/Annotation/Scalar.php +++ b/src/Annotation/Scalar.php @@ -25,7 +25,7 @@ final class Scalar extends Annotation * @param string|null $name The GraphQL name of the Scalar * @param string|null $scalarType Expression to reuse an other scalar type */ - public function __construct(string $name = null, string $scalarType = null) + public function __construct(?string $name = null, ?string $scalarType = null) { $this->name = $name; $this->scalarType = $scalarType; diff --git a/src/Annotation/Type.php b/src/Annotation/Type.php index e731f627e..7483a5b0a 100644 --- a/src/Annotation/Type.php +++ b/src/Annotation/Type.php @@ -52,11 +52,11 @@ class Type extends Annotation * @param string|null $isTypeOf An expression to resolve if the field is of given type */ public function __construct( - string $name = null, + ?string $name = null, array $interfaces = [], bool $isRelay = false, - string $resolveField = null, - string $isTypeOf = null + ?string $resolveField = null, + ?string $isTypeOf = null ) { $this->name = $name; $this->interfaces = $interfaces; diff --git a/src/Annotation/TypeInterface.php b/src/Annotation/TypeInterface.php index f92bd3853..cd6af4ae1 100644 --- a/src/Annotation/TypeInterface.php +++ b/src/Annotation/TypeInterface.php @@ -28,7 +28,7 @@ final class TypeInterface extends Annotation public ?string $name; /** - * @param string $resolveType The express resolve type + * @param string|null $resolveType The express resolve type * @param string|null $name The GraphQL name of the interface */ public function __construct(?string $resolveType = null, ?string $name = null) diff --git a/src/Annotation/Union.php b/src/Annotation/Union.php index dd32b3c45..c33d1a1eb 100644 --- a/src/Annotation/Union.php +++ b/src/Annotation/Union.php @@ -37,7 +37,7 @@ final class Union extends Annotation * @param string[] $types List of types included in the union * @param string|null $resolveType The resolve type expression */ - public function __construct(string $name = null, array $types = [], ?string $resolveType = null) + public function __construct(?string $name = null, array $types = [], ?string $resolveType = null) { $this->name = $name; $this->types = $types; diff --git a/src/CacheWarmer/CompileCacheWarmer.php b/src/CacheWarmer/CompileCacheWarmer.php index e23f17c2a..ebfcac4be 100644 --- a/src/CacheWarmer/CompileCacheWarmer.php +++ b/src/CacheWarmer/CompileCacheWarmer.php @@ -29,7 +29,7 @@ public function isOptional(): bool /** * @return string[] */ - public function warmUp(string $cacheDir, string $buildDir = null): array + public function warmUp(string $cacheDir, ?string $buildDir = null): array { if ($this->compiled) { // use warm up cache dir if type generator cache dir not already explicitly declared diff --git a/src/Config/Processor/InheritanceProcessor.php b/src/Config/Processor/InheritanceProcessor.php index 2e73edd9e..32c3da62a 100644 --- a/src/Config/Processor/InheritanceProcessor.php +++ b/src/Config/Processor/InheritanceProcessor.php @@ -124,7 +124,7 @@ private static function flattenInherits( string $name, array $configs, array $allowedTypes, - string $child = null, + ?string $child = null, array $typesTreated = [] ): array { self::checkTypeExists($name, $configs, $child); diff --git a/src/Controller/GraphController.php b/src/Controller/GraphController.php index 95fd0991a..f1985ab6b 100644 --- a/src/Controller/GraphController.php +++ b/src/Controller/GraphController.php @@ -38,7 +38,7 @@ public function __construct( /** * @return JsonResponse|Response */ - public function endpointAction(Request $request, string $schemaName = null) + public function endpointAction(Request $request, ?string $schemaName = null) { return $this->createResponse($request, $schemaName, false); } @@ -46,7 +46,7 @@ public function endpointAction(Request $request, string $schemaName = null) /** * @return JsonResponse|Response */ - public function batchEndpointAction(Request $request, string $schemaName = null) + public function batchEndpointAction(Request $request, ?string $schemaName = null) { return $this->createResponse($request, $schemaName, true); } @@ -92,7 +92,7 @@ private function processQuery(Request $request, ?string $schemaName, bool $batch return $payload; } - private function processBatchQuery(Request $request, string $schemaName = null): array + private function processBatchQuery(Request $request, ?string $schemaName = null): array { $queries = $this->batchParser->parse($request); $payloads = []; @@ -110,7 +110,7 @@ private function processBatchQuery(Request $request, string $schemaName = null): return $payloads; } - private function processNormalQuery(Request $request, string $schemaName = null): array + private function processNormalQuery(Request $request, ?string $schemaName = null): array { $params = $this->requestParser->parse($request); diff --git a/src/DataCollector/GraphQLCollector.php b/src/DataCollector/GraphQLCollector.php index c9ac7c3a2..577b9b14f 100644 --- a/src/DataCollector/GraphQLCollector.php +++ b/src/DataCollector/GraphQLCollector.php @@ -25,7 +25,7 @@ final class GraphQLCollector extends DataCollector */ protected array $batches = []; - public function collect(Request $request, Response $response, Throwable $exception = null): void + public function collect(Request $request, Response $response, ?Throwable $exception = null): void { $error = false; $count = 0; diff --git a/src/Definition/Argument.php b/src/Definition/Argument.php index 8c16deb60..ba446e5bc 100644 --- a/src/Definition/Argument.php +++ b/src/Definition/Argument.php @@ -11,12 +11,12 @@ final class Argument implements ArgumentInterface { private array $rawArguments = []; - public function __construct(array $rawArguments = null) + public function __construct(?array $rawArguments = null) { $this->exchangeArray($rawArguments); } - public function exchangeArray(array $array = null): array + public function exchangeArray(?array $array = null): array { $old = $this->rawArguments; $this->rawArguments = $array ?? []; diff --git a/src/Definition/Builder/SchemaBuilder.php b/src/Definition/Builder/SchemaBuilder.php index aee461512..dc3482bd1 100644 --- a/src/Definition/Builder/SchemaBuilder.php +++ b/src/Definition/Builder/SchemaBuilder.php @@ -23,7 +23,7 @@ public function __construct(TypeResolver $typeResolver, bool $enableValidation = $this->enableValidation = $enableValidation; } - public function getBuilder(string $name, ?string $queryAlias, string $mutationAlias = null, string $subscriptionAlias = null, array $types = []): Closure + public function getBuilder(string $name, ?string $queryAlias, ?string $mutationAlias = null, ?string $subscriptionAlias = null, array $types = []): Closure { return function () use ($name, $queryAlias, $mutationAlias, $subscriptionAlias, $types): ExtensibleSchema { static $schema = null; @@ -38,7 +38,7 @@ public function getBuilder(string $name, ?string $queryAlias, string $mutationAl /** * @param string[] $types */ - public function create(string $name, ?string $queryAlias, string $mutationAlias = null, string $subscriptionAlias = null, array $types = []): ExtensibleSchema + public function create(string $name, ?string $queryAlias, ?string $mutationAlias = null, ?string $subscriptionAlias = null, array $types = []): ExtensibleSchema { $this->typeResolver->setCurrentSchemaName($name); $query = $this->typeResolver->resolve($queryAlias); diff --git a/src/Definition/Type/CustomScalarType.php b/src/Definition/Type/CustomScalarType.php index c1858b873..1fb09c2cb 100644 --- a/src/Definition/Type/CustomScalarType.php +++ b/src/Definition/Type/CustomScalarType.php @@ -63,7 +63,7 @@ public function parseValue($value): mixed /** * {@inheritdoc} */ - public function parseLiteral(/* GraphQL\Language\AST\ValueNode */ $valueNode, array $variables = null): mixed + public function parseLiteral(/* GraphQL\Language\AST\ValueNode */ $valueNode, ?array $variables = null): mixed { return $this->call('parseLiteral', $valueNode); } diff --git a/src/Definition/Type/PhpEnumType.php b/src/Definition/Type/PhpEnumType.php index 21e0f4452..dcdaf72b0 100644 --- a/src/Definition/Type/PhpEnumType.php +++ b/src/Definition/Type/PhpEnumType.php @@ -93,7 +93,7 @@ public function parseValue($value): mixed return parent::parseValue($value); } - public function parseLiteral(Node $valueNode, array $variables = null): mixed + public function parseLiteral(Node $valueNode, ?array $variables = null): mixed { if ($this->enumClass) { if (!$valueNode instanceof EnumValueNode) { diff --git a/src/DependencyInjection/Compiler/ConfigParserPass.php b/src/DependencyInjection/Compiler/ConfigParserPass.php index e23e55211..3d5ecd308 100644 --- a/src/DependencyInjection/Compiler/ConfigParserPass.php +++ b/src/DependencyInjection/Compiler/ConfigParserPass.php @@ -240,7 +240,7 @@ private function mappingFromBundles(ContainerBuilder $container): array return $typesMappings; } - private function detectFilesByTypes(ContainerBuilder $container, string $path, string $suffix, array $types = null): array + private function detectFilesByTypes(ContainerBuilder $container, string $path, string $suffix, ?array $types = null): array { // add the closest existing directory as a resource $resource = $path; diff --git a/src/Error/InvalidArgumentError.php b/src/Error/InvalidArgumentError.php index 793b288db..5f17e63c3 100644 --- a/src/Error/InvalidArgumentError.php +++ b/src/Error/InvalidArgumentError.php @@ -18,7 +18,7 @@ public function __construct( ConstraintViolationListInterface $errors, string $message = '', int $code = 0, - Exception $previous = null + ?Exception $previous = null ) { $this->name = $name; $this->errors = $errors; diff --git a/src/Error/InvalidArgumentsError.php b/src/Error/InvalidArgumentsError.php index 93168041b..a9a450e88 100644 --- a/src/Error/InvalidArgumentsError.php +++ b/src/Error/InvalidArgumentsError.php @@ -16,7 +16,7 @@ public function __construct( array $errors, string $message = '', int $code = 0, - Exception $previous = null + ?Exception $previous = null ) { $this->errors = $errors; parent::__construct($message, $code, $previous); diff --git a/src/Error/UserErrors.php b/src/Error/UserErrors.php index 426145ce7..66e4a3f42 100644 --- a/src/Error/UserErrors.php +++ b/src/Error/UserErrors.php @@ -22,7 +22,7 @@ public function __construct( array $errors, string $message = '', int $code = 0, - Exception $previous = null + ?Exception $previous = null ) { $this->setErrors($errors); parent::__construct($message, $code, $previous); diff --git a/src/Event/ExecutorArgumentsEvent.php b/src/Event/ExecutorArgumentsEvent.php index ffe6096a5..f6c708b5e 100644 --- a/src/Event/ExecutorArgumentsEvent.php +++ b/src/Event/ExecutorArgumentsEvent.php @@ -30,8 +30,8 @@ public static function create( string $requestString, ArrayObject $contextValue, mixed $rootValue = null, - array $variableValue = null, - string $operationName = null + ?array $variableValue = null, + ?string $operationName = null ): self { $instance = new self(); $instance->setSchemaName($schemaName); diff --git a/src/EventListener/ErrorLoggerListener.php b/src/EventListener/ErrorLoggerListener.php index efbd62ad8..4c3670667 100644 --- a/src/EventListener/ErrorLoggerListener.php +++ b/src/EventListener/ErrorLoggerListener.php @@ -20,7 +20,7 @@ final class ErrorLoggerListener private LoggerInterface $logger; - public function __construct(LoggerInterface $logger = null) + public function __construct(?LoggerInterface $logger = null) { $this->logger = $logger ?? new NullLogger(); } diff --git a/src/Executor/Executor.php b/src/Executor/Executor.php index 6294b1bb1..222d3c6a7 100644 --- a/src/Executor/Executor.php +++ b/src/Executor/Executor.php @@ -28,8 +28,8 @@ public function execute( $contextValue = null, $variableValues = null, $operationName = null, - callable $fieldResolver = null, - array $validationRules = null + ?callable $fieldResolver = null, + ?array $validationRules = null ): ExecutionResult { if (!method_exists($promiseAdapter, 'wait')) { throw new RuntimeException( diff --git a/src/Executor/ExecutorInterface.php b/src/Executor/ExecutorInterface.php index 22240abf1..0cd6ec452 100644 --- a/src/Executor/ExecutorInterface.php +++ b/src/Executor/ExecutorInterface.php @@ -25,7 +25,7 @@ public function execute( $contextValue = null, $variableValues = null, $operationName = null, - callable $fieldResolver = null, - array $validationRules = null + ?callable $fieldResolver = null, + ?array $validationRules = null ): ExecutionResult; } diff --git a/src/Executor/Promise/Adapter/ReactPromiseAdapter.php b/src/Executor/Promise/Adapter/ReactPromiseAdapter.php index e09c49c8f..05ffa478a 100644 --- a/src/Executor/Promise/Adapter/ReactPromiseAdapter.php +++ b/src/Executor/Promise/Adapter/ReactPromiseAdapter.php @@ -42,7 +42,7 @@ public function convertThenable($thenable): Promise * * @throws Exception */ - public function wait(Promise $promise, callable $onProgress = null): ?ExecutionResult + public function wait(Promise $promise, ?callable $onProgress = null): ?ExecutionResult { if (!$this->isThenable($promise)) { throw new InvalidArgumentException(sprintf('The "%s" method must be call with compatible a Promise.', __METHOD__)); diff --git a/src/ExpressionLanguage/Exception/EvaluatorIsNotAllowedException.php b/src/ExpressionLanguage/Exception/EvaluatorIsNotAllowedException.php index 58d23de12..be4053c84 100644 --- a/src/ExpressionLanguage/Exception/EvaluatorIsNotAllowedException.php +++ b/src/ExpressionLanguage/Exception/EvaluatorIsNotAllowedException.php @@ -9,7 +9,7 @@ final class EvaluatorIsNotAllowedException extends Exception { - public function __construct(string $expressionFunctionName, int $code = 0, Throwable $previous = null) + public function __construct(string $expressionFunctionName, int $code = 0, ?Throwable $previous = null) { parent::__construct( "The expression function '$expressionFunctionName' cannot be used by it's evaluator.", diff --git a/src/ExpressionLanguage/ExpressionFunction.php b/src/ExpressionLanguage/ExpressionFunction.php index 5bd965ee8..06b9610ff 100644 --- a/src/ExpressionLanguage/ExpressionFunction.php +++ b/src/ExpressionLanguage/ExpressionFunction.php @@ -12,7 +12,7 @@ class ExpressionFunction extends BaseExpressionFunction { protected string $gqlServices = '$'.TypeGenerator::GRAPHQL_SERVICES; - public function __construct(string $name, callable $compiler, callable $evaluator = null) + public function __construct(string $name, callable $compiler, ?callable $evaluator = null) { if (null === $evaluator) { $evaluator = new EvaluatorIsNotAllowedException($name); diff --git a/src/ExpressionLanguage/ExpressionFunction/GraphQL/Relay/GlobalID.php b/src/ExpressionLanguage/ExpressionFunction/GraphQL/Relay/GlobalID.php index 4c923500b..4f41042c2 100644 --- a/src/ExpressionLanguage/ExpressionFunction/GraphQL/Relay/GlobalID.php +++ b/src/ExpressionLanguage/ExpressionFunction/GraphQL/Relay/GlobalID.php @@ -15,7 +15,7 @@ public function __construct() { parent::__construct( 'globalId', - function (string $id, string $typeName = null): string { + function (string $id, ?string $typeName = null): string { $typeName = $this->isTypeNameEmpty($typeName) ? '$info->parentType->name' : $typeName; return sprintf('\%s::toGlobalId(%s, %s)', GlobalIdHelper::class, $typeName, $id); diff --git a/src/Generator/TypeBuilder.php b/src/Generator/TypeBuilder.php index 5eb64041c..6952abeaf 100644 --- a/src/Generator/TypeBuilder.php +++ b/src/Generator/TypeBuilder.php @@ -449,7 +449,7 @@ private function buildScalarCallback($callback, string $fieldName) * * @throws GeneratorException */ - private function buildResolve($resolve, array $groups = null): GeneratorInterface + private function buildResolve($resolve, ?array $groups = null): GeneratorInterface { if (is_callable($resolve) && is_array($resolve)) { return Collection::numeric($resolve); diff --git a/src/Generator/TypeGeneratorOptions.php b/src/Generator/TypeGeneratorOptions.php index 14ae5df19..54b65bfae 100644 --- a/src/Generator/TypeGeneratorOptions.php +++ b/src/Generator/TypeGeneratorOptions.php @@ -36,8 +36,8 @@ public function __construct( string $namespace, ?string $cacheDir, bool $useClassMap = true, - string $cacheBaseDir = null, - int $cacheDirMask = null + ?string $cacheBaseDir = null, + ?int $cacheDirMask = null ) { $this->namespace = $namespace; $this->cacheDir = $cacheDir; diff --git a/src/Relay/Connection/ConnectionBuilder.php b/src/Relay/Connection/ConnectionBuilder.php index 629624ea3..d0b701762 100644 --- a/src/Relay/Connection/ConnectionBuilder.php +++ b/src/Relay/Connection/ConnectionBuilder.php @@ -59,7 +59,7 @@ final class ConnectionBuilder * @phpstan-param ConnectionFactoryFunc|null $connectionCallback * @phpstan-param EdgeFactoryFunc|null $edgeCallback */ - public function __construct(CursorEncoderInterface $cursorEncoder = null, callable $connectionCallback = null, callable $edgeCallback = null) + public function __construct(?CursorEncoderInterface $cursorEncoder = null, ?callable $connectionCallback = null, ?callable $edgeCallback = null) { $this->cursorEncoder = $cursorEncoder ?? new Base64CursorEncoder(); $this->connectionCallback = $connectionCallback ?? static fn (array $edges, PageInfoInterface $pageInfo): Connection => new Connection($edges, $pageInfo); diff --git a/src/Relay/Connection/Output/Connection.php b/src/Relay/Connection/Output/Connection.php index ce36a6dd4..d3fa1f739 100644 --- a/src/Relay/Connection/Output/Connection.php +++ b/src/Relay/Connection/Output/Connection.php @@ -31,7 +31,7 @@ class Connection implements ConnectionInterface /** * @param EdgeInterface[] $edges */ - public function __construct(array $edges = [], PageInfoInterface $pageInfo = null) + public function __construct(array $edges = [], ?PageInfoInterface $pageInfo = null) { $this->edges = $edges; $this->pageInfo = $pageInfo; diff --git a/src/Relay/Connection/Output/Edge.php b/src/Relay/Connection/Output/Edge.php index ad4f1c9da..295829c2e 100644 --- a/src/Relay/Connection/Output/Edge.php +++ b/src/Relay/Connection/Output/Edge.php @@ -25,7 +25,7 @@ class Edge implements EdgeInterface * * @phpstan-param T|null $node */ - public function __construct(string $cursor = null, $node = null) + public function __construct(?string $cursor = null, $node = null) { $this->cursor = $cursor; $this->node = $node; diff --git a/src/Relay/Connection/Output/PageInfo.php b/src/Relay/Connection/Output/PageInfo.php index da9a5b999..40f522ea3 100644 --- a/src/Relay/Connection/Output/PageInfo.php +++ b/src/Relay/Connection/Output/PageInfo.php @@ -15,7 +15,7 @@ final class PageInfo implements PageInfoInterface protected ?bool $hasPreviousPage; protected ?bool $hasNextPage; - public function __construct(string $startCursor = null, string $endCursor = null, bool $hasPreviousPage = null, bool $hasNextPage = null) + public function __construct(?string $startCursor = null, ?string $endCursor = null, ?bool $hasPreviousPage = null, ?bool $hasNextPage = null) { $this->startCursor = $startCursor; $this->endCursor = $endCursor; diff --git a/src/Relay/Connection/Paginator.php b/src/Relay/Connection/Paginator.php index 90ab63ff8..e7f810d92 100644 --- a/src/Relay/Connection/Paginator.php +++ b/src/Relay/Connection/Paginator.php @@ -27,7 +27,7 @@ final class Paginator /** @var callable */ private $fetcher; - public function __construct(callable $fetcher, bool $promise = self::MODE_REGULAR, ConnectionBuilder $connectionBuilder = null) + public function __construct(callable $fetcher, bool $promise = self::MODE_REGULAR, ?ConnectionBuilder $connectionBuilder = null) { $this->fetcher = $fetcher; $this->promise = $promise; diff --git a/src/Request/Executor.php b/src/Request/Executor.php index 706cd4fa1..e6af42b84 100644 --- a/src/Request/Executor.php +++ b/src/Request/Executor.php @@ -44,7 +44,7 @@ public function __construct( ExecutorInterface $executor, PromiseAdapter $promiseAdapter, EventDispatcherInterface $dispatcher, - callable $defaultFieldResolver = null + ?callable $defaultFieldResolver = null ) { $this->executor = $executor; $this->promiseAdapter = $promiseAdapter; @@ -73,7 +73,7 @@ public function addSchema(string $name, Schema $schema): self return $this; } - public function getSchema(string $name = null): Schema + public function getSchema(?string $name = null): Schema { if (empty($this->schemas)) { throw new RuntimeException('At least one schema should be declare.'); @@ -171,8 +171,8 @@ private function preExecute( string $requestString, ArrayObject $contextValue, $rootValue = null, - array $variableValue = null, - string $operationName = null + ?array $variableValue = null, + ?string $operationName = null ): ExecutorArgumentsEvent { // @phpstan-ignore-next-line (only for Symfony 4.4) $this->dispatcher->dispatch(new ExecutorContextEvent($contextValue), Events::EXECUTOR_CONTEXT); diff --git a/src/Resolver/AccessResolver.php b/src/Resolver/AccessResolver.php index 187a2e25c..c73f95e6c 100644 --- a/src/Resolver/AccessResolver.php +++ b/src/Resolver/AccessResolver.php @@ -138,7 +138,7 @@ private function extractAdoptedPromise($object) /** * @param mixed $promise */ - private function createPromise($promise, callable $onFulfilled = null): Promise + private function createPromise($promise, ?callable $onFulfilled = null): Promise { return $this->promiseAdapter->then( new Promise($this->extractAdoptedPromise($promise), $this->promiseAdapter), diff --git a/src/Resolver/ResolverMap.php b/src/Resolver/ResolverMap.php index 816c0da69..497ec86ea 100644 --- a/src/Resolver/ResolverMap.php +++ b/src/Resolver/ResolverMap.php @@ -70,7 +70,7 @@ public function isResolvable(string $typeName, string $fieldName): bool /** * {@inheritdoc} */ - public function covered(string $typeName = null) + public function covered(?string $typeName = null) { $loadedMap = $this->getLoadedMap(); $covered = []; diff --git a/src/Resolver/ResolverMapInterface.php b/src/Resolver/ResolverMapInterface.php index c6938b46e..6dd99ccda 100644 --- a/src/Resolver/ResolverMapInterface.php +++ b/src/Resolver/ResolverMapInterface.php @@ -42,5 +42,5 @@ public function isResolvable(string $typeName, string $fieldName): bool; * * @return array */ - public function covered(string $typeName = null); + public function covered(?string $typeName = null); } diff --git a/src/Resolver/ResolverMaps.php b/src/Resolver/ResolverMaps.php index c2b60510e..be838adc3 100644 --- a/src/Resolver/ResolverMaps.php +++ b/src/Resolver/ResolverMaps.php @@ -52,7 +52,7 @@ public function isResolvable(string $typeName, string $fieldName): bool /** * {@inheritdoc} */ - public function covered(string $typeName = null) + public function covered(?string $typeName = null) { $covered = []; foreach ($this->resolverMaps as $resolverMap) { diff --git a/src/Transformer/ArgumentsTransformer.php b/src/Transformer/ArgumentsTransformer.php index c653d881a..12fce60a7 100644 --- a/src/Transformer/ArgumentsTransformer.php +++ b/src/Transformer/ArgumentsTransformer.php @@ -34,7 +34,7 @@ final class ArgumentsTransformer private ?ValidatorInterface $validator; private array $classesMap; - public function __construct(ValidatorInterface $validator = null, array $classesMap = []) + public function __construct(?ValidatorInterface $validator = null, array $classesMap = []) { $this->validator = $validator; $this->accessor = PropertyAccess::createPropertyAccessor(); diff --git a/src/Upload/Type/GraphQLUploadType.php b/src/Upload/Type/GraphQLUploadType.php index 7a4d30ec0..8f493dd7d 100644 --- a/src/Upload/Type/GraphQLUploadType.php +++ b/src/Upload/Type/GraphQLUploadType.php @@ -14,7 +14,7 @@ final class GraphQLUploadType extends ScalarType { - public function __construct(string $name = null) + public function __construct(?string $name = null) { parent::__construct([ 'name' => $name, @@ -52,7 +52,7 @@ public function serialize($value): void /** * {@inheritdoc} */ - public function parseLiteral($valueNode, array $variables = null): void + public function parseLiteral($valueNode, ?array $variables = null): void { throw new InvariantViolation(sprintf('%s scalar literal unsupported.', $this->name)); } diff --git a/src/Validator/Exception/ArgumentsValidationException.php b/src/Validator/Exception/ArgumentsValidationException.php index fca5e611b..92ed7f8bf 100644 --- a/src/Validator/Exception/ArgumentsValidationException.php +++ b/src/Validator/Exception/ArgumentsValidationException.php @@ -13,7 +13,7 @@ final class ArgumentsValidationException extends Exception implements ClientAwar { private ConstraintViolationListInterface $violations; - public function __construct(ConstraintViolationListInterface $violations, Throwable $previous = null) + public function __construct(ConstraintViolationListInterface $violations, ?Throwable $previous = null) { $this->violations = $violations; parent::__construct('validation', 0, $previous); diff --git a/src/Validator/InputValidator.php b/src/Validator/InputValidator.php index 18846c393..8059456ed 100644 --- a/src/Validator/InputValidator.php +++ b/src/Validator/InputValidator.php @@ -63,7 +63,7 @@ public function __construct( /** * @throws ArgumentsValidationException */ - public function validate(string|array $groups = null, bool $throw = true): ?ConstraintViolationListInterface + public function validate(string|array|null $groups = null, bool $throw = true): ?ConstraintViolationListInterface { $rootNode = new ValidationNode( $this->info->parentType, diff --git a/src/Validator/ValidationNode.php b/src/Validator/ValidationNode.php index a13d3848a..7a0c39b56 100644 --- a/src/Validator/ValidationNode.php +++ b/src/Validator/ValidationNode.php @@ -50,9 +50,9 @@ final class ValidationNode public function __construct( ObjectType|InputObjectType $type, - string $field = null, - ValidationNode $parent = null, - ResolverArgs $resolverArgs = null + ?string $field = null, + ?ValidationNode $parent = null, + ?ResolverArgs $resolverArgs = null ) { $this->__type = $type; $this->__fieldName = $field; diff --git a/tests/Config/Parser/fixtures/annotations/Type/Battle.php b/tests/Config/Parser/fixtures/annotations/Type/Battle.php index 30be8b833..678277975 100644 --- a/tests/Config/Parser/fixtures/annotations/Type/Battle.php +++ b/tests/Config/Parser/fixtures/annotations/Type/Battle.php @@ -29,12 +29,12 @@ final class Battle public function getCasualties( int $areaId, ?string $raceId, - int $dayStart = null, - int $dayEnd = null, + ?int $dayStart = null, + ?int $dayEnd = null, string $nameStartingWith = '', - Planet $planet = null, + ?Planet $planet = null, bool $away = false, - float $maxDistance = null + ?float $maxDistance = null ): ?int { return 12; } diff --git a/tests/DependencyInjection/Builder/TimestampFields.php b/tests/DependencyInjection/Builder/TimestampFields.php index bcfdff2f9..4878df0bb 100644 --- a/tests/DependencyInjection/Builder/TimestampFields.php +++ b/tests/DependencyInjection/Builder/TimestampFields.php @@ -8,7 +8,7 @@ final class TimestampFields implements MappingInterface { - public function toMappingDefinition(array $config = null): array + public function toMappingDefinition(?array $config = null): array { return [ 'createdAt' => [ diff --git a/tests/DependencyInjection/Compiler/ConfigParserPassTest.php b/tests/DependencyInjection/Compiler/ConfigParserPassTest.php index 7ce3e90d1..ff20a7fe9 100644 --- a/tests/DependencyInjection/Compiler/ConfigParserPassTest.php +++ b/tests/DependencyInjection/Compiler/ConfigParserPassTest.php @@ -564,7 +564,7 @@ public function fieldBuilderTypeOverrideNotAllowedProvider(): array ]; } - private function processCompilerPass(array $configs, ConfigParserPass $compilerPass = null, ContainerBuilder $container = null): void + private function processCompilerPass(array $configs, ?ConfigParserPass $compilerPass = null, ?ContainerBuilder $container = null): void { $container ??= $this->container; $compilerPass ??= $this->compilerPass; diff --git a/tests/EventListener/TypeDecoratorListenerTest.php b/tests/EventListener/TypeDecoratorListenerTest.php index ccd07160a..ccfbf74b8 100644 --- a/tests/EventListener/TypeDecoratorListenerTest.php +++ b/tests/EventListener/TypeDecoratorListenerTest.php @@ -33,7 +33,7 @@ final class TypeDecoratorListenerTest extends TestCase * * @dataProvider specialTypeFieldProvider */ - public function testSpecialField($fieldName, ObjectType|UnionType|InterfaceType|CustomScalarType $typeWithSpecialField, callable $fieldValueRetriever = null, $strict = true): void + public function testSpecialField($fieldName, ObjectType|UnionType|InterfaceType|CustomScalarType $typeWithSpecialField, ?callable $fieldValueRetriever = null, $strict = true): void { if (null === $fieldValueRetriever) { $fieldValueRetriever = fn (ObjectType|UnionType|InterfaceType|CustomScalarType $type, $fieldName) => $type->config[$fieldName]; @@ -292,12 +292,12 @@ public function specialTypeFieldProvider(): array // custom scalar [ResolverMapInterface::SERIALIZE, new CustomScalarType(['name' => 'Custom', 'scalarType' => Type::string(), 'serialize' => fn (mixed $input): mixed => ''])], [ResolverMapInterface::PARSE_VALUE, new CustomScalarType(['name' => 'Custom', 'scalarType' => Type::string(), 'serialize' => fn (mixed $input): mixed => '', 'parseValue' => fn (mixed $input): mixed => ''])], - [ResolverMapInterface::PARSE_LITERAL, new CustomScalarType(['name' => 'Custom', 'scalarType' => Type::string(), 'serialize' => fn (mixed $input): mixed => '', 'parseLiteral' => fn (Node $a, array|null $b): mixed => ''])], + [ResolverMapInterface::PARSE_LITERAL, new CustomScalarType(['name' => 'Custom', 'scalarType' => Type::string(), 'serialize' => fn (mixed $input): mixed => '', 'parseLiteral' => fn (Node $a, ?array $b): mixed => ''])], [ResolverMapInterface::SCALAR_TYPE, new CustomScalarType(['name' => 'Custom', 'scalarType' => Type::string(), 'serialize' => fn (mixed $input): mixed => ''])], ]; } - private function assertDecorateException(array $types, array $map, string $exception = null, string $exceptionMessage = null): void + private function assertDecorateException(array $types, array $map, ?string $exception = null, ?string $exceptionMessage = null): void { if ($exception) { $this->expectException($exception); // @phpstan-ignore-line diff --git a/tests/ExpressionLanguage/ExpressionFunction/GraphQL/ArgumentsTest.php b/tests/ExpressionLanguage/ExpressionFunction/GraphQL/ArgumentsTest.php index 5e24b1c21..ffa8996d8 100644 --- a/tests/ExpressionLanguage/ExpressionFunction/GraphQL/ArgumentsTest.php +++ b/tests/ExpressionLanguage/ExpressionFunction/GraphQL/ArgumentsTest.php @@ -44,7 +44,7 @@ public function getResolveInfo(array $types): ResolveInfo return $info; } - private function getTransformer(array $classesMap = null): ArgumentsTransformer + private function getTransformer(?array $classesMap = null): ArgumentsTransformer { $validator = $this->createMock(RecursiveValidator::class); $validator->method('validate')->willReturn(new ConstraintViolationList()); diff --git a/tests/ExpressionLanguage/TestCase.php b/tests/ExpressionLanguage/TestCase.php index 0db2a43d1..43df70737 100644 --- a/tests/ExpressionLanguage/TestCase.php +++ b/tests/ExpressionLanguage/TestCase.php @@ -55,7 +55,7 @@ protected function assertExpressionCompile( $expression, $with, array $vars = [], - InvokedCount $expects = null, + ?InvokedCount $expects = null, bool $return = true, string $assertMethod = 'assertTrue' ): void { diff --git a/tests/Functional/App/Mutation/InputValidatorMutation.php b/tests/Functional/App/Mutation/InputValidatorMutation.php index 056917717..e4aee1c27 100644 --- a/tests/Functional/App/Mutation/InputValidatorMutation.php +++ b/tests/Functional/App/Mutation/InputValidatorMutation.php @@ -16,7 +16,7 @@ final class InputValidatorMutation implements MutationInterface /** * @throws ArgumentsValidationException */ - public function mutationMock(Argument $args, InputValidator $validator = null): bool + public function mutationMock(Argument $args, ?InputValidator $validator = null): bool { if (null !== $validator) { $validator($args['groups']); diff --git a/tests/Functional/App/TestKernel.php b/tests/Functional/App/TestKernel.php index 3c2c5981f..6f5c6874d 100644 --- a/tests/Functional/App/TestKernel.php +++ b/tests/Functional/App/TestKernel.php @@ -31,7 +31,7 @@ public function registerBundles(): iterable yield new OverblogGraphQLBundle(); } - public function __construct(string $environment, bool $debug, string $testCase = null) + public function __construct(string $environment, bool $debug, ?string $testCase = null) { $this->testCase = $testCase; parent::__construct($environment, $debug); diff --git a/tests/Functional/App/Type/YearScalarType.php b/tests/Functional/App/Type/YearScalarType.php index ffa1832b4..e2a215725 100644 --- a/tests/Functional/App/Type/YearScalarType.php +++ b/tests/Functional/App/Type/YearScalarType.php @@ -32,7 +32,7 @@ public function parseValue($value): mixed /** * {@inheritdoc} */ - public function parseLiteral($valueNode, array $variables = null): mixed + public function parseLiteral($valueNode, ?array $variables = null): mixed { if (!$valueNode instanceof StringValueNode) { throw new Error('Query error: Can only parse strings got: '.$valueNode->kind, $valueNode); diff --git a/tests/Functional/BaseTestCase.php b/tests/Functional/BaseTestCase.php index 172e613b0..670c86386 100644 --- a/tests/Functional/BaseTestCase.php +++ b/tests/Functional/BaseTestCase.php @@ -71,7 +71,7 @@ protected function tearDown(): void static::ensureKernelShutdown(); } - protected static function executeGraphQLRequest(string $query, array $rootValue = [], string $schemaName = null, array $variables = []): array + protected static function executeGraphQLRequest(string $query, array $rootValue = [], ?string $schemaName = null, array $variables = []): array { $request = new Request(); $request->query->set('query', $query); @@ -87,7 +87,7 @@ protected static function executeGraphQLRequest(string $query, array $rootValue return $res->toArray(); } - protected static function assertGraphQL(string $query, array $expectedData = null, array $expectedErrors = null, array $rootValue = [], string $schemaName = null): void + protected static function assertGraphQL(string $query, ?array $expectedData = null, ?array $expectedErrors = null, array $rootValue = [], ?string $schemaName = null): void { $result = static::executeGraphQLRequest($query, $rootValue, $schemaName); @@ -127,7 +127,7 @@ protected static function createClientAuthenticated(?string $username, string $t return $client; } - protected static function assertResponse(string $query, array $expected, ?string $username, string $testCase, ?string $password = self::DEFAULT_PASSWORD, array $variables = null): KernelBrowser + protected static function assertResponse(string $query, array $expected, ?string $username, string $testCase, ?string $password = self::DEFAULT_PASSWORD, ?array $variables = null): KernelBrowser { $client = self::createClientAuthenticated($username, $testCase, $password); $result = self::sendRequest($client, $query, false, $variables); @@ -140,7 +140,7 @@ protected static function assertResponse(string $query, array $expected, ?string /** * @return mixed */ - protected static function sendRequest(KernelBrowser $client, string $query, bool $isDecoded = false, array $variables = null) + protected static function sendRequest(KernelBrowser $client, string $query, bool $isDecoded = false, ?array $variables = null) { $client->request('GET', '/', ['query' => $query, 'variables' => json_encode($variables)]); $result = $client->getResponse()->getContent(); diff --git a/tests/Relay/Connection/ConnectionBuilderFromPromisedTest.php b/tests/Relay/Connection/ConnectionBuilderFromPromisedTest.php index 3b02f6a54..7dc744761 100644 --- a/tests/Relay/Connection/ConnectionBuilderFromPromisedTest.php +++ b/tests/Relay/Connection/ConnectionBuilderFromPromisedTest.php @@ -87,7 +87,7 @@ public function testInvalidPromiseWhenSlicing($invalidPromise): void /** * @return ExtendedPromiseInterface|FulfilledPromise|Promise|PromiseInterface */ - private function promisedLetters(array $letters = null) + private function promisedLetters(?array $letters = null) { return resolve($letters ?: $this->letters); } diff --git a/tests/Transformer/ArgumentsTransformerTest.php b/tests/Transformer/ArgumentsTransformerTest.php index 9ef2d3398..408d508ab 100644 --- a/tests/Transformer/ArgumentsTransformerTest.php +++ b/tests/Transformer/ArgumentsTransformerTest.php @@ -37,7 +37,7 @@ protected function setUp(): void } } - private function getTransformer(array $classesMap = [], ConstraintViolationList $validateReturn = null): ArgumentsTransformer + private function getTransformer(array $classesMap = [], ?ConstraintViolationList $validateReturn = null): ArgumentsTransformer { $validator = $this->createMock(RecursiveValidator::class); $validator->method('validate')->willReturn($validateReturn ?? new ConstraintViolationList());