1.2.1304. Unused Parameter¶
Those parameters are not used inside the method or function.
Unused parameters should be removed in functions : they are dead code, and seem to offer features that they do not deliver.
Some parameters are unused, due to the signature compatibility: for example, if an interface or a parent class defines that parameter, but it is not useful in the current method. Then, it must stay.
This is a silent error: no error message is emitted when doing so.
<?php
// $unused is in the signature, but not used.
function foo($unused, $b, $c) {
return $b + $c;
}
interface i {
function goo($a);
}
class a implements i {
// goo signature comes from the interface
function goo($a) {
return 3;
}
}
?>
1.2.1304.1. Connex PHP features¶
1.2.1304.1.1. Suggestions¶
Drop the argument from the signature
Actually use that argument in the body of the method
1.2.1304.1.2. Specs¶
Short name |
Functions/UnusedArguments |
Rulesets |
|
Exakat since |
0.8.4 |
PHP Version |
All |
Severity |
Major |
Time To Fix |
Quick (30 mins) |
Precision |
Very high |
Examples |
|
Related rule |
|
Available in |