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: /** @var ArrayShapeItemNode[] */
17: public $items;
18:
19: /** @var bool */
20: public $sealed;
21:
22: /** @var self::KIND_* */
23: public $kind;
24:
25: /**
26: * @param ArrayShapeItemNode[] $items
27: * @param self::KIND_* $kind
28: */
29: public function __construct(array $items, bool $sealed = true, string $kind = self::KIND_ARRAY)
30: {
31: $this->items = $items;
32: $this->sealed = $sealed;
33: $this->kind = $kind;
34: }
35:
36:
37: public function __toString(): string
38: {
39: $items = $this->items;
40:
41: if (! $this->sealed) {
42: $items[] = '...';
43: }
44:
45: return $this->kind . '{' . implode(', ', $items) . '}';
46: }
47:
48: }
49: