1: | <?php |
2: | |
3: | declare(strict_types=1); |
4: | |
5: | namespace PHPStan\BetterReflection\Reflection\Exception; |
6: | |
7: | use PHPStan\BetterReflection\Reflection\ReflectionClass; |
8: | use UnexpectedValueException; |
9: | |
10: | use function sprintf; |
11: | |
12: | class NotAClassReflection extends UnexpectedValueException |
13: | { |
14: | public static function fromReflectionClass(ReflectionClass $class): self |
15: | { |
16: | $type = 'interface'; |
17: | |
18: | if ($class->isTrait()) { |
19: | $type = 'trait'; |
20: | } |
21: | |
22: | return new self(sprintf('Provided node "%s" is not class, but "%s"', $class->getName(), $type)); |
23: | } |
24: | } |
25: | |