Talk to an engineer

PHP 8.6: new features, deprecations and how to upgrade

PHP 8.6 was released on November 19, 2026. Partial function application, the Duration class, the polling API and clamp(), every deprecation that will show up in your logs, and an upgrade plan that works.

SeaPHP engineering · December 1, 2026

PHP 8.6 was released on November 19, 2026. It is a large release for a minor version: partial function application changes how everyday code is written, two new standard types (Duration and SortDirection) arrive in core, and a polling API gives PHP a native event loop primitive for the first time. It also has a longer deprecation list than PHP 8.5, and a change to session defaults that deserves attention before you deploy.

This guide covers what is new with working examples, what will break or warn, how long 8.6 is supported, and how to plan the upgrade.

PHP 8.6 release date and support timeline

Date
Released November 19, 2026
Active support (bug fixes) until December 31, 2028
Security support until December 31, 2030

PHP now gives every release two years of active support and two years of security fixes, both ending on December 31. See the full PHP end-of-life timeline for every version.

Partial function application

The headline feature. You can now call a function with some arguments filled in and a ? placeholder for the rest, and PHP returns a closure that takes the missing arguments. It replaces most of the short arrow functions written only to fix one argument.

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

// Before: an arrow function to fix the second and third arguments
$current = array_filter($versions, fn ($v) => version_compare($v, '8.6', '>='));

// PHP 8.6: the ? marks the argument the callback receives
$current = array_filter($versions, version_compare(?, '8.6', '>='));

? stands for exactly one argument, and ... for all remaining arguments. Placeholders work with named arguments too, which makes partial application readable for functions with long parameter lists:

$waitBeforeRetry = backoff(
    Duration::fromSeconds(1),
    Duration::fromMilliseconds(100),
    attempt: ?,
);

$waitBeforeRetry($attempt);

It combines naturally with the pipe operator from PHP 8.5:

$slug = $title
    |> trim(...)
    |> strtolower(...)
    |> str_replace(' ', '-', ?);

The Duration class

\Time\Duration represents an amount of elapsed time with nanosecond precision, covering more than 250 years. It replaces the integer seconds, float milliseconds and ad hoc arrays that most code uses for timeouts, retries and measurements, and which are a common source of unit bugs.

use Time\Duration;

$timeout = Duration::fromSeconds(30);
$step = Duration::fromMilliseconds(250);

$delay = $step->multiplyBy(4)->add(Duration::fromSeconds(1));

// Durations are comparable, so min(), max() and clamp() work directly
$delay = min($delay, $timeout);

time_nanosleep($delay->seconds, $delay->nanoseconds);

Adopt it at the edges first: configuration values, HTTP client timeouts and retry policies. Those are where mixed units cause incidents.

clamp()

A small function that removes a lot of max(min(...)) code. It returns the value if it is within the range, or the nearest boundary if not, and works with any comparable values, including Duration.

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

clamp(
    Duration::fromSeconds(30),
    min: Duration::fromMinutes(1),
    max: Duration::fromMinutes(10),
)->seconds;          // 60

The polling API

Io\Poll lets one PHP process watch many streams at once using the best mechanism the operating system offers: epoll on Linux, kqueue on BSD and macOS, event ports on Solaris and WSAPoll on Windows. Until now that needed an extension such as ev or event, or the limited stream_select().

use Io\Poll\{Context, Event};

$server = stream_socket_server('tcp://0.0.0.0:8080');

$poll = new Context();
$poll->add(new StreamPollHandle($server), [Event::Read]);

while (true) {
    foreach ($poll->wait() as $watcher) {
        $stream = $watcher->getHandle()->getStream();
        // accept new clients, read from existing ones
    }
}

Most web applications will not use this directly. Frameworks and libraries for long-running PHP processes, such as queue workers, WebSocket servers and async runtimes, will, and should get simpler and faster as a result.

Exceptions for stream errors

Stream functions such as file_get_contents() and fopen() have always reported problems with warnings and a false return value. PHP 8.6 lets a stream context ask for exceptions instead, with structured error objects:

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

try {
    $config = file_get_contents('/etc/app/config.json', context: $context);
} catch (StreamException $e) {
    foreach ($e->getErrors() as $error) {
        $logger->error($error->message, ['code' => $error->code->name]);
    }
}

This removes the need for the @ operator and error_get_last() checks around file and network calls.

The SortDirection enum

PHP now has a built-in SortDirection enum with Ascending and Descending cases. Use it in your own APIs instead of strings or the SORT_ASC and SORT_DESC integers, and the type system rejects invalid values:

public function orderBy(string $column, SortDirection $direction = SortDirection::Ascending): static

Smaller additions worth knowing

  • Readonly properties can have default values, including in readonly classes.
  • Doc comments on parameters can be read with ReflectionParameter::getDocComment(), useful for API documentation generators.
  • ReflectionProperty::isReadable() and isWritable() answer whether a property can be read or written from a given scope, which matters with asymmetric visibility.
  • #[\Override] works on class constants and enum cases.
  • URI builders: Uri\Rfc3986\UriBuilder and Uri\WhatWg\UrlBuilder build on the URI extension added in PHP 8.5.
  • Sodium adds post-quantum key encapsulation (X-Wing and ML-KEM-768), plus SHAKE and TurboSHAKE.
  • TLS session resumption, external pre-shared keys and 0-RTT in the OpenSSL stream layer.
  • mysqli::quote_string(), JSON error messages that include the location of the error, and ZipArchive::openString().

Deprecations and breaking changes

These are what will appear in your logs. Deprecations do not break code yet, but each one is removed in a future version, and noisy deprecation logs hide real errors.

Language

  • return inside a finally block is deprecated.
  • Returning a value from __construct() or __destruct() is deprecated.
  • let and is as class, function or constant names are deprecated, which reserves them for future syntax. _ as a constant name and readonly as a function name are deprecated too.
  • A third argument to define() (case-insensitive constants) is deprecated.

Functions

  • is_double(), is_long(), is_integer() and doubleval() are deprecated. Use is_float(), is_int() and floatval(). These are easy to fix automatically and very common in older code.
  • spl_object_hash() is deprecated in favor of spl_object_id().
  • The mbstring regex functions, such as mb_ereg() and mb_split(), are deprecated. Use preg_* with the u modifier.
  • strcoll() and SORT_LOCALE_STRING are deprecated.
  • Passing an object where an array is expected to array_walk(), http_build_query() and some other functions is deprecated.
  • metaphone(), mysqli_get_charset(), mysqli_stmt_init() and the CSV methods of SplFileObject are deprecated.

Behavior changes that can break things

  • Session defaults are stricter: session.use_strict_mode and session.cookie_httponly are on by default, and session.cookie_samesite defaults to Lax. This is good for security, but applications that read the session cookie from JavaScript, or rely on cross-site POSTs carrying the session (some payment and single sign-on callbacks), will notice. Set these explicitly in php.ini before upgrading so the change is deliberate.
  • Custom session handlers that do not implement both create_sid() and validateId() are deprecated.
  • trim(), ltrim() and rtrim() also strip the form feed character by default.
  • fclose(), file_put_contents() and copy() now return false when the final flush or close fails, where they used to report success.
  • More functions throw ValueError for out-of-range values, invalid flags or NUL bytes in strings.

The full list is in the official PHP 8.6 migration guide.

How to upgrade to PHP 8.6

  1. Get to PHP 8.5 cleanly first. Upgrading one minor version at a time keeps each step small. If you are on 8.4 or older, see PHP 8.5: new features and what breaks.
  2. Check your dependencies. Run composer why-not php 8.6.0 to list packages whose constraints block 8.6. Frameworks usually support a new PHP version within weeks of release, but smaller packages can take months.
  3. Run static analysis against 8.6. PHPStan and Psalm flag most deprecated calls, and Rector rules can rewrite the mechanical ones, such as is_double() to is_float().
  4. Decide on session settings. Set session.use_strict_mode, session.cookie_httponly and session.cookie_samesite explicitly, test login, logout and any cross-site callback flows.
  5. Run the test suite on 8.6 with deprecations logged, and fix what it reports. Then run production traffic on a canary before switching everything.
  6. Wait for the first bug-fix releases for business-critical systems. A new minor version's early patch releases fix the bugs that real-world use finds.

Should you upgrade now?

If you are on PHP 8.4 or 8.5, there is no rush: both are supported until the end of 2028 and 2029. Plan 8.6 into the next quarter, after your dependencies declare support.

If you are on PHP 8.2, security support ends on December 31, 2026, a few weeks from now. That upgrade is urgent; read PHP 8.2 end of life. If you are on PHP 8.1 or older, you are already past community end of life, and upgrading straight to 8.6 is usually a multi-step project. We run those upgrades one version at a time, and cover the old version with SeaPHP LTS while the work happens.

Find out what your PHP estate needs

Tell us which versions you run and where. An engineer replies within one business day.