1: <?php declare(strict_types = 1);
2:
3: namespace PHPStan\PhpDocParser\Ast\Type;
4:
5: use PHPStan\PhpDocParser\Ast\NodeAttributes;
6:
7: class OffsetAccessTypeNode implements TypeNode
8: {
9:
10: use NodeAttributes;
11:
12: /** @var TypeNode */
13: public $type;
14:
15: /** @var TypeNode */
16: public $offset;
17:
18: public function __construct(TypeNode $type, TypeNode $offset)
19: {
20: $this->type = $type;
21: $this->offset = $offset;
22: }
23:
24: public function __toString(): string
25: {
26: if (
27: $this->type instanceof CallableTypeNode
28: || $this->type instanceof NullableTypeNode
29: ) {
30: return '(' . $this->type . ')[' . $this->offset . ']';
31: }
32:
33: return $this->type . '[' . $this->offset . ']';
34: }
35:
36: }
37: