Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

[Console] Make SymfonyQuestionHelper::ask optional by default#22317

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
ro0NL wants to merge1 commit intosymfony:3.4fromro0NL:console/sf-question
Closed

[Console] Make SymfonyQuestionHelper::ask optional by default#22317

ro0NL wants to merge1 commit intosymfony:3.4fromro0NL:console/sf-question

Conversation

@ro0NL
Copy link
Contributor

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?yes
Tests pass?yes (nothing in core depends on it)
Fixed tickets#...
LicenseMIT
Doc PRsymfony/symfony-docs#...

i noticed when writing commands i always keep doing

$io =newSymfonyStyle($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...

sstok reacted with thumbs up emoji
@chalasr
Copy link
Member

👍 Already pointed out in#20141 when making it more flexible, I don't know why this default validator has been added, console's Symfony* stuff should only be about output styling, not input filtering.

/**
* {@inheritdoc}
*
* @deprecated since version 3.3, to be removed in 4.0
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Not sure about this.. it creates some nasty strikethroughs in IDE's, and the same method call will work in 4.0

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Indeed, I think I would talk only about the removed validation. Btw this needs to be documented :)

@nicolas-grekasnicolas-grekas added this to the3.3 milestoneApr 7, 2017
@nicolas-grekas
Copy link
Member

Moving to milestone 3.4 as this is not a blocker for 3.3. If you don't agree, please tell :)

@nicolas-grekasnicolas-grekas modified the milestones:3.3,3.4Apr 28, 2017
@ro0NL
Copy link
ContributorAuthor

Just annoying :) 👍 for 3.4, im used doing this already.

Copy link
Member

@fabpotfabpot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Target should also be changed to 3.4.

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

should be moved to 3.4.

}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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

3.4 instead of 3.3

@ro0NLro0NL changed the base branch frommaster to3.4July 20, 2017 18:57
fabpot added a commit that referenced this pull requestJul 20, 2017
…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
chalasr pushed a commit to chalasr/symfony that referenced this pull requestJul 22, 2017
…nal 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
@chalasr
Copy link
Member

Thank you@ro0NL

@ro0NLro0NL deleted the console/sf-question branchJuly 22, 2017 18:56
}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);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@ro0NL is this really in the correct code path? Throwing both a deprecation and an exception is suspicious to me.

Copy link
Member

@chalasrchalasrJul 26, 2017
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

indeed

Copy link
ContributorAuthor

@ro0NLro0NLJul 26, 2017
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

We're deprecating the fact this exception is thrown when the value is blank. Meaning in 4.0 ask() is optional by default, whereas now it's required by default.

I actually considered putting the trigger aboveif (!is_array($value) && !is_bool($value) && 0 === strlen($value)) {, but its weird to get the deprecation for a case that is still valid in 4.0.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Indeed, I think it's the right place for this deprecation.

nicolas-grekas added a commit that referenced this pull requestJul 26, 2017
* 3.4:  [DI] use assertStringEqualsFile when possible  [VarDumper] Adapt to php 7.2 changes  [DI] Fix using private services in expressions  [Form][TwigBridge] Don't render _method in form_rest() for a child form  [Form] Static call TimezoneType::getTimezones  Removed references for non existent validator constraints  Suggest using quotes instead of Yaml::PARSE_KEYS_AS_STRINGS  [DI] Fix test  [Cache] Handle unserialization failures for Memcached  Remove unused prop + added@deprecated  Remove unused mocks/vars  feature#22317 [Console] Make SymfonyQuestionHelper::ask optional by default (ro0NL)  [DoctrineBridge][PropertyInfo] Added support for Doctrine Embeddables  [Validator] Fix IbanValidator for ukrainian IBANs  Router: allow HEAD method to be defined first  [WebProfilerBundle] Display trace and context in the logger profiler  Fixing a bug where if a core class was autowired, autowiring tried to autowire optional args as if they were required
@fabpotfabpot mentioned this pull requestOct 19, 2017
ostrolucky pushed a commit to ostrolucky/symfony that referenced this pull requestMar 25, 2018
* 3.4:  [DI] use assertStringEqualsFile when possible  [VarDumper] Adapt to php 7.2 changes  [DI] Fix using private services in expressions  [Form][TwigBridge] Don't render _method in form_rest() for a child form  [Form] Static call TimezoneType::getTimezones  Removed references for non existent validator constraints  Suggest using quotes instead of Yaml::PARSE_KEYS_AS_STRINGS  [DI] Fix test  [Cache] Handle unserialization failures for Memcached  Remove unused prop + added@deprecated  Remove unused mocks/vars  featuresymfony#22317 [Console] Make SymfonyQuestionHelper::ask optional by default (ro0NL)  [DoctrineBridge][PropertyInfo] Added support for Doctrine Embeddables  [Validator] Fix IbanValidator for ukrainian IBANs  Router: allow HEAD method to be defined first  [WebProfilerBundle] Display trace and context in the logger profiler  Fixing a bug where if a core class was autowired, autowiring tried to autowire optional args as if they were required
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

@chalasrchalasrchalasr approved these changes

@fabpotfabpotfabpot requested changes

+1 more reviewer

@ogizanagiogizanagiogizanagi left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

3.4

Development

Successfully merging this pull request may close these issues.

6 participants

@ro0NL@chalasr@nicolas-grekas@fabpot@ogizanagi@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp