diff --git a/UPGRADE-3.4.md b/UPGRADE-3.4.md index 0e1e966d6660d..5a7aaf420f524 100644 --- a/UPGRADE-3.4.md +++ b/UPGRADE-3.4.md @@ -1,6 +1,11 @@ UPGRADE FROM 3.3 to 3.4 ======================= +Console +------- + + * Default validation in `SymfonyQuestionHelper::ask` has been deprecated and will be removed in 4.0. Apply validation using `Question::setValidator` instead. + DependencyInjection ------------------- diff --git a/UPGRADE-4.0.md b/UPGRADE-4.0.md index 1a7a2542376ca..f823c774b595d 100644 --- a/UPGRADE-4.0.md +++ b/UPGRADE-4.0.md @@ -61,6 +61,8 @@ Console * The `console.exception` event and the related `ConsoleExceptionEvent` class have been removed in favor of the `console.error` event and the `ConsoleErrorEvent` class. + * Default validation in `SymfonyQuestionHelper::ask` has been removed in favor of `Question::setValidator`. + Debug ----- diff --git a/src/Symfony/Bundle/WebServerBundle/Command/ServerStartCommand.php b/src/Symfony/Bundle/WebServerBundle/Command/ServerStartCommand.php index 57de788608547..af90a53f32c99 100644 --- a/src/Symfony/Bundle/WebServerBundle/Command/ServerStartCommand.php +++ b/src/Symfony/Bundle/WebServerBundle/Command/ServerStartCommand.php @@ -93,7 +93,7 @@ protected function execute(InputInterface $input, OutputInterface $output) 'You can either install it or use the "server:run" command instead.', )); - if ($io->ask('Do you want to execute server:run immediately? [yN] ', false)) { + if ($io->confirm('Do you want to execute server:run immediately?', false)) { return $this->getApplication()->find('server:run')->run($input, $output); } diff --git a/src/Symfony/Component/Console/CHANGELOG.md b/src/Symfony/Component/Console/CHANGELOG.md index b337ecf992f4d..616f70e137c0c 100644 --- a/src/Symfony/Component/Console/CHANGELOG.md +++ b/src/Symfony/Component/Console/CHANGELOG.md @@ -18,6 +18,7 @@ CHANGELOG * deprecated console.exception event in favor of console.error * added ability to handle `CommandNotFoundException` through the `console.error` event +* deprecated default validation in `SymfonyQuestionHelper::ask` 3.2.0 ------ diff --git a/src/Symfony/Component/Console/Helper/SymfonyQuestionHelper.php b/src/Symfony/Component/Console/Helper/SymfonyQuestionHelper.php index 25e094a04f45c..aa2701311d8e7 100644 --- a/src/Symfony/Component/Console/Helper/SymfonyQuestionHelper.php +++ b/src/Symfony/Component/Console/Helper/SymfonyQuestionHelper.php @@ -29,6 +29,8 @@ class SymfonyQuestionHelper extends QuestionHelper { /** * {@inheritdoc} + * + * BC to be removed in 4.0 */ public function ask(InputInterface $input, OutputInterface $output, Question $question) { @@ -39,6 +41,8 @@ public function ask(InputInterface $input, OutputInterface $output, Question $qu } else { // make required if (!is_array($value) && !is_bool($value) && 0 === strlen($value)) { + @trigger_error('The default question validator is deprecated since Symfony 3.4 and will not be used anymore in version 4.0. Set a custom question validator instead.', E_USER_DEPRECATED); + throw new LogicException('A value is required.'); } } diff --git a/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php index ce946e5b6259e..d07c30e25d921 100644 --- a/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php @@ -120,6 +120,18 @@ public function testAskThrowsExceptionOnMissingInput() $dialog->ask($this->createStreamableInputInterfaceMock($this->getInputStream('')), $this->createOutputInterface(), new Question('What\'s your name?')); } + /** + * @group legacy + * @expectedException \Symfony\Component\Console\Exception\RuntimeException + * @expectedExceptionMessage Aborted + * @expectedDeprecation The default question validator is deprecated since Symfony 3.4 and will not be used anymore in version 4.0. Set a custom question validator instead. + */ + public function testLegacyAsk() + { + $dialog = new SymfonyQuestionHelper(); + $dialog->ask($this->createStreamableInputInterfaceMock($this->getInputStream(' ')), $this->createOutputInterface(), new Question('Question')); + } + protected function getInputStream($input) { $stream = fopen('php://memory', 'r+', false);