1 | <?php |
||
23 | class Argument |
||
24 | { |
||
25 | /** |
||
26 | * @var string |
||
27 | */ |
||
28 | private $name; |
||
29 | |||
30 | /** |
||
31 | * @var string|null |
||
32 | */ |
||
33 | private $typeHint; |
||
34 | |||
35 | /** |
||
36 | * @var string |
||
37 | */ |
||
38 | private $type = 'mixed'; |
||
39 | |||
40 | /** |
||
41 | * @var string |
||
42 | */ |
||
43 | private $description; |
||
44 | |||
45 | /** |
||
46 | * @var string |
||
47 | */ |
||
48 | private $defaultValue; |
||
49 | |||
50 | /** |
||
51 | * Creates a new argument. |
||
52 | * |
||
53 | * @param string $name The name of the argument. |
||
54 | */ |
||
55 | 69 | public function __construct($name) |
|
61 | |||
62 | /** |
||
63 | * Returns the name of the argument. |
||
64 | * |
||
65 | * @return string The argument name. |
||
66 | */ |
||
67 | 46 | public function getName() |
|
71 | |||
72 | /** |
||
73 | * Returns the type hint of the argument. |
||
74 | * |
||
75 | * @return string|null The type hint or `null` if the argument has no type |
||
76 | * hint. |
||
77 | */ |
||
78 | 2 | public function getTypeHint() |
|
82 | |||
83 | /** |
||
84 | * Returns whether the argument has a type hint. |
||
85 | * |
||
86 | * @return bool Returns `true` if the argument has a type hint and `false` |
||
87 | * otherwise. |
||
88 | */ |
||
89 | 1 | public function hasTypeHint() |
|
93 | |||
94 | /** |
||
95 | * Sets the type hint of the argument. |
||
96 | * |
||
97 | * @param string $typeHint The type hint. |
||
98 | * |
||
99 | * @return static The current instance. |
||
100 | */ |
||
101 | 35 | public function setTypeHint($typeHint) |
|
109 | |||
110 | /** |
||
111 | * Removes the type hint of the argument. |
||
112 | * |
||
113 | * @return static The current instance. |
||
114 | */ |
||
115 | 2 | public function removeTypeHint() |
|
121 | |||
122 | /** |
||
123 | * Returns the type of the argument. |
||
124 | * |
||
125 | * @return string The argument type. |
||
126 | */ |
||
127 | 30 | public function getType() |
|
131 | |||
132 | /** |
||
133 | * Sets the type of the argument. |
||
134 | * |
||
135 | * @param string $type The argument type. |
||
136 | * |
||
137 | * @return static The current instance. |
||
138 | */ |
||
139 | 33 | public function setType($type) |
|
147 | |||
148 | /** |
||
149 | * Returns the description of the argument. |
||
150 | * |
||
151 | * @return string The argument description. |
||
152 | */ |
||
153 | 30 | public function getDescription() |
|
157 | |||
158 | /** |
||
159 | * Sets the description of the argument. |
||
160 | * |
||
161 | * @param string $description The argument description. |
||
162 | * |
||
163 | * @return static The current instance. |
||
164 | */ |
||
165 | 33 | public function setDescription($description) |
|
173 | |||
174 | /** |
||
175 | * Returns the default value of the argument. |
||
176 | * |
||
177 | * @return string|null The default value as source code or `null` if the |
||
178 | * argument has no default value. |
||
179 | */ |
||
180 | 2 | public function getDefaultValue() |
|
184 | |||
185 | /** |
||
186 | * Sets the default value of the argument. |
||
187 | * |
||
188 | * @param string $defaultValue The default value as source code. |
||
189 | * |
||
190 | * @return static The current instance. |
||
191 | */ |
||
192 | 7 | public function setDefaultValue($defaultValue) |
|
200 | |||
201 | /** |
||
202 | * Returns whether the argument has a default value. |
||
203 | * |
||
204 | * @return bool Returns `true` if the argument has a default value and |
||
205 | * `false` otherwise. |
||
206 | */ |
||
207 | 1 | public function hasDefaultValue() |
|
211 | |||
212 | /** |
||
213 | * Removes the default value of the argument. |
||
214 | * |
||
215 | * If the argument has no default value, this method does nothing. |
||
216 | * |
||
217 | * @return static The current instance. |
||
218 | */ |
||
219 | 2 | public function removeDefaultValue() |
|
225 | |||
226 | /** |
||
227 | * Returns the source code of the argument. |
||
228 | * |
||
229 | * @return string The source code. |
||
230 | */ |
||
231 | 29 | public function __toString() |
|
245 | } |
||
246 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: