1.2.571. Inconsistent Variable Usage¶
Those variables are used in various and inconsistent ways. It is difficult to understand if they are an array, an object or a scalar variable.
<?php
// $a is an array, then $b is a string.
$a = ['a', 'b', 'c'];
$b = implode('-', $a);
// $a is an array, then it is a string.
$a = ['a', 'b', 'c'];
$a = implode('-', $a);
?>
1.2.571.1. Suggestions¶
Keep one type for each variable. This keeps the code readable.
Give different names to variables with different types.
1.2.571.2. Specs¶
Short name |
Variables/InconsistentUsage |
Rulesets |
|
Exakat since |
1.6.9 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Slow (1 hour) |
Precision |
High |
Examples |
|
Available in |