Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions src/Type/VerbosityLevel.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,19 @@ final class VerbosityLevel
/** @var self[] */
private static array $registry;

/**
* @param self::* $value
*/
private function __construct(private int $value)
{
}
private static self $TYPE_ONLY;

private static self $VALUE;

private static self $PRECISE;

private static self $CACHE;

/**
* @param self::* $value
*/
private static function create(int $value): self
private function __construct(private int $value)
{
self::$registry[$value] ??= new self($value);
return self::$registry[$value];
}

/** @return self::* */
Expand All @@ -75,19 +74,19 @@ public function getLevelValue(): int
/** @api */
public static function typeOnly(): self
{
return self::create(self::TYPE_ONLY);
return self::$TYPE_ONLY ??= (self::$registry[self::TYPE_ONLY] ??= new self(self::TYPE_ONLY));
}

/** @api */
public static function value(): self
{
return self::create(self::VALUE);
return self::$VALUE ??= (self::$registry[self::VALUE] ??= new self(self::VALUE));
}

/** @api */
public static function precise(): self
{
return self::create(self::PRECISE);
return self::$PRECISE ??= (self::$registry[self::PRECISE] ??= new self(self::PRECISE));
}

/**
Expand All @@ -97,7 +96,7 @@ public static function precise(): self
*/
public static function cache(): self
{
return self::create(self::CACHE);
return self::$CACHE ??= (self::$registry[self::CACHE] ??= new self(self::CACHE));
}

public function isTypeOnly(): bool
Expand Down
Loading