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

remove Yoda condition #5381

Merged
merged 1 commit into from
Jun 27, 2015
Merged

remove Yoda condition #5381

merged 1 commit into from
Jun 27, 2015

Conversation

greg0ire
Copy link
Contributor

Yoda conditions : a questionable best practice that makes code less error-prone, but also harder to read for people that don't share the same grammar rules as people from Dagobah. Anyway, they are useful when you want to avoid confusing assignment and equality operators, but I doubt people often write = while meaning to write <=.

Yoda conditions : a questionable best practice that makes code less error-prone, but also harder to read for people that don't share the same grammar rules as on Dagobah. Anyway, they are useful when you want to avoid confusing assignment and equality operators, but I doubt people often write `=` while meaning to write `<=`.
@javiereguiluz
Copy link
Member

@greg0ire as you may know, the source code of Symfony uses this style of coding. However, in this particular case, I totally agree with you. The non-Yoda conditional is much easier to understand. Let's see what others think about this.

@stof
Copy link
Member

stof commented Jun 11, 2015

This is perfectly fine here. This is comparing a constant and the return value of a method call, so the Yoda condition does not add benefit here.
The benefit applies only when one side of the comparison is a variable (which should then be on the right). We don't apply it in the source code in other cases than that (we don't enforce it at least. There might still be occurences)

@greg0ire
Copy link
Contributor Author

@stof : this PR removes the yodaism, not the other way around.

This is perfectly fine here

Does "here" mean before or after the P.R. ? It feels like you mean before…

@stof
Copy link
Member

stof commented Jun 11, 2015

I mean the change is fine here (i.e. in this kind of code snippet). Sorry for being unclear. My vote is a 👍

@greg0ire
Copy link
Contributor Author

No problem, thanks for your support!

@xabbuh
Copy link
Member

xabbuh commented Jun 11, 2015

👍 Fine for me.

@wouterj
Copy link
Member

wouterj commented Jun 27, 2015

I love this PR. It was created, reviewed and accepted within one day. It's a shame it took us 16 days to merge... Thanks Grégoire!

@wouterj wouterj merged commit 9dcac5a into symfony:2.3 Jun 27, 2015
wouterj added a commit that referenced this pull request Jun 27, 2015
This PR was merged into the 2.3 branch.

Discussion
----------

remove Yoda condition

Yoda conditions : a questionable best practice that makes code less error-prone, but also harder to read for people that don't share the same grammar rules as people from Dagobah. Anyway, they are useful when you want to avoid confusing assignment and equality operators, but I doubt people often write `=` while meaning to write `<=`.

Commits
-------

9dcac5a remove Yoda condition
@greg0ire greg0ire deleted the patch-8 branch June 27, 2015 13:47
@greg0ire
Copy link
Contributor Author

Haha thanks for merging, there was no hurry though :)

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