Closed
Description
Subject | Details |
---|---|
Plugin | Php Inspections (EA Extended) 4.0.6 |
Language level | e.g. PHP 7.2, but doesn’t matter |
Current behaviour
$s = '0';
if ($s === '0.00') echo 'really equal'; // condition is false
if ($s == '0.00') echo 'not quite equal, but still'; // condition is true
The suggestion for the last line is _Safely use '===' here._
Expected behaviour
Suggestion should be _Please consider using more strict '===' here_
when the string is numeric and can be cast to (float) 0.0
or better yet point out that numbers and nully strings will equal a nully string.
To use only strict comparisions, the former example would require type checking and casting.
Environment details
PHP treats these as true:
0==' 0.00'
0.0=='0'
'0.000000'=='0.0'
Activity