Hi Larry
On Thu, Jan 22, 2026 at 6:19 PM Larry Garfield <larry@garfieldtech.com> wrote:
>
> On Thu, Jan 22, 2026, at 10:41 AM, Ilija Tovilo wrote:
> >
> > As mentioned, the rules for when static can be inferred are slightly
> > esoteric. For example, your code may be calling Foo::bar(), which
> > _looks_ like a static call, but could actually be an instance
> > grand-parent call (https://3v4l.org/uDi8W#v8.4.14). If you were to
> > remove this ambiguous call, and the closure could now be inferred as
> > static, it would be bad if existing Closure::bind[To]() calls would
> > break because they provide an object. For this reason,
> > Closure::bind[To]() will _accept but discard_ objects only for
> > closures inferred as static.
>
> Ah, so it's just a "don't break code that's already wrong but not harmfully so" feature.
I wouldn't consider it wrong to not mark functions as static that
could be static, otherwise there wouldn't be a need for this
optimization. Consequently, it would also not be wrong to attempt to
Closure::bind() an object to such a closure, which is why I felt it
was important to keep this case working. The caveat here being that
the object is discarded, so ReflectionFunction::getClosureThis() will
still return NULL.
> I'm OK with that, but please add that to the RFC.
I did not plan to make an RFC for this, given the BC breaks are mostly
theoretical. But if anybody objects, I'm happy to create one.
Ilija
On Thu, Jan 22, 2026 at 6:19 PM Larry Garfield <larry@garfieldtech.com> wrote: