[wp-trac] [WordPress Trac] #42885: Fix PHPCS "Yoda Condition checks" for root files of WordPress Core.

WordPress Trac noreply at wordpress.org
Wed Dec 13 13:13:54 UTC 2017


#42885: Fix PHPCS "Yoda Condition checks" for root files of WordPress Core.
------------------------------+-------------------------------
 Reporter:  chetan200891      |       Owner:
     Type:  defect (bug)      |      Status:  new
 Priority:  normal            |   Milestone:  5.0
Component:  General           |     Version:
 Severity:  normal            |  Resolution:
 Keywords:  has-patch commit  |     Focuses:  coding-standards
------------------------------+-------------------------------

Comment (by jdgrimes):

 Before committing this, maybe a good time to reconsider this rule? Now
 that we can run PHPCS over the code, we could just disallow assignments in
 conditions, and then Yoda conditions wouldn't really be necessary. As I
 understand it, the main reason for the Yoda conditions rule is to avoid
 accidentally using an assignment in a condition when a comparison was
 intended. Disallowing assignments in conditions would make that impossible
 to begin with.

 I know that some developers find Yoda conditions more difficult to grok
 than others. @jrf has brought this up before, for example. I don't have a
 strong opinion either way, but I thought it was worth mentioning. The
 rule, a bit antiquated, seems.

 Perhaps this should really be discussed elsewhere though. I'll bring it up
 in Slack.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/42885#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list