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

Remove redundant sprintf argument.#24613

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

Merged
Tobion merged 1 commit intosymfony:2.7fromAliance:fix-sprintf-arguments
Oct 26, 2017

Conversation

@Aliance
Copy link
Contributor

@AlianceAliance commentedOct 19, 2017
edited
Loading

QA
Branch?2.7
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#22820
LicenseMIT
Doc PR

cc@fabpot@ogizanagi

}

returnsprintf('($context["%s"] ?? $this->getContext($context, "%s"))',$name,$name,$name);
returnsprintf('($context["%s"] ?? $this->getContext($context, "%s"))',$name,$name);
Copy link
Contributor

Choose a reason for hiding this comment

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

%1$s? thus assign$name once here as well.

Choose a reason for hiding this comment

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

Don't you find that notation (%1$s) difficult to understand? I always struggle with it.

Copy link
Contributor

Choose a reason for hiding this comment

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

No strong opinion. Just to make things less error prone :) basically the two assignments must always stay the same, thus id prefer a single assignment.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

@ro0NL I thought about it, but decided not to change. But I agree that%1$s is better.

Copy link
Member

Choose a reason for hiding this comment

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

I prefer%1$s. That's howsprintf() should be used to avoid duplications, and we already have some usages in the code base

@Tobion
Copy link
Contributor

This PR should be opened against 2.7 as it is wrong there as well.

ogizanagi reacted with thumbs up emoji

@Aliance
Copy link
ContributorAuthor

@Tobion there is different code in different branches:
https://github.com/symfony/symfony/blob/v2.7.35/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php#L74-L85

https://github.com/symfony/symfony/blob/v2.8.28/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php#L74-L85

https://github.com/symfony/symfony/blob/v3.0.9/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php#L67-L70

https://github.com/symfony/symfony/blob/v3.1.10/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php#L67-L74

https://github.com/symfony/symfony/blob/v3.2.13/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php#L74-L81

https://github.com/symfony/symfony/blob/v3.3.10/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php#L74-L81

https://github.com/symfony/symfony/blob/v3.4.0-BETA1/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php#L103-L110

https://github.com/symfony/symfony/blob/v4.0.0-BETA1/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php#L103-L106

So in some branches there is php version checks, in others – not. May be merge this pr to branches w/o php version checks and create another one for other branches?

@Tobion
Copy link
Contributor

@Aliance it's enough if you open a PR for 2.7. We then merge it upwards and will resolve conflicts.

@nicolas-grekasnicolas-grekas added this to the2.7 milestoneOct 19, 2017
@AlianceAliance changed the base branch frommaster to2.7October 20, 2017 09:44
@Aliance
Copy link
ContributorAuthor

Aliance commentedOct 20, 2017
edited
Loading

@Tobion I rebased it on 2.7, also changed duplicated arguments to%1$s and also tried to find all the same occurrences with regexpsprintf\('(.*?)', \$(.*?), \$\2\)

$formId = Crawler::xpathLiteral($this->node->getAttribute('id'));

$fieldNodes =$xpath->query(sprintf('descendant::input[@form=%s] | descendant::button[@form=%s] | descendant::textarea[@form=%s] | descendant::select[@form=%s] | //form[@id=%s]//input[not(@form)] | //form[@id=%s]//button[not(@form)] | //form[@id=%s]//textarea[not(@form)] | //form[@id=%s]//select[not(@form)]',$formId,$formId,$formId,$formId,$formId,$formId,$formId,$formId));
$fieldNodes =$xpath->query(sprintf('descendant::input[@form=%s] | descendant::button[@form=%1$s] | descendant::textarea[@form=%1$s] | descendant::select[@form=%1$s] | //form[@id=%1$s]//input[not(@form)] | //form[@id=%1$s]//button[not(@form)] | //form[@id=%1$s]//textarea[not(@form)] | //form[@id=%1$s]//select[not(@form)]',$formId));
Copy link
Contributor

@ro0NLro0NLOct 26, 2017
edited
Loading

Choose a reason for hiding this comment

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

lol :) definitely up for%1$s now.

@Tobion
Copy link
Contributor

Good catch, thanks@Aliance.

@TobionTobion merged commitc8012f0 intosymfony:2.7Oct 26, 2017
Tobion added a commit that referenced this pull requestOct 26, 2017
This PR was merged into the 2.7 branch.Discussion----------Remove redundant sprintf argument.| Q             | A| ------------- | ---| Branch?       | 2.7| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#22820| License       | MIT| Doc PR        | –cc@fabpot@ogizanagiCommits-------c8012f0 Remove redundant sprintf arguments.
@AlianceAliance deleted the fix-sprintf-arguments branchOctober 26, 2017 14:28
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@javiereguiluzjaviereguiluzjaviereguiluz left review comments

@chalasrchalasrchalasr left review comments

+2 more reviewers

@TobionTobionTobion approved these changes

@ro0NLro0NLro0NL approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

2.7

Development

Successfully merging this pull request may close these issues.

7 participants

@Aliance@Tobion@javiereguiluz@ro0NL@chalasr@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp