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