| 1: | <?php declare(strict_types=1); |
| 2: | |
| 3: | namespace Salient\PHPDoc\Tag; |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | class VarTag extends AbstractTag |
| 9: | { |
| 10: | |
| 11: | |
| 12: | |
| 13: | public function __construct( |
| 14: | string $type, |
| 15: | ?string $name = null, |
| 16: | ?string $description = null, |
| 17: | ?string $class = null, |
| 18: | ?string $member = null, |
| 19: | ?string $static = null, |
| 20: | ?string $self = null, |
| 21: | array $aliases = [] |
| 22: | ) { |
| 23: | parent::__construct('var', $name, $type, $description, $class, $member, $static, $self, $aliases); |
| 24: | } |
| 25: | |
| 26: | |
| 27: | |
| 28: | |
| 29: | public function getType(): string |
| 30: | { |
| 31: | return $this->Type; |
| 32: | } |
| 33: | |
| 34: | |
| 35: | |
| 36: | |
| 37: | |
| 38: | |
| 39: | public function withName(?string $name) |
| 40: | { |
| 41: | if ($name === null) { |
| 42: | return $this->without('Name'); |
| 43: | } |
| 44: | return $this->with('Name', $this->filterString($name, 'name')); |
| 45: | } |
| 46: | |
| 47: | |
| 48: | |
| 49: | |
| 50: | public function __toString(): string |
| 51: | { |
| 52: | $string = "@{$this->Tag} {$this->Type}"; |
| 53: | if (isset($this->Name)) { |
| 54: | $string .= " \${$this->Name}"; |
| 55: | } |
| 56: | if ($this->Description !== null) { |
| 57: | $string .= " {$this->Description}"; |
| 58: | } |
| 59: | return $string; |
| 60: | } |
| 61: | } |
| 62: | |