-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console] SymonfyStyle - Check value isset to avoid PHP notice #34114
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Can you please rebase against 3.4 and add a test to prevent regressions? |
@chalasr Yep… I thought I would throw in a quick PR to get some feedback. |
I am not really sure how this could happen. Could you please add a test that illustrates why this is necessary? |
I think we need to clarify that the |
I thought this was about supporting using the choice key instead of the value as default, read too fast. |
Thanks for the feedback @xabbuh
I ran into this issue when I was trying to figure out how to confirm option inputs during the interact function see: #34093 In the original example the flow should probably be that if the user enters an option skip the question but if I did that when I use the value I would need to throw an
That doesn't seem to be enforced in the
If the user is prevented an invalid default and quickly presses enter the console shows an Invalid value error and prompts the user to select a valid value. |
It looks like nothing requires it in |
Yep that was my thinking. The implementation mirrors the |
friendly ping @leevigraham |
Thank you @leevigraham. |
…tice (leevigraham) This PR was merged into the 3.4 branch. Discussion ---------- [Console] SymonfyStyle - Check value isset to avoid PHP notice | Q | A | ------------- | --- | Branch? | 4.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #34093 | License | MIT | Doc PR | n/a This PR addresses the issue when a default value is not a valid choice. Currently this would throw a notice which outputs to the console. This fix is a similar implementation to the `QuestionHelper`: https://github.com/symfony/symfony/blob/4.4/src/Symfony/Component/Console/Helper/QuestionHelper.php#L63 Example console command and output can be found in the issue: #34093 Commits ------- c9072c7 Check value isset to avoid PHP notice
@fabpot @nicolas-grekas Thanks for merging… I was overseas on holidays for a few months. |
This PR addresses the issue when a default value is not a valid choice. Currently this would throw a notice which outputs to the console.
This fix is a similar implementation to the
QuestionHelper
: https://github.com/symfony/symfony/blob/4.4/src/Symfony/Component/Console/Helper/QuestionHelper.php#L63Example console command and output can be found in the issue: #34093