The PHP 8.6 deprecations RFC bundled 35 separate proposals, each with its own vote and each needing a two-thirds majority. 31 passed and 4 didn't. Everything that passed emits a deprecation notice in PHP 8.6, with removal no earlier than PHP 9.
What's deprecated#
The one most likely to catch a real bug is returning from a finally block. A return there silently throws away any exception the try block raised:
function getConfig(): array {
try {
return loadConfig();
} finally {
return [];
}
}
In PHP 8.6 this triggers Deprecated: Returning from a finally block is deprecated at compile time, so you see it while writing the code rather than in production.
Some of the other items that passed include:
is_double(), is_integer(), is_long() and doubleval(), in favor of is_float(), is_int() and floatval()
let and is as identifiers, namespace as a class constant name, readonly as a function name, and _ as a constant, all reserved for possible future keywords
- Passing objects where
array_walk(), array_walk_recursive(), http_build_query(), mb_convert_variables(), deflate_init() and inflate_init() expect arrays, plus the same for the zlib and bzip2 stream filters
spl_object_hash(), since spl_object_id() returns the same identifier as an integer
- The
SplFileObject CSV methods: fgetcsv(), fputcsv(), setCsvControl() and getCsvControl()
strcoll(), the SORT_LOCALE_STRING flag, metaphone(), spl_classes() and mysqli_get_charset()
define() with $case_insensitive, and is_a() or is_subclass_of() with a string when $allow_string is false
The full list also covers changes to Reflection, ArrayIterator, mysqli::stmt_init() and session_set_save_handler().
What didn't pass#
- The
list() construct, so list($a, $b) = $array stays next to [$a, $b] = $array
in, out and inout as identifiers
_ as a function name, and _() as the alias for gettext()
- The
dechunk stream filter
What it means for existing code#
Nothing breaks in PHP 8.6. You get new deprecation notices, and the code keeps running. The alias deprecations are one-line swaps, like is_double() to is_float(). For most items, the RFC links an impact analysis run against popular Composer packages, so you can see how common each pattern is.