Edit report at https://bugs.php.net/bug.php?id=60955&edit=1
ID: 60955 Comment by: john dot papaioannou at gmail dot com Reported by: frederic dot hardy at mageekbox dot net Summary: spl_autoload_register() accept a protected method Status: Open Type: Bug Package: SPL related Operating System: Linux PHP Version: 5.3.9 Block user comment: N Private report: N New Comment: Protected methods have been valid as callbacks *if the callback is provided from a scope where the protected method is visible* for quite some time, and this certainly feels "natural". Why should this not work? It should also be noted that the line that errors out is the body of the last foreach, which attempts to use the protected method as a callback without being in a scope where the method would be visible. Previous Comments: ------------------------------------------------------------------------ [2012-02-05 14:15:55] frederic dot hardy at mageekbox dot net All my apologize, my bug report is not very clear. My problem is that the error message is throwed only if spl_autoload_register() was called outsite a class. A call to autoloader::register() does not throw any error message, even if autoloader::requireClass(), a protected method, is used. ------------------------------------------------------------------------ [2012-02-04 16:06:14] php-dev at zerocue dot com This report is requesting a change in the error output? It already doesn't allow the protected member to be registered as your actual result indicates, it throws an error. What is this report about? ------------------------------------------------------------------------ [2012-02-02 14:02:59] frederic dot hardy at mageekbox dot net Description: ------------ It's possible to register a protected method as an autoloader callback with the function spl_autoload_register(). Test script: --------------- <?php class autoloader { function register() { spl_autoload_register(array($this, 'requireClass')); } protected function requireClass() {} } $autoloader = new autoloader(); $autoloader->register(); $autoloadFunctions = spl_autoload_functions(); foreach ($autoloadFunctions as $autoloadFunction) { spl_autoload_unregister($autoloadFunction); } foreach ($autoloadFunctions as $autoloadFunction) { spl_autoload_register($autoloadFunction); } Expected result: ---------------- Cannot register the protected method autoload::requireClass() as a callback Actual result: -------------- Passed array does not specify a callable method (cannot access protected method autoloader::requireClass()) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=60955&edit=1