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