Re: BC break: ReflectionMethod::invoke() expects parameter1to be object, string given

From: Date: Tue, 23 Aug 2016 14:49:54 +0000
Subject: Re: BC break: ReflectionMethod::invoke() expects parameter1to be object, string given
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17  Groups: php.internals 
Request: Send a blank email to internals+get-95414@lists.php.net to get a copy of this message
On Tue, Aug 23, 2016 at 4:13 PM, Levi Morrison <levim@php.net> wrote: > On Tue, Aug 23, 2016 at 7:56 AM, Alexander Lisachenko > <lisachenko.it@gmail.com> wrote: >> >> 2016-08-23 16:40 GMT+03:00 Julien Pauli <jpauli@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 <jpauli@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

« previous php.internals (#95414) next »