Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b9cc089

Browse filesBrowse files
committed
feature #22317 [Console] Make SymfonyQuestionHelper::ask optional by default (ro0NL)
This PR was merged into the 4.0-dev branch. Discussion ---------- [Console] Make SymfonyQuestionHelper::ask optional by default | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | yes | Tests pass? | yes (nothing in core depends on it) | Fixed tickets | #... <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | symfony/symfony-docs#... <!--highly recommended for new features--> i noticed when writing commands i always keep doing ```php $io = new SymfonyStyle($input, $output); $answer = $io->ask('...', null, function ($value) { return $value; }); // instead of just $answer = $io->ask('...'); ``` only to bypass a built-in validation, of which im not sure why it's there. Note the base question helper doesnt make this assumption... Commits ------- 2da429c [Console] Make SymfonyQuestionHelper::ask optional by default
2 parents 1cac0a0 + 2da429c commit b9cc089
Copy full SHA for b9cc089

File tree

5 files changed

+10
-1
lines changed
Filter options

5 files changed

+10
-1
lines changed

‎UPGRADE-3.3.md

Copy file name to clipboardExpand all lines: UPGRADE-3.3.md
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ Console
7272
have been deprecated in favor of the `console.error` event and the `ConsoleErrorEvent`
7373
class. The deprecated event and class will be removed in 4.0.
7474

75+
* The `SymfonyQuestionHelper::ask` default validation has been deprecated and will be removed in 4.0. Apply validation using `Question::setValidator` instead.
76+
7577
Debug
7678
-----
7779

‎UPGRADE-4.0.md

Copy file name to clipboardExpand all lines: UPGRADE-4.0.md
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ Console
6161
* The `console.exception` event and the related `ConsoleExceptionEvent` class have
6262
been removed in favor of the `console.error` event and the `ConsoleErrorEvent` class.
6363

64+
* The `SymfonyQuestionHelper::ask` default validation has been removed in favor of `Question::setValidator`.
65+
6466
Debug
6567
-----
6668

‎src/Symfony/Bundle/WebServerBundle/Command/ServerStartCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebServerBundle/Command/ServerStartCommand.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
9494
'You can either install it or use the "server:run" command instead.',
9595
));
9696

97-
if ($io->ask('Do you want to execute <info>server:run</info> immediately? [yN] ', false)) {
97+
if ($io->confirm('Do you want to execute <info>server:run</info> immediately?', false)) {
9898
return $this->getApplication()->find('server:run')->run($input, $output);
9999
}
100100

‎src/Symfony/Component/Console/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ CHANGELOG
2727
* deprecated console.exception event in favor of console.error
2828
* added ability to handle `CommandNotFoundException` through the
2929
`console.error` event
30+
* deprecated default validation in `SymfonyQuestionHelper::ask`
3031

3132
3.2.0
3233
------

‎src/Symfony/Component/Console/Helper/SymfonyQuestionHelper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Helper/SymfonyQuestionHelper.php
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ class SymfonyQuestionHelper extends QuestionHelper
2929
{
3030
/**
3131
* {@inheritdoc}
32+
*
33+
* To be removed in 4.0
3234
*/
3335
public function ask(InputInterface $input, OutputInterface $output, Question $question)
3436
{
@@ -39,6 +41,8 @@ public function ask(InputInterface $input, OutputInterface $output, Question $qu
3941
} else {
4042
// make required
4143
if (!is_array($value) && !is_bool($value) && 0 === strlen($value)) {
44+
@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);
45+
4246
throw new LogicException('A value is required.');
4347
}
4448
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.