1: | <?php declare(strict_types = 1); |
2: | |
3: | namespace PHPStan\PhpDocParser\Ast\Type; |
4: | |
5: | use PHPStan\PhpDocParser\Ast\NodeAttributes; |
6: | use function implode; |
7: | |
8: | class ArrayShapeNode implements TypeNode |
9: | { |
10: | |
11: | public const KIND_ARRAY = 'array'; |
12: | public const KIND_LIST = 'list'; |
13: | |
14: | use NodeAttributes; |
15: | |
16: | |
17: | public $items; |
18: | |
19: | |
20: | public $sealed; |
21: | |
22: | |
23: | public $kind; |
24: | |
25: | |
26: | |
27: | |
28: | public function __construct(array $items, bool $sealed = true, string $kind = self::KIND_ARRAY) |
29: | { |
30: | $this->items = $items; |
31: | $this->sealed = $sealed; |
32: | $this->kind = $kind; |
33: | } |
34: | |
35: | |
36: | public function __toString(): string |
37: | { |
38: | $items = $this->items; |
39: | |
40: | if (! $this->sealed) { |
41: | $items[] = '...'; |
42: | } |
43: | |
44: | return $this->kind . '{' . implode(', ', $items) . '}'; |
45: | } |
46: | |
47: | } |
48: | |