-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
remove Yoda condition #5381
Conversation
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 `<=`.
@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. |
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. |
@stof : this PR removes the yodaism, not the other way around.
Does "here" mean before or after the P.R. ? It feels like you mean before… |
I mean the change is fine here (i.e. in this kind of code snippet). Sorry for being unclear. My vote is a 👍 |
No problem, thanks for your support! |
👍 Fine for me. |
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! |
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
Haha thanks for merging, there was no hurry though :) |
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<=
.