Skip to content

Commit

Permalink
Apply feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
ruudk committed Nov 12, 2024
1 parent 457b23c commit f111e7a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
12 changes: 4 additions & 8 deletions src/Type/Definition/Directive.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class Directive
/**
* Lazily initialized.
*
* @var array<string, Directive>
* @var null|array<string, Directive>
*/
protected static array $internalDirectives = [];
protected static ?array $internalDirectives = null;

public string $name;

Expand Down Expand Up @@ -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.',
Expand Down Expand Up @@ -169,6 +165,6 @@ public static function isSpecifiedDirective(Directive $directive): bool

public static function reset(): void
{
self::$internalDirectives = [];
self::$internalDirectives = null;
}
}
14 changes: 5 additions & 9 deletions src/Type/Definition/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ abstract class Type implements \JsonSerializable
];

/** @var array<string, ScalarType> */
protected static array $standardTypes = [];
protected static ?array $standardTypes = [];

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

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

0 comments on commit f111e7a

Please sign in to comment.