1.2.34. Ambiguous Types With Variables¶
The same variable is assigned various types, in different methods. This means that one may expect the same named variable to behave differently in different context.
<?php
function foo() {
$i = 1;
$user = new User();
}
function goo() {
$i = 2; // $i is always an integer
$user = new Propect(); // Sometimes $user is a User, and sometimes it is a Propect
}
?>
1.2.34.1. Specs¶
Short name |
Variables/AmbiguousTypes |
Rulesets |
|
Exakat since |
2.5.0 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
High |
Available in |