PHP 8.6 was released on November 19, 2026, and its headline features are partial function application (PFA), a new \Time\Duration class, an Io\Poll polling API, structured stream errors and a native clamp() function. Upgrading to PHP 8.6 is mostly smooth for modern codebases, but three changes deserve attention before you flip production: stricter session defaults, a long list of deprecations, and new ValueErrors where functions used to fail silently.

This guide covers what is new in PHP 8.6 with runnable examples, what breaks, how long each branch is supported, and a practical upgrade path with Composer, Rector and Docker. Everything below is checked against the official PHP 8.6 release page, the migration guide and the RFCs on wiki.php.net.

PHP 8.6 at a glance

Item Detail
Release date November 19, 2026 (8.6.0)
Active support until December 31, 2028
Security support until December 31, 2030
Headline features Partial function application, Time\Duration, Io\Poll, stream error handling, clamp(), SortDirection enum
Biggest upgrade risk Session INI defaults (use_strict_mode, cookie_httponly, cookie_samesite=Lax)
Official Docker tags php:8.6, php:8.6-fpm, php:8.6-apache, php:8.6-cli-alpine and more

If you skipped PHP 8.5, note that the pipe operator |> arrived in 8.5. PHP 8.6 is the release that makes it pleasant to use, because PFA lets you pipe into functions that take more than one argument.

What's new in PHP 8.6

Partial function application

Partial function application lets you call a function with some arguments filled in and placeholders for the rest. The result is a Closure that waits for the missing arguments. The PFA v2 RFC passed 33 to 0 and defines two placeholders:

  • ? stands for exactly one argument.
  • ... stands for zero or more remaining arguments and may only appear once, at the end.
<?php
// PHP 8.6+
$dashify = str_replace(' ', '-', ?);
echo $dashify('php 8.6 is out'), PHP_EOL; // php-8.6-is-out

$versions = ['8.4', '8.5', '8.6', '8.7', '9.0'];
$modern = array_filter($versions, version_compare(?, '8.6', '>='));
print_r($modern); // [2 => '8.6', 3 => '8.7', 4 => '9.0']

// Named placeholders work too
$debugJson = json_encode(?, flags: JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR);
echo $debugJson(['php' => '8.6']), PHP_EOL;

The generated closure inherits parameter names, types, defaults and by-reference status from the original function, so static analysers and IDEs can reason about it. Before 8.6 you wrote fn($s) => str_replace(' ', '-', $s); the PFA form is shorter and keeps the original signature metadata.

Three details matter in real code:

  1. Pre-bound arguments are evaluated immediately. In speak(?, getArg()), getArg() runs when the closure is created, not when it is called. That differs from an arrow function, which defers evaluation. If the argument has side effects or reads mutable state, keep the arrow function.
  2. Constructors are excluded. new Order(1, ?) is a compile error ("Cannot create Closure for new expression"). Use a static factory such as Order::make(1, ?) instead.
  3. Some functions cannot be partially applied: compact(), extract(), func_get_arg() and get_defined_vars() are excluded, as are __get and __set.

PFA plus the pipe operator

The pipe operator from 8.5 passes the left-hand value into a single-parameter callable. In 8.5 that meant wrapping anything with two or more parameters in an arrow function inside parentheses. With PFA, the ? marks where the piped value goes. This example is adapted from the functional operators page in the manual:

<?php
// PHP 8.6+
$result = "PHP Rocks"
    |> htmlentities(...)
    |> str_split(...)
    |> array_map(strtoupper(...), ?)
    |> array_filter(?, fn($letter) => $letter != 'O')
    |> implode('', ?);

echo $result, PHP_EOL; // PHP RCKS

And a more everyday case, building a slug:

<?php
$slug = '  PHP 8.6 Is Out  '
    |> trim(...)
    |> strtolower(...)
    |> str_replace(['.', ' '], '-', ?);

echo $slug, PHP_EOL; // php-8-6-is-out

The RFC also notes a performance detail: when a PFA call on the right of |> has a statically known arity of one (forms like foo(?), foo(1, ?) or foo(1, ...)), the compiler turns it into a direct call instead of allocating a closure. The release notes add that array_map() with first-class callables or PFA callbacks now compiles to loops.

The Time\Duration class

Time\Duration is a final readonly value object for elapsed time, like a stopwatch reading, with no clock or timezone attached. According to the release page it covers more than 250 years at nanosecond precision. The class reference lists factories (fromHours(), fromMinutes(), fromSeconds(), fromMilliseconds(), fromMicroseconds(), fromNanoseconds(), fromIso8601DurationString()), arithmetic (add(), sub(), multiplyBy(), divideBy(), negate(), absolute()) and the read-only properties seconds, nanoseconds and negative.

Durations are comparable with <, >, == and <=>, which is what makes them work with min(), max() and the new clamp():

<?php
use Time\Duration;

function retryDelay(int $attempt): Duration
{
    $base = Duration::fromMilliseconds(200);
    $delay = $base->multiplyBy(2 ** $attempt);

    return clamp($delay, min: Duration::fromMilliseconds(200), max: Duration::fromSeconds(30));
}

$delay = retryDelay(4);                 // 3.2 seconds
time_nanosleep($delay->seconds, $delay->nanoseconds);

If you have been passing timeouts around as int $ms or float $seconds, Duration removes a whole class of unit bugs.

clamp()

clamp(mixed $value, mixed $min, mixed $max): mixed returns $value if it falls between the bounds, otherwise the nearest bound. It works with anything comparable: ints, floats, strings, DateTimeImmutable and Duration.

<?php
echo clamp(-5, min: 0, max: 100), PHP_EOL;  // 0
echo clamp(55, min: 0, max: 100), PHP_EOL;  // 55
echo clamp(103, min: 0, max: 100), PHP_EOL; // 100

Edge cases from the manual: clamp() throws a ValueError if $min is greater than $max or if either bound is NAN, and a NAN value passes through unchanged. Mixing types (for example, a string against int bounds) uses PHP's standard comparison rules and can surprise you, so keep the types consistent.

Polling API (Io\Poll)

Io\Poll monitors many streams at once and picks the best native mechanism for the platform: epoll, kqueue, event ports or WSAPoll. It is intended as the foundation for event-loop libraries such as ReactPHP and AMPHP rather than for everyday application code, and it removes the descriptor limits that come with stream_select(). See the Poll API RFC for the full design. Unless you maintain an async library, the practical effect is that your event-loop dependencies may get faster and simpler in their next releases.

Structured stream errors

Stream operations can now throw a StreamException or fail silently instead of emitting warnings you have to suppress with @. Each error is a StreamError object with a StreamErrorCode enum case, the wrapper name and the path or URL.

<?php
$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) {
        error_log(sprintf('%s: %s (%s)', $error->code->name, $error->message, $error->wrapperName));
    }
}

The behaviour is opt-in per context, so existing code that checks for false keeps working.

Smaller language and library additions

  • SortDirection enum with Ascending and Descending cases, a shared type for sort order across libraries.
  • Readonly property defaults: instance readonly properties, including those in readonly classes, can declare a default value. The default counts as initialization, so the constructor cannot overwrite it.
  • Parameter DocComments, readable through ReflectionParameter::getDocComment().
  • ReflectionProperty::isReadable() and isWritable(), which account for visibility, asymmetric visibility, hooks and magic methods.
  • #[\Override] on class constants and enum cases, and enums can implement __debugInfo().
  • URI builders: Uri\Rfc3986\UriBuilder and Uri\WhatWg\UrlBuilder build on the URI extension that landed in 8.5.
  • Sodium post-quantum KEMs: X-Wing and ML-KEM-768, plus SHAKE and TurboSHAKE. If you are planning a post-quantum rollout, our guide to post-quantum TLS with Nginx and OpenSSL covers the transport side.
  • TLS streams support session resumption, external pre-shared keys and TLS 1.3 early data (0-RTT).
  • mysqli::quote_string(), matching PDO::quote().
  • JSON errors now include the location of the error in the input, which makes json_decode() failures far easier to debug.
  • ZipArchive::openString() and closeString() for in-memory archives, and grapheme_strrev() for grapheme-aware string reversal.

PHP 8.6 deprecations

Deprecations emit E_DEPRECATED notices in 8.6 and are candidates for removal in a future major version. The release announcement lists these as the most notable:

Deprecated Use instead
return inside a finally block Restructure control flow
Returning a value from __construct() or __destruct(), or making them generators Return nothing
let or is as class, function or constant names Rename
mb_ereg(), mb_split() and other mbstring regex functions (Oniguruma is unmaintained) PCRE with the u modifier
is_double(), is_long(), is_integer(), doubleval() is_float(), is_int(), floatval()
spl_object_hash() spl_object_id()
spl_classes() ReflectionExtension::getClassNames()
Objects passed where arrays are expected to array_walk(), http_build_query() and others get_object_vars() first
strcoll() and SORT_LOCALE_STRING intl Collator
Third argument to define() Remove it
More than 16 filters in a php://filter URL without filter.max_filter_count Set the INI value or reduce filters
Custom session handlers without both create_sid() and validateId() Implement both
metaphone(), mysqli_get_charset(), mysqli_stmt_init(), CSV methods of SplFileObject See the manual for each

Most of these are mechanical renames, which is exactly what Rector's PHP 8.6 set automates (covered below).

Backward-incompatible changes in PHP 8.6

The full list lives in Backward Incompatible Changes. These are the ones most likely to bite a typical web application.

Session defaults changed

This is the change most likely to cause a production incident:

  • session.use_strict_mode now defaults to 1 (was 0). Custom session handlers that accept externally supplied IDs must implement validateId() and create_sid(), or you must set the value back to 0.
  • session.cookie_httponly now defaults to 1. If front-end JavaScript reads the session cookie, it will stop working.
  • session.cookie_samesite now defaults to "Lax". Flows that rely on the session cookie arriving on a cross-site POST, such as some payment gateway or SSO callbacks, need "None" together with session.cookie_secure=1.

If your php.ini or framework already sets these explicitly, nothing changes. If you rely on defaults, test login, logout, SSO and any third-party POST-back flows before you deploy.

Silent failures now throw

Many functions throw ValueError where they used to truncate or ignore bad input:

  • NUL bytes in file paths for file_exists(), is_file(), filesize(), stat() and related functions, and in getenv(), putenv(), parse_str() and proc_open()'s cwd.
  • Invalid flag values in array_filter() (mode), array_change_key_case(), pathinfo() and scandir().
  • Out-of-range values in number_format() (decimals), sleep() and usleep().

fclose(), file_put_contents() and copy() also return false when flushing or closing fails, instead of hiding the error. That is a correctness improvement, but code that treated those calls as infallible may start taking error branches it never exercised.

Other changes worth testing

  • trim(), ltrim() and rtrim() strip form feed (\f) by default.
  • ?? and empty() on magic properties no longer call __get() if __isset() already wrote the property.
  • unpack() treats < and > after a format code as endianness modifiers, so "s<value" now yields key value, not <value.
  • preg_grep() returns false on a PCRE execution error instead of a partial array.
  • PDO_PGSQL resets session state (SET values, temporary tables) when the last object using a persistent connection is destroyed.
  • SplFileObject::fgets() no longer caches its line, which changes what current() returns afterwards.

PHP supported versions timeline

From php.net/supported-versions, as of November 2026:

Branch Released Active support until Security support until
8.2 Dec 8, 2022 Dec 31, 2024 Dec 31, 2026
8.3 Nov 23, 2023 Dec 31, 2025 Dec 31, 2027
8.4 Nov 21, 2024 Dec 31, 2026 Dec 31, 2028
8.5 Nov 20, 2025 Dec 31, 2027 Dec 31, 2029
8.6 Nov 19, 2026 Dec 31, 2028 Dec 31, 2030

Two dates matter this quarter: PHP 8.2 reaches end of life on December 31, 2026, and PHP 8.4 leaves active support on the same day and moves to security fixes only. If you are on 8.2, plan the jump now. Going straight to 8.5 or 8.6 is reasonable; the deprecations stack up, but Rector handles most of them in one pass.

How to upgrade to PHP 8.6

This is the sequence that works for most Composer-based projects. The same discipline applies to other runtime upgrades; our Node.js 26 upgrade guide and Python 3.15 upgrade guide follow the same pattern.

1. Check whether your dependencies allow 8.6

Ask Composer which packages block the new version:

composer why-not php 8.6.0

Each line names a package whose require.php constraint excludes 8.6. Upgrade those first, or open issues upstream. Then check the extensions your production image actually loads against your lock file:

composer check-platform-reqs --lock

2. Pin the platform version in composer.json

If your developers run a different PHP locally than production, set config.platform.php so Composer resolves dependencies for the production version:

{
  "require": {
    "php": "^8.6"
  },
  "config": {
    "platform": {
      "php": "8.6.0"
    }
  }
}

Run composer update --dry-run first to see how much moves, then a real composer update on a branch.

3. Let Rector do the mechanical work

Rector's source registers a PHP_86 version, an UP_TO_PHP_86 level set and a php86 flag for withPhpSets(). The Rector releases show 2.8.4 adding PHP 8.6 deprecated-alias renames and removing the deprecated third argument of define(), and 2.9.0 adding a min()/max()-to-clamp() rule to the PHP 8.6 set. Use 2.9.0 or newer:

composer require --dev rector/rector:^2.9
<?php
// rector.php
use Rector\Config\RectorConfig;

return RectorConfig::configure()
    ->withPaths([__DIR__ . '/src', __DIR__ . '/tests'])
    ->withPhpSets(php86: true);
vendor/bin/rector process --dry-run
vendor/bin/rector process

Review the diff carefully. Automatic clamp() folding only fires when Rector can prove min <= max, but you should still read every change. Pasting the before and after of a tricky file into a code difference checker makes review easier when your diff tool collapses long lines.

For PHP_CodeSniffer users: as of mid-November 2026, PHPCompatibility 10 is still in pre-release (10.0.0-alpha3 on Packagist), and its PHP 8.6 sniffs are partly on work-in-progress branches. Treat it as a second opinion, not a gate.

4. Run tests with deprecations visible

Make sure your test runner reports deprecations rather than hiding them. In PHPUnit, keep displayDetailsOnTestsThatTriggerDeprecations="true" in phpunit.xml, and in CI set error_reporting=E_ALL. Then fix, or knowingly baseline, everything that appears.

5. Audit php.ini for the session changes

Diff your effective configuration between the old and new runtime:

php -i > php85.txt          # on the old image
php -i > php86.txt          # on the new image
diff php85.txt php86.txt | grep -E 'session\.|error_|opcache'

Decide explicitly on session.use_strict_mode, session.cookie_httponly and session.cookie_samesite rather than inheriting the new defaults by accident.

6. Update Docker images

The official php image already ships 8.6.0 variants. php:8.6 tracks the newest 8.6 patch release on Debian trixie, and latest now points to 8.6 as well. Common choices:

# Web app behind Nginx
FROM php:8.6-fpm

# Smaller image for CLI workers
FROM php:8.6-cli-alpine

# Apache with mod_php
FROM php:8.6-apache

There are also -bookworm, -alpine3.23, -alpine3.24, -zts and -nts variants. Pin 8.6 (minor) rather than 8 or latest in production; 8 will silently move to 8.7 next year. Third-party extensions installed via PECL or docker-php-ext-install need to support 8.6, so build the image in CI before anything else.

7. Roll out gradually

Run PHP 8.6 on one worker pool or canary first, watch error logs for new ValueErrors and deprecations, and keep the previous image tag available for rollback. OPcache is reset by the new binary, so expect a short warm-up period after the switch.

Should you upgrade now?

Upgrade now if you are on 8.2 (security support ends December 31, 2026), if you start new projects, or if you write a lot of callback-heavy code that benefits from PFA and pipes. Wait for 8.6.1 or 8.6.2 if you depend on a framework or extension that has not declared 8.6 support yet, or if you have custom session handlers. That is a normal posture for a .0 release, not a criticism of 8.6. The same reasoning appears in our .NET 11 and C# 15 upgrade guide: new syntax is rarely urgent, end-of-life dates are.

Frequently Asked Questions

When was PHP 8.6 released?

PHP 8.6.0 was released on November 19, 2026. It receives active support (bug fixes) until December 31, 2028 and security fixes until December 31, 2030.

What is partial function application in PHP 8.6?

It lets you call a function with ? (one argument) or ... (the rest) placeholders and get a Closure back. For example, str_replace(' ', '-', ?) returns a closure that takes the subject string. Arguments you pass up front are evaluated when the closure is created.

Is PHP 8.6 backward compatible with PHP 8.5?

Mostly. The risky areas are the new session defaults (strict mode, HttpOnly cookies, SameSite=Lax), functions that now throw ValueError on invalid input, and the deprecation notices that will appear in logs and tests. Read the migration guide's incompatible-changes page before upgrading.

Does Rector support PHP 8.6?

Yes. Rector 2.x defines a php86 set (->withPhpSets(php86: true)) and an UP_TO_PHP_86 level set. Releases 2.8.4 and 2.9.0 added PHP 8.6 rules, including deprecated alias renames and a clamp() refactoring.

Which Docker image should I use for PHP 8.6?

Use php:8.6-fpm behind Nginx, php:8.6-apache for mod_php, or php:8.6-cli-alpine for workers. Pin the minor version (8.6) instead of 8 or latest so the image does not jump to 8.7 unexpectedly.

Should I skip PHP 8.5 and go straight to 8.6?

If you are on 8.3 or 8.4, going straight to 8.6 is fine: run Rector with the 8.5 and 8.6 sets, fix deprecations, and test. Skipping saves one full regression cycle.

Conclusion

PHP 8.6 is a strong release for code readability: PFA finally makes the 8.5 pipe operator practical, Duration and clamp() remove common helper functions, and stream errors stop hiding behind warnings. The upgrade work is concentrated in three places: session INI defaults, new ValueErrors and deprecations. Pin your Composer platform, run Rector's php86 set, diff php -i between images, and canary the rollout. And if you are still on PHP 8.2, the December 31, 2026 end-of-life date is the real deadline.