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
ReflectionParameter default value throws "Failed to retrieve the default value" for trait, interface and prelude-class (Exception, ArrayObject) methods #287
ReflectionParameter default value throws "Failed to retrieve the default value" for trait, interface and prelude-class (Exception, ArrayObject) methods.
Repro
<?phpinterface I { publicfunctionf(int$a = 5); }
trait T { publicfunctiont($z = 'a', $q = null) {} }
class C implements I { use T; publicfunctionf(int$a = 5) {} }
class MyEx extends Exception {}
classAOextends ArrayObject {}
foreach ([['C', 't'], ['I', 'f'], ['MyEx', '__construct'], ['AO', '__construct']] as [$cls, $m]) {
foreach ((newReflectionMethod($cls, $m))->getParameters() as$p) {
echo$cls, '::', $m, '', (string)$p, "\n";
}
}
C::t
[exit code 255]
PHP Fatal error: Uncaught ReflectionException: Internal error: Failed to retrieve the default value
Tracking
Known-bug repro: tests/aot/repro/wrong/refl_param_default_missing_factory.php — bash tests/aot/xfail.sh -k refl_param_default_missing_factory reports XFAIL while this is open and XPASS once it is fixed; then move the repro into tests/aot/cases/ and close this issue.
examples/symfony-app does not start with APP_ENV=dev (exit 255, PHP Fatal error: Uncaught ReflectionException: Internal error: Failed to retrieve the default value). prod works. Present since #165 (checked on 7f2be542 and b394c2dc, so not caused by #274 or #286).
The debug container dump hashes every class's reflected signature, including inherited methods, so one such parameter is enough.
Cause
prelude/reflection.phpReflectionParameter::isDefaultValueAvailable() reads a flag bit set from the AST ($p->default !== null), while getDefaultValue() calls the per-parameter factory __mc_pdef_<Class>__<method>_<pos>. LowerFromAst::synthAttrFactories (src/Compile/Mir/Passes/LowerFromAst.php, ~2233) synthesizes those factories only for methods in $decl->methods of non-prelude classes (if ($cd->isStruct || $cd->isPreludeClass) { continue; }). So the flag says "has a default" and the factory symbol is absent (EmitLlvmRuntime writes null) for:
methods imported from a trait (not in the class's own $decl->methods),
methods of interfaces,
inherited methods whose declaring class is a prelude class (Exception::__construct, ArrayObject::__construct, ...).
Reproduced with the file above. A second, separate defect (#288): a default written self::X is evaluated in a free factory function, outside the class.
Suggested direction
Synthesize the default factories for every reflectable method regardless of how it reached the class (trait uses, interfaces, prelude classes), in the declaring class's scope (fixes #288 too), and make isDefaultValueAvailable() agree with the table (never report a default whose factory is missing).
Activity
blacktrs commentedon Oct 16, 2026
Impact
examples/symfony-appdoes not start withAPP_ENV=dev(exit 255,PHP Fatal error: Uncaught ReflectionException: Internal error: Failed to retrieve the default value).prodworks. Present since #165 (checked on7f2be542andb394c2dc, so not caused by #274 or #286).Native backtrace at the throw (lldb):
The debug container dump hashes every class's reflected signature, including inherited methods, so one such parameter is enough.
Cause
prelude/reflection.phpReflectionParameter::isDefaultValueAvailable()reads a flag bit set from the AST ($p->default !== null), whilegetDefaultValue()calls the per-parameter factory__mc_pdef_<Class>__<method>_<pos>.LowerFromAst::synthAttrFactories(src/Compile/Mir/Passes/LowerFromAst.php, ~2233) synthesizes those factories only for methods in$decl->methodsof non-prelude classes (if ($cd->isStruct || $cd->isPreludeClass) { continue; }). So the flag says "has a default" and the factory symbol is absent (EmitLlvmRuntimewritesnull) for:$decl->methods),Exception::__construct,ArrayObject::__construct, ...).Reproduced with the file above. A second, separate defect (#288): a default written
self::Xis evaluated in a free factory function, outside the class.Suggested direction
Synthesize the default factories for every reflectable method regardless of how it reached the class (trait uses, interfaces, prelude classes), in the declaring class's scope (fixes #288 too), and make
isDefaultValueAvailable()agree with the table (never report a default whose factory is missing).