1 | <?php |
||
8 | class Argument |
||
9 | { |
||
10 | /** |
||
11 | * An argument's name. |
||
12 | * |
||
13 | * Use this name when internally referring to the argument. |
||
14 | * |
||
15 | * @var string |
||
16 | */ |
||
17 | protected $name; |
||
18 | |||
19 | /** |
||
20 | * An argument's short representation. |
||
21 | * |
||
22 | * @var string |
||
23 | */ |
||
24 | protected $prefix; |
||
25 | |||
26 | /** |
||
27 | * An argument's long representation. |
||
28 | * |
||
29 | * @var string |
||
30 | */ |
||
31 | protected $longPrefix; |
||
32 | |||
33 | /** |
||
34 | * An argument's description. |
||
35 | * |
||
36 | * @var string |
||
37 | */ |
||
38 | protected $description; |
||
39 | |||
40 | /** |
||
41 | * Whether or not an argument is required. |
||
42 | * |
||
43 | * @var bool |
||
44 | */ |
||
45 | protected $required = false; |
||
46 | |||
47 | /** |
||
48 | * Whether or not an argument only needs to be defined to have a value. |
||
49 | * |
||
50 | * These arguments have the value true when they are defined on the command |
||
51 | * line. |
||
52 | * |
||
53 | * @var bool |
||
54 | */ |
||
55 | protected $noValue = false; |
||
56 | |||
57 | /** |
||
58 | * Which data type to cast an argument's value to. |
||
59 | * |
||
60 | * Valid data types are "string", "int", "float", and "bool". |
||
61 | * |
||
62 | * @var string |
||
63 | */ |
||
64 | protected $castTo = 'string'; |
||
65 | |||
66 | /** |
||
67 | * An argument's default value. |
||
68 | * |
||
69 | * @var string |
||
70 | */ |
||
71 | protected $defaultValue = []; |
||
72 | |||
73 | /** |
||
74 | * An argument's value, after type casting. |
||
75 | * |
||
76 | * @var string[]|int[]|float[]|bool[] |
||
77 | */ |
||
78 | protected $values = []; |
||
79 | |||
80 | /** |
||
81 | * Build a new command argument. |
||
82 | 48 | * |
|
83 | * @param string $name |
||
84 | 48 | */ |
|
85 | 48 | public function __construct($name) |
|
89 | |||
90 | /** |
||
91 | * Build a new command argument from an array. |
||
92 | * |
||
93 | * @param string $name |
||
94 | * @param array $params |
||
95 | 48 | * |
|
96 | * @return Argument |
||
97 | 48 | */ |
|
98 | 48 | public static function createFromArray($name, array $params) |
|
110 | |||
111 | /** |
||
112 | * Get argument params based on settable properties |
||
113 | * |
||
114 | * @param array $params |
||
115 | * |
||
116 | * @return array |
||
117 | */ |
||
118 | protected static function getSettableArgumentParams(array $params) |
||
132 | |||
133 | /** |
||
134 | * Retrieve an argument's name. |
||
135 | * |
||
136 | * Use this name when internally referring to the argument. |
||
137 | * |
||
138 | * @return string |
||
139 | */ |
||
140 | public function name() |
||
144 | |||
145 | /** |
||
146 | * Set an argument's name. |
||
147 | * |
||
148 | * Use this name when internally referring to the argument. |
||
149 | * |
||
150 | * @param string $name |
||
151 | */ |
||
152 | protected function setName($name) |
||
156 | 48 | ||
157 | /** |
||
158 | * Retrieve an argument's short form. |
||
159 | * |
||
160 | * @return string |
||
161 | */ |
||
162 | public function prefix() |
||
166 | |||
167 | /** |
||
168 | * Set an argument's short form. |
||
169 | * |
||
170 | * @param string $prefix |
||
171 | */ |
||
172 | protected function setPrefix($prefix) |
||
176 | 20 | ||
177 | /** |
||
178 | * Retrieve an argument's long form. |
||
179 | * |
||
180 | * @return string |
||
181 | */ |
||
182 | public function longPrefix() |
||
186 | |||
187 | /** |
||
188 | * Set an argument's short form. |
||
189 | * |
||
190 | * @param string $longPrefix |
||
191 | */ |
||
192 | protected function setLongPrefix($longPrefix) |
||
196 | 20 | ||
197 | /** |
||
198 | * Determine if an argument has a prefix. |
||
199 | * |
||
200 | * @return bool |
||
201 | */ |
||
202 | public function hasPrefix() |
||
206 | |||
207 | /** |
||
208 | * Retrieve an argument's description. |
||
209 | * |
||
210 | * @return string |
||
211 | */ |
||
212 | public function description() |
||
216 | |||
217 | /** |
||
218 | * Set an argument's description. |
||
219 | * |
||
220 | * @param string $description |
||
221 | */ |
||
222 | protected function setDescription($description) |
||
226 | 4 | ||
227 | /** |
||
228 | * Determine whether or not an argument is required. |
||
229 | * |
||
230 | * @return bool |
||
231 | */ |
||
232 | public function isRequired() |
||
236 | |||
237 | /** |
||
238 | * Set whether an argument is required or not. |
||
239 | * |
||
240 | * @param bool $required |
||
241 | */ |
||
242 | protected function setRequired($required) |
||
246 | 8 | ||
247 | /** |
||
248 | * Determine whether or not an argument only needs to be defined to have a |
||
249 | * value. |
||
250 | * |
||
251 | * @return bool |
||
252 | */ |
||
253 | public function noValue() |
||
257 | |||
258 | /** |
||
259 | * Set whether or not an argument only needs to be defined to have a value. |
||
260 | * |
||
261 | * @param bool $noValue |
||
262 | */ |
||
263 | protected function setNoValue($noValue) |
||
268 | 12 | ||
269 | /** |
||
270 | * Retrieve the data type to cast an argument's value to. |
||
271 | * |
||
272 | * @return string |
||
273 | */ |
||
274 | public function castTo() |
||
278 | |||
279 | /** |
||
280 | * Set the data type to cast an argument's value to. |
||
281 | * |
||
282 | * Valid data types are "string", "int", "float", and "bool". |
||
283 | * |
||
284 | * @param string $castTo |
||
285 | * |
||
286 | * @return void |
||
287 | * @throws UnexpectedValueException if $castTo is not a valid data type. |
||
288 | 32 | */ |
|
289 | protected function setCastTo($castTo) |
||
300 | |||
301 | /** |
||
302 | * Retrieve an argument's default values. |
||
303 | * |
||
304 | * @return string |
||
305 | 44 | */ |
|
306 | public function defaultValue() |
||
310 | |||
311 | /** |
||
312 | * Set an argument's default value. |
||
313 | * |
||
314 | * @param string $defaultValue |
||
315 | 8 | */ |
|
316 | public function setDefaultValue($defaultValue) |
||
323 | |||
324 | /** |
||
325 | * Retrieve an argument's value. |
||
326 | * |
||
327 | 28 | * Argument values are type cast based on the value of $castTo. |
|
328 | * |
||
329 | 28 | * @return string|int|float|bool |
|
330 | */ |
||
331 | public function value() |
||
339 | 36 | ||
340 | /** |
||
341 | 36 | * Retrieve an argument's values. |
|
342 | 36 | * |
|
343 | 36 | * Argument values are type cast based on the value of $castTo. |
|
344 | * |
||
345 | * @return string[]|int[]|float[]|bool[] |
||
346 | */ |
||
347 | public function values() |
||
355 | |||
356 | /** |
||
357 | * @deprecated use values() instead. |
||
358 | */ |
||
359 | public function valueArray() |
||
363 | |||
364 | /** |
||
365 | * Set an argument's value based on its command line entry. |
||
366 | * |
||
367 | * Argument values are type cast based on the value of $castTo. |
||
368 | * |
||
369 | * @param string|bool $value |
||
370 | 4 | */ |
|
371 | public function setValue($value) |
||
376 | |||
377 | /** |
||
378 | * @param string $value |
||
379 | * |
||
380 | 8 | * @return string |
|
381 | */ |
||
382 | 8 | protected function castToString($value) |
|
386 | |||
387 | /** |
||
388 | * @param string $value |
||
389 | * |
||
390 | * @return int |
||
391 | */ |
||
392 | protected function castToInt($value) |
||
396 | |||
397 | /** |
||
398 | * @param string $value |
||
399 | * |
||
400 | * @return float |
||
401 | */ |
||
402 | protected function castToFloat($value) |
||
406 | |||
407 | /** |
||
408 | * @param string $value |
||
409 | * |
||
410 | * @return bool |
||
411 | */ |
||
412 | protected function castToBool($value) |
||
416 | } |
||
417 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..