1: <?php declare(strict_types = 1);
2:
3: namespace PHPStan\PhpDocParser\Ast\PhpDoc\Doctrine;
4:
5: use PHPStan\PhpDocParser\Ast\NodeAttributes;
6: use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode;
7: use function trim;
8:
9: class DoctrineTagValueNode implements PhpDocTagValueNode
10: {
11:
12: use NodeAttributes;
13:
14: public DoctrineAnnotation $annotation;
15:
16: /** @var string (may be empty) */
17: public string $description;
18:
19: public function __construct(
20: DoctrineAnnotation $annotation,
21: string $description
22: )
23: {
24: $this->annotation = $annotation;
25: $this->description = $description;
26: }
27:
28: public function __toString(): string
29: {
30: return trim("{$this->annotation} {$this->description}");
31: }
32:
33: /**
34: * @param array<string, mixed> $properties
35: */
36: public static function __set_state(array $properties): self
37: {
38: $instance = new self($properties['annotation'], $properties['description']);
39: if (isset($properties['attributes'])) {
40: foreach ($properties['attributes'] as $key => $value) {
41: $instance->setAttribute($key, $value);
42: }
43: }
44: return $instance;
45: }
46:
47: }
48: