Navigation Menu

Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add annotation with proper types for entity properties #394

Closed
wants to merge 3 commits into from

Conversation

bocharsky-bw
Copy link
Contributor

@bocharsky-bw bocharsky-bw commented Nov 2, 2016

The most IDEs start showing returned types on getter calls after these changes.

@bocharsky-bw
Copy link
Contributor Author

I also wonder about using @var annotation for setters and @return one for getters in Symfony Demo. What do you think about adding it?

@javiereguiluz
Copy link
Member

If we add the @var for properties, I guess it makes sense it add it to getters/setters too.

@@ -22,56 +22,74 @@
class Post
{
/**
* @var int
Copy link
Member

Choose a reason for hiding this comment

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

useless for constants. The IDE already reads the value anyway. A constant is not a variable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted.
Thanks, Christophe!

@xabbuh
Copy link
Member

xabbuh commented Nov 4, 2016

When the properties are annotated, you shouldn't have to repeat the type for the returned values of the getter methods as IDEs are able to infer the return types then.

public function getPublishedAt()
{
return $this->publishedAt;
}

/**
* @param \DateTime $publishedAt
Copy link
Member

Choose a reason for hiding this comment

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

not needed as the type hint already provides this information

@bocharsky-bw
Copy link
Contributor Author

@xabbuh Do you suggest to fully revert commit about annotations for setters / getters?

@xabbuh
Copy link
Member

xabbuh commented Nov 5, 2016

@bocharsky-bw For setters where we do not have type hints (i.e. scalar type arguments) we should keep them.

@javiereguiluz
Copy link
Member

@bocharsky-bw thanks for proposing this improvement. I love it when we make our code more consistent and IDE-friendly. Thanks!

@bocharsky-bw bocharsky-bw deleted the properties-types branch November 10, 2016 19:54
javiereguiluz added a commit that referenced this pull request Apr 21, 2017
…ency pov" (bocharsky-bw)

This PR was merged into the master branch.

Discussion
----------

Revert "Updated the DocBlocks of the Entities from consistency pov"

This reverts #527

The reasons were described earlier in #394

Commits
-------

88d2100 Revert "Updated the DocBlocks of the Entities from consistency point of view."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants