Skip to content

Commit

Permalink
Store built-in types in static property
Browse files Browse the repository at this point in the history
This way, it behaves the same as the standard types.
  • Loading branch information
ruudk committed Nov 11, 2024
1 parent 9bc956c commit 9954572
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Type/Definition/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ abstract class Type implements \JsonSerializable
/** @var array<string, ScalarType> */
protected static array $standardTypes = [];

/** @var array<string, Type&NamedType> */
protected static array $builtInTypes = [];

/**
* @api
*
Expand Down Expand Up @@ -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()
);
Expand Down Expand Up @@ -265,5 +270,6 @@ public function jsonSerialize(): string
public static function reset(): void
{
static::$standardTypes = [];
static::$builtInTypes = [];
}
}

0 comments on commit 9954572

Please sign in to comment.