1.2.375. Don’t Use The Type As Variable Name¶
When it is difficult to find a good name, it is very tempting to use the type.
Such a name should carry its actual usage, as the type is already hold by the data.
This rule check for parameters and variables which uses the type as name. It also report instantiation which hold the same name than the instantiated class.
<?php
$sqlite3 = new Sqlite3();
function foo(int $int) : array {
$array = [];
return $array;
}
?>
1.2.375.1. Suggestions¶
Use another name than the class or the type
1.2.375.2. Specs¶
Short name |
Structures/DontUseTheTypeAsVariable |
Rulesets |
|
Exakat since |
2.6.2 |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
High |
Features |
semantics |
Available in |