From fd4da564f82dcbbab676839b7d4b9f8891d44ec0 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Thu, 28 Nov 2024 14:02:59 +1300 Subject: [PATCH] API Explicity mark nullable paramters for PHP 8.4 --- src/Dev/Benchmark.php | 2 +- src/Dev/SchemaBuild.php | 2 +- src/Schema/DataObject/CreateCreator.php | 2 +- src/Schema/Services/SchemaTranscriber.php | 2 +- tests/Schema/SchemaTest.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Dev/Benchmark.php b/src/Dev/Benchmark.php index a922954d..9bf00836 100644 --- a/src/Dev/Benchmark.php +++ b/src/Dev/Benchmark.php @@ -29,7 +29,7 @@ public static function start(string $id): void * @return string|null * @throws \Exception */ - public static function end(string $id, string $message = null, bool $return = true): ?string + public static function end(string $id, ?string $message = null, bool $return = true): ?string { $benchmark = Benchmark::$benchmarks[$id] ?? null; if (!$benchmark) { diff --git a/src/Dev/SchemaBuild.php b/src/Dev/SchemaBuild.php index e12cee87..f3786e80 100644 --- a/src/Dev/SchemaBuild.php +++ b/src/Dev/SchemaBuild.php @@ -61,7 +61,7 @@ protected function getHeading(): string * @throws SchemaNotFoundException * @throws SchemaBuilderException */ - public function buildSchema(string $key = null, bool $clear = true): void + public function buildSchema(?string $key = null, bool $clear = true): void { /** @var LoggerInterface $logger */ $logger = Injector::inst()->get(LoggerInterface::class . '.graphql-build'); diff --git a/src/Schema/DataObject/CreateCreator.php b/src/Schema/DataObject/CreateCreator.php index d3fa8802..ab3e8655 100644 --- a/src/Schema/DataObject/CreateCreator.php +++ b/src/Schema/DataObject/CreateCreator.php @@ -79,7 +79,7 @@ public function createOperation( public static function resolve(array $resolverContext = []): Closure { $dataClass = $resolverContext['dataClass'] ?? null; - return function ($obj, $args = [], $context = [], ResolveInfo $info = null) use ($dataClass) { + return function ($obj, $args = [], $context = [], ?ResolveInfo $info = null) use ($dataClass) { if (!$dataClass) { return null; } diff --git a/src/Schema/Services/SchemaTranscriber.php b/src/Schema/Services/SchemaTranscriber.php index 16632152..0b1409d0 100644 --- a/src/Schema/Services/SchemaTranscriber.php +++ b/src/Schema/Services/SchemaTranscriber.php @@ -38,7 +38,7 @@ class SchemaTranscriber * @param string $rootDir Storage path for the generated file. * Caution: This location may be used by frontend assets relying on GraphQL, e.g. silverstripe/assets. */ - public function __construct(GraphQLSchema $schema, string $name, string $rootDir = null) + public function __construct(GraphQLSchema $schema, string $name, ?string $rootDir = null) { $this->fs = new Filesystem(); $this->schema = $schema; diff --git a/tests/Schema/SchemaTest.php b/tests/Schema/SchemaTest.php index 8ca2d078..28673276 100644 --- a/tests/Schema/SchemaTest.php +++ b/tests/Schema/SchemaTest.php @@ -285,7 +285,7 @@ public static function noop() { } - private function buildSchema(string $key = 'test', SchemaConfig $context = null): Schema + private function buildSchema(string $key = 'test', ?SchemaConfig $context = null): Schema { $schema = new Schema($key, $this->createSchemaContext());