8000 Simplify the explanation leaving just one solution · symfony/symfony-docs@99f9e3f · GitHub
[go: up one dir, main page]

Skip to content

Commit 99f9e3f

Browse files
Jean85javiereguiluz
authored andcommitted
Simplify the explanation leaving just one solution
1 parent a05b002 commit 99f9e3f

File tree

1 file changed

+3
-16
lines changed

1 file changed

+3
-16
lines changed

console/input.rst

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -242,21 +242,7 @@ passing the option at all; however, the task of distinguishing between when
242242
the option was used without a value (``greet --yell``) or when it wasn't used
243243
at all (``greet``) it's a bit impervious.
244244

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``::
260246

261247
// ...
262248
use Symfony\Component\Console\Input\InputOption;
@@ -271,7 +257,8 @@ to ``false``::
271257
false // this is the new default value, instead of null
272258
);
273259

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``::
275262

276263
$optionValue = $input->getOptions('yell');
277264
$yell = ($optionValue !== false);

0 commit comments

Comments
 (0)
0