Skip to content

Commit 4430f75

Browse files
committed
bug #12180 Prevent an empty choice list being passed in debug:container (weaverryan)
This PR was squashed before being merged into the 2.6-dev branch (closes #12180). Discussion ---------- Prevent an empty choice list being passed in debug:container Hi guys! | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | -- | License | MIT | Doc PR | n/a Currently, there is a "bug" where if you pass an empty array to ChoiceList, then you get this following warning from `QuestionHelper::doAsk()`: > Warning: max(): Array must contain at least one element That should probably be fixed too, but it would go on an earlier version, so I didn't want to mix fixes for different branches. Thanks! Commits ------- ef23b63 Prevent an empty choice list being passed in debug:container
2 parents ade0db7 + ef23b63 commit 4430f75

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,12 @@ private function findProperServiceName(InputInterface $input, OutputInterface $o
184184
return $name;
185185
}
186186

187-
$question = new ChoiceQuestion('Choose a number for more information on the service', $this->findServiceIdsContaining($builder, $name));
187+
$matchingServices = $this->findServiceIdsContaining($builder, $name);
188+
if (empty($matchingServices)) {
189+
throw new \InvalidArgumentException(sprintf('No services found that match "%s".', $name));
190+
}
191+
192+
$question = new ChoiceQuestion('Choose a number for more information on the service', $matchingServices);
188193
$question->setErrorMessage('Service %s is invalid.');
189194

190195
return $this->getHelper('question')->ask($input, $output, $question);

0 commit comments

Comments
 (0)