Skip to content

Commit 4f7e20b

Browse files
committed
VerbosityLevel offers getLevelValue()
1 parent 96e4443 commit 4f7e20b

1 file changed

Lines changed: 18 additions & 11 deletions

File tree

src/Type/VerbosityLevel.php

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace PHPStan\Type;
44

5-
use PHPStan\ShouldNotHappenException;
65
use PHPStan\Type\Accessory\AccessoryArrayListType;
76
use PHPStan\Type\Accessory\AccessoryLiteralStringType;
87
use PHPStan\Type\Accessory\AccessoryNonEmptyStringType;
@@ -23,16 +22,28 @@ class VerbosityLevel
2322
/** @var self[] */
2423
private static array $registry;
2524

25+
/**
26+
* @param self::* $value
27+
*/
2628
private function __construct(private int $value)
2729
{
2830
}
2931

32+
/**
33+
* @param self::* $value
34+
*/
3035
private static function create(int $value): self
3136
{
3237
self::$registry[$value] ??= new self($value);
3338
return self::$registry[$value];
3439
}
3540

41+
/** @return self::* */
42+
public function getLevelValue(): int
43+
{
44+
return $this->value;
45+
}
46+
3647
/** @api */
3748
public static function typeOnly(): self
3849
{
@@ -174,19 +185,15 @@ public function handle(
174185
return $valueCallback();
175186
}
176187

177-
if ($this->value === self::CACHE) {
178-
if ($cacheCallback !== null) {
179-
return $cacheCallback();
180-
}
181-
182-
if ($preciseCallback !== null) {
183-
return $preciseCallback();
184-
}
188+
if ($cacheCallback !== null) {
189+
return $cacheCallback();
190+
}
185191

186-
return $valueCallback();
192+
if ($preciseCallback !== null) {
193+
return $preciseCallback();
187194
}
188195

189-
throw new ShouldNotHappenException();
196+
return $valueCallback();
190197
}
191198

192199
}

0 commit comments

Comments
 (0)