On Tue, Aug 23, 2016 at 4:58 PM, Levi Morrison <le...@php.net> wrote:
> On Tue, Aug 23, 2016 at 8:49 AM, Julien Pauli <jpa...@php.net> wrote:
>> On Tue, Aug 23, 2016 at 4:13 PM, Levi Morrison <le...@php.net> wrote:
>>> On Tue, Aug 23, 2016 at 7:56 AM, Alexander Lisachenko
>>> <lisachenko...@gmail.com> wrote:
>>>>
>>>> 2016-08-23 16:40 GMT+03:00 Julien Pauli <jpa...@php.net>:
>>>>>
>>>>> My patch allows that, but I can't find a use case to it.
>>>>
>>>>
>>>>
>>>> My use case for that was decorating of static methods with additional
>>>> behaviour, so it's possible to cache the result of static methods, etc.
>>>> Unfortunately, reflection API doesn't provide me such an ability, so I
>>>> decided to switch to the combination of special closure with
>>>> forward_static_call_array() and binding it to the desired scope.
>>>>
>>>>
>>>> 2016-08-23 16:40 GMT+03:00 Julien Pauli <jpa...@php.net>:
>>>>>
>>>>> Try it.
>>>>
>>>>
>>>> Yes, sure, I will check. However as I say earlier, now I use closure
>>>> extraction and scope binding as more natural way to invoke such methods. So
>>>> missing scope argument for static methods and ReflectionMethod->invoke() is
>>>> a nice thing to have, but not a critical one.
>>>
>>> Seems to me you should be calling getClosure() and using
>>> Closure::bindTo before invoking it. ReflectionMethod::invoke is really
>>> just a short-cut for a common case; I don't think it's reasonable to
>>> have it mirror the Closure API just to save one method call to get a
>>> Closure.
>>
>> This cannot work.
>> There is a special use case forbidding that.
>> "Cannot rebind scope of closure created by
>> ReflectionFunctionAbstract::getClosure()"
>>
>>
>> Julien
>
> I know this is a stability concern for internal classes but is there
> anything really preventing this from user-land classes?

I remember problems and bugs around this , but I don't remember the
exact use-case why we forbid that.
I guess Dmitry, Xinchen or Nikic could remember.


Julien

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

Reply via email to