From 995457209b37324d80368b1a667f505c689d3c5e Mon Sep 17 00:00:00 2001 From: Ruud Kamphuis Date: Mon, 11 Nov 2024 14:02:01 +0100 Subject: [PATCH] Store built-in types in static property This way, it behaves the same as the standard types. --- src/Type/Definition/Type.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Type/Definition/Type.php b/src/Type/Definition/Type.php index e757e7d32..6a2a29c52 100644 --- a/src/Type/Definition/Type.php +++ b/src/Type/Definition/Type.php @@ -33,6 +33,9 @@ abstract class Type implements \JsonSerializable /** @var array */ protected static array $standardTypes = []; + /** @var array */ + protected static array $builtInTypes = []; + /** * @api * @@ -116,9 +119,11 @@ public static function nonNull($type): NonNull */ public static function builtInTypes(): array { - static $builtInTypes; + if (self::$builtInTypes !== []) { + return self::$builtInTypes; + } - return $builtInTypes ??= \array_merge( + return self::$builtInTypes = \array_merge( Introspection::getTypes(), self::getStandardTypes() ); @@ -265,5 +270,6 @@ public function jsonSerialize(): string public static function reset(): void { static::$standardTypes = []; + static::$builtInTypes = []; } }