Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Console] Add method to know parsed option#12773
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
blanchonvincent commentedNov 30, 2014
| Q | A |
|---|---|
| Bug fix? | no |
| New feature? | yes |
| BC breaks? | no |
| Deprecations? | no |
| Tests pass? | yes |
| Fixed tickets | #12769,#11572 |
| License | MIT |
| Doc PR | - |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
maybe faster with isset ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
@samsonasikarray_key_exists is different fromisset. Here, a value can benull
jakzal commentedDec 12, 2014
What's the use case? If the option is not defined why would you like to check if it was passed? |
xabbuh commentedDec 12, 2014
@jakzal The issue is that you can't determine if an option was passed by the user when the value is optional (see#11572 andsymfony/symfony-docs#4110). |
javiereguiluz commentedOct 2, 2015
@xabbuh do you like the |
fabpot commentedOct 2, 2015
I think the implementation should be actually different. There is no need to add another method with a weird name nobody will understand. I was more thinking about adding an additional argument to the existing |
bishopb commentedNov 9, 2015
@fabpot I think the challenge with an additional argument to Also, I just noticed changing
|
tomzx commentedJan 25, 2016
While you guys are at it, it might also be useful to be able to determine if an argument has been set. |
…empty) should remain empty (chalasr)This PR was merged into the 3.3-dev branch.Discussion----------[Console] Explicitly passed options without value (or empty) should remain empty| Q | A| ------------- | ---| Branch? | master| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#21215#11572#12773| License | MIT| Doc PR | n/a (maybe look at updating the existing one)This conserves empty values for options instead of returning their default values.Code:```php// cli.php$application = new Application();$application ->register('echo') ->addOption('prefix', null, InputOption::VALUE_OPTIONAL, null, 'my-default') ->addArgument('value', InputArgument::REQUIRED) ->setCode(function ($input, $output) { var_dump($input->getOption('prefix')); });$application->run();```Before:After:Commits-------8086742 [Console] Explicitly passed options without value (or empty) should remain empty