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: | |
15: | public string $name; |
16: | |
17: | public ?TypeNode $bound; |
18: | |
19: | public ?TypeNode $default; |
20: | |
21: | public ?TypeNode $lowerBound; |
22: | |
23: | |
24: | public string $description; |
25: | |
26: | |
27: | |
28: | |
29: | public function __construct(string $name, ?TypeNode $bound, string $description, ?TypeNode $default = null, ?TypeNode $lowerBound = null) |
30: | { |
31: | $this->name = $name; |
32: | $this->bound = $bound; |
33: | $this->lowerBound = $lowerBound; |
34: | $this->default = $default; |
35: | $this->description = $description; |
36: | } |
37: | |
38: | |
39: | public function __toString(): string |
40: | { |
41: | $upperBound = $this->bound !== null ? " of {$this->bound}" : ''; |
42: | $lowerBound = $this->lowerBound !== null ? " super {$this->lowerBound}" : ''; |
43: | $default = $this->default !== null ? " = {$this->default}" : ''; |
44: | return trim("{$this->name}{$upperBound}{$lowerBound}{$default} {$this->description}"); |
45: | } |
46: | |
47: | } |
48: | |