Some PHP operations do surprising things without telling you. This RFC from Gina Peter Banyard proposed warnings for five of those cases in PHP 8.5, with the plan to turn them into errors no earlier than PHP 9. Each warning had its own vote.
The five warnings
Coercing NAN to other types. NAN is a float that functions return to signal an error, yet today it converts to other types without complaint. It even counts as true, except under an (int) cast, where it becomes 0. The new warning is unexpected NAN value was coerced to TYPE.
Casting out-of-range floats to int. A float that's too large or too small for an integer gives strange results when cast:
$a = PHP_INT_MAX + 25; var_dump((int) $a); // int(-9223372036854775808)
INF and -INF both cast to 0. The new warning is non-representable float was cast to int.
Destructuring non-array values. [$a, $b] = $value throws an Error for objects, but for a bool, int, float, string or resource, it quietly sets each variable to null. The new warning is Cannot use TYPE as array. Destructuring null stays silent.
Offsets on non-container values in isset() and empty(). Checking isset($int[0]) on a scalar quietly returns false. The proposed warning was Cannot use TYPE as array, with null staying silent.
Invalid offset types on strings in isset() and empty(). Using an object as a string offset inside isset() returns false, while the same thing with ?? throws a TypeError. The proposed warning was Cannot access offset of type TYPE on string.
What it means for existing code
On PHP 8.5 you may see new warnings, but nothing stops working yet. If one shows up, it most likely points to a bug in your code. The RFC says these become errors no sooner than PHP 9.
The vote
Each warning needed a two-thirds majority. The page doesn't list a closing date.
- Coercing
NAN: passed 20 to 0. - Out-of-range floats to
int: passed 17 to 0. - Destructuring non-arrays: passed 16 to 0.
- Offsets on non-containers in
isset()/empty(): failed, 10 to 6. - Invalid string offset types in
isset()/empty(): failed, 10 to 6.
The three warnings that passed shipped in PHP 8.5.