1.2.1441. Written Only Variables¶
Those variables are being written, but never read. In this way, they are useless and should be removed, or be read at some point in the code.
When the variables are only written, it takes time to process them, while discarding their result without usage. Also, when those variables are built with a complex process, it makes it difficult to understand their point, and still create maintenance work.
<?php
// $a is used multiple times, but never read
$a = 'a';
$a .= 'b';
$b = 3;
//$b is actually read once
$a .= $b + 3;
?>
1.2.1441.1. Connex PHP features¶
1.2.1441.1.1. Suggestions¶
Check that variables are written AND read in each context
Remove variables that are only read
Use the variable that are only read
1.2.1441.1.2. Specs¶
Short name |
Variables/WrittenOnlyVariable |
Rulesets |
|
Exakat since |
0.8.4 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Slow (1 hour) |
Precision |
Very high |
ClearPHP |
|
Examples |
|
Available in |