| 1: | <?php declare(strict_types=1); |
| 2: | |
| 3: | namespace Salient\PHPDoc\Tag; |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | class ParamTag extends AbstractTag |
| 9: | { |
| 10: | protected bool $IsPassedByReference; |
| 11: | protected bool $IsVariadic; |
| 12: | |
| 13: | |
| 14: | |
| 15: | |
| 16: | public function __construct( |
| 17: | string $name, |
| 18: | ?string $type = null, |
| 19: | bool $isPassedByReference = false, |
| 20: | bool $isVariadic = false, |
| 21: | ?string $description = null, |
| 22: | ?string $class = null, |
| 23: | ?string $member = null, |
| 24: | ?string $static = null, |
| 25: | ?string $self = null, |
| 26: | array $aliases = [] |
| 27: | ) { |
| 28: | parent::__construct('param', $name, $type, $description, $class, $member, $static, $self, $aliases); |
| 29: | $this->IsPassedByReference = $isPassedByReference; |
| 30: | $this->IsVariadic = $isVariadic; |
| 31: | } |
| 32: | |
| 33: | |
| 34: | |
| 35: | |
| 36: | public function getName(): string |
| 37: | { |
| 38: | return $this->Name; |
| 39: | } |
| 40: | |
| 41: | |
| 42: | |
| 43: | |
| 44: | public function isPassedByReference(): bool |
| 45: | { |
| 46: | return $this->IsPassedByReference; |
| 47: | } |
| 48: | |
| 49: | |
| 50: | |
| 51: | |
| 52: | public function isVariadic(): bool |
| 53: | { |
| 54: | return $this->IsVariadic; |
| 55: | } |
| 56: | |
| 57: | |
| 58: | |
| 59: | |
| 60: | public function __toString(): string |
| 61: | { |
| 62: | $string = "@{$this->Tag} "; |
| 63: | if (isset($this->Type)) { |
| 64: | $string .= "{$this->Type} "; |
| 65: | } |
| 66: | if ($this->IsPassedByReference) { |
| 67: | $string .= '&'; |
| 68: | } |
| 69: | if ($this->IsVariadic) { |
| 70: | $string .= '...'; |
| 71: | } |
| 72: | $string .= "\${$this->Name}"; |
| 73: | if ($this->Description !== null) { |
| 74: | $string .= " {$this->Description}"; |
| 75: | } |
| 76: | return $string; |
| 77: | } |
| 78: | } |
| 79: | |