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