1 | <?php declare(strict_types=1); |
||
32 | use NamePart; |
||
33 | use TypePart; |
||
34 | use ValuePart; |
||
35 | |||
36 | private bool $passedByReference = false; |
||
|
|||
37 | |||
38 | /** |
||
39 | * Creates a new PHP parameter. |
||
40 | * |
||
41 | * @param string $name the parameter name |
||
42 | * |
||
43 | * @return static |
||
44 | */ |
||
45 | public static function create(string $name = ''): static { |
||
46 | 18 | return new static($name); |
|
47 | 18 | } |
|
48 | |||
49 | /** |
||
50 | * Creates a new PHP parameter |
||
51 | * |
||
52 | * @param string $name the parameter name |
||
53 | */ |
||
54 | public function __construct(string $name = '') { |
||
55 | 29 | $this->setName($name); |
|
56 | 29 | } |
|
57 | 29 | ||
58 | /** |
||
59 | * Sets whether this parameter is passed by reference |
||
60 | * |
||
61 | * @param bool $bool `true` if passed by reference and `false` if not |
||
62 | * |
||
63 | * @return $this |
||
64 | */ |
||
65 | 8 | public function setPassedByReference(bool $bool): static { |
|
66 | 8 | $this->passedByReference = $bool; |
|
67 | |||
68 | 8 | return $this; |
|
69 | } |
||
70 | |||
71 | /** |
||
72 | * Returns whether this parameter is passed by reference |
||
73 | * |
||
74 | * @return bool `true` if passed by reference and `false` if not |
||
75 | */ |
||
76 | 12 | public function isPassedByReference(): bool { |
|
77 | 12 | return $this->passedByReference; |
|
78 | } |
||
79 | |||
80 | /** |
||
81 | * Returns a docblock tag for this parameter |
||
82 | * |
||
83 | * @return ParamTag |
||
84 | */ |
||
85 | 7 | public function getDocblockTag(): ParamTag { |
|
86 | 7 | return ParamTag::create() |
|
87 | 7 | ->setType($this->getType()) |
|
88 | 7 | ->setVariable($this->getName()) |
|
89 | 7 | ->setDescription($this->getTypeDescription()); |
|
90 | } |
||
91 | |||
92 | /** |
||
93 | * Alias for setDescription() |
||
94 | * |
||
95 | * @see #setDescription |
||
96 | * |
||
97 | * @param string $description |
||
98 | * |
||
99 | 4 | * @return $this |
|
100 | 4 | */ |
|
101 | public function setTypeDescription(string $description): static { |
||
102 | return $this->setDescription($description); |
||
103 | } |
||
104 | |||
105 | /** |
||
106 | * Alias for getDescription() |
||
107 | * |
||
108 | * @see #getDescription |
||
109 | 9 | * |
|
110 | 9 | * @return string |
|
111 | */ |
||
112 | public function getTypeDescription(): string { |
||
113 | return $this->getDescription(); |
||
116 |