From:             byoung2 at gmail dot com
Operating system: Windows or Linux
PHP version:      5.4.16
Package:          SPL related
Bug Type:         Bug
Bug description:spl_autoload_register fails with multiple callables using self, 
same method

Description:
------------
spl_autoload_register should properly resolve 'self' to the current
execution scope, which it does for the 'first' class, but it does not for
the 'second' class.  Only the first autoload is registered.  If I change
the method name in the 'second' class to 'load2' for example, and register
array('self','load2') using spl_autoload_register, it works. It also works
if I replace 'self' with __CLASS__, which I have done as a workaround.
Using 'static' instead of 'self' has the same bug, but __CLASS__ won't work
in this case if you want late static binding.   

Test script:
---------------
<?php 
first::init();
second::init();
print_r(spl_autoload_functions());
class first
{
        public static function init() {
                spl_autoload_register(array('self','load'));
        }       
        public static function load($class) {}
}

class second
{
        public static function init() {
                spl_autoload_register(array('self','load'));
        }       
        public static function load($class){}
}

Expected result:
----------------
Array
(
    [0] => Array
        (
            [0] => first
            [1] => load
        )

    [1] => Array
        (
            [0] => second
            [1] => load
        )

)


Actual result:
--------------
Array
(
    [0] => Array
        (
            [0] => first
            [1] => load
        )

)


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

Reply via email to