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 $lowerBound;
22:
23: /** @var TypeNode|null */
24: public $default;
25:
26: /** @var string (may be empty) */
27: public $description;
28:
29: /**
30: * @param non-empty-string $name
31: */
32: public function __construct(string $name, ?TypeNode $bound, string $description, ?TypeNode $default = null, ?TypeNode $lowerBound = null)
33: {
34: $this->name = $name;
35: $this->bound = $bound;
36: $this->lowerBound = $lowerBound;
37: $this->default = $default;
38: $this->description = $description;
39: }
40:
41:
42: public function __toString(): string
43: {
44: $upperBound = $this->bound !== null ? " of {$this->bound}" : '';
45: $lowerBound = $this->lowerBound !== null ? " super {$this->lowerBound}" : '';
46: $default = $this->default !== null ? " = {$this->default}" : '';
47: return trim("{$this->name}{$upperBound}{$lowerBound}{$default} {$this->description}");
48: }
49:
50: }
51: