I suspect it is not possible to globally cause an error when more arguments are passed than are specified in the function signature, because PHP supports a variable number of arguments in user-defined functions by way func_get_args()
, for example. PHP will report an error (of level E_WARNING
at the time of writing this answer) if you call a function with less arguments than specified in the signature, but it does not report an error if you call the function with more arguments than specified in the signature.
It's not quite what you're specifically asking for, but of course you can write code to enforce exactly 1 parameter if you absolutely need this behaviour.
function foo($only_param) {
if (func_num_args() > 1) {
trigger_error(__FUNCTION__ . "(): Too many params", E_USER_ERROR);
}
...
}