Re: com php-src: Do not create a fake Closure for real Closures That is solved by just returning the Closure as is, which is safe due to Closures
being immutable objects: Zend/tests/closure_061.phpt ext/reflection/php_reflection.c
| From: | Nikita Popov | Date: | Wed, 14 Oct 2015 11:57:31 +0000 |
| Subject: | Re: com php-src: Do not create a fake Closure for real Closures That is solved by just returning the Closure as is, which is safe due to Closures being immutable objects: Zend/tests/closure_061.phpt ext/reflection/php_reflection.c |
||
| References: | 1 2 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-89398@lists.php.net to get a copy of this message | ||
On Wed, Oct 14, 2015 at 1:23 PM, Anatol Belski <anatol.php@belski.net>
wrote:
> Hi Nikita,
>
> Could you pls check how this check comply with the latest patch for
> forbidding scope change of closures created by ReflectionFunctionAbstract?
> From what was discussed, when the new scope is not NULL, the new part of
> test should be failing.
>
Turns out some code broke, because people were trying to rebind the result
of what essentially is (new ReflectionFunction($closure))->getClosure().
This wasn't intentional: It is perfectly safe to rebind normal closures in
every possible way, even if they went through getClosure(). So this patch
removes the new restriction for the "real" closure case again.
If you're wondering why somebody would do (new
ReflectionFunction($closure))->getClosure(), the reason seems to be that if
you have only a ReflectionFunction instance, that's the only way to get
back to the closure it was constructed from.
Nikita