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