Christian Seiler wrote:
> Hi Greg,
>
>> I can do it if someone can answer this question: how do closures
>> uniquely identify themselves? spl_autoload_register is mistakenly
>> treating all closures as if they were a single copy of the static method
>> "Closure::__invoke", and so only the first registered closure is ever
>> called (plus it leaks the other closures at shutdown). If the system
>> can be made to better identify the closure, then spl_autoload_register
>> can use that (and also properly free the refcount on a dupe).
>
> A closure can only be uniquely identified by the object storage id the
> object has. You cannot assume any identity with regard to, for example,
> file name and line where it was defined, since one could imagine the
> following:
>
> foreach ($dirs as $dir) {
> spl_autoload_register (function ($class) use ($dir) {
> include $dir.'/'.$class.'.php';
> });
> }
>
> (or something like it)
>
> If nobody else does it I'll fix this later today.
Hi,
Thanks Christian, I've got a patch and a test I'm about to commit, would
be great if you can review it.
Thanks,
Greg
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php