[wp-trac] [WordPress Trac] #44227: Inconsistency in Yoda condition check in WordPress core
WordPress Trac
noreply at wordpress.org
Fri May 25 13:31:43 UTC 2018
#44227: Inconsistency in Yoda condition check in WordPress core
------------------------------+-----------------------------
Reporter: subrataemfluence | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: trunk
Severity: normal | Keywords: 2nd-opinion
Focuses: coding-standards |
------------------------------+-----------------------------
According to @pento in #42885
> Ultimately, the aim is to have phpcs run on every commit. If we don't
allow assignments in conditions, then the reason for Yoda conditions
(avoiding accidental assignment in conditions) should no longer be
necessary.
@jdgrimes says in the same ticket
> 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.
However, we have a good amount of Yoda condition applied already. Here is
an example:
{{{#!php
<?php
if ( '.' !== $plugin_slug && false === strpos( $plugin_slug, '/' ) ) {
...
}
}}}
at line number 98 of `wp-admin/includes/plugin.php`.
I think the coding style and pattern should be consistent across the whole
application. Otherwise, it will lead to even more confusion if both exist
side by side.
Please correct me if I am wrong.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/44227>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list