[wp-trac] [WordPress Trac] #10861: Clean up constructors and destructors

WordPress Trac wp-trac at lists.automattic.com
Sun Sep 27 02:48:40 UTC 2009


#10861: Clean up constructors and destructors
--------------------------+-------------------------------------------------
 Reporter:  hakre         |       Owner:       
     Type:  defect (bug)  |      Status:  new  
 Priority:  normal        |   Milestone:  2.9  
Component:  General       |     Version:  2.8.4
 Severity:  normal        |    Keywords:       
--------------------------+-------------------------------------------------

Comment(by filosofo):

 Replying to [comment:11 jacobsantos]:
 > Replying to [comment:10 dd32]:
 > > I think that code is to call the child classes that extend it perhaps?
 (Not sure its needed though.. Just checking)
 > That doesn't exactly make sense. The child classes can define their own
 arguments. Actually, the entire WP_Dependencies violates proper object-
 oriented practices, so it makes sense it would be ass backward. I think it
 tries too hard to be a Iterator, except without PHP5, it fails in its
 attempt.

 {{{call_user_func_array( array(&$this, '__construct'), $args );}}}

 is a hack to keep from having to specify the parent class as the
 constructor in PHP 4.

 WP_Scripts is the child of WP_Dependencies.  If WP_Scripts used the PHP 4
 class-name constructor, WP_Scripts, it would have to call the PHP 4 parent
 constructor explicitly, like so: {{{parent::WP_Dependencies($args);}}},
 and then you have maintenance issues.

 Instead, the hack omits the PHP 4 child class-name constructors, so when
 WP_Scripts is instantiated, PHP 4 calls {{{WP_Dependencies()}}} as its
 constructor, which in turn calls the child {{{__construct()}}}
 constructors.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/10861#comment:12>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list