News 4 min read

PHP 8.6 released with partial function application and clamp()


The PHP project released PHP 8.6 on November 19, 2026, calling it “a major update of the PHP language.” The headline features are partial function application, a new \Time\Duration class, a native Polling API for event loops and a clamp() function. It also turns on stricter session defaults and deprecates a long list of old aliases and edge cases, so it is worth reading before you bump the version in production.

What’s new

Partial function application. You can now call a function with some of its arguments and use ? and ... as placeholders for the rest. The result is a Closure, and the real call happens only once the missing arguments are passed in. The release page’s example filters a list of versions:

$versions = ['8.4', '8.5', '8.6', '8.7', '9.0'];

$supportsPfa = array_filter(
    $versions,
    version_compare(?, '8.6', '>='),
);

\Time\Duration. A class for elapsed time, the way a stopwatch measures it, independent of dates and time zones. It covers more than 250 years with nanosecond precision and is meant for timeouts and benchmark timings. Durations are comparable, so min(), max() and the new clamp() work on them directly.

Polling API. The new Io\Poll API watches many streams at once using the best mechanism each platform offers (epoll, kqueue, event ports or WSAPoll), without the scalability limits of stream_select(). The PHP team positions it as a foundation for event loop libraries such as ReactPHP and AMPHP.

Exceptions for stream errors. Stream operations can now be set to throw a StreamException, or to fail silently, instead of emitting warnings. Errors come back as structured StreamError objects with a StreamErrorCode enum case, the wrapper name and the path or URL involved; stream_last_errors() returns them later.

clamp(). Keeps a value inside a range and returns the nearest boundary when it falls outside:

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

var_dump(clamp(110, 0, 100));
// int(100)

Smaller language additions:

  • A SortDirection enum with Ascending and Descending cases, so libraries can type sort order instead of passing ints like SORT_STRING.
  • DocComments on individual function parameters, read with the new ReflectionParameter::getDocComment().
  • ReflectionProperty::isReadable() and isWritable(), which account for visibility, initialization, property hooks and magic methods.
  • Readonly instance properties, including those in readonly classes, can declare a default value.
  • #[\Override] works on class constants and enum cases, and enums can implement __debugInfo().

Library and extension updates. The Sodium extension gains post-quantum key encapsulation (X-Wing and ML-KEM-768), IP address encryption and the SHAKE and TurboSHAKE functions. TLS streams support session resumption, external pre-shared keys and TLS 1.3 early data (0-RTT). There are also URI builder classes, mysqli::quote_string(), ZipArchive::openString() for in-memory archives, grapheme_strrev(), and JSON error messages that point to where the error is in the input.

Performance. The release notes list array_map() with first-class callable or partial application callbacks compiled into loops, faster printf() calls, caching of stateless closures and faster JSON encoding. The page gives no benchmark numbers.

What it means for developers

The changes most likely to affect an existing app are the new defaults and stricter errors:

  • Sessions are stricter by default: session.use_strict_mode and session.cookie_httponly are on, and session.cookie_samesite is Lax. If your app relies on cross-site POSTs carrying the session cookie, test that flow.
  • trim(), ltrim() and rtrim() now strip form feed (\f) characters too.
  • fclose(), file_put_contents() and copy() return false when flushing or closing the stream fails, instead of ignoring it.
  • Many functions now throw ValueError for out-of-range values, invalid flags or strings containing NUL bytes, instead of truncating or ignoring them.

Deprecations will show up as warnings in logs and tests. Among them: return inside a finally block, returning a value from __construct() or __destruct(), the mb_ereg() family (use PCRE with the u modifier), the is_double(), is_long(), is_integer() and doubleval() aliases, spl_object_hash() (use spl_object_id()), strcoll() and SORT_LOCALE_STRING, and let or is as names of classes, functions or constants.

To try it, PHP 8.6.0 is on the downloads page. Run your test suite with deprecations visible first; framework and package support for a new PHP version usually trails the release by days or weeks, so check your Composer dependencies before upgrading. The migration guide has the complete list of new features and incompatible changes. If you still have small legacy scripts around, such as our snippet for redirecting pages in PHP, they are the kind of code where old aliases tend to linger.

How it compares

Partial function application builds on first-class callable syntax (strlen(...)), which arrived in PHP 8.1: that syntax turned a function into a Closure with no arguments bound, and PHP 8.6 lets you bind some of them. Before clamp(), the usual way to keep a value in range was max($min, min($max, $value)); the new function also accepts any comparable value, including Duration.

Sources