1 | <?php |
||
14 | trait ParametersPart { |
||
15 | |||
16 | /** @var array */ |
||
17 | private $parameters = []; |
||
18 | |||
19 | 47 | private function initParameters() { |
|
22 | |||
23 | /** |
||
24 | * Sets a collection of parameters |
||
25 | * |
||
26 | * Note: clears all parameters before setting the new ones |
||
27 | * |
||
28 | * @param PhpParameter[] $parameters |
||
29 | * @return $this |
||
30 | */ |
||
31 | 1 | public function setParameters(array $parameters) { |
|
39 | |||
40 | /** |
||
41 | * Adds a parameter |
||
42 | * |
||
43 | * @param PhpParameter $parameter |
||
44 | * @return $this |
||
45 | */ |
||
46 | 22 | public function addParameter(PhpParameter $parameter) { |
|
51 | |||
52 | /** |
||
53 | * Checks whether a parameter exists |
||
54 | * |
||
55 | * @param string $name parameter name |
||
56 | * @return bool `true` if a parameter exists and `false` if not |
||
57 | */ |
||
58 | 2 | public function hasParameter($name) { |
|
67 | |||
68 | /** |
||
69 | * A quick way to add a parameter which is created from the given parameters |
||
70 | * |
||
71 | * @param string $name |
||
72 | * @param null|string $type |
||
73 | * @param mixed $defaultValue omit the argument to define no default value |
||
74 | * |
||
75 | * @return $this |
||
76 | */ |
||
77 | 1 | public function addSimpleParameter($name, $type = null, $defaultValue = null) { |
|
88 | |||
89 | /** |
||
90 | * A quick way to add a parameter with description which is created from the given parameters |
||
91 | * |
||
92 | * @param string $name |
||
93 | * @param null|string $type |
||
94 | * @param null|string $typeDescription |
||
95 | * @param mixed $defaultValue omit the argument to define no default value |
||
96 | * |
||
97 | * @return $this |
||
98 | */ |
||
99 | 1 | public function addSimpleDescParameter($name, $type = null, $typeDescription = null, $defaultValue = null) { |
|
111 | |||
112 | /** |
||
113 | * Returns a parameter by index or name |
||
114 | * |
||
115 | * @param string|int $nameOrIndex |
||
116 | * @throws \InvalidArgumentException |
||
117 | * @return PhpParameter |
||
118 | */ |
||
119 | 9 | public function getParameter($nameOrIndex) { |
|
133 | |||
134 | /** |
||
135 | * Replaces a parameter at a given position |
||
136 | * |
||
137 | * @param int $position |
||
138 | * @param PhpParameter $parameter |
||
139 | * @throws \InvalidArgumentException |
||
140 | * @return $this |
||
141 | */ |
||
142 | 2 | public function replaceParameter($position, PhpParameter $parameter) { |
|
148 | |||
149 | /** |
||
150 | * Remove a parameter at a given position |
||
151 | * |
||
152 | * @param int|string|PhpParameter $position |
||
153 | * @return $this |
||
154 | */ |
||
155 | 2 | public function removeParameter($param) { |
|
166 | |||
167 | 2 | private function removeParameterByPosition($position) { |
|
172 | |||
173 | private function removeParameterByName($name) { |
||
185 | |||
186 | 4 | private function checkPosition($position) { |
|
191 | |||
192 | /** |
||
193 | * Returns a collection of parameters |
||
194 | * |
||
195 | * @return array |
||
196 | */ |
||
197 | 16 | public function getParameters() { |
|
200 | |||
201 | /** |
||
202 | * Returns the docblock |
||
203 | * |
||
204 | * @return Docblock |
||
205 | */ |
||
206 | abstract protected function getDocblock(); |
||
207 | |||
208 | /** |
||
209 | * Generates docblock for params |
||
210 | */ |
||
211 | 14 | protected function generateParamDocblock() { |
|
233 | |||
234 | } |
||
235 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.