1: <?php declare(strict_types=1);
2:
3: namespace Salient\PHPDoc\Tag;
4:
5: /**
6: * @api
7: */
8: class ParamTag extends AbstractTag
9: {
10: protected bool $IsPassedByReference;
11: protected bool $IsVariadic;
12:
13: /**
14: * Creates a new ParamTag object
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: array $aliases = []
25: ) {
26: parent::__construct('param', $name, $type, $description, $class, $member, $aliases);
27: $this->IsPassedByReference = $isPassedByReference;
28: $this->IsVariadic = $isVariadic;
29: }
30:
31: /**
32: * @inheritDoc
33: */
34: public function getName(): string
35: {
36: return $this->Name;
37: }
38:
39: /**
40: * Check if the parameter is passed by reference
41: */
42: public function isPassedByReference(): bool
43: {
44: return $this->IsPassedByReference;
45: }
46:
47: /**
48: * Check if the parameter is variadic
49: */
50: public function isVariadic(): bool
51: {
52: return $this->IsVariadic;
53: }
54:
55: /**
56: * @inheritDoc
57: */
58: public function __toString(): string
59: {
60: $string = "@{$this->Tag} ";
61: if (isset($this->Type)) {
62: $string .= "{$this->Type} ";
63: }
64: if ($this->IsPassedByReference) {
65: $string .= '&';
66: }
67: if ($this->IsVariadic) {
68: $string .= '...';
69: }
70: $string .= "\${$this->Name}";
71: if ($this->Description !== null) {
72: $string .= " {$this->Description}";
73: }
74: return $string;
75: }
76: }
77: