Replies: 5 comments 8 replies
-
I find both Yoda and non-Yoda easy to read but I would definitely rather we go with one or the other. I definitely do not want violence 😅 |
Beta Was this translation helpful? Give feedback.
-
I've never been a fan of Yoda-conditionals and don't think I've ever hid that fact. Though it's not the end of the world it almost feels non-standard in comparison to projects outside of WordPress, and not to mention as a dyslexic it's annoying to read. And I know it's not part of the question but thanks for putting this down as a breaking change, that will prevent a lot of headaches. |
Beta Was this translation helpful? Give feedback.
-
I choose violence 🤣 On serious note I think we should remove Yoga and enforce non-yoga going forward. I would be happy allowing both but its best being strict and if theres issue at project level they can remove the rule. |
Beta Was this translation helpful? Give feedback.
-
I personally don't like yoda conditionals, i never have. They're a PITA and non standard from the rest of the PHP world. I find my self frequently having to still switch them round as logically in my mind i am checking if the variable is equal to a value not the other way around. Plus it would bring more consistency between JS and PHP |
Beta Was this translation helpful? Give feedback.
-
I chose option 4, which avoids introducing a breaking change and protects against any actual issues. Beyond that it's a minor formatting preference IMO and not worth enforcing. I'd change my mind if it was an a11y issue but haven't seen any non-anecdotal evidence of this. Either way, I'd say the direction WordPress take is going to have the biggest impact on what we do in turn since it will probably make the most sense to follow suit. |
Beta Was this translation helpful? Give feedback.
-
WPCS are proposing to remove the enforcement of Yoda conditionals in WPCS v3.0.0, potentially with a goal of disallowing Yoda conditionals in WPCS v4.0.0, including changing all occurrences in WP Core.
WordPress/WordPress-Coding-Standards#1624
https://make.wordpress.org/core/2022/06/14/upcoming-disallow-assignments-in-conditions-and-remove-the-yoda-condition-requirement-for-php/
If they go ahead with removing Yoda conditionals, should we follow suit?
Further, should we simply remove the requirement, or enforce non-yoda?
Edit (clarification): If we did make this change, we would release a new major version of our PHPCS config; this would allow existing projects to choose to remain as they are, or to adopt the change at their own pace. Releasing as a new major version will prevent composer/CI from pulling in something which could cause build failures.
14 votes ·
Beta Was this translation helpful? Give feedback.
All reactions