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

Bug #872 PEAR QA: improvement for get_class()-usage
Submitted: 2004-02-26 13:46 UTC
From: pear-qa at lists dot php dot net Assigned: avb
Status: Closed Package: HTML_QuickForm
PHP Version: Irrelevant OS:
Roadmaps: (Not assigned)    

 [2004-02-26 13:46 UTC] pear-qa at lists dot php dot net
Description: ------------ ## from the PEAR QA team ## ## quality-assurance related ## Please note that if you don't react to this issue within 4 weeks the PEAR QA-team will take care of it automatically. This is not "rude" but necessary for QA. If this is a "false positive" and your package is not affected please apologize. This package uses get_class()-calls without care for case-sensitivity of the returned classnames. In PHP 4.x the default for getclass() was that lowercase classnames were returned. However, due to extended DOM functionality, PHP 5.x returns classnames with correct upper-and-lowercase. If you intend to run your package under both PHP4 and PHP5 please consider using case-independent comparisons or apply case-fixes. Found in: FILE: '/cvs/php/pear/HTML_QuickForm/QuickForm.php' : /cvs/php/pear/HTML_QuickForm/QuickForm.php(1187): $ruleName = !empty($name->name)? $name->name: get_class($name); /cvs/php/pear/HTML_QuickForm/QuickForm.php(1721): return (is_object($value) && (get_class($value) == 'html_quickform_error' || is_subclass_of($value, 'html_quickform_error'))); ---------------------------------------- FILE: '/cvs/php/pear/HTML_QuickForm/QuickForm/element.php' : /cvs/php/pear/HTML_QuickForm/QuickForm/element.php(332): $className = get_class($this); ---------------------------------------- FILE: '/cvs/php/pear/HTML_QuickForm/QuickForm/file.php' : /cvs/php/pear/HTML_QuickForm/QuickForm/file.php(179): $className = get_class($this); ---------------------------------------- FILE: '/cvs/php/pear/HTML_QuickForm/QuickForm/RuleRegistry.php' : /cvs/php/pear/HTML_QuickForm/QuickForm/RuleRegistry.php(94): $this->_rules[get_class($data1)] = $data1; /cvs/php/pear/HTML_QuickForm/QuickForm/RuleRegistry.php(95): $GLOBALS['_HTML_QuickForm_registered_rules'][$ruleName] = array(get_class($data1), null); ---------------------------------------- FILE: '/cvs/php/pear/HTML_QuickForm/QuickForm/select.php' : /cvs/php/pear/HTML_QuickForm/QuickForm/select.php(360): if (!is_object($result) || (get_class($result) != "db_result" && /cvs/php/pear/HTML_QuickForm/QuickForm/select.php(447): case (get_class($options) == "db_result" || is_subclass_of($options, "db_result")): Reproduce code: --------------- Affected are constructs like: if (get_class($foo) == 'foo') { ... } Possible solutions for correct class-checks: strtolower(get_class($foo)) == 'foo' is_a($foo, 'foo') !strcasecmp(get_class($foo), 'foo')


 [2004-02-27 21:53 UTC] avb
The ones from element.php and file.php look harmless. Checks like get_class($value) == 'foo' || is_subclass_of($value, 'foo') should really use is_a(). The ones related to rule registering require closer review.
 [2004-02-28 15:40 UTC] avb
Fixed in CVS