1: <?php declare(strict_types = 1);
2:
3: namespace PHPStan\Type;
4:
5: use PHPStan\Php\PhpVersion;
6: use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
7: use PHPStan\PhpDocParser\Ast\Type\TypeNode;
8: use PHPStan\TrinaryLogic;
9: use PHPStan\Type\Traits\FalseyBooleanTypeTrait;
10: use PHPStan\Type\Traits\NonArrayTypeTrait;
11: use PHPStan\Type\Traits\NonCallableTypeTrait;
12: use PHPStan\Type\Traits\NonGeneralizableTypeTrait;
13: use PHPStan\Type\Traits\NonGenericTypeTrait;
14: use PHPStan\Type\Traits\NonIterableTypeTrait;
15: use PHPStan\Type\Traits\NonObjectTypeTrait;
16: use PHPStan\Type\Traits\NonOffsetAccessibleTypeTrait;
17: use PHPStan\Type\Traits\NonRemoveableTypeTrait;
18: use PHPStan\Type\Traits\UndecidedComparisonTypeTrait;
19:
20: /** @api */
21: class VoidType implements Type
22: {
23:
24: use NonArrayTypeTrait;
25: use NonCallableTypeTrait;
26: use NonIterableTypeTrait;
27: use NonObjectTypeTrait;
28: use NonOffsetAccessibleTypeTrait;
29: use FalseyBooleanTypeTrait;
30: use NonGenericTypeTrait;
31: use UndecidedComparisonTypeTrait;
32: use NonRemoveableTypeTrait;
33: use NonGeneralizableTypeTrait;
34:
35: /** @api */
36: public function __construct()
37: {
38: }
39:
40: public function getReferencedClasses(): array
41: {
42: return [];
43: }
44:
45: public function getObjectClassNames(): array
46: {
47: return [];
48: }
49:
50: public function getObjectClassReflections(): array
51: {
52: return [];
53: }
54:
55: public function accepts(Type $type, bool $strictTypes): AcceptsResult
56: {
57: if ($type instanceof CompoundType) {
58: return $type->isAcceptedBy($this, $strictTypes);
59: }
60:
61: return new AcceptsResult($type->isVoid()->or($type->isNull()), []);
62: }
63:
64: public function isSuperTypeOf(Type $type): IsSuperTypeOfResult
65: {
66: if ($type instanceof self) {
67: return IsSuperTypeOfResult::createYes();
68: }
69:
70: if ($type instanceof CompoundType) {
71: return $type->isSubTypeOf($this);
72: }
73:
74: return IsSuperTypeOfResult::createNo();
75: }
76:
77: public function equals(Type $type): bool
78: {
79: return $type instanceof self;
80: }
81:
82: public function describe(VerbosityLevel $level): string
83: {
84: return 'void';
85: }
86:
87: public function toNumber(): Type
88: {
89: return new ErrorType();
90: }
91:
92: public function toAbsoluteNumber(): Type
93: {
94: return new ErrorType();
95: }
96:
97: public function toString(): Type
98: {
99: return new ErrorType();
100: }
101:
102: public function toInteger(): Type
103: {
104: return new ErrorType();
105: }
106:
107: public function toFloat(): Type
108: {
109: return new ErrorType();
110: }
111:
112: public function toArray(): Type
113: {
114: return new ErrorType();
115: }
116:
117: public function toArrayKey(): Type
118: {
119: return new ErrorType();
120: }
121:
122: public function isOffsetAccessLegal(): TrinaryLogic
123: {
124: return TrinaryLogic::createYes();
125: }
126:
127: public function isNull(): TrinaryLogic
128: {
129: return TrinaryLogic::createNo();
130: }
131:
132: public function isConstantValue(): TrinaryLogic
133: {
134: return TrinaryLogic::createNo();
135: }
136:
137: public function isConstantScalarValue(): TrinaryLogic
138: {
139: return TrinaryLogic::createNo();
140: }
141:
142: public function getConstantScalarTypes(): array
143: {
144: return [];
145: }
146:
147: public function getConstantScalarValues(): array
148: {
149: return [];
150: }
151:
152: public function isTrue(): TrinaryLogic
153: {
154: return TrinaryLogic::createNo();
155: }
156:
157: public function isFalse(): TrinaryLogic
158: {
159: return TrinaryLogic::createNo();
160: }
161:
162: public function isBoolean(): TrinaryLogic
163: {
164: return TrinaryLogic::createNo();
165: }
166:
167: public function isFloat(): TrinaryLogic
168: {
169: return TrinaryLogic::createNo();
170: }
171:
172: public function isInteger(): TrinaryLogic
173: {
174: return TrinaryLogic::createNo();
175: }
176:
177: public function isString(): TrinaryLogic
178: {
179: return TrinaryLogic::createNo();
180: }
181:
182: public function isNumericString(): TrinaryLogic
183: {
184: return TrinaryLogic::createNo();
185: }
186:
187: public function isNonEmptyString(): TrinaryLogic
188: {
189: return TrinaryLogic::createNo();
190: }
191:
192: public function isNonFalsyString(): TrinaryLogic
193: {
194: return TrinaryLogic::createNo();
195: }
196:
197: public function isLiteralString(): TrinaryLogic
198: {
199: return TrinaryLogic::createNo();
200: }
201:
202: public function isLowercaseString(): TrinaryLogic
203: {
204: return TrinaryLogic::createNo();
205: }
206:
207: public function isUppercaseString(): TrinaryLogic
208: {
209: return TrinaryLogic::createNo();
210: }
211:
212: public function isClassString(): TrinaryLogic
213: {
214: return TrinaryLogic::createNo();
215: }
216:
217: public function getClassStringObjectType(): Type
218: {
219: return new ErrorType();
220: }
221:
222: public function getObjectTypeOrClassStringObjectType(): Type
223: {
224: return new ErrorType();
225: }
226:
227: public function isVoid(): TrinaryLogic
228: {
229: return TrinaryLogic::createYes();
230: }
231:
232: public function isScalar(): TrinaryLogic
233: {
234: return TrinaryLogic::createNo();
235: }
236:
237: public function looseCompare(Type $type, PhpVersion $phpVersion): BooleanType
238: {
239: return new BooleanType();
240: }
241:
242: public function traverse(callable $cb): Type
243: {
244: return $this;
245: }
246:
247: public function traverseSimultaneously(Type $right, callable $cb): Type
248: {
249: return $this;
250: }
251:
252: public function exponentiate(Type $exponent): Type
253: {
254: return new ErrorType();
255: }
256:
257: public function getFiniteTypes(): array
258: {
259: return [];
260: }
261:
262: public function toPhpDocNode(): TypeNode
263: {
264: return new IdentifierTypeNode('void');
265: }
266:
267: }
268: