1.2.903. Overwritten Literals¶
The same variable is assigned a literal twice. It is possible that one of the assignation is too many.
This analysis doesn’t take into account the distance between two assignations : it may report false positives when the variable is actually used for several purposes, and, as such, assigned twice with different values.
<?php
function foo() {
// Two assignations in a short sequence : one is too many.
$a = 1;
$a = 2;
for($i = 0; $i < 10; $i++) {
$a += $i;
}
$b = $a;
// New assignation. $a is now used as an array.
$a = array(0);
}
?>
1.2.903.1. Connex PHP features¶
1.2.903.1.1. Suggestions¶
Remove one of the assignation (the earliest)
1.2.903.1.2. Specs¶
Short name |
Variables/OverwrittenLiterals |
Rulesets |
|
Exakat since |
0.8.4 |
PHP Version |
All |
Severity |
Major |
Time To Fix |
Instant (5 mins) |
Precision |
Very high |
Available in |