Re: Anonymous functions inside static methods.
> > 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)