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
Incorrect Closure scope for FCC in constant expression #19637
A function turned into a callable has its ReflectionFunction::getClosureCalledClass() return the class around, while ::getClosureScopeClass() returns null.
Give that a function doesn't have any class context, ::getClosureCalledClass() should also return null.
The following code:
<?php
#[Attribute(Attribute::TARGET_CLASS | Attribute::IS_REPEATABLE)]
class Attr {
publicfunction__construct(publicClosure$value) {}
}
#[Attr(self::myMethod(...))]
#[Attr(strrev(...))]
#[Attr(staticfunction ($value) {
return\strtoupper($value);
})]
class C {
privatestaticfunctionmyMethod(string$foo) {
return"XXX";
}
}
foreach ((newReflectionClass(C::class))->getAttributes() as$reflectionAttribute) {
$a = $reflectionAttribute->newInstance();
$r = new \ReflectionFunction($a->value);
var_dump($r->getClosureCalledClass());
var_dump($r->getClosureScopeClass());
}
changed the title [-]ReflectionFunction::getClosureCalledClass() mismatch[/-][+]Incorrect Closure scope for FCC in constant expression[/+]on Sep 1, 2025
Activity
DanielEScherzer commentedon Aug 30, 2025
CC @TimWolla @edorian from #17213
zend_ast: Fix Closure scope for FCC in constant expression
[-]ReflectionFunction::getClosureCalledClass() mismatch[/-][+]Incorrect Closure scope for FCC in constant expression[/+]zend_ast: Fix Closure scope for FCC in constant expression (#19639)