1.2.1432. Variables With One Letter Names¶
Variables with one letter name are the shortest name for variables. They also bear very little meaning : what does contain the variable $w
?
Some one-letter variables have meaning : $x
and $y
for coordinates, $i
, $j
, $k
for blind variables. Others tend to be an easy way to give a name to a variable, without thinking too hard a good name.
<?php
// $a is reported as a one-letter variable
$a = 0;
// $i is considered a false positive.
for($i = 0; $i < 10; ++$i) {
$a += doSomething($i);
}
?>
See also Using single characters for variable names in loops/exceptions and Single Letter Variable Names Still Considered Harmful.
1.2.1432.1. Suggestions¶
Make the variable more meaningful, with full words
1.2.1432.2. Specs¶
Short name |
Variables/VariableOneLetter |
Rulesets |
|
Exakat since |
0.8.4 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
Very high |
Available in |