From:             
Operating system: Debian
PHP version:      5.3.10
Package:          Class/Object related
Bug Type:         Bug
Bug description:is_subclass_of(string, string, false) always returns false

Description:
------------
According to the documentation (
http://php.net/manual/en/function.is-subclass-of.php ) the third parameter
of is_subclass_of decides "Whether to call autoloader if the class doesn't
exist." 

That means that is_subclass_of('class1', 'class2', false) should
- return true if class1 is loaded and a subclass of class2
- return false if class1 is loaded but not a subclass of class2
- return false if class1 is not loaded

What actually happens is that it always returns false, no matter what. The
naming of the parameter - "$allow_string" - suggests this is somewhat
intentional, but it is a completely unintuitive and unhelpful behavior,
which makes the option completely useless: is_subclass_of with
$allow_string set to false becomes worthless if the first argument is a
string, and if it is an object, the third parameter is pointless again as
the class must have been loaded already.

Test script:
---------------
class Super {}
class Sub extends Super {}

var_dump(is_subclass_of('Sub', 'Super')); // true

var_dump(is_subclass_of('Sub', 'Super'), false); // should be true but
false



-- 
Edit bug report at https://bugs.php.net/bug.php?id=61526&edit=1
-- 
Try a snapshot (PHP 5.4):            
https://bugs.php.net/fix.php?id=61526&r=trysnapshot54
Try a snapshot (PHP 5.3):            
https://bugs.php.net/fix.php?id=61526&r=trysnapshot53
Try a snapshot (trunk):              
https://bugs.php.net/fix.php?id=61526&r=trysnapshottrunk
Fixed in SVN:                        
https://bugs.php.net/fix.php?id=61526&r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=61526&r=needdocs
Fixed in release:                    
https://bugs.php.net/fix.php?id=61526&r=alreadyfixed
Need backtrace:                      
https://bugs.php.net/fix.php?id=61526&r=needtrace
Need Reproduce Script:               
https://bugs.php.net/fix.php?id=61526&r=needscript
Try newer version:                   
https://bugs.php.net/fix.php?id=61526&r=oldversion
Not developer issue:                 
https://bugs.php.net/fix.php?id=61526&r=support
Expected behavior:                   
https://bugs.php.net/fix.php?id=61526&r=notwrong
Not enough info:                     
https://bugs.php.net/fix.php?id=61526&r=notenoughinfo
Submitted twice:                     
https://bugs.php.net/fix.php?id=61526&r=submittedtwice
register_globals:                    
https://bugs.php.net/fix.php?id=61526&r=globals
PHP 4 support discontinued:          
https://bugs.php.net/fix.php?id=61526&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=61526&r=dst
IIS Stability:                       
https://bugs.php.net/fix.php?id=61526&r=isapi
Install GNU Sed:                     
https://bugs.php.net/fix.php?id=61526&r=gnused
Floating point limitations:          
https://bugs.php.net/fix.php?id=61526&r=float
No Zend Extensions:                  
https://bugs.php.net/fix.php?id=61526&r=nozend
MySQL Configuration Error:           
https://bugs.php.net/fix.php?id=61526&r=mysqlcfg

Reply via email to