Edit report at https://bugs.php.net/bug.php?id=60955&edit=1

 ID:                 60955
 User updated by:    frederic dot hardy at mageekbox dot net
 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:

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.


Previous Comments:
------------------------------------------------------------------------
[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

Reply via email to