[wp-trac] [WordPress Trac] #10264: use instanceof instead of is_a()

WordPress Trac wp-trac at lists.automattic.com
Fri Jul 31 21:16:28 UTC 2009


#10264: use instanceof instead of is_a()
-------------------------+--------------------------------------------------
 Reporter:  Mittineague  |       Owner:                         
     Type:  enhancement  |      Status:  assigned               
 Priority:  low          |   Milestone:  Future Release         
Component:  Performance  |     Version:  2.8                    
 Severity:  normal       |    Keywords:  needs-patch 2nd-opinion
-------------------------+--------------------------------------------------

Comment(by Mittineague):

 I must admit this turns out to be more complex than I first imagined.
 There is PHP version support. The instanceof operator requires PHP 5+, but
 using version_compare() slows things down considerably. Both instanceof
 and is_subclass_of() have the potential for autoload induced fatal errors
 and neccessitate a work-around (easy enough I guess, but just the same).
 Using a work-around, get_class() and is_subclass_of() works in PHP 4,5 and
 is a bit faster than is_a() but makes the conditional less readable.

 So it comes down to a question of a slight improvement in performance vs.
 code readability. And all this for an E_STRICT error that in ways isn't
 even a "real" error.

 The decision is yours of course, but I think if it was up to me I'd
 probably wait until WordPress no longer supports PHP 4 and then use the
 instanceof operator with the work-around.

 Thanks for your time and indulgence.

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


More information about the wp-trac mailing list