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] Negatable option are null by default#40986
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
javiereguiluz left a comment
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.
I like this! It turns "negatable options" into tri-state options, which is something that was asked for by some developers. Thanks Jérémy!
Uh oh!
There was an error while loading.Please reload this page.
fabpot left a comment
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.
This change means that$this->getOption('ansi') can now returnnull, which is a BC break as it always returns a bool right now. Maybe we should havefalse as a default for this internal flag (no need for 3 states here anyway).
javiereguiluz commentedApr 29, 2021
The main difference is about "What's a negatable option?" (1) A single option with two behaviors (yes/no) Incase (1), we need a tri-state to differentiate these cases: $useAnsi =$input->getOption('ansi');if (true ===$useAnsi) {// force ANSI usage}elseif (false ===$useAnsi) {// don't use ANSI}elseif (null ===$useAnsi) {// user didn't pass any ANSI preference;// we must decide what to do} Incase (2), you only need two cases (the third one happens automatically): $useAnsi =$input->getOption('ansi');$dontUseAnsi =$input->getOption('no-ansi');if ($useAnsi) {// force ANSI usage}elseif ($dontUseAnsi) {// don't use ANSI}else {// user didn't pass any ANSI preference;// we must decide what to do} |
jderusse commentedApr 29, 2021
The BC break has been solved by setting the default to
|
fabpot commentedApr 29, 2021
Thank you@jderusse. |
Uh oh!
There was an error while loading.Please reload this page.
given the command
bin/console test --no-ansifalsebin/console test --ansitruebin/console testnull