Merge branch '8.0' into 8.1

* 8.0:
  bump symfony/type-info dependency
  [Console] Fix validator exception masked by MissingInputException on empty input
This commit is contained in:
Alexandre Daubois
2026-02-22 19:09:14 +01:00
2 changed files with 22 additions and 0 deletions

View File

@@ -492,6 +492,8 @@ class QuestionHelper extends Helper
}
return $value;
} catch (MissingInputException $e) {
throw $error ?? $e;
} catch (RuntimeException $e) {
throw $e;
} catch (\Exception $error) {

View File

@@ -824,6 +824,26 @@ class QuestionHelperTest extends AbstractQuestionHelperTestCase
$dialog->ask($this->createStreamableInputInterfaceMock($this->getInputStream('')), $this->createOutputInterface(), $question);
}
public function testValidatorExceptionPropagatesOnEmptyInput()
{
$dialog = new QuestionHelper();
$question = new Question('What\'s your name?');
$question->setValidator(function ($value) {
if ('' === $value || null === $value) {
throw new \InvalidArgumentException('A value is required.');
}
return $value;
});
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('A value is required.');
// Simulate setInputs(['']), which writes "\n" to the stream then EOF
$dialog->ask($this->createStreamableInputInterfaceMock($this->getInputStream("\n")), $this->createOutputInterface(), $question);
}
public function testQuestionValidatorRepeatsThePrompt()
{
$tries = 0;