[wp-trac] [WordPress Trac] #44365: Coding Standards: Yoda condition check is not present

WordPress Trac noreply at wordpress.org
Thu Jun 14 13:08:42 UTC 2018


#44365: Coding Standards: Yoda condition check is not present
------------------------------+-----------------------------
 Reporter:  subrataemfluence  |      Owner:  (none)
     Type:  enhancement       |     Status:  new
 Priority:  normal            |  Milestone:  Awaiting Review
Component:  General           |    Version:  trunk
 Severity:  normal            |   Keywords:  2nd-opinion
  Focuses:  coding-standards  |
------------------------------+-----------------------------
 In wp-admin/admin.php between line nos. 358 and 372, Yoda conditions are
 not met according to the sniffer.

 Here is the code we have now:

 {{{#!php
 <?php
 if ( $typenow == 'page' ) {
    if ( $pagenow == 'post-new.php' ) {
      do_action( 'load-page-new.php' );
    } elseif ( $pagenow == 'post.php' ) {
      do_action( 'load-page.php' );
    }
 } elseif ( $pagenow == 'edit-tags.php' ) {
    if ( $taxnow == 'category' ) {
      do_action( 'load-categories.php' );
    } elseif ( $taxnow == 'link_category' ) {
      do_action( 'load-edit-link-categories.php' );
    }
 } elseif ( 'term.php' === $pagenow ) {
    do_action( 'load-edit-tags.php' );
 }
 }}}


 One thing to notice at the end of the above code block. We have a Yoda
 condition checked. I am not sure why it used only at one place. Is this
 done in purpose?

 {{{#!php
 <?php
 ...
 } elseif ( 'term.php' === $pagenow ) {
    do_action( 'load-edit-tags.php' );
 }
 }}}


 Can we re-write the block of code and make it consistent as proposed in my
 patch?

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/44365>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list