Edit report at https://bugs.php.net/bug.php?id=60816&edit=1
ID: 60816 Comment by: le...@php.net Reported by: dan dot lugg at gmail dot com Summary: spl_autoload_register fails with __call magic Status: Open Type: Bug Package: SPL related Operating System: Windows 7x64 PHP Version: 5.3.9 Block user comment: N Private report: N New Comment: This works on viper-7: http://viper-7.com/KPlQLa Previous Comments: ------------------------------------------------------------------------ [2012-01-20 06:22:38] dan dot lugg at gmail dot com Description: ------------ When registering a callback object/method pair to spl_autoload_register(), if the method is not defined, though the object class has defined __call() magic, the method will not be called during an autoload attempt. In a larger project, I found that the PHP executable was crashing out altogether, appending no output to the logs, and offering minimal information. When I isolated what I suspected to be the problem, it was in fact the spl_autoload_register()/__call() combination. In isolation, it did not crash out spectacularly as in my project, however it still failed. While I marked this 5.3.9, these failures have been observed on 5.3.8, 5.3.9, and 5.4.0.RC3. While this is a bit of an edge case, I doubt that this is expected or acceptable behaviour, and have not been able to find mention of this elsewhere. Test script: --------------- <?php class Loader { public function __call($name, $arguments) { var_dump(get_defined_vars()); } } spl_autoload_register(array(new Loader(), 'load_class')); $foo = new Bar(); Expected result: ---------------- array(2) { ["name"]=> string(10) "load_class" ["arguments"]=> array(1) { [0]=> string(3) "Bar" } } Fatal error: Class 'Bar' not found in - on line 12 Actual result: -------------- Fatal error: Class 'Bar' not found in - on line 12 As you can see, while this test script made no attempt to actually load the class, it should at least be dumping the array before failing, as in the expected output. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=60816&edit=1