Skip to content

PHP 8.6 ships today, and its deprecations are the part to check

The release adds a built-in polling API for event loops, but mbstring regex functions, spl_object_hash and return inside finally are now deprecated.

Source: PHP.net

PHP 8.6 reached general availability today, 19 November. The headline language feature, partial function application, was already locked in at feature freeze: use ? as a placeholder to pre-bind some arguments of a call and get back a closure for the rest.

The final release also ships a new Io\Poll namespace, giving PHP a built-in interface to platform polling, epoll on Linux, kqueue on BSD and macOS, event ports on Solaris, WSAPoll on Windows, without the 1024-connection limit of stream_select(). It is aimed squarely at event loop libraries like ReactPHP and AMPHP. Alongside it comes a clamp() function, a nanosecond-precision Duration class, and readonly properties that can now declare default values.

PHP 8.6 also deprecates several things that have been load-bearing in older codebases: the mbstring regex functions mb_ereg() and mb_split(), spl_object_hash() in favour of spl_object_id(), strcoll(), return inside a finally block, returning a value from __construct() or __destruct(), and custom session handlers that define create_sid() without also defining validateId().

clamp(-10, 0, 100); // int(0)
clamp(50, 0, 100);  // int(50)

Why it matters: none of these deprecations break anything today, but they are tomorrow’s removals. Run your test suite against 8.6 now, particularly if you touch mbstring regex functions or custom session handlers, so the warnings show up on your terms rather than during a future upgrade.

Share

Related reading

More from The Wire

All briefs