Re: [VOTE][RFC] Closure::apply() (re-opening)

From: Date: Wed, 20 Aug 2014 19:30:10 +0000
Subject: Re: [VOTE][RFC] Closure::apply() (re-opening)
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-76740@lists.php.net to get a copy of this message
On Wed, Aug 20, 2014 at 11:51 AM, Nathan <nathan.bruer@starin.biz> wrote: > The only thing I'd suggest is like I said in the last email is to make the > syntax more like Closure::bind(Closure $closure, object $newThis, [mixed > $newScope = 'static']) and make it Closure::apply(mixed $newObjectOrScope > [, mixed ... $parameters]) $newObjectOrScope would then allow a user to > supply a class name or an object. If class name is passed you have access > to "static::", "self::", and "parent::" inside the function > everything else > works as described in the RFC. > > Give the ability to call a closure as a static method of a class or a > normal method of an object. Right now the only way to do it is doing > binding and creating new closures and calling those closures then > destroying them. I think you are confused. This proposal basically binds the closure to the new object and invokes it immediately. I genuinely don't see how it being statically bound to the object will make a difference. Please elaborate.

« previous php.internals (#76740) next »