PHP 8.6
Leave a ? now. Fill it in later.
Partial function application, a real Duration type, a modern polling API, clamp() and a long list of quality-of-life upgrades. Don't just read the changelog. Poke at it.
Time\Duration precision, across a range of ~292 yearsPartial function application
Call a function with some arguments missing and PHP hands you back a Closure that is waiting for the rest. ? stands for exactly one argument, and a trailing ... stands for everything else. Bound arguments are evaluated once, when the partial is created.
Build a partial
Pick a function, then decide for each argument: bind a value, leave a ?, or don't write it at all.
Made for the pipe operator
PHP 8.5's |> needs a callable that takes one argument. With ? you can aim the piped value at any parameter. Type something, toggle stages, reorder them.
clamp()
No more max($min, min($max, $value)) and squinting at which bound goes where. clamp() returns the value if it is inside the range, and the nearest bound if it is not.
clamp(2.5, 1.3, 3.4); // 2.5
clamp("a", "c", "g"); // "c"
clamp(
new DateTimeImmutable('2025-08-01'),
min: new DateTimeImmutable('2025-08-15'),
max: new DateTimeImmutable('2025-09-15'),
)->format('Y-m-d'); // 2025-08-15
Time\Duration
Was that timeout in seconds, milliseconds or microseconds? Duration is an immutable stopwatch value with nanosecond precision, so the unit lives in the type instead of a comment. Durations are comparable, which means min(), max() and clamp() just work.
Retry back-off, by attempt
Delay before each retry: base plus a step that doubles every attempt, capped at 30 seconds.
Show the data as a table
Duration::fromSeconds(1, nanoseconds: 500_000_000);
Duration::fromMilliseconds(250);
Duration::fromMinutes(5);
Duration::fromHours(1)->negate();
$d->add($other); $d->sub($other);
$d->multiplyBy(3); $d->divideBy(2);
$d->absolute();
$d->seconds; $d->nanoseconds; $d->negative;
usort($timings, Duration::compare(...));
The Io\Poll API
stream_select() re-checks every stream each time it wakes up, and typically tops out around 1,024 descriptors. The new polling API asks the operating system instead and only hands back the streams that are actually ready. It is a building block for event loops like ReactPHP and AMPHP, not an event loop itself.
stream_select()scans everythingIo\Poll\Contextonly what's readyConceptual illustration, not a benchmark. Each dot is a connection; yellow ones have data waiting.
An echo server on the new API
use Io\Poll\{Context, Event};
$server = stream_socket_server('tcp://0.0.0.0:8080');
$poll = new Context(); // picks epoll, kqueue, event ports or WSAPoll
$poll->add(new StreamPollHandle($server), [Event::Read]);
while (true) {
foreach ($poll->wait() as $watcher) {
$stream = $watcher->getHandle()->getStream();
if ($stream === $server) {
$client = stream_socket_accept($server);
$poll->add(new StreamPollHandle($client), [Event::Read]);
continue;
}
$data = fread($stream, 8192);
if ($data === '' || $data === false) {
$watcher->remove();
fclose($stream);
} else {
fwrite($stream, $data);
}
}
}
Five smaller wins, before and after
Not every feature needs a headline. These are the ones you'll quietly start using in the first week.
And there's more
Text that reverses properly, post-quantum crypto, safer sessions and a faster engine.
grapheme_strrev(): reverse what people see, not bytes
strrev() flips bytes, which shreds anything outside ASCII. The new function reverses whole grapheme clusters, so emoji and accents survive.
Will my code complain?
PHP 8.6 deprecates a batch of old aliases and footguns. Paste some PHP below for a quick first pass. It is a simple pattern match that runs entirely in your browser, so treat it as a hint and run a real static analyser before you upgrade.