[wp-trac] [WordPress Trac] #37699: Death to Globals Episode #1: A Registry, A Pattern

WordPress Trac noreply at wordpress.org
Thu Aug 18 18:27:27 UTC 2016


#37699: Death to Globals Episode #1: A Registry, A Pattern
----------------------------+------------------
 Reporter:  wonderboymusic  |       Owner:
     Type:  enhancement     |      Status:  new
 Priority:  normal          |   Milestone:  4.7
Component:  General         |     Version:
 Severity:  normal          |  Resolution:
 Keywords:                  |     Focuses:
----------------------------+------------------

Comment (by ChriCo):

 Replying to [comment:17 charliespider]:
 > Replying to [comment:15 wonderboymusic]:

 > why not:
 >
 > {{{#!php
 > <?php
 > // src/wp-includes/class-wp-comment-query.php
 >     public function __construct( $query = '', wpdb $wpdb = null ) {
 >         this->db = $wpdb instanceof wpdb ? $wpdb : $GLOBALS['wpdb'];
 > }}}

 this was already pointed out by @schlessera . Also you should not add the
 {{{wpdb}}}-class type-hint. Instead you should implement an interface and
 use this for Type Hinting (see above why) ...

 But yes, the {{{$wpdb = NULL}}} should be added to the constructor.

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


More information about the wp-trac mailing list