1.2.108. Cancelled Parameter¶
A parameter is cancelled, when its value is hardcoded, and cannot be changed by the calling expression. The argument is in the signature, but it is later hardcoded to a literal value : thus, it is not usable, from the caller point of view.
Reference argument are omitted in this rule, as their value changes, however hardcoded, may have an impact on the calling code.
<?php
function foo($a, $b) {
// $b is cancelled, and cannot be changed.
$b = 3;
// $a is the only parameter here
return $a + $b;
}
function bar($a, $b) {
// $b is actually processed
$c = $b;
$c = process($c);
$b = $c;
// $a is the only parameter here
return $a + $b;
}
?>
1.2.108.1. Connex PHP features¶
1.2.108.1.1. Suggestions¶
Remove the parameter in the method signature
1.2.108.1.2. Specs¶
Short name |
Functions/CancelledParameter |
Rulesets |
|
Exakat since |
2.2.0 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
Very high |
Available in |