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