Re: Anonymous functions inside static methods.

From: Date: Tue, 13 May 2014 16:24:58 +0000
Subject: Re: Anonymous functions inside static methods.
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
> > Another option is to implicitly promote closures inside of static
contexts
> > to be also be static; this is basically what HHVM does.

> PHP does this! That's why you get 'Cannot bind an instance to a static
> closure' if you closure->bindTo() inside a static method, even if
> the closure itself is not keyworded static.

I didn't explain that well enough; I meant that it automatically promotes
the
closure to be 'static' in that it uses late static binding.

> The difference between HHVM and PHP is the default class scope of the
> closure. PHP makes the decision that the owning class scope of the
> closure is the compile-time class of the parent method. Why this was
> done I couldn't say.

This is actually the same issue as the one above. Basically the closures
aren't respecting late static binding and I am pretty sure it was just an
oversight, not a conscious decision.


Thread (9 messages)

« previous php.internals (#74147) next »