1.2.1174. Strpos() Less Than One¶
This rule reports a comparison of strpos() or stripos() with 1. This is a variable of strpos() == 0, since both false and 0 are processed the same way. Yet, 0 might be a valid value.
This rule was suggested by Yann Ouche.
<?php
// this works both when $a starts with .
// and when the . is not in the string.
if (strpos($a, '.') < 1) {
}
?>
1.2.1174.1. Suggestions¶
Make sure that the 2 cases are valid business cases.
1.2.1174.2. Specs¶
Short name |
Structures/StrposLessThanOne |
Rulesets |
|
Exakat since |
2.6.6 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
High |
Available in |