ZF-7191: Zend_Loader_Autoloader::autoload() doesn't invoke anonymous callbacks

Issue Type: Bug Created: 2009-07-03T17:46:24.000+0000 Last Updated: 2010-07-16T20:36:35.000+0000 Status: Resolved Fix version(s): - 1.10.6 (22/Jun/10)

Reporter: Mon Zafra (monzee) Assignee: Ramon Henrique Ornelas (ramon) Tags: - Zend_Loader

Related issues: Attachments: - Autoloader.diff


When calling $autoloader->(push|unshift)Autoloader($callback) where $callback is a lambda, the callback is added to the stack but is never invoked during the actual autoloading. The autoload() method validates every callback and handles only callbacks of the form $functionName or array($objectOrClassname, $method).

It also might be a good idea to move the callback validation from autoload() to (push|unshift)Autoloader() so that the validation occurs only once and we may throw an exception if the callback passed is invalid.


Posted by Mon Zafra (monzee) on 2009-11-20T05:23:29.000+0000

My proposed changes, not sure if these are satisfactory. NOTE: The attached AutoloaderTest.diff is for PHP 5.3+ only! * changed the autoload method, replaced the if checks for array and string with is_callable * added _validateCallback() method which is called by setAutoloaders(), (push|unshift)Autoloader() * added $validate param for setAutoloaders() which defaults to true. This is because unshift, push and remove all call setAutoloaders() which would unnecessarily trigger validation for every registered autoloader.

Posted by Ramon Henrique Ornelas (ramon) on 2010-07-16T20:35:24.000+0000

Support the anonymous functions was added in 22481 present in the release 1.10.6.

See ZF-10024.

Have you found an issue?

See the Overview section for more details.


© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.