diff --git a/src/Type/Definition/Directive.php b/src/Type/Definition/Directive.php index f2c546f93..31bb127d3 100644 --- a/src/Type/Definition/Directive.php +++ b/src/Type/Definition/Directive.php @@ -31,9 +31,9 @@ class Directive /** * Lazily initialized. * - * @var array + * @var null|array */ - protected static array $internalDirectives = []; + protected static ?array $internalDirectives = null; public string $name; @@ -90,11 +90,7 @@ public static function includeDirective(): Directive */ public static function getInternalDirectives(): array { - if (self::$internalDirectives !== []) { - return self::$internalDirectives; - } - - return self::$internalDirectives = [ + return self::$internalDirectives ??= [ 'include' => new self([ 'name' => self::INCLUDE_NAME, 'description' => 'Directs the executor to include this field or fragment only when the `if` argument is true.', @@ -169,6 +165,6 @@ public static function isSpecifiedDirective(Directive $directive): bool public static function reset(): void { - self::$internalDirectives = []; + self::$internalDirectives = null; } } diff --git a/src/Type/Definition/Type.php b/src/Type/Definition/Type.php index 6a2a29c52..fc4262eff 100644 --- a/src/Type/Definition/Type.php +++ b/src/Type/Definition/Type.php @@ -31,10 +31,10 @@ abstract class Type implements \JsonSerializable ]; /** @var array */ - protected static array $standardTypes = []; + protected static ?array $standardTypes = []; - /** @var array */ - protected static array $builtInTypes = []; + /** @var null|array */ + protected static ?array $builtInTypes = null; /** * @api @@ -119,11 +119,7 @@ public static function nonNull($type): NonNull */ public static function builtInTypes(): array { - if (self::$builtInTypes !== []) { - return self::$builtInTypes; - } - - return self::$builtInTypes = \array_merge( + return self::$builtInTypes ??= \array_merge( Introspection::getTypes(), self::getStandardTypes() ); @@ -270,6 +266,6 @@ public function jsonSerialize(): string public static function reset(): void { static::$standardTypes = []; - static::$builtInTypes = []; + static::$builtInTypes = null; } }