Skip to content
PHP

What's New in PHP 8.6: Every Feature You Need to Know

PHP 8.6 lands on November 19, 2026, bringing partial function application, a clamp() function, a Duration class, readonly property defaults, a polling API, and more. Here's a full breakdown.

Published · Updated · 3 min read

What's New in PHP 8.6: Every Feature You Need to Know

PHP 8.6 is scheduled for general availability on November 19, 2026, and it's shaping up to be one of the most feature-rich releases in recent memory. The release is currently in beta, with a feature freeze on September 22 and RC 1 on September 24. Release managers are Daniel Scherzer, Matteo Beccati, and Joe Ferguson.

Here's a rundown of every significant addition.

Partial Function Application

Partial function application (PFA) lets you pre-fill some arguments of a function and receive a closure that accepts the rest. Use ? as a placeholder for a single argument, or ... for all remaining arguments:

$makeSlug = str_replace(' ', '-', ?);
$makeSlug('Hello World'); // Hello-World

$titles = array_map(strtolower(?), $titles);

Arguments supplied at creation time are evaluated immediately, not at call time. Every ? placeholder becomes a required parameter on the resulting closure, even if the original parameter was optional. The v2 RFC passed 33–0.

The clamp() Function

The new clamp() function constrains a value between a minimum and maximum, replacing the error-prone min(max($value, $min), $max) pattern:

clamp(10,  min: 0, max: 100); // 10
clamp(101, min: 0, max: 100); // 100
clamp(-1,  min: 0, max: 100); // 0

It works with any comparable type, including strings and DateTime objects. Passing $min > $max throws a ValueError.

A Duration Class

Time\Duration is a new final readonly class representing a length of time with nanosecond precision. It supports factory methods, arithmetic, ISO 8601 strings, and comparison operators:

use Time\Duration;

$oneSecond  = Duration::fromSeconds(1);
$halfSecond = $oneSecond->divideBy(2);
$total      = $oneSecond->add($halfSecond);

$delay = Duration::fromMilliseconds(100)->multiplyBy(2 ** $attempt);
$total > $delay; // comparison operators work

The class is designed as a shared type for core functions and the new polling API.

Readonly Property Defaults

Readonly properties can now carry a default value — previously a compile-time error:

final readonly class CreateBooksTable implements Migration
{
    public string $name = '2026_01_01_create_books_table';
}

Readonly semantics are unchanged; the property still cannot be reassigned after initialization.

DocComments for Function Parameters

Doc comments can now be placed directly on individual parameters, and ReflectionParameter::getDocComment() returns them:

function search(
    /** Terms to search for in the database */
    string $query,
    /** Maximum number of entries to return */
    int $limit = 10,
): array {}

A Polling API

The Io\Poll namespace provides a unified interface to platform-native polling (epoll, kqueue, WSAPoll). It replaces stream_select() for event loops and async runtimes:

use Io\Poll\{Context, Event, StreamPollHandle};

$poll   = new Context();
$server = stream_socket_server('tcp://0.0.0.0:8080');
stream_set_blocking($server, false);
$poll->add(new StreamPollHandle($server), [Event::Read], ['type' => 'server']);

while (true) {
    foreach ($poll->wait(1) as $watcher) {
        if ($watcher->hasTriggered(Event::Read)) {
            // accept the connection
        }
    }
}

Other Notable Additions

  • SortDirection enum — a built-in Ascending/Descending enum so libraries stop defining their own.
  • Enums can implement __debugInfo() — customize var_dump() output on backed enums.
  • Stream error handling — a new error_mode context option and StreamException replace scattered warnings.
  • URI builder classes — fluent UriBuilder added to the URI extension introduced in PHP 8.5.
  • Secure session defaults — session.use_strict_mode, session.cookie_httponly, and session.cookie_samesite all default to safer values on new installations. Laravel-managed sessions are unaffected.

Key Takeaways

  • Partial function application finally lands after a 2021 rejection, passing 33–0 on the second attempt.
  • clamp() eliminates a common, easy-to-get-wrong pattern.
  • Time\Duration gives the ecosystem a standard type for time lengths.
  • The polling API lays groundwork for better async support in PHP's core.
  • Readonly properties with defaults unblock interface patterns introduced in PHP 8.4.
  • Session security defaults improve out-of-the-box safety for apps not using a framework.

Source: What's New in PHP 8.6 — Laravel News

Frequently asked questions

When is PHP 8.6 released?

PHP 8.6 is scheduled for general availability on November 19, 2026. The feature freeze is September 22, 2026, and RC 1 ships September 24, 2026.

Does PHP 8.6's new secure session defaults affect Laravel applications?

No. Laravel manages its own session cookies independently of php.ini session settings, so the new defaults for session.use_strict_mode, session.cookie_httponly, and session.cookie_samesite do not affect most Laravel apps. Only applications using native PHP sessions and relying on the old defaults need to review the change.

What is partial function application in PHP 8.6 and how does it work?

Partial function application lets you call a function with some arguments pre-filled and receive a closure for the rest. Use ? as a placeholder for each argument you want to supply later. Pre-filled arguments are evaluated at creation time, and every ? placeholder becomes a required parameter on the resulting closure.

Mohamed Said

About the author

Senior Backend Engineer specializing in Laravel, scalable SaaS platforms, APIs, and cloud infrastructure. I build secure, high-performance web applications that help businesses grow.

About GitHub LinkedIn WhatsApp Email Address My CV

Have a technical challenge?

Tell me what you’re building. I reply within two working days.

Discuss your project