Dev News Daily ENDE

PHP 8.6 ships partial function application, a Duration class and polling

PHP 8.6.0 was released on 19 November. The main language addition is partial function application: a call can supply some arguments and mark the rest with ? and ... placeholders, and the result is a Closure that runs the function only once the remaining arguments arrive. The release page shows version_compare(?, '8.6', '>=') passed straight to array_filter in place of an arrow function.

The release adds a \Time\Duration class for elapsed time as a stopwatch measures it, independent of any time zone, with nanosecond precision over a range of more than 250 years; the project pitches it for timeouts and benchmark timings. A new polling API exposes epoll, kqueue and other native mechanisms for I/O multiplexing, aimed at event-loop libraries such as ReactPHP and AMPHP. Smaller additions are a clamp() function, a SortDirection enum and default values for readonly properties.

The upgrade list is long. Sessions are stricter by default: session.use_strict_mode and session.cookie_httponly are on and session.cookie_samesite is Lax. return inside a finally block is deprecated, as are the mb_ereg() family (the underlying Oniguruma library is unmaintained), the is_double()/is_long()/is_integer()/doubleval() aliases and spl_object_hash(). fclose(), file_put_contents() and copy() now return false when flushing or closing fails, and trim() also strips form feeds.

PHP 8.6 ships partial function application, a Duration class and polling
PHP 8.6 ships partial function application, a Duration class and polling — Dev News Daily

Why it matters

The session defaults change behaviour without a code change: an application that relied on cross-site cookies or on accepting uninitialised session IDs will notice on the first deploy, not in the changelog.