spl_autoload_register with 2 instances of the same class
| Bug #40091 | spl_autoload_register with 2 instances of the same class | ||||
|---|---|---|---|---|---|
| Submitted: | 2007-01-10 15:20 UTC | Modified: | 2007-01-10 18:14 UTC | ||
| From: | dweller at devonweller dot com | Assigned: | |||
| Status: | Closed | Package: | SPL related | ||
| PHP Version: | 5.2.0 | OS: | Mac OS X | ||
| Private report: | No | CVE-ID: | None | ||
[2007-01-10 15:20 UTC] dweller at devonweller dot com
Description:
------------
When using spl_autoload_register with two instances of the same class name, the autoload stack only stores one function callback instead of two.
Reproduce code:
---------------
class MyAutoloader {
function __construct($directory_to_use) {}
function autoload($class_name) {
// code to autoload based on directory
}
}
$autloader1 = new MyAutoloader('dir1');
spl_autoload_register(array($autloader1, 'autoload'));
$autloader2 = new MyAutoloader('dir2');
spl_autoload_register(array($autloader2, 'autoload'));
print_r(spl_autoload_functions());
Expected result:
----------------
Array
(
[0] => Array
(
[0] => MyAutoloader
[1] => autoload
)
[1] => Array
(
[0] => MyAutoloader
[1] => autoload
)
)
Actual result:
--------------
Array
(
[0] => Array
(
[0] => MyAutoloader
[1] => autoload
)
)
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits