| 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\Turbo\ShadowedByTurboExtension; |
| 10: | use PHPStan\Type\Constant\ConstantArrayType; |
| 11: | use PHPStan\Type\Constant\ConstantIntegerType; |
| 12: | use PHPStan\Type\Traits\NonArrayTypeTrait; |
| 13: | use PHPStan\Type\Traits\NonCallableTypeTrait; |
| 14: | use PHPStan\Type\Traits\NonGeneralizableTypeTrait; |
| 15: | use PHPStan\Type\Traits\NonGenericTypeTrait; |
| 16: | use PHPStan\Type\Traits\NonIterableTypeTrait; |
| 17: | use PHPStan\Type\Traits\NonObjectTypeTrait; |
| 18: | use PHPStan\Type\Traits\NonOffsetAccessibleTypeTrait; |
| 19: | use PHPStan\Type\Traits\NonRemoveableTypeTrait; |
| 20: | use PHPStan\Type\Traits\TruthyBooleanTypeTrait; |
| 21: | use PHPStan\Type\Traits\UndecidedComparisonTypeTrait; |
| 22: | |
| 23: | |
| 24: | #[ShadowedByTurboExtension(implementation: __DIR__ . '/../../turbo-ext/src/ResourceType.cpp')] |
| 25: | class ResourceType implements Type |
| 26: | { |
| 27: | |
| 28: | use JustNullableTypeTrait; |
| 29: | use NonArrayTypeTrait; |
| 30: | use NonCallableTypeTrait; |
| 31: | use NonIterableTypeTrait; |
| 32: | use NonObjectTypeTrait; |
| 33: | use TruthyBooleanTypeTrait; |
| 34: | use NonGenericTypeTrait; |
| 35: | use UndecidedComparisonTypeTrait; |
| 36: | use NonOffsetAccessibleTypeTrait; |
| 37: | use NonRemoveableTypeTrait; |
| 38: | use NonGeneralizableTypeTrait; |
| 39: | |
| 40: | |
| 41: | public function __construct() |
| 42: | { |
| 43: | } |
| 44: | |
| 45: | public function describe(VerbosityLevel $level): string |
| 46: | { |
| 47: | return 'resource'; |
| 48: | } |
| 49: | |
| 50: | public function getConstantStrings(): array |
| 51: | { |
| 52: | return []; |
| 53: | } |
| 54: | |
| 55: | public function toNumber(): Type |
| 56: | { |
| 57: | return new ErrorType(); |
| 58: | } |
| 59: | |
| 60: | public function toBitwiseNotType(): Type |
| 61: | { |
| 62: | return new ErrorType(); |
| 63: | } |
| 64: | |
| 65: | public function toAbsoluteNumber(): Type |
| 66: | { |
| 67: | return new ErrorType(); |
| 68: | } |
| 69: | |
| 70: | public function toString(): Type |
| 71: | { |
| 72: | return new StringType(); |
| 73: | } |
| 74: | |
| 75: | public function toInteger(): Type |
| 76: | { |
| 77: | return new IntegerType(); |
| 78: | } |
| 79: | |
| 80: | public function toFloat(): Type |
| 81: | { |
| 82: | return new FloatType(); |
| 83: | } |
| 84: | |
| 85: | public function toArray(): Type |
| 86: | { |
| 87: | return new ConstantArrayType( |
| 88: | [new ConstantIntegerType(0)], |
| 89: | [$this], |
| 90: | [1], |
| 91: | isList: TrinaryLogic::createYes(), |
| 92: | ); |
| 93: | } |
| 94: | |
| 95: | public function toArrayKey(): Type |
| 96: | { |
| 97: | return new ErrorType(); |
| 98: | } |
| 99: | |
| 100: | public function toCoercedArgumentType(bool $strictTypes): Type |
| 101: | { |
| 102: | return $this; |
| 103: | } |
| 104: | |
| 105: | public function isOffsetAccessLegal(): TrinaryLogic |
| 106: | { |
| 107: | return TrinaryLogic::createYes(); |
| 108: | } |
| 109: | |
| 110: | public function isScalar(): TrinaryLogic |
| 111: | { |
| 112: | return TrinaryLogic::createNo(); |
| 113: | } |
| 114: | |
| 115: | public function looseCompare(Type $type, PhpVersion $phpVersion): BooleanType |
| 116: | { |
| 117: | return new BooleanType(); |
| 118: | } |
| 119: | |
| 120: | public function exponentiate(Type $exponent): Type |
| 121: | { |
| 122: | return new ErrorType(); |
| 123: | } |
| 124: | |
| 125: | public function getFiniteTypes(): array |
| 126: | { |
| 127: | return []; |
| 128: | } |
| 129: | |
| 130: | public function toPhpDocNode(): TypeNode |
| 131: | { |
| 132: | return new IdentifierTypeNode('resource'); |
| 133: | } |
| 134: | |
| 135: | public function hasTemplateOrLateResolvableType(): bool |
| 136: | { |
| 137: | return false; |
| 138: | } |
| 139: | |
| 140: | } |
| 141: | |