| 1: | <?php declare(strict_types = 1); |
| 2: | |
| 3: | namespace PHPStan\Type; |
| 4: | |
| 5: | use PHPStan\Reflection\ClassMemberAccessAnswerer; |
| 6: | use PHPStan\Reflection\ConstantReflection; |
| 7: | use PHPStan\Reflection\ExtendedMethodReflection; |
| 8: | use PHPStan\Reflection\ParametersAcceptor; |
| 9: | use PHPStan\Reflection\PropertyReflection; |
| 10: | use PHPStan\Reflection\TrivialParametersAcceptor; |
| 11: | use PHPStan\Reflection\Type\UnresolvedMethodPrototypeReflection; |
| 12: | use PHPStan\Reflection\Type\UnresolvedPropertyPrototypeReflection; |
| 13: | use PHPStan\ShouldNotHappenException; |
| 14: | use PHPStan\TrinaryLogic; |
| 15: | use PHPStan\Type\Traits\NonGeneralizableTypeTrait; |
| 16: | use PHPStan\Type\Traits\NonGenericTypeTrait; |
| 17: | use PHPStan\Type\Traits\NonRemoveableTypeTrait; |
| 18: | use PHPStan\Type\Traits\UndecidedBooleanTypeTrait; |
| 19: | use PHPStan\Type\Traits\UndecidedComparisonCompoundTypeTrait; |
| 20: | |
| 21: | |
| 22: | class NeverType implements CompoundType |
| 23: | { |
| 24: | |
| 25: | use UndecidedBooleanTypeTrait; |
| 26: | use NonGenericTypeTrait; |
| 27: | use UndecidedComparisonCompoundTypeTrait; |
| 28: | use NonRemoveableTypeTrait; |
| 29: | use NonGeneralizableTypeTrait; |
| 30: | |
| 31: | |
| 32: | public function __construct(private bool $isExplicit = false) |
| 33: | { |
| 34: | } |
| 35: | |
| 36: | public function isExplicit(): bool |
| 37: | { |
| 38: | return $this->isExplicit; |
| 39: | } |
| 40: | |
| 41: | |
| 42: | |
| 43: | |
| 44: | public function getReferencedClasses(): array |
| 45: | { |
| 46: | return []; |
| 47: | } |
| 48: | |
| 49: | public function getArrays(): array |
| 50: | { |
| 51: | return []; |
| 52: | } |
| 53: | |
| 54: | public function getConstantArrays(): array |
| 55: | { |
| 56: | return []; |
| 57: | } |
| 58: | |
| 59: | public function getConstantStrings(): array |
| 60: | { |
| 61: | return []; |
| 62: | } |
| 63: | |
| 64: | public function accepts(Type $type, bool $strictTypes): TrinaryLogic |
| 65: | { |
| 66: | return TrinaryLogic::createYes(); |
| 67: | } |
| 68: | |
| 69: | public function isSuperTypeOf(Type $type): TrinaryLogic |
| 70: | { |
| 71: | if ($type instanceof self) { |
| 72: | return TrinaryLogic::createYes(); |
| 73: | } |
| 74: | |
| 75: | return TrinaryLogic::createNo(); |
| 76: | } |
| 77: | |
| 78: | public function equals(Type $type): bool |
| 79: | { |
| 80: | return $type instanceof self; |
| 81: | } |
| 82: | |
| 83: | public function isSubTypeOf(Type $otherType): TrinaryLogic |
| 84: | { |
| 85: | return TrinaryLogic::createYes(); |
| 86: | } |
| 87: | |
| 88: | public function isAcceptedBy(Type $acceptingType, bool $strictTypes): TrinaryLogic |
| 89: | { |
| 90: | return $this->isSubTypeOf($acceptingType); |
| 91: | } |
| 92: | |
| 93: | public function describe(VerbosityLevel $level): string |
| 94: | { |
| 95: | return '*NEVER*'; |
| 96: | } |
| 97: | |
| 98: | public function canAccessProperties(): TrinaryLogic |
| 99: | { |
| 100: | return TrinaryLogic::createYes(); |
| 101: | } |
| 102: | |
| 103: | public function hasProperty(string $propertyName): TrinaryLogic |
| 104: | { |
| 105: | return TrinaryLogic::createNo(); |
| 106: | } |
| 107: | |
| 108: | public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): PropertyReflection |
| 109: | { |
| 110: | throw new ShouldNotHappenException(); |
| 111: | } |
| 112: | |
| 113: | public function getUnresolvedPropertyPrototype(string $propertyName, ClassMemberAccessAnswerer $scope): UnresolvedPropertyPrototypeReflection |
| 114: | { |
| 115: | throw new ShouldNotHappenException(); |
| 116: | } |
| 117: | |
| 118: | public function canCallMethods(): TrinaryLogic |
| 119: | { |
| 120: | return TrinaryLogic::createYes(); |
| 121: | } |
| 122: | |
| 123: | public function hasMethod(string $methodName): TrinaryLogic |
| 124: | { |
| 125: | return TrinaryLogic::createNo(); |
| 126: | } |
| 127: | |
| 128: | public function getMethod(string $methodName, ClassMemberAccessAnswerer $scope): ExtendedMethodReflection |
| 129: | { |
| 130: | throw new ShouldNotHappenException(); |
| 131: | } |
| 132: | |
| 133: | public function getUnresolvedMethodPrototype(string $methodName, ClassMemberAccessAnswerer $scope): UnresolvedMethodPrototypeReflection |
| 134: | { |
| 135: | throw new ShouldNotHappenException(); |
| 136: | } |
| 137: | |
| 138: | public function canAccessConstants(): TrinaryLogic |
| 139: | { |
| 140: | return TrinaryLogic::createYes(); |
| 141: | } |
| 142: | |
| 143: | public function hasConstant(string $constantName): TrinaryLogic |
| 144: | { |
| 145: | return TrinaryLogic::createNo(); |
| 146: | } |
| 147: | |
| 148: | public function getConstant(string $constantName): ConstantReflection |
| 149: | { |
| 150: | throw new ShouldNotHappenException(); |
| 151: | } |
| 152: | |
| 153: | public function isIterable(): TrinaryLogic |
| 154: | { |
| 155: | return TrinaryLogic::createYes(); |
| 156: | } |
| 157: | |
| 158: | public function isIterableAtLeastOnce(): TrinaryLogic |
| 159: | { |
| 160: | return TrinaryLogic::createMaybe(); |
| 161: | } |
| 162: | |
| 163: | public function getArraySize(): Type |
| 164: | { |
| 165: | return new NeverType(); |
| 166: | } |
| 167: | |
| 168: | public function getIterableKeyType(): Type |
| 169: | { |
| 170: | return new NeverType(); |
| 171: | } |
| 172: | |
| 173: | public function getFirstIterableKeyType(): Type |
| 174: | { |
| 175: | return new NeverType(); |
| 176: | } |
| 177: | |
| 178: | public function getLastIterableKeyType(): Type |
| 179: | { |
| 180: | return new NeverType(); |
| 181: | } |
| 182: | |
| 183: | public function getIterableValueType(): Type |
| 184: | { |
| 185: | return new NeverType(); |
| 186: | } |
| 187: | |
| 188: | public function getFirstIterableValueType(): Type |
| 189: | { |
| 190: | return new NeverType(); |
| 191: | } |
| 192: | |
| 193: | public function getLastIterableValueType(): Type |
| 194: | { |
| 195: | return new NeverType(); |
| 196: | } |
| 197: | |
| 198: | public function isArray(): TrinaryLogic |
| 199: | { |
| 200: | return TrinaryLogic::createNo(); |
| 201: | } |
| 202: | |
| 203: | public function isConstantArray(): TrinaryLogic |
| 204: | { |
| 205: | return TrinaryLogic::createNo(); |
| 206: | } |
| 207: | |
| 208: | public function isOversizedArray(): TrinaryLogic |
| 209: | { |
| 210: | return TrinaryLogic::createNo(); |
| 211: | } |
| 212: | |
| 213: | public function isList(): TrinaryLogic |
| 214: | { |
| 215: | return TrinaryLogic::createNo(); |
| 216: | } |
| 217: | |
| 218: | public function isOffsetAccessible(): TrinaryLogic |
| 219: | { |
| 220: | return TrinaryLogic::createYes(); |
| 221: | } |
| 222: | |
| 223: | public function hasOffsetValueType(Type $offsetType): TrinaryLogic |
| 224: | { |
| 225: | return TrinaryLogic::createYes(); |
| 226: | } |
| 227: | |
| 228: | public function getOffsetValueType(Type $offsetType): Type |
| 229: | { |
| 230: | return new NeverType(); |
| 231: | } |
| 232: | |
| 233: | public function setOffsetValueType(?Type $offsetType, Type $valueType, bool $unionValues = true): Type |
| 234: | { |
| 235: | return new ErrorType(); |
| 236: | } |
| 237: | |
| 238: | public function unsetOffset(Type $offsetType): Type |
| 239: | { |
| 240: | return new NeverType(); |
| 241: | } |
| 242: | |
| 243: | public function getKeysArray(): Type |
| 244: | { |
| 245: | return new NeverType(); |
| 246: | } |
| 247: | |
| 248: | public function getValuesArray(): Type |
| 249: | { |
| 250: | return new NeverType(); |
| 251: | } |
| 252: | |
| 253: | public function fillKeysArray(Type $valueType): Type |
| 254: | { |
| 255: | return new NeverType(); |
| 256: | } |
| 257: | |
| 258: | public function flipArray(): Type |
| 259: | { |
| 260: | return new NeverType(); |
| 261: | } |
| 262: | |
| 263: | public function intersectKeyArray(Type $otherArraysType): Type |
| 264: | { |
| 265: | return new NeverType(); |
| 266: | } |
| 267: | |
| 268: | public function popArray(): Type |
| 269: | { |
| 270: | return new NeverType(); |
| 271: | } |
| 272: | |
| 273: | public function searchArray(Type $needleType): Type |
| 274: | { |
| 275: | return new NeverType(); |
| 276: | } |
| 277: | |
| 278: | public function shiftArray(): Type |
| 279: | { |
| 280: | return new NeverType(); |
| 281: | } |
| 282: | |
| 283: | public function shuffleArray(): Type |
| 284: | { |
| 285: | return new NeverType(); |
| 286: | } |
| 287: | |
| 288: | public function isCallable(): TrinaryLogic |
| 289: | { |
| 290: | return TrinaryLogic::createYes(); |
| 291: | } |
| 292: | |
| 293: | |
| 294: | |
| 295: | |
| 296: | public function getCallableParametersAcceptors(ClassMemberAccessAnswerer $scope): array |
| 297: | { |
| 298: | return [new TrivialParametersAcceptor()]; |
| 299: | } |
| 300: | |
| 301: | public function isCloneable(): TrinaryLogic |
| 302: | { |
| 303: | return TrinaryLogic::createYes(); |
| 304: | } |
| 305: | |
| 306: | public function toNumber(): Type |
| 307: | { |
| 308: | return $this; |
| 309: | } |
| 310: | |
| 311: | public function toString(): Type |
| 312: | { |
| 313: | return $this; |
| 314: | } |
| 315: | |
| 316: | public function toInteger(): Type |
| 317: | { |
| 318: | return $this; |
| 319: | } |
| 320: | |
| 321: | public function toFloat(): Type |
| 322: | { |
| 323: | return $this; |
| 324: | } |
| 325: | |
| 326: | public function toArray(): Type |
| 327: | { |
| 328: | return $this; |
| 329: | } |
| 330: | |
| 331: | public function toArrayKey(): Type |
| 332: | { |
| 333: | return $this; |
| 334: | } |
| 335: | |
| 336: | public function traverse(callable $cb): Type |
| 337: | { |
| 338: | return $this; |
| 339: | } |
| 340: | |
| 341: | public function isNull(): TrinaryLogic |
| 342: | { |
| 343: | return TrinaryLogic::createNo(); |
| 344: | } |
| 345: | |
| 346: | public function isTrue(): TrinaryLogic |
| 347: | { |
| 348: | return TrinaryLogic::createNo(); |
| 349: | } |
| 350: | |
| 351: | public function isFalse(): TrinaryLogic |
| 352: | { |
| 353: | return TrinaryLogic::createNo(); |
| 354: | } |
| 355: | |
| 356: | public function isBoolean(): TrinaryLogic |
| 357: | { |
| 358: | return TrinaryLogic::createNo(); |
| 359: | } |
| 360: | |
| 361: | public function isFloat(): TrinaryLogic |
| 362: | { |
| 363: | return TrinaryLogic::createNo(); |
| 364: | } |
| 365: | |
| 366: | public function isInteger(): TrinaryLogic |
| 367: | { |
| 368: | return TrinaryLogic::createNo(); |
| 369: | } |
| 370: | |
| 371: | public function isString(): TrinaryLogic |
| 372: | { |
| 373: | return TrinaryLogic::createNo(); |
| 374: | } |
| 375: | |
| 376: | public function isNumericString(): TrinaryLogic |
| 377: | { |
| 378: | return TrinaryLogic::createNo(); |
| 379: | } |
| 380: | |
| 381: | public function isNonEmptyString(): TrinaryLogic |
| 382: | { |
| 383: | return TrinaryLogic::createNo(); |
| 384: | } |
| 385: | |
| 386: | public function isNonFalsyString(): TrinaryLogic |
| 387: | { |
| 388: | return TrinaryLogic::createNo(); |
| 389: | } |
| 390: | |
| 391: | public function isLiteralString(): TrinaryLogic |
| 392: | { |
| 393: | return TrinaryLogic::createNo(); |
| 394: | } |
| 395: | |
| 396: | public function isClassStringType(): TrinaryLogic |
| 397: | { |
| 398: | return TrinaryLogic::createNo(); |
| 399: | } |
| 400: | |
| 401: | public function isVoid(): TrinaryLogic |
| 402: | { |
| 403: | return TrinaryLogic::createNo(); |
| 404: | } |
| 405: | |
| 406: | public function isScalar(): TrinaryLogic |
| 407: | { |
| 408: | return TrinaryLogic::createNo(); |
| 409: | } |
| 410: | |
| 411: | |
| 412: | |
| 413: | |
| 414: | public static function __set_state(array $properties): Type |
| 415: | { |
| 416: | return new self($properties['isExplicit']); |
| 417: | } |
| 418: | |
| 419: | } |
| 420: | |