1.2.202. Comparison Is Always The Same¶
Based on the incoming type of arguments, the comparison always yields the same value. The whole condition might be useless.
<?php
function foo(array $a) {
// This will always fail
if ($a === 1) {
} elseif (is_int($a)) {
}
// This will always succeed
if ($a !== null) {
} elseif (is_null($a)) {
}
}
?>
1.2.202.1. Suggestions¶
Remove the constant condition and its corresponding blocks
Make the constant condition variable
1.2.202.2. Specs¶
Short name |
Structures/AlwaysFalse |
Rulesets |
|
Exakat since |
1.9.4 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
High |
Features |
comparison |
Available in |