1: | <?php declare(strict_types = 1); |
2: | |
3: | namespace PHPStan\Type; |
4: | |
5: | use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode; |
6: | use PHPStan\PhpDocParser\Ast\Type\TypeNode; |
7: | use PHPStan\TrinaryLogic; |
8: | |
9: | |
10: | class ClassStringType extends StringType |
11: | { |
12: | |
13: | |
14: | public function __construct() |
15: | { |
16: | parent::__construct(); |
17: | } |
18: | |
19: | public function describe(VerbosityLevel $level): string |
20: | { |
21: | return 'class-string'; |
22: | } |
23: | |
24: | public function accepts(Type $type, bool $strictTypes): TrinaryLogic |
25: | { |
26: | return $this->acceptsWithReason($type, $strictTypes)->result; |
27: | } |
28: | |
29: | public function acceptsWithReason(Type $type, bool $strictTypes): AcceptsResult |
30: | { |
31: | if ($type instanceof CompoundType) { |
32: | return $type->isAcceptedWithReasonBy($this, $strictTypes); |
33: | } |
34: | |
35: | return new AcceptsResult($type->isClassStringType(), []); |
36: | } |
37: | |
38: | public function isSuperTypeOf(Type $type): TrinaryLogic |
39: | { |
40: | if ($type instanceof CompoundType) { |
41: | return $type->isSubTypeOf($this); |
42: | } |
43: | |
44: | return $type->isClassStringType(); |
45: | } |
46: | |
47: | public function isString(): TrinaryLogic |
48: | { |
49: | return TrinaryLogic::createYes(); |
50: | } |
51: | |
52: | public function isNumericString(): TrinaryLogic |
53: | { |
54: | return TrinaryLogic::createMaybe(); |
55: | } |
56: | |
57: | public function isNonEmptyString(): TrinaryLogic |
58: | { |
59: | return TrinaryLogic::createYes(); |
60: | } |
61: | |
62: | public function isNonFalsyString(): TrinaryLogic |
63: | { |
64: | return TrinaryLogic::createYes(); |
65: | } |
66: | |
67: | public function isLiteralString(): TrinaryLogic |
68: | { |
69: | return TrinaryLogic::createMaybe(); |
70: | } |
71: | |
72: | public function isClassStringType(): TrinaryLogic |
73: | { |
74: | return TrinaryLogic::createYes(); |
75: | } |
76: | |
77: | public function getClassStringObjectType(): Type |
78: | { |
79: | return new ObjectWithoutClassType(); |
80: | } |
81: | |
82: | public function getObjectTypeOrClassStringObjectType(): Type |
83: | { |
84: | return new ObjectWithoutClassType(); |
85: | } |
86: | |
87: | public function toPhpDocNode(): TypeNode |
88: | { |
89: | return new IdentifierTypeNode('class-string'); |
90: | } |
91: | |
92: | |
93: | |
94: | |
95: | public static function __set_state(array $properties): Type |
96: | { |
97: | return new self(); |
98: | } |
99: | |
100: | } |
101: | |