diff --git a/src/Symfony/Component/Console/Helper/QuestionHelper.php b/src/Symfony/Component/Console/Helper/QuestionHelper.php index 757fed4746de..2d910f435611 100644 --- a/src/Symfony/Component/Console/Helper/QuestionHelper.php +++ b/src/Symfony/Component/Console/Helper/QuestionHelper.php @@ -367,19 +367,17 @@ private function autocomplete(OutputInterface $output, Question $question, $inpu private function mostRecentlyEnteredValue($entered) { - $tempEntered = $entered; - // Determine the most recent value that the user entered - if (false !== strpos($entered, ',')) { - $choices = explode(',', $entered); - $lastChoice = trim($choices[\count($choices) - 1]); + if (false === strpos($entered, ',')) { + return $entered; + } - if (\strlen($lastChoice) > 0) { - $tempEntered = $lastChoice; - } + $choices = explode(',', $entered); + if (\strlen($lastChoice = trim($choices[\count($choices) - 1])) > 0) { + return $lastChoice; } - return $tempEntered; + return $entered; } /**