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 NotAnInterfaceReflection extends UnexpectedValueException |
13: | { |
14: | public static function fromReflectionClass(ReflectionClass $class): self |
15: | { |
16: | $type = 'class'; |
17: | |
18: | if ($class->isTrait()) { |
19: | $type = 'trait'; |
20: | } |
21: | |
22: | return new self(sprintf('Provided node "%s" is not interface, but "%s"', $class->getName(), $type)); |
23: | } |
24: | } |
25: | |