Debian Codegraph @

vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/Doctrine/DoctrineArray.php

raw
1 <?php declare(strict_types = 1);
2
3 namespace PHPStan\PhpDocParser\Ast\PhpDoc\Doctrine;
4
5 use PHPStan\PhpDocParser\Ast\Node;
6 use PHPStan\PhpDocParser\Ast\NodeAttributes;
7 use function implode;
8
9 class DoctrineArray implements Node
10 {
11
12 use NodeAttributes;
13
14 /** @var list<DoctrineArrayItem> */
15 public array $items;
16
17 /**
18 * @param list<DoctrineArrayItem> $items
19 */
20 public function __construct(array $items)
21 {
22 $this->items = $items;
23 }
24
25 public function __toString(): string
26 {
27 $items = implode(', ', $this->items);
28
29 return '{' . $items . '}';
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['items']);
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 }