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): AcceptsResult |
25: | { |
26: | if ($type instanceof CompoundType) { |
27: | return $type->isAcceptedBy($this, $strictTypes); |
28: | } |
29: | |
30: | return new AcceptsResult($type->isClassString(), []); |
31: | } |
32: | |
33: | public function isSuperTypeOf(Type $type): IsSuperTypeOfResult |
34: | { |
35: | if ($type instanceof CompoundType) { |
36: | return $type->isSubTypeOf($this); |
37: | } |
38: | |
39: | return new IsSuperTypeOfResult($type->isClassString(), []); |
40: | } |
41: | |
42: | public function isString(): TrinaryLogic |
43: | { |
44: | return TrinaryLogic::createYes(); |
45: | } |
46: | |
47: | public function isNumericString(): TrinaryLogic |
48: | { |
49: | return TrinaryLogic::createMaybe(); |
50: | } |
51: | |
52: | public function isNonEmptyString(): TrinaryLogic |
53: | { |
54: | return TrinaryLogic::createYes(); |
55: | } |
56: | |
57: | public function isNonFalsyString(): TrinaryLogic |
58: | { |
59: | return TrinaryLogic::createYes(); |
60: | } |
61: | |
62: | public function isLiteralString(): TrinaryLogic |
63: | { |
64: | return TrinaryLogic::createMaybe(); |
65: | } |
66: | |
67: | public function isLowercaseString(): TrinaryLogic |
68: | { |
69: | return TrinaryLogic::createMaybe(); |
70: | } |
71: | |
72: | public function isUppercaseString(): TrinaryLogic |
73: | { |
74: | return TrinaryLogic::createMaybe(); |
75: | } |
76: | |
77: | public function isClassString(): TrinaryLogic |
78: | { |
79: | return TrinaryLogic::createYes(); |
80: | } |
81: | |
82: | public function getClassStringObjectType(): Type |
83: | { |
84: | return new ObjectWithoutClassType(); |
85: | } |
86: | |
87: | public function getObjectTypeOrClassStringObjectType(): Type |
88: | { |
89: | return new ObjectWithoutClassType(); |
90: | } |
91: | |
92: | public function toPhpDocNode(): TypeNode |
93: | { |
94: | return new IdentifierTypeNode('class-string'); |
95: | } |
96: | |
97: | } |
98: | |