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 @return statements to use $this or static when relevant#21054

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
fabpot merged 1 commit intosymfony:2.7fromfabpot:return-stmt
Dec 27, 2016

Conversation

@fabpot
Copy link
Member

QA
Branch?2.7
Bug fix?no
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#20290
LicenseMIT
Doc PRn/a

see#20290

ro0NL, javiereguiluz, ogizanagi, chalasr, Koc, and yceruto reacted with hooray emoji
@ro0NL
Copy link
Contributor

ro0NL commentedDec 26, 2016
edited
Loading

With#21047 i also spotted some cases where@return FQCN|$this is used. (FQCN from the current class file, ie. the same ;-))

I have no clear ref on this, but PhpStorm really doesnt seem to like it. Or at least not when used inconsistently so it seems 😕 (1 class mixing$this,FQCN and/orFQCN|$this[|...]).

Perhaps worth looking at.

* Opens a new child scope.
*
* @returnScope
* @return$this
Copy link
Contributor

Choose a reason for hiding this comment

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

this should be@return self right?
this - return exactly the same instance
self - return new instance of exactly same type
static - return new instance of same type or any child of type

@fabpotfabpotforce-pushed thereturn-stmt branch 6 times, most recently from21c14d3 to78f726aCompareDecember 26, 2016 09:47
@fabpotfabpot changed the base branch frommaster to2.7December 26, 2016 09:49
@fabpotfabpotforce-pushed thereturn-stmt branch 2 times, most recently fromc66a477 to683eaf2CompareDecember 26, 2016 10:46
@fabpot
Copy link
MemberAuthor

I would appreciate some careful review before merging as re-reading the PR several times allowed me to fix some issues I introduced. I know, this is quite painful to do, but let's try to do it well.

* @returnNormalizationBuilder
* @return$this
*/
publicfunctionremap($key,$plural =null)
Copy link
Contributor

Choose a reason for hiding this comment

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

before() (below) can be$this|ExprBuilder

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

fixed

* @param string|null $type The resource type or null if unknown
*
* @returnLoaderInterface A LoaderInterface instance
* @return$this|self
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be$this|LoaderInterface

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

fixed

* Gets the helper set associated with this helper.
*
* @return HelperSet A HelperSet instance
* @return HelperSet
Copy link
Contributor

Choose a reason for hiding this comment

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

Should beHelperSet|null

ogizanagi and wouterj reacted with thumbs up emoji
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

fixed

* Returns the EventDispatcher that dispatches this Event.
*
* @returnEventDispatcherInterface
* @returnEventDispatcher
Copy link
Contributor

Choose a reason for hiding this comment

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

EventDispatcherInterface was right? The@var is wrong..

wouterj reacted with thumbs up emoji
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

fixed

* @param string $expr
*
* @returnExpression
* @returnstatic
Copy link
Contributor

Choose a reason for hiding this comment

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

self

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

fixed

* Opens a new child scope.
*
* @returnScope
* @returnself
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems to be inconsistent with a lot of changes below.. where it goes tostatic fornew self.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ifnew self is used, it should beself anyway.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree.

* @param string $expr
*
* @returnRegex
* @returnstatic
Copy link
Contributor

Choose a reason for hiding this comment

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

self. Im stopping here for now.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

fixed

* Closes current scope and returns parent one.
*
* @returnScope|null
* @returnself|null
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure we should prefer usingself over the class/interface name. IMHO, we should only distinguish$this,static andclassname usages, butself does not bring anything more, so it isn't worth it.

Copy link
Contributor

@ro0NLro0NLDec 26, 2016
edited
Loading

Choose a reason for hiding this comment

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

I'm not sure we should prefer using self over the class/interface name.

Personally, i prefer it... so while we're at it 👍 for doing this as well.

Copy link
Contributor

@ogizanagiogizanagiDec 26, 2016
edited
Loading

Choose a reason for hiding this comment

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

Personally, i prefer it...

I don't 😆

I just don't understand the motivations behind, and there are many places where this was not applied (FormFactoryBuilderInterface::getFormFactory() for instance).

Copy link
Contributor

Choose a reason for hiding this comment

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

Avoid duplicating terms. But you're right, if not done consistently it's not really worth it anyway.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I will keepself as in the code, that's also what we are using.

* @param string $name The style name
*
* @returnTableStyle A TableStyle instance
* @returnstatic
Copy link
Contributor

Choose a reason for hiding this comment

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

This change looks wrong to me.self::$styles is an array ofTableStyle.

wouterj and ro0NL reacted with thumbs up emoji
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

fixed

* @param Token $foundToken
*
* @returnSyntaxErrorException
* @returnstatic
Copy link
Contributor

Choose a reason for hiding this comment

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

Should beself (same below)

wouterj reacted with thumbs up emoji
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

fixed

* @param array $options The options
*
* @returnFormBuilderInterface The created builder
* @return$this
Copy link
Contributor

@ogizanagiogizanagiDec 26, 2016
edited
Loading

Choose a reason for hiding this comment

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

This change looks wrong to me. It doesn't return the current instance, but creates another one, for a child for instance.

wouterj reacted with thumbs up emoji
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

fixed

* @param string $name The name of the child
*
* @returnFormBuilderInterface The builder for the child
* @return$this
Copy link
Contributor

Choose a reason for hiding this comment

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

Same. It returns a child. Not the same instance.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

fixed

* @param bool $inheritData Whether the form should inherit its parent's data
*
* @returnFormConfigBuilder The configuration object
* @return$this
Copy link
Contributor

Choose a reason for hiding this comment

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

It doesn't return anything actually.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

fixed

* Alias of {@link getInheritData()}.
*
* @returnFormConfigBuilder The configuration object
* @return$this
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmmm. It returns a boolean actually.

wouterj reacted with thumbs up emoji
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

indeed :)

Copy link
Contributor

@ogizanagiogizanagi left a comment
edited
Loading

Choose a reason for hiding this comment

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

I'm done 😅
Sorry, I've left a lot of comment related to what seems misleading usages ofstatic to me (see#21054 (comment)), in order to keep track of it. If you don't agree, I'll remove them.

Anyway, what a colossal job you've achieved here!

* Returns the parent form.
*
* @returnFormInterface|null The parent form or null if there is none
* @return$this|null The parent form or null if there is none
Copy link
Contributor

@ogizanagiogizanagiDec 26, 2016
edited
Loading

Choose a reason for hiding this comment

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

Wrong change. The returned instance is the form parent.

Copy link
Member

Choose a reason for hiding this comment

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

Should beself|null then

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

fixed

* Returns all children in this group.
*
* @return FormInterface[] An array of FormInterface instances
* @return FormInterface[]
Copy link
Contributor

Choose a reason for hiding this comment

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

Why notself[] then? (Related to#21054 (comment))

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

fixed

* @param Guess[] $guesses An array of guesses
*
* @returnGuess|null The guess with the highest confidence
* @returnstatic|null
Copy link
Contributor

Choose a reason for hiding this comment

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

Should keepGuess|null

Copy link
Member

Choose a reason for hiding this comment

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

Orself|null

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

fixed

* @param string $headerValue
*
* @returnAcceptHeader
* @returnstatic
Copy link
Contributor

Choose a reason for hiding this comment

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

self

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

fixed

* @param string $itemValue
*
* @returnAcceptHeaderItem
* @returnstatic
Copy link
Contributor

Choose a reason for hiding this comment

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

self ?

wouterj reacted with thumbs up emoji
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

fixed

* described in the ICU DecimalFormat or ICU RuleBasedNumberFormat documentation
*
* @returnNumberFormatter
* @returnstatic
Copy link
Contributor

Choose a reason for hiding this comment

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

self?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

fixed

* Creates a property accessor with the default configuration.
*
* @returnPropertyAccessor The new property accessor
* @returnstatic
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks wrong. (same for other changes in this class)

wouterj reacted with thumbs up emoji
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

fixed

* @param object $domainObject
*
* @returnObjectIdentity
* @returnstatic
Copy link
Contributor

Choose a reason for hiding this comment

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

self?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

fixed

* @param UserInterface $user
*
* @returnUserSecurityIdentity
* @returnstatic
Copy link
Contributor

Choose a reason for hiding this comment

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

self?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

fixed

* @returnUserSecurityIdentity
* @returnstatic
*/
publicstaticfunctionfromToken(TokenInterface$token)
Copy link
Contributor

Choose a reason for hiding this comment

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

self?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

fixed

Copy link
Member

@wouterjwouterj left a comment

Choose a reason for hiding this comment

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

Did just a quick review, these are the glitches I found.

* @param Command|null $parent Parent command
*
* @returnCommand New Command instance
* @returnstatic
Copy link
Member

Choose a reason for hiding this comment

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

self

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

fixed

* @param string $label The unique label
*
* @returnCommand The current Command instance
* @returnself
Copy link
Member

Choose a reason for hiding this comment

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

Should beself|string, according toadd().

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

fixed

* Returns parent command (if any).
*
* @returnCommand Parent command
* @returnself
Copy link
Member

Choose a reason for hiding this comment

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

self|null

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I don't think so as it throws an exception is parent isnull.

wouterj reacted with thumbs up emoji
* @param string $label
*
* @returnCommand The labeled command
* @returnself
Copy link
Member

Choose a reason for hiding this comment

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

self|string

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

fixed

* Returns the parent form.
*
* @returnFormInterface|null The parent form or null if there is none
* @return$this|null The parent form or null if there is none
Copy link
Member

Choose a reason for hiding this comment

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

Should beself|null then

* @param string $name The name of the child to remove
*
* @returnFormInterface The form instance
* @returnself
Copy link
Member

Choose a reason for hiding this comment

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

It's actually$this.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

fixed

* @param Guess[] $guesses An array of guesses
*
* @returnGuess|null The guess with the highest confidence
* @returnstatic|null
Copy link
Member

Choose a reason for hiding this comment

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

Orself|null

* Finds children profilers.
*
* @return Profile[] An array of Profile
* @return Profile[]
Copy link
Member

Choose a reason for hiding this comment

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

self[] ?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

fixed

@fabpot
Copy link
MemberAuthor

@wouterj@ogizanagi@ro0NL Thank you very much for your reviews. I think we're good now.

ogizanagi and xabbuh reacted with hooray emoji

@ro0NL
Copy link
Contributor

@fabpot are you planning to do all branches?

@fabpotfabpot merged commit3c0693d intosymfony:2.7Dec 27, 2016
fabpot added a commit that referenced this pull requestDec 27, 2016
…ant (fabpot)This PR was merged into the 2.7 branch.Discussion----------Fix@return statements to use $this or static when relevant| Q             | A| ------------- | ---| Branch?       | 2.7| Bug fix?      | no| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#20290| License       | MIT| Doc PR        | n/asee#20290Commits-------3c0693d fixed@return when returning this or static
fabpot added a commit that referenced this pull requestDec 29, 2016
This PR was merged into the 2.8 branch.Discussion----------fixed@return when returning this or static| Q             | A| ------------- | ---| Branch?       | 2.8| Bug fix?      | no| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | n/a| License       | MIT| Doc PR        | n/aFollow-up of#21054 for the 2.8 branch.Commits-------7808b67 fixed@return when returning this or static
nicolas-grekas added a commit that referenced this pull requestJan 2, 2017
…terface (wouterj)This PR was merged into the 2.7 branch.Discussion----------Fixed `@return self` with `$this` in FormConfigBuilderInterface| Q             | A| ------------- | ---| Branch?       | 2.7| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | -| License       | MIT| Doc PR        | -Fixes a tiny bug introduced by#21054 . `FormConfigBuilder` methods actually return `$this` and not `self`. This is important, as the `FormBuilder` (extending `FormConfigBuilder`) methods can also be called (e.g. `$builder->setDataMapper(...)->add()` is perfectly possible).Commits-------505e84d Fixed `@return self` with `$this`
@fabpotfabpot deleted the return-stmt branchJanuary 7, 2017 00:34
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@wouterjwouterjwouterj left review comments

+3 more reviewers

@ro0NLro0NLro0NL left review comments

@ogizanagiogizanagiogizanagi left review comments

@SpacePossumSpacePossumSpacePossum left review comments

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

@fabpot@ro0NL@wouterj@ogizanagi@SpacePossum@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp