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

Fix redundant type casts#44274

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

Conversation

@fancyweb
Copy link
Contributor

QA
Branch?4.4
Bug fix?no
New feature?no
Deprecations?-
Tickets-
LicenseMIT
Doc PR-

Firstly, let's see if the CI is green as I expect it. I'll explain every change with a review comment.

protectedfunctionrenderForm(FormView$view,array$vars = [])
{
return(string)$this->renderer->renderBlock($view,'form',$vars);
return$this->renderer->renderBlock($view,'form',$vars);
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

FormRendererInterface::renderBlock() retturns a string

}

return(string)$this->renderer->searchAndRenderBlock($view,'label',$vars);
return$this->renderer->searchAndRenderBlock($view,'label',$vars);
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

FormRendererInterface::searchAndRenderBlock() retturns a string (same for the others)


privatefunctiongetStorage():StringStorage
{
return$this->getMockBuilder(StringStorage::class)
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I replaced the mock with a real instance.

{
if ($methods) {
$methods =array_map('strtoupper',(array)$methods);
$methods =array_map('strtoupper',$methods);
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

array $methods in the method args

*/
privatefunctionconvertValueDataType($value,int$type)
{
$type = (int)$type;
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

int $type in the args

['prefix1',false,'->parse() does not parse a number with a string prefix.',0,false],
['1.4suffix',(float)1.4,'->parse() parses a number with a string suffix.',3],
['1.4suffix',(float)1.4,'->parse() parses a number with a string suffix.',3,false],
['1.4suffix',1.4,'->parse() parses a number with a string suffix.',3],
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

1.4 is already a float

}

$score =(int) ($this->getCurrentTimeInMilliseconds() +$delayInMs);
$score =$this->getCurrentTimeInMilliseconds() +$delayInMs;
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

getCurrentTimeInMilliseconds() returns an int,int $delayInMs = 0 in the args

publicfunction__toString()
{
return(string)$this->template;
return$this->template;
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

The$template property is set by the constructor with thestring $template arg.

case'+' ===$scalar[0] ||'-' ===$scalar[0] ||'.' ===$scalar[0] ||is_numeric($scalar[0]):
if (Parser::preg_match('{^[+-]?[0-9][0-9_]*$}',$scalar)) {
$scalar =str_replace('_','',(string)$scalar);
$scalar =str_replace('_','',$scalar);
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

$scalar comes from$scalar = trim($scalar);,trim returns a string.

@fancywebfancywebforce-pushed theminor/type-cast-redundancy branch from6158331 toe724d5aCompareNovember 25, 2021 16:40

/**
* @return string
* @return string|false
Copy link
Member

Choose a reason for hiding this comment

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

But, right now, we guarantee a string, so this is a BC break.

@nicolas-grekas
Copy link
Member

Thank you@fancyweb.

@nicolas-grekasnicolas-grekas merged commit7b27c8d intosymfony:4.4Nov 28, 2021
@fancywebfancyweb deleted the minor/type-cast-redundancy branchNovember 29, 2021 12:19
@fancywebfancyweb mentioned this pull requestNov 29, 2021
nicolas-grekas added a commit that referenced this pull requestNov 29, 2021
This PR was merged into the 5.3 branch.Discussion----------Fix redundant type casts| Q             | A| ------------- | ---| Branch?       | 5.3| Bug fix?      | no| New feature?  | no| Deprecations? | no| Tickets       | -| License       | MIT| Doc PR        | -Continuation of#44274 on 5.3Commits-------4243335 Fix redundant type casts
symfony-splitter pushed a commit to symfony/translation that referenced this pull requestNov 29, 2021
This PR was merged into the 5.3 branch.Discussion----------Fix redundant type casts| Q             | A| ------------- | ---| Branch?       | 5.3| Bug fix?      | no| New feature?  | no| Deprecations? | no| Tickets       | -| License       | MIT| Doc PR        | -Continuation ofsymfony/symfony#44274 on 5.3Commits-------4243335012 Fix redundant type casts
SerhiyMytrovtsiy added a commit to SerhiyMytrovtsiy/translation that referenced this pull requestOct 19, 2022
This PR was merged into the 5.3 branch.Discussion----------Fix redundant type casts| Q             | A| ------------- | ---| Branch?       | 5.3| Bug fix?      | no| New feature?  | no| Deprecations? | no| Tickets       | -| License       | MIT| Doc PR        | -Continuation ofsymfony/symfony#44274 on 5.3Commits-------4243335012 Fix redundant type casts
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@fabpotfabpotfabpot requested changes

@chalasrchalasrAwaiting requested review from chalasrchalasr is a code owner

@wouterjwouterjAwaiting requested review from wouterjwouterj is a code owner

@xabbuhxabbuhAwaiting requested review from xabbuhxabbuh is a code owner

@ycerutoycerutoAwaiting requested review from ycerutoyceruto is a code owner

+1 more reviewer

@ro0NLro0NLro0NL left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

4.4

Development

Successfully merging this pull request may close these issues.

5 participants

@fancyweb@nicolas-grekas@fabpot@ro0NL@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp