File tree 1 file changed +3
-16
lines changed
1 file changed +3
-16
lines changed Original file line number Diff line number Diff line change @@ -242,21 +242,7 @@ passing the option at all; however, the task of distinguishing between when
242
242
the option was used without a value (``greet --yell ``) or when it wasn't used
243
243
at all (``greet ``) it's a bit impervious.
244
244
245
- To solve this issue, you have two possible solutions: in the first case, you
246
- can use the ``hasParameterOption `` method::
247
-
248
- if ($input->hasParameterOption('--yell')) {
249
- $yell = true;
250
- $yellLouder = $input->getOption('yell') === 'louder';
251
- }
252
-
253
- .. caution ::
254
-
255
- Note that the ``hasParameterOption `` method requires prepending ``-- ``
256
- to the option name.
257
-
258
- The second solution is to alter the option definition, setting the default value
259
- to ``false ``::
245
+ To solve this issue, you have to set the option's default value to ``false ``::
260
246
261
247
// ...
262
248
use Symfony\Component\Console\Input\InputOption;
@@ -271,7 +257,8 @@ to ``false``::
271
257
false // this is the new default value, instead of null
272
258
);
273
259
274
- And then checking carefully the value of the option, minding that ``false !== null ``::
260
+ And then you just have to check carefully the value of the option, minding that
261
+ ``false !== null ``::
275
262
276
263
$optionValue = $input->getOptions('yell');
277
264
$yell = ($optionValue !== false);
You can’t perform that action at this time.
0 commit comments