Skip to content
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

PHP 8.4 deprecates implicitly nullable types #1198

Merged
merged 1 commit into from
Dec 19, 2024
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
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
- '8.1'
- '8.2'
- '8.3'
- '8.4'
symfony-version:
- '5.4.*'
- '6.0.*'
Expand All @@ -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.*'
Expand Down
1 change: 1 addition & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/Annotation/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ abstract class Builder extends Annotation
/**
* Builder name.
*/
public string $name;
public ?string $name;

/**
* The builder config.
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Annotation/Input.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/Annotation/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Annotation/Relay/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Annotation/Scalar.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/Annotation/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Annotation/TypeInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/Annotation/Union.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/CacheWarmer/CompileCacheWarmer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Processor/InheritanceProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions src/Controller/GraphController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ 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);
}

/**
* @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);
}
Expand Down Expand Up @@ -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 = [];
Expand All @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/DataCollector/GraphQLCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/Definition/Argument.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?? [];
Expand Down
4 changes: 2 additions & 2 deletions src/Definition/Builder/SchemaBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Definition/Type/CustomScalarType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Definition/Type/PhpEnumType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/Compiler/ConfigParserPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Error/InvalidArgumentError.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Error/InvalidArgumentsError.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Error/UserErrors.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/Event/ExecutorArgumentsEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/EventListener/ErrorLoggerListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Executor/Executor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions src/Executor/ExecutorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion src/Executor/Promise/Adapter/ReactPromiseAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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__));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
2 changes: 1 addition & 1 deletion src/ExpressionLanguage/ExpressionFunction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Generator/TypeBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/Generator/TypeGeneratorOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Relay/Connection/ConnectionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Relay/Connection/Output/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Connection implements ConnectionInterface
/**
* @param EdgeInterface<T>[] $edges
*/
public function __construct(array $edges = [], PageInfoInterface $pageInfo = null)
public function __construct(array $edges = [], ?PageInfoInterface $pageInfo = null)
{
$this->edges = $edges;
$this->pageInfo = $pageInfo;
Expand Down
2 changes: 1 addition & 1 deletion src/Relay/Connection/Output/Edge.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Relay/Connection/Output/PageInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading