[wp-trac] [WordPress Trac] #46846: Tight comparisons and use of Yoda conditions are not consistent

WordPress Trac noreply at wordpress.org
Wed Oct 22 22:54:24 UTC 2025


#46846: Tight comparisons and use of Yoda conditions are not consistent
------------------------------------+-------------------------------
 Reporter:  subrataemfluence        |       Owner:  SergeyBiryukov
     Type:  defect (bug)            |      Status:  reviewing
 Priority:  normal                  |   Milestone:  6.9
Component:  Formatting              |     Version:
 Severity:  normal                  |  Resolution:
 Keywords:  has-patch dev-feedback  |     Focuses:  coding-standards
------------------------------------+-------------------------------
Changes (by SergeyBiryukov):

 * owner:  (none) => SergeyBiryukov
 * status:  reopened => reviewing


Comment:

 Replying to [comment:2 sabernhardt]:
 > I'll upload a patch editing those 8 lines, in case it is worth reopening
 the ticket for any of them.

 Thanks for the patch!

 Looking at the [https://developer.wordpress.org/coding-standards
 /wordpress-coding-standards/php/#yoda-conditions PHP coding standards],
 Yoda conditions are mostly relevant for variables:
 > When doing logical comparisons involving variables, always put the
 variable on the right side and put constants, literals, or function calls
 on the left side. ''If neither side is a variable, the order is not
 important.''

 So technically, I'm not sure this needs any changes. However, if the goal
 is to make the order more consistent throughout the file, I have no
 objections to that :)

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


More information about the wp-trac mailing list