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
Too few arguments to a user function or method are padded with defaults instead of throwing ArgumentCountError #175
Known-bug repro: tests/aot/repro/wrong/too_few_arguments_not_thrown.php — bash tests/aot/xfail.sh -k too_few_arguments_not_thrown reports XFAIL while this is open and XPASS once it is fixed; then move the repro into tests/aot/cases/ and close this issue.
Runtime (always). Every call path that binds arguments to a user function/method must throw ArgumentCountError ("Too few arguments to function X::m(), N passed in %s on line %d and exactly|at least M expected") when a required parameter has no argument: direct, dynamic method/function name, call_user_func*, spread (...$args, including a leading fixed arg + spread), closures, constructors. Today every path except the compile-time diagnostic pads with defaults/null (see repro: 6 of 7 cases print a value).
Compile time (when provable). If the callee resolves statically and the argument count is known, report it. Direct calls already get error: too few arguments to two(): 1 passed, at least 2 expected from analyze, but compile still emits a binary that returns 1: the error is not fatal and the call site does not throw.
Policy for the static layer (to decide in the fix):
user code being compiled as the main program: fatal error (like --analyze-strict);
vendor/composer code: warning + a call site that throws ArgumentCountError at run time, never a build failure. Third-party code routinely contains unreachable bad calls (this repo already hit it: Symfony's JsonDescriptor::writeData($service::class), HttpException::fromStatusCode LSB clones), and Zend only fails if the branch runs. Same rule as the provable-argument-type-mismatch handling in TypeCheck (fix/symfony-ownflow-inference, 376cdd7).
The runtime half is the substance; the static half is a diagnostic on top of it and must not replace it.
Activity
blacktrs commentedon Oct 11, 2026
Expected behaviour: two layers
Runtime (always). Every call path that binds arguments to a user function/method must throw
ArgumentCountError("Too few arguments to function X::m(), N passed in %s on line %d and exactly|at least M expected") when a required parameter has no argument: direct, dynamic method/function name,call_user_func*, spread (...$args, including a leading fixed arg + spread), closures, constructors. Today every path except the compile-time diagnostic pads with defaults/null (see repro: 6 of 7 cases print a value).Compile time (when provable). If the callee resolves statically and the argument count is known, report it. Direct calls already get
error: too few arguments to two(): 1 passed, at least 2 expectedfromanalyze, butcompilestill emits a binary that returns1: the error is not fatal and the call site does not throw.Policy for the static layer (to decide in the fix):
--analyze-strict);ArgumentCountErrorat run time, never a build failure. Third-party code routinely contains unreachable bad calls (this repo already hit it: Symfony'sJsonDescriptor::writeData($service::class),HttpException::fromStatusCodeLSB clones), and Zend only fails if the branch runs. Same rule as the provable-argument-type-mismatch handling inTypeCheck(fix/symfony-ownflow-inference, 376cdd7).The runtime half is the substance; the static half is a diagnostic on top of it and must not replace it.
Fix batch: reflection, leaks, by-ref crashes, misc semantics (#207)
test(repro): too few arguments are padded instead of throwing Argumen…
Promote the 14 xfail repros that pass now and drop 9 stale repros who…
Compile and serve a Symfony app natively: ownership/inference fixes, …