Development

PHP 8.6 Is Here: The Features Worth Knowing About (and What Might Break)

John Cuthbert 19 November 2026 7 min read

On 19 November 2026 the PHP team released PHP 8.6.0, the yearly feature release. Like most recent releases it doesn’t try to reinvent the language. It fills gaps that developers have been working around for years, deprecates some long-standing oddities, and tightens a few defaults in ways that will matter in production.

Below are the changes we think matter most for the platforms we work on every day: Magento Open Source, Adobe Commerce, WordPress, WooCommerce and Pimcore.

Partial function application

This is the headline feature. You can now call a function with placeholders for the arguments you don’t have yet, and PHP gives you back a Closure that takes the rest. ? stands in for exactly one argument. ... stands in for all the remaining ones.

function add(int $a, int $b, int $c = 0): int
{
    return $a + $b + $c;
}

$addOne = add(1, ?);
$addOne(5);        // 6

$addToOne = add(1, ...);
$addToOne(2, 3);   // 6

It works with any callable, including built-in functions. That’s where it really helps, because it gets rid of the throwaway arrow functions that pile up around array_map() and array_filter():

// Before
$clean = array_map(fn ($s) => str_replace(' ', '', $s), $skus);

// PHP 8.6
$clean = array_map(str_replace(' ', '', ?), $skus);
$supportsPfa = array_filter($versions, version_compare(?, '8.6', '>='));

It’s also quicker than it looks. PHP 8.6 compiles array_map() calls that use first-class callables or partial application down to plain loops, so the tidier version doesn’t cost you anything at runtime.

Readonly properties can finally have defaults

Since readonly properties arrived in PHP 8.1, they couldn’t declare a default value. That meant adding a constructor just to set a constant-like value. PHP 8.6 removes that restriction, including inside readonly classes:

final readonly class SlugRule implements Rule
{
    public string $parser = SlugParser::class;
}

One thing to note: the default counts as initialisation, so the property can’t be reassigned afterwards, not even in the constructor. Use a default when the value really is fixed, and keep constructor promotion for values that vary per instance.

clamp(): a one-liner everyone has written themselves

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

Every codebase we’ve worked on has a version of max($min, min($max, $value)) somewhere, often with the arguments the wrong way round. clamp() works on any comparable value, so you can use it for quantities, discount percentages, pagination limits and so on.

\Time\Duration: elapsed time without the guesswork

DateInterval has always been awkward for measuring time, because it mixes in calendar ideas like “a month” whose length depends on context. The new immutable \Time\Duration class is just a fixed length of time with nanosecond precision:

use Time\Duration;

$timeout = Duration::fromSeconds(2)->add(Duration::fromMilliseconds(500));

printf("%d.%09d seconds\n", $timeout->seconds, $timeout->nanoseconds);
// 2.500000000 seconds

var_dump($timeout > Duration::fromSeconds(2));
// bool(true)

Durations can be compared with the normal operators, so min() and max() work on them. That makes them a good fit for retry back-off, timeouts and rate limiting, which come up constantly in integration work:

$delay = min($delay, Duration::fromSeconds(30));
time_nanosleep($delay->seconds, $delay->nanoseconds);

It also has fromIso8601DurationString(), arithmetic (add, sub, multiplyBy, divideBy), and a compare() method you can pass straight to usort().

Io\Poll: a modern event loop foundation

stream_select() has long been the bottleneck for async PHP. It’s capped at 1,024 file descriptors and doesn’t scale well. The new Io\Poll API uses each operating system’s native mechanism (epoll on Linux, kqueue on macOS/BSD, event ports on Solaris, WSAPoll on Windows) and removes that cap.

Most application developers won’t use it directly. Its main audience is libraries such as ReactPHP and AMPHP, which can now build on a native core API instead of optional extensions. If you run long-lived workers, queue consumers or WebSocket servers in PHP, this is one of the biggest changes in the release, even though you’ll mostly see it through those libraries.

Streams can throw exceptions

File and network errors have always come through as warnings, which most code either suppresses with @ or misses entirely. Streams can now be set to throw a StreamException instead, with structured StreamError objects and a StreamErrorCode enum:

$context = stream_context_create(['stream' => [
    'error_mode' => StreamErrorMode::Exception,
]]);

Because this is opt-in per context, you can adopt it gradually. We’d start with outbound integrations, such as ERP feeds, PIM imports and payment callbacks, where a silent failure is the worst result.

Smaller additions worth a mention

  • SortDirection enum: a shared Ascending / Descending type. Expect frameworks and query builders to adopt it in place of 'ASC' strings.
  • #[\Override] on class constants and enum cases: you get a compile-time error if the constant you think you’re overriding doesn’t exist.
  • Changing objects held in constants: CONFIG->debug = true; now works where it used to be a fatal error.
  • Parameter DocComments, readable through ReflectionParameter::getDocComment(), plus ReflectionProperty::isReadable() / isWritable().
  • JSON errors now report where in the input the problem is. That’s a real help when debugging large API payloads.
  • Post-quantum cryptography in Sodium: ML-KEM-768 and X-Wing key encapsulation, along with SHAKE/TurboSHAKE.
  • TLS improvements: session resumption, external pre-shared keys and 0-RTT early data.
  • URI builders (Uri\Rfc3986\UriBuilder, Uri\WhatWg\UrlBuilder), building on the URI extension added in 8.5.
  • Faster printf() and JSON encoding, and stateless closures are now cached.

What might break

Session defaults are stricter

This is the change most likely to cause problems on upgrade day. Three php.ini defaults have changed:

SettingBeforePHP 8.6
session.use_strict_mode01
session.cookie_httponly01
session.cookie_samesiteunsetLax

These are sensible security defaults, but they can change behaviour:

  • Custom session handlers that accept externally supplied session IDs now need to implement validateId() and create_sid(). If they don’t, they trigger deprecation notices.
  • Any JavaScript that reads the session cookie will stop working.
  • SameSite=Lax means session cookies are no longer sent on cross-site POSTs. Payment gateways and SSO providers that POST back to your site are the classic example. Those flows need SameSite=None together with session.cookie_secure = 1.

If your platform manages its own cookie settings, these defaults may not affect you. Check what your stack actually does rather than assuming.

Deprecations to plan for

Deprecations don’t break anything yet, but they will fill your logs and need fixing before PHP 9:

  • return inside a finally block.
  • Returning a value from __construct() or __destruct().
  • The mb_ereg*() / mb_split() family. Switch to PCRE with the u modifier.
  • The alias functions is_double(), is_long(), is_integer() and doubleval().
  • spl_object_hash(). Use spl_object_id() instead.
  • strcoll() and SORT_LOCALE_STRING. Use intl’s Collator instead.
  • let and is as class, function or constant names, which suggests what may be coming to the language next.

Quieter behaviour changes

  • trim(), ltrim() and rtrim() now strip form feed (\f) by default.
  • fclose(), file_put_contents() and copy() now return false if the final flush or close fails. Code that ignored these return values may now see failures it never noticed before.
  • Many functions now throw ValueError for out-of-range arguments, invalid flags or embedded NUL bytes, where they used to warn or silently truncate.
  • preg_grep() returns false on PCRE errors instead of a partial array.

Should you upgrade?

Not straight away in production, but start testing now. For most businesses the right order is:

  1. Wait for your platform to support it. Magento, Adobe Commerce, WordPress, WooCommerce and Pimcore each publish their own supported PHP versions, and the main extensions and plugins usually take a little longer. Running an unsupported combination on a live store isn’t worth the risk.
  2. Run your test suite and static analysis against 8.6 in CI so you can see the deprecation list early.
  3. Check your session and cookie behaviour, especially around payment and SSO redirects.

Your current PHP version matters too. PHP 8.2 reaches end of life on 31 December 2026, so after six weeks from now it gets no more security fixes. If your site is still on 8.2 or older, that upgrade is the urgent one, and 8.6 can come later.

How Devsigh can help

We run PHP version upgrades for Magento, Adobe Commerce, WordPress and Pimcore sites as part of our development retainer and technical support services. That covers compatibility audits, extension and plugin remediation, and staged roll-outs that keep your live site stable. If you aren’t sure where your platform stands, get in touch and we’ll tell you how much work is involved.

Sources: PHP 8.6.0 release announcement, What’s new in PHP 8.6, PHP 8.6 migration guide.

John Cuthbert

Devsigh — commerce and technology specialists working directly with ambitious retail, hospitality, and B2B brands.

Ready to talk about your next project?