Re:Whats New in PHP 8.2
by blowski on Monday April 25, 2022 @10:13AM
(#31155076)
It's for backwards compatibility with functions that return either the expected value (maybe an array or a string) or false (never true). So you can use it in a union like `foo(): string|false {}`. In that sense, it's not a boolean because it will only ever be a string or false.
[ Parent
| on HN ]
That makes sense, though you would want a linter or something to check that callers are doing "=== false" and not "== false", since falsy (but not false) values would match the latter.
If you're using `==` in 2022 without testing or linting, this would be the least of your problems. Also, with the strict_types declaration, it wouldn't be coerced.