1.2.1393. Useless Default Argument¶
One of the argument has a default value, and this default value is never used. Every time the method is called, the argument is provided explicitly, rendering the default value actually useless.
<?php
function goo($a, $b = 3) {
// do something here
}
// foo is called 3 times, and sometimes, $b is not provided.
goo(1,2);
goo(1,2);
goo(1);
function foo($a, $b = 3) {
// do something here
}
// foo is called 3 times, and $b is always provided.
foo(1,2);
foo(1,2);
foo(1,2);
?>
1.2.1393.1. Connex PHP features¶
1.2.1393.1.1. Suggestions¶
Remove the default value
Remove the explicit argument in the function call, when it is equal to the default value
1.2.1393.1.2. Specs¶
Short name |
Functions/UselessDefault |
Rulesets |
|
Exakat since |
1.7.9 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
High |
Available in |