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 TemplateTagValueNode implements PhpDocTagValueNode
10: {
11:
12: use NodeAttributes;
13:
14: /** @var non-empty-string */
15: public $name;
16:
17: /** @var TypeNode|null */
18: public $bound;
19:
20: /** @var TypeNode|null */
21: public $default;
22:
23: /** @var string (may be empty) */
24: public $description;
25:
26: /**
27: * @param non-empty-string $name
28: */
29: public function __construct(string $name, ?TypeNode $bound, string $description, ?TypeNode $default = null)
30: {
31: $this->name = $name;
32: $this->bound = $bound;
33: $this->default = $default;
34: $this->description = $description;
35: }
36:
37:
38: public function __toString(): string
39: {
40: $bound = $this->bound !== null ? " of {$this->bound}" : '';
41: $default = $this->default !== null ? " = {$this->default}" : '';
42: return trim("{$this->name}{$bound}{$default} {$this->description}");
43: }
44:
45: }
46: