1.2.1451. Wrong Number Of Arguments In Methods¶
Those methods are called with a wrong number of arguments : too many or too few. Check the signature. Methods with a variable number of argument, either using ellipsis or func_get_args() are ignored.
PHP emits an error at runtime, when arguments are not enough : ‘’. PHP doesn’t emit an error when too many arguments are provided.
<?php
class Foo {
private function Bar($a, $b) {
return $a + $b;
}
public function foobar() {
$this->Bar(1);
// Good amount
$this->Bar(1, 2);
// Too Many
$this->Bar(1, 2, 3);
}
}
?>
1.2.1451.2. Connex PHP features¶
1.2.1451.2.1. Suggestions¶
Adapt the call to use one of the right number of arguments : this means dropping the extra ones, or adding the missing ones
Adapt the signature of the method, and use a default value
1.2.1451.2.2. Specs¶
Short name |
Functions/WrongNumberOfArgumentsMethods |
Rulesets |
|
Exakat since |
0.8.4 |
PHP Version |
All |
Severity |
Major |
Time To Fix |
Quick (30 mins) |
Precision |
Very high |
Available in |