You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PHP 8.6: cached static closure keeps static:: of the first called class #23911
<?phpclass A {
publicstaticfunctionname(): string {
return (staticfn () => static::class)();
}
}
class B extends A {}
class C extends A {}
var_dump(B::name(), C::name());
Resulted in this output:
string(1) "B"
string(1) "B"
But I expected this output instead:
string(1) "B"
string(1) "C"
8.4 and 8.5 give the expected output. 8.6.0RC2 does not, with or without opcache.
Written with LLM assistance, per CONTRIBUTING.md. The code, outputs and bisect above are measured.
It also happens in inherited instance methods, and with new static() and get_called_class(). A non-static closure is fine. We hit it in bensampo/laravel-enum, where the second enum class gets instances of the first.
Unverified guess: ZEND_DECLARE_LAMBDA_FUNCTION returns the cached closure without checking the called scope, and all subclasses share the slot in the declaring op_array.
Activity
Fix phpGH-23911: Cached static closure keeps static:: of the first ca…