1.2.1435. Weak Typing¶
The variable’s validation is not enough to allow for a sophisticated usage. For example, the variable is checked for null, then used as an object or an array.
<?php
if ($a !== null) {
echo $a->b;
}
?>
See also From assumptions to assertions.
1.2.1435.1. Connex PHP features¶
1.2.1435.1.1. Suggestions¶
Use instanceof when checking for objects
Use is_array() when checking for arrays. Also consider is_string(), is_int(), etc.
Use typehint when the variable is an argument
1.2.1435.1.2. Specs¶
Short name |
Classes/WeakType |
Rulesets |
|
Exakat since |
1.2.8 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Instant (5 mins) |
Precision |
Very high |
Examples |
|
Available in |