[wp-trac] [WordPress Trac] #42887: variable assignment in if statement

WordPress Trac noreply at wordpress.org
Tue Dec 19 00:09:27 UTC 2017


#42887: variable assignment in if statement
--------------------------+-------------------------------
 Reporter:  freetheweb    |       Owner:
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:
Component:  Widgets       |     Version:  4.9.1
 Severity:  normal        |  Resolution:  invalid
 Keywords:                |     Focuses:  coding-standards
--------------------------+-------------------------------
Changes (by dd32):

 * status:  new => closed
 * focuses:   => coding-standards
 * resolution:   => invalid
 * milestone:  Awaiting Review =>


Comment:

 Hi @freetheweb,

 Yes, this is intended, and is a supported PHP construct.
 The `if(  )` statement operates on the resulting variable `$form` and so
 this could be written simply as:
 {{{
 $form = $wp_registered_widget_controls[ $widget_id ];
 if ( $form ) {
    call_user_func_array( $form['callback'], $form['params'] );
 }
 }}}

 I'm going to close this as invalid, as there isn't any bug here, however
 will note that this may be changed with the ongoing coding-standards work,
 if this doesn't fit a decided coding standard, it'll be automatically
 updated as that process goes on.

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


More information about the wp-trac mailing list