Skip to content

Fix annotations code style issues for entities #408

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

Closed
wants to merge 2 commits into from

Conversation

voronkovich
Copy link
Contributor

No description provided.

@@ -95,7 +95,7 @@ class Post
* mappedBy="post",
* orphanRemoval=true
* )
* @ORM\OrderBy({"publishedAt" = "DESC"})
* @ORM\OrderBy({"publishedAt": "DESC"})
Copy link
Member

Choose a reason for hiding this comment

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

Are we sure about this change? In http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/tutorials/ordered-associations.html they use "publishedAt" = "DESC"

Copy link
Contributor

@bocharsky-bw bocharsky-bw Dec 14, 2016

Choose a reason for hiding this comment

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

Good spot! I think : is more native since it looks like a JSON object here, so I like : more. But if both works, I'd rather send a PR to Doctrine docs to use : instead of = and see what they'll say :)

Copy link
Member

Choose a reason for hiding this comment

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

recent versions of doctrine/annotations allow both = and : as delimiter between the array key and value. Old versions were allowing only =, which is why the ORM doc uses it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@frastel frastel Dec 14, 2016

Choose a reason for hiding this comment

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

The new syntax could confuse Newbies while they are writing their first Symfony app. The annotations from the framework bundle are still using = and the devs might wonder, why the annotations in this case look complete different. They might not recognize the difference of the two separate projects.

Copy link
Member

Choose a reason for hiding this comment

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

I'm sorry. I wasn't aware of this Doctrine feature and I thought this was a bug. Let's keep it then.

Copy link
Member

Choose a reason for hiding this comment

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

@frastel FrameworkBundle does not have annotations. It uses doctrine/annotations.

The difference you see corresponds to 2 different features of the annotation syntax.
Putting a value in a property of the annotation and writing an associative array in a value are already 2 different things.
what could confuse you is that the property name is omitted here (thanks to a feature allowing to do it in some cases). The complete syntax is @ORM\OrderBy(value={"publishedAt": "DESC"})

Copy link
Contributor

Choose a reason for hiding this comment

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

@stof You are totally right! I think I didn't finished my thoughts :D. After thinking 3 times about the fact I think : is much cleaner.
I never thought about that the shortcut syntax misses value= actually.

And yeah, I meant the FrameworkExtraBundle, not the FrameworkBundle.

@javiereguiluz
Copy link
Member

Thanks @voronkovich.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants