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: public TypeNode $type;
13:
14: public function __construct(TypeNode $type)
15: {
16: $this->type = $type;
17: }
18:
19: public function __toString(): string
20: {
21: if (
22: $this->type instanceof CallableTypeNode
23: || $this->type instanceof ConstTypeNode
24: || $this->type instanceof NullableTypeNode
25: ) {
26: return '(' . $this->type . ')[]';
27: }
28:
29: return $this->type . '[]';
30: }
31:
32: /**
33: * @param array<string, mixed> $properties
34: */
35: public static function __set_state(array $properties): self
36: {
37: $instance = new self($properties['type']);
38: if (isset($properties['attributes'])) {
39: foreach ($properties['attributes'] as $key => $value) {
40: $instance->setAttribute($key, $value);
41: }
42: }
43: return $instance;
44: }
45:
46: }
47: