Re: Forbid rebinding scope of closures created by ReflectionFunctionAbstract::getClosure()
| From: | Bob Weinand | Date: | Sat, 10 Oct 2015 23:15:52 +0000 |
| Subject: | Re: Forbid rebinding scope of closures created by ReflectionFunctionAbstract::getClosure() | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-88745@lists.php.net to get a copy of this message | ||
> Am 11.10.2015 um 00:16 schrieb Levi Morrison <levim@php.net>:
>
>> Based on feedback received on an earlier version of this patch [6] [7], we
>> have not added any additional restrictions on rebinding of $this.
>> getClosure()s of userland methods can still be bound to arbitrary $this
>> values and getClosure()s of internal methods can still be bound to
>> "compatible" $this values. (If someone sees a problem with allowing the
>> former, please speak up!)
>>
>> Note that all this applies to ReflectionFunctionAbstract::getClosure()
>> only. Rebinding behavior of ordinary closures doesn't change.
>
> A user-defined closure can be rebound freely, but not one created from
> Reflection - is that correct?
Yes, correct.
> My personal opinion is that we should be working to eliminate
> differences between internal and user functions (including closures).
> In your opinion can we make user and internal closures act more alike?
> I'm assuming rebind internal methods can't be done properly because
> internal objects may use different C structs than a plain zend_object
> (hence the crashes). Is that correct?
It's rather about the additional meta-data before the object which the internal object
requires. Hence you usually can use internal objects like normal zend_object *'s, but not the
inverse.
The only way to make them actually more alike is putting more restrictions (and BC breaks) than
necessary onto the binding rules. Loosening internal binding rules doesn't work as well...
Bob