From 2da429cd0a4bebac84b8b91537867a08156aca7a Mon Sep 17 00:00:00 2001 From: Roland Franssen Date: Thu, 6 Apr 2017 18:31:06 +0200 Subject: [PATCH] [Console] Make SymfonyQuestionHelper::ask optional by default --- UPGRADE-3.3.md | 2 ++ UPGRADE-4.0.md | 2 ++ .../Bundle/WebServerBundle/Command/ServerStartCommand.php | 2 +- src/Symfony/Component/Console/CHANGELOG.md | 1 + .../Component/Console/Helper/SymfonyQuestionHelper.php | 4 ++++ 5 files changed, 10 insertions(+), 1 deletion(-) diff --git a/UPGRADE-3.3.md b/UPGRADE-3.3.md index f068e4f432..4233503730 100644 --- a/UPGRADE-3.3.md +++ b/UPGRADE-3.3.md @@ -72,6 +72,8 @@ Console have been deprecated in favor of the `console.error` event and the `ConsoleErrorEvent` class. The deprecated event and class will be removed in 4.0. + * The `SymfonyQuestionHelper::ask` default validation has been deprecated and will be removed in 4.0. Apply validation using `Question::setValidator` instead. + Debug ----- diff --git a/UPGRADE-4.0.md b/UPGRADE-4.0.md index 401f3ae736..ed4c2f674f 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. + * The `SymfonyQuestionHelper::ask` default validation 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 c0888e944e..0648ae3470 100644 --- a/src/Symfony/Bundle/WebServerBundle/Command/ServerStartCommand.php +++ b/src/Symfony/Bundle/WebServerBundle/Command/ServerStartCommand.php @@ -88,7 +88,7 @@ EOF '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 f8539491d2..901fdcf602 100644 --- a/src/Symfony/Component/Console/CHANGELOG.md +++ b/src/Symfony/Component/Console/CHANGELOG.md @@ -12,6 +12,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 25e094a04f..cf071d594d 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} + * + * To be removed in 4.0 */ public function ask(InputInterface $input, OutputInterface $output, Question $question) { @@ -39,6 +41,8 @@ class SymfonyQuestionHelper extends QuestionHelper } else { // make required if (!is_array($value) && !is_bool($value) && 0 === strlen($value)) { + @trigger_error('The default question validator is deprecated since Symfony 3.3 and will not be used anymore in version 4.0. Set a custom question validator if needed.', E_USER_DEPRECATED); + throw new LogicException('A value is required.'); } }