PHP 8.6.0 was released on 19 November 2026. It is this year’s feature release and brings partial function application, a new \Time\Duration class, a native polling API, clamp(), a shared SortDirection enum, readonly property defaults and a long list of deprecations. On the same day the PHP team also shipped security releases for every supported branch, which matters even if you aren’t upgrading to 8.6 yet.
This guide covers the features you are most likely to use, the changes most likely to break something, and a practical upgrade checklist. Sources: the official PHP 8.6 release page and the php.net news archive.
First: patch your current PHP version today
Alongside 8.6.0, the PHP team released PHP 8.5.13, 8.4.28, 8.3.37 and 8.2.36, all marked as security releases. A day earlier the security team had announced that the highest severity in this batch is critical. Whatever version you run, update to the latest patch for your branch before planning a bigger migration:
php -v # check the running version
# Debian/Ubuntu (ondrej/php style packages)
sudo apt update && sudo apt install --only-upgrade 'php8.4*'
# Docker
docker pull php:8.4-fpm # rebuild and redeploy your images
Remember that PHP-FPM keeps the old binary until you restart it.
The headline features
Partial function application
You can now pre-fill some arguments of a function using ? (one argument) and ... (the rest) placeholders. The result is a Closure that runs the function once the remaining arguments arrive:
<?php
$versions = ['8.4', '8.5', '8.6', '8.7', '9.0'];
$supportsPfa = array_filter(
$versions,
version_compare(?, '8.6', '>='),
);
print_r($supportsPfa); // 8.6, 8.7, 9.0
It replaces many short arrow functions, and the release notes say array_map() with partial-application callbacks is now compiled into loops for better performance. We covered this feature in depth during the release candidate phase, so here we’ll focus on the rest.
\Time\Duration
Duration represents elapsed time like a stopwatch, independent of dates and time zones, with nanosecond precision over a range of more than 250 years. It’s ideal for timeouts, delays and benchmark timings:
<?php
use Time\Duration;
function backoff(Duration $base, Duration $step, int $attempt): void
{
$delay = $base->add($step->multiplyBy(2 ** $attempt));
// Durations are comparable, so min() works directly.
$delay = min($delay, Duration::fromSeconds(30));
time_nanosleep($delay->seconds, $delay->nanoseconds);
}
backoff(Duration::fromSeconds(1), Duration::fromMilliseconds(100), attempt: 3);
No more guessing whether an integer means seconds, milliseconds or microseconds.
clamp()
A tiny function that removes a very common max(min(...)) pattern:
<?php
var_dump(clamp(-10, 0, 100)); // int(0)
var_dump(clamp(50, 0, 100)); // int(50)
var_dump(clamp(110, 0, 100)); // int(100)
// Works with any comparable value, including Duration
$timeout = clamp(
\Time\Duration::fromSeconds(30),
min: \Time\Duration::fromMinutes(1),
max: \Time\Duration::fromMinutes(10),
);
var_dump($timeout->seconds); // int(60)
SortDirection enum
Libraries can now share one type-safe way to express sort order, with SortDirection::Ascending and SortDirection::Descending:
<?php
final class QueryBuilder
{
private array $orderBy = [];
public function orderBy(
string $column,
SortDirection $direction = SortDirection::Ascending,
): static {
$this->orderBy[] = $column . ' ' . match ($direction) {
SortDirection::Ascending => 'ASC',
SortDirection::Descending => 'DESC',
};
return $this;
}
}
(new QueryBuilder())->orderBy('name', SortDirection::Descending);
Passing an old constant like SORT_STRING now fails immediately with a TypeError instead of breaking deep inside the method.
Readonly property defaults
Readonly properties, including those in readonly classes, can declare a default value. That makes it easy to implement get-only interface properties:
<?php
interface Rule
{
public string $parser { get; }
}
final readonly class SlugRule implements Rule
{
public string $parser = SlugParser::class;
}
The default counts as initialization, so a constructor can’t overwrite it.
Io\Poll: scalable stream monitoring
The new polling API watches many streams at once using the best mechanism on each platform (epoll, kqueue, event ports or WSAPoll), avoiding the roughly 1,024-connection ceiling typical of stream_select(). It’s mainly a foundation for event-loop libraries such as ReactPHP and AMPHP, so most application developers will benefit indirectly once those libraries adopt it.
Structured stream errors
Stream operations can be configured to throw a StreamException carrying structured StreamError objects, instead of emitting warnings you suppress with @:
<?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($error->code->name . ': ' . $error->message);
}
}
Other useful additions
#[\Override]now works on class constants and enum cases.- Parameters can have their own DocComments, readable with
ReflectionParameter::getDocComment(). ReflectionProperty::isReadable()andisWritable()account for visibility, hooks and readonly state.- New
mysqli::quote_string(), matchingPDO::quote(). - JSON error messages now include the error location in the input.
- Sodium adds post-quantum key encapsulation (X-Wing and ML-KEM-768).
ZipArchive::openString()andcloseString()handle in-memory archives.
Changes most likely to bite
Read the full migration guide, but these items deserve a search through your codebase:
- Secure session defaults.
session.use_strict_modeandsession.cookie_httponlyare now on, andsession.cookie_samesitedefaults toLax. Cross-site POST flows and some SSO setups may need explicit configuration. returninsidefinallyis deprecated, as it silently discards exceptions.- Alias functions deprecated:
is_double(),is_long(),is_integer()anddoubleval(). Useis_float(),is_int()andfloatval(). spl_object_hash()is deprecated in favour ofspl_object_id().- mbstring regex functions such as
mb_ereg()andmb_split()are deprecated; use PCRE with theumodifier. trim()now strips form feed (\f) by default.fclose(),file_put_contents()andcopy()returnfalsewhen flushing or closing fails, instead of hiding the failure.- More
ValueErrors for out-of-range values, invalid flags or strings containing NUL bytes. letandisare deprecated as class, function or constant names.
A quick way to find some of these:
grep -rnE "is_double\(|is_long\(|is_integer\(|doubleval\(|spl_object_hash\(|mb_ereg|mb_split\(" src/
A practical upgrade checklist
- Patch your current branch to the 19 November security release.
- Add PHP 8.6 to your CI matrix and run tests with
error_reporting=E_ALLso deprecations show up. - Run static analysis (PHPStan or Psalm) targeting PHP 8.6.
- Rebuild or update PECL/PIE extensions for 8.6, and confirm your framework and key packages declare 8.6 support.
- Review session configuration and test login, SSO and payment-return flows.
- Deploy to staging, watch logs for new warnings and
ValueErrors, then roll out gradually.
Key takeaways
- PHP 8.6.0 is out with partial function application,
Duration,clamp(),SortDirection, readonly defaults andIo\Poll. - Security releases for PHP 8.2–8.5 shipped the same day, rated critical at the top end, so patch first.
- Session defaults,
finallyreturns and several deprecated aliases are the most likely sources of upgrade noise.
Full details are on the official PHP 8.6 release page and in the PHP manual’s migration guide.
