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\Constant\ConstantArrayType;
8: use PHPStan\Type\Constant\ConstantIntegerType;
9: use PHPStan\Type\Traits\NonArrayTypeTrait;
10: use PHPStan\Type\Traits\NonCallableTypeTrait;
11: use PHPStan\Type\Traits\NonGeneralizableTypeTrait;
12: use PHPStan\Type\Traits\NonGenericTypeTrait;
13: use PHPStan\Type\Traits\NonIterableTypeTrait;
14: use PHPStan\Type\Traits\NonObjectTypeTrait;
15: use PHPStan\Type\Traits\NonOffsetAccessibleTypeTrait;
16: use PHPStan\Type\Traits\NonRemoveableTypeTrait;
17: use PHPStan\Type\Traits\TruthyBooleanTypeTrait;
18: use PHPStan\Type\Traits\UndecidedComparisonTypeTrait;
19:
20: /** @api */
21: class ResourceType implements Type
22: {
23:
24: use JustNullableTypeTrait;
25: use NonArrayTypeTrait;
26: use NonCallableTypeTrait;
27: use NonIterableTypeTrait;
28: use NonObjectTypeTrait;
29: use TruthyBooleanTypeTrait;
30: use NonGenericTypeTrait;
31: use UndecidedComparisonTypeTrait;
32: use NonOffsetAccessibleTypeTrait;
33: use NonRemoveableTypeTrait;
34: use NonGeneralizableTypeTrait;
35:
36: /** @api */
37: public function __construct()
38: {
39: }
40:
41: public function describe(VerbosityLevel $level): string
42: {
43: return 'resource';
44: }
45:
46: public function getConstantStrings(): array
47: {
48: return [];
49: }
50:
51: public function toNumber(): Type
52: {
53: return new ErrorType();
54: }
55:
56: public function toString(): Type
57: {
58: return new StringType();
59: }
60:
61: public function toInteger(): Type
62: {
63: return new IntegerType();
64: }
65:
66: public function toFloat(): Type
67: {
68: return new ErrorType();
69: }
70:
71: public function toArray(): Type
72: {
73: return new ConstantArrayType(
74: [new ConstantIntegerType(0)],
75: [$this],
76: [1],
77: [],
78: true,
79: );
80: }
81:
82: public function toArrayKey(): Type
83: {
84: return new ErrorType();
85: }
86:
87: public function isScalar(): TrinaryLogic
88: {
89: return TrinaryLogic::createNo();
90: }
91:
92: public function looseCompare(Type $type, PhpVersion $phpVersion): BooleanType
93: {
94: return new BooleanType();
95: }
96:
97: public function exponentiate(Type $exponent): Type
98: {
99: return new ErrorType();
100: }
101:
102: /**
103: * @param mixed[] $properties
104: */
105: public static function __set_state(array $properties): Type
106: {
107: return new self();
108: }
109:
110: }
111: