ID: 44021 Updated by: [EMAIL PROTECTED] Reported By: rpanning at hotmail dot com -Status: Open +Status: Feedback Bug Type: Class/Object related Operating System: Windows XP SP2 PHP Version: 5.3CVS-2008-02-02 (snap) New Comment:
<?php namespace NS; class ParentClass {} class ChildClass extends ParentClass {} if (is_subclass_of('NS::ChildClass', 'NS::ParentClass')) { print 'Yes'; } else { print 'No'; } ?> Does the above code work for you? If yes, please close this bug as bogus. Automatic prefixing only occurs with absolute classnames, not compiled variables. Imagine, for instance this code: <?php namespace Foo; function testsit($cl) { return is_subclass_of($cl, 'ParentClass'); } ?> Now, if one calls this code from this file: <?php namespace Blah; var_dump(testsit('ChildClass')); ?> should it look for Blah::ChildClass, Foo::ChildClass, or ::ChildClass? There is no deterministic way to answer this question. Therefore fully qualified classnames must be used for anything that isn't a T_STRING. Previous Comments: ------------------------------------------------------------------------ [2008-02-02 02:01:37] rpanning at hotmail dot com Description: ------------ The is_subclass_of() function does not accept classes in namespaces. A warning is generated and the statement results as FALSE. Also, in the example, if the namespace definition is removed it works. Reproduce code: --------------- namespace NS; class ParentClass {} class ChildClass extends ParentClass {} if (is_subclass_of('ChildClass', 'ParentClass')) { print 'Yes'; } else { print 'No'; } Expected result: ---------------- Yes Actual result: -------------- Warning: Unknown class passed as parameter in C:\test.php on line 7 No ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=44021&edit=1