[wp-trac] [WordPress Trac] #44363: Coding Standards: Assignments must be the first block of code on a line

WordPress Trac noreply at wordpress.org
Thu Jun 14 12:36:20 UTC 2018


#44363: Coding Standards: Assignments must be the first block of code on a line
------------------------------+-----------------------------
 Reporter:  subrataemfluence  |      Owner:  (none)
     Type:  defect (bug)      |     Status:  new
 Priority:  normal            |  Milestone:  Awaiting Review
Component:  Plugins           |    Version:  trunk
 Severity:  normal            |   Keywords:  needs-patch
  Focuses:  coding-standards  |
------------------------------+-----------------------------
 In `wp-admin/admin.php` (line 177) the `$page_hook` was not assigned as
 the first block.

 Rather it is first directly checked against the return value of the
 function `get_plugin_page_hook` and the value is not `null` the function
 has been called again to assign the value to `$page_hook` variable.

 Currently we have:

 {{{#!php
 <?php
 if ( ! $page_hook = get_plugin_page_hook( $plugin_page, $the_parent ) ) {
    $page_hook = get_plugin_page_hook( $plugin_page, $plugin_page );
    ...
 }
 }}}


 Which could be avoided easily if we restructure the code like this:

 {{{#!php
 <?php
 $page_hook = get_plugin_page_hook( $plugin_page, $the_parent );
 if ( null !== $page_hook ) {
  ...
 }
 }}}


 Proposed patch added.

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


More information about the wp-trac mailing list