Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.3.2

Request #17568 loadClass()
Submitted: 2010-07-06 22:52 UTC
From: vipsoft Assigned:
Status: Wont fix Package: HTML_QuickForm2 (version SVN)
PHP Version: 5.3.2 OS: Ubuntu 10.04
Roadmaps: (Not assigned)    
Subscription  


 [2010-07-06 22:52 UTC] vipsoft (Anthon Pang)
Description: ------------ Wherever we have: HTML_QuickForm2_Loader::loadClass(...); change to: if (!class_exists($class)) { HTML_QuickForm2_Loader::loadClass(...); } By not specifying the second parameter (i.e., false), any registered autoloaders (including HTML_QuickForm_Loader::autoload) will have first crack at loading the class.

Comments

 [2010-07-07 13:29 UTC] avb (Alexey Borzov)
-Status: Open +Status: Wont fix
I don't see any benefit here as a) loadClass() immediately calls class_exists() itself so the only overhead is the method call; b) the provided autoload implementation uses the same loadClass() Please bear in mind that PEAR1 isn't exactly designed for autoload.
 [2010-07-07 16:41 UTC] vipsoft (Anthon Pang)
I hope you'll reconsider. The difference is the absence of the second parameter (false). Our app implements its own autoloader that follows the PEAR naming convention, but doesn't rely on the include_path. By calling class_exists() without the second parameter (false), our autoloader is called. p.s. this idiom is seen throughout ZendFramework, so this isn't a novel idea, i.e., if (!class_exists($className)) { Zend_Loader::loadClass($className); }