Edit report at http://bugs.php.net/bug.php?id=52464&edit=1
ID: 52464 Updated by: johan...@php.net Reported by: delphists at apollo dot lv Summary: spl_autoload_register() can use protected/private methods if called from class -Status: Open +Status: Bogus Type: Bug Package: SPL related Operating System: Windows 7, Linux Slackware PHP Version: 5.3.3 Block user comment: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php This is made on purpose. Previous Comments: ------------------------------------------------------------------------ [2010-07-28 01:08:37] delphists at apollo dot lv Description: ------------ If spl_autoload_register() is called from class method, SPL autoloader can use private and protected methods, although SPL is not a part of this class. It works well if spl_autoload_register() is called from somewhere else. Test script: --------------- <?php class CallbackTest { public function __construct() { spl_autoload_register(array($this, 'publicCallback')); spl_autoload_register(array($this, 'protectedCallback')); spl_autoload_register(array($this, 'privateCallback')); } public function publicCallback($className) { echo __METHOD__, "\n"; } protected function protectedCallback($className) { echo __METHOD__, "\n"; } private function privateCallback($className) { echo __METHOD__, "\n"; } } new CallbackTest(); new AutoloadTest(); Expected result: ---------------- PHP Fatal error: Uncaught exception 'LogicException' with message 'Passed array does not specify a callable method (cannot access protected method CallbackTest::protectedCallback())' in /home/binary/test.php:5 Stack trace: #0 test.php(5): spl_autoload_register(Array) #1 test.php(18): CallbackTest->__construct() #2 {main} thrown in test.php on line 5 Actual result: -------------- CallbackTest::publicCallback CallbackTest::protectedCallback CallbackTest::privateCallback PHP Fatal error: Class 'AutoloadTest' not found in test.php on line 19 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=52464&edit=1