Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a536342

Browse files
committed
bug #34114 [Console] SymonfyStyle - Check value isset to avoid PHP notice (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
2 parents 78641e0 + c9072c7 commit a536342

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Symfony/Component/Console/Style/SymfonyStyle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ public function choice($question, array $choices, $default = null)
229229
{
230230
if (null !== $default) {
231231
$values = array_flip($choices);
232-
$default = $values[$default];
232+
$default = isset($values[$default]) ? $values[$default] : $default;
233233
}
234234

235235
return $this->askQuestion(new ChoiceQuestion($question, $choices, $default));

0 commit comments

Comments
 (0)