[wp-meta] [Making WordPress.org] #5429: PHP Coding Standards - Yoda Conditionals - Absolute Phrasing
Making WordPress.org
noreply at wordpress.org
Wed Sep 9 16:57:25 UTC 2020
#5429: PHP Coding Standards - Yoda Conditionals - Absolute Phrasing
---------------------------+--------------------
Reporter: sabernhardt | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone:
Component: Developer Hub | Keywords:
---------------------------+--------------------
originally reported by @theistand on
https://core.trac.wordpress.org/ticket/50276
> In the PHP coding standards page under the Yoda Conditionals it is
stated
> "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."
> The concern being the use of the word "always" because at the bottom it
is then stated "Yoda conditions for <, >, <=, or >= are significantly more
difficult to read and are best avoided."
>
> The issue with this is that <, >, <=, >= are in fact conditional
operators and should apply to your standards with logical comparison. The
emphasis "are significantly more difficult to read" implies that the
decisions are on readability, however the entire purpose for the Yoda
Conditionals has nothing to do with readability as it is the most
illogical and unreadable implementation. The use of Yoda Conditionals
should only be for ease in debugging.
> Also quoting "Computer Science Terms" l-values stands for left-values
and r-values stands for right-values. This is a logical approach and is a
industry standard across the board which is the exact opposite as your
call for use of Yoda Conditionals.
>
> No argument on using them only pointing out some areas that can cause
substantial confusion to newbies coming into the wordpress world.
[https://developer.wordpress.org/coding-standards/wordpress-coding-
standards/php/#yoda-conditions PHP Coding Standards DevHub page]
--
Ticket URL: <https://meta.trac.wordpress.org/ticket/5429>
Making WordPress.org <https://meta.trac.wordpress.org/>
Making WordPress.org
More information about the wp-meta
mailing list