Hi

I've modified Closure::bindTo/Closure::bindTo so that they accept another argument that defines the new scope. This can either be an object (its class is used as the scope) or a class name.

I changed the current behavior so that:

* If the scope is not given, the current one is kept. This permits changing the bound instance without changing the calling scope. The current behavior (set the scope to the class of the new bound instance) makes useless rebinding of closures that were defined up in the class hierarchy. * I also changed the order of the arguments of Closure::bindTo so that I could unify Closure::bind and Closure::bindTo under a single implementation which plays nice with zend_parse_method.

Additionally, I added the method Closure::getScope, which returns the currently set calling scope of the closure.

Finally, I added four tests. Tests closure_038 and closure_039 fail. Both present memory corruption and, in addition to that, closure_039 also gives incorrect results because the rebounding confuses the cache. Note that these problems were already present (they weren't caused by the changes, as far as I know). I attached the logs.

--
Gustavo Lopes
-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to