1: <?php declare(strict_types = 1);
2:
3: namespace PHPStan\Type;
4:
5: use PHPStan\TrinaryLogic;
6: use PHPStan\Type\Traits\FalseyBooleanTypeTrait;
7: use PHPStan\Type\Traits\NonArrayTypeTrait;
8: use PHPStan\Type\Traits\NonCallableTypeTrait;
9: use PHPStan\Type\Traits\NonGeneralizableTypeTrait;
10: use PHPStan\Type\Traits\NonGenericTypeTrait;
11: use PHPStan\Type\Traits\NonIterableTypeTrait;
12: use PHPStan\Type\Traits\NonObjectTypeTrait;
13: use PHPStan\Type\Traits\NonOffsetAccessibleTypeTrait;
14: use PHPStan\Type\Traits\NonRemoveableTypeTrait;
15: use PHPStan\Type\Traits\UndecidedComparisonTypeTrait;
16:
17: /** @api */
18: class VoidType implements Type
19: {
20:
21: use NonArrayTypeTrait;
22: use NonCallableTypeTrait;
23: use NonIterableTypeTrait;
24: use NonObjectTypeTrait;
25: use NonOffsetAccessibleTypeTrait;
26: use FalseyBooleanTypeTrait;
27: use NonGenericTypeTrait;
28: use UndecidedComparisonTypeTrait;
29: use NonRemoveableTypeTrait;
30: use NonGeneralizableTypeTrait;
31:
32: /** @api */
33: public function __construct()
34: {
35: }
36:
37: /**
38: * @return string[]
39: */
40: public function getReferencedClasses(): array
41: {
42: return [];
43: }
44:
45: public function accepts(Type $type, bool $strictTypes): TrinaryLogic
46: {
47: if ($type instanceof CompoundType) {
48: return $type->isAcceptedBy($this, $strictTypes);
49: }
50:
51: return TrinaryLogic::createFromBoolean($type instanceof self);
52: }
53:
54: public function isSuperTypeOf(Type $type): TrinaryLogic
55: {
56: if ($type instanceof self) {
57: return TrinaryLogic::createYes();
58: }
59:
60: if ($type instanceof CompoundType) {
61: return $type->isSubTypeOf($this);
62: }
63:
64: return TrinaryLogic::createNo();
65: }
66:
67: public function equals(Type $type): bool
68: {
69: return $type instanceof self;
70: }
71:
72: public function describe(VerbosityLevel $level): string
73: {
74: return 'void';
75: }
76:
77: public function toNumber(): Type
78: {
79: return new ErrorType();
80: }
81:
82: public function toString(): Type
83: {
84: return new ErrorType();
85: }
86:
87: public function toInteger(): Type
88: {
89: return new ErrorType();
90: }
91:
92: public function toFloat(): Type
93: {
94: return new ErrorType();
95: }
96:
97: public function toArray(): Type
98: {
99: return new ErrorType();
100: }
101:
102: public function toArrayKey(): Type
103: {
104: return new ErrorType();
105: }
106:
107: public function isNull(): TrinaryLogic
108: {
109: return TrinaryLogic::createNo();
110: }
111:
112: public function isTrue(): TrinaryLogic
113: {
114: return TrinaryLogic::createNo();
115: }
116:
117: public function isFalse(): TrinaryLogic
118: {
119: return TrinaryLogic::createNo();
120: }
121:
122: public function isBoolean(): TrinaryLogic
123: {
124: return TrinaryLogic::createNo();
125: }
126:
127: public function isFloat(): TrinaryLogic
128: {
129: return TrinaryLogic::createNo();
130: }
131:
132: public function isInteger(): TrinaryLogic
133: {
134: return TrinaryLogic::createNo();
135: }
136:
137: public function isString(): TrinaryLogic
138: {
139: return TrinaryLogic::createNo();
140: }
141:
142: public function isNumericString(): TrinaryLogic
143: {
144: return TrinaryLogic::createNo();
145: }
146:
147: public function isNonEmptyString(): TrinaryLogic
148: {
149: return TrinaryLogic::createNo();
150: }
151:
152: public function isNonFalsyString(): TrinaryLogic
153: {
154: return TrinaryLogic::createNo();
155: }
156:
157: public function isLiteralString(): TrinaryLogic
158: {
159: return TrinaryLogic::createNo();
160: }
161:
162: public function isClassStringType(): TrinaryLogic
163: {
164: return TrinaryLogic::createNo();
165: }
166:
167: public function isVoid(): TrinaryLogic
168: {
169: return TrinaryLogic::createYes();
170: }
171:
172: public function isScalar(): TrinaryLogic
173: {
174: return TrinaryLogic::createNo();
175: }
176:
177: public function traverse(callable $cb): Type
178: {
179: return $this;
180: }
181:
182: /**
183: * @param mixed[] $properties
184: */
185: public static function __set_state(array $properties): Type
186: {
187: return new self();
188: }
189:
190: }
191: