1: <?php declare(strict_types = 1);
2:
3: namespace PHPStan\Type;
4:
5: use PHPStan\Type\Constant\ConstantArrayType;
6: use PHPStan\Type\Constant\ConstantIntegerType;
7: use PHPStan\Type\Traits\NonCallableTypeTrait;
8: use PHPStan\Type\Traits\NonGeneralizableTypeTrait;
9: use PHPStan\Type\Traits\NonGenericTypeTrait;
10: use PHPStan\Type\Traits\NonIterableTypeTrait;
11: use PHPStan\Type\Traits\NonObjectTypeTrait;
12: use PHPStan\Type\Traits\NonOffsetAccessibleTypeTrait;
13: use PHPStan\Type\Traits\NonRemoveableTypeTrait;
14: use PHPStan\Type\Traits\TruthyBooleanTypeTrait;
15: use PHPStan\Type\Traits\UndecidedComparisonTypeTrait;
16:
17: /** @api */
18: class ResourceType implements Type
19: {
20:
21: use JustNullableTypeTrait;
22: use NonCallableTypeTrait;
23: use NonIterableTypeTrait;
24: use NonObjectTypeTrait;
25: use TruthyBooleanTypeTrait;
26: use NonGenericTypeTrait;
27: use UndecidedComparisonTypeTrait;
28: use NonOffsetAccessibleTypeTrait;
29: use NonRemoveableTypeTrait;
30: use NonGeneralizableTypeTrait;
31:
32: /** @api */
33: public function __construct()
34: {
35: }
36:
37: public function describe(VerbosityLevel $level): string
38: {
39: return 'resource';
40: }
41:
42: public function toNumber(): Type
43: {
44: return new ErrorType();
45: }
46:
47: public function toString(): Type
48: {
49: return new StringType();
50: }
51:
52: public function toInteger(): Type
53: {
54: return new IntegerType();
55: }
56:
57: public function toFloat(): Type
58: {
59: return new ErrorType();
60: }
61:
62: public function toArray(): Type
63: {
64: return new ConstantArrayType(
65: [new ConstantIntegerType(0)],
66: [$this],
67: [1],
68: );
69: }
70:
71: /**
72: * @param mixed[] $properties
73: */
74: public static function __set_state(array $properties): Type
75: {
76: return new self();
77: }
78:
79: }
80: