Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 99f9e3f

Browse filesBrowse files
Jean85javiereguiluz
authored andcommitted
Simplify the explanation leaving just one solution
1 parent a05b002 commit 99f9e3f
Copy full SHA for 99f9e3f

File tree

Expand file treeCollapse file tree

1 file changed

+3
-16
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+3
-16
lines changed

‎console/input.rst

Copy file name to clipboardExpand all lines: console/input.rst
+3-16Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.