Ehsan Bagherzadegan
Back to articles
7 min read

PHP 8.6 RC3: Partial Functions, Time\Duration, clamp(), and What Else Ships in November

PHP 8.6 RC3 locks in the feature set for the November 19 GA release. Partial function application cuts callback boilerplate, Time\Duration brings nanosecond precision without calendar baggage, and clamp() adds a missing range-constrain utility — plus extended #[Override], readonly defaults, and a native event-loop primitive.

PHP 8.6 RC3 arrived on October 8, 2026, bringing the feature set for the November 19 general availability release into focus. Release candidates only receive bug fixes from here, so what we see now is what ships in 8.6. The headline additions — partial function application, a nanosecond Time\Duration class, and a global clamp() function — address everyday pain points without adding complexity. There are also meaningful improvements to the override attribute, readonly properties, and a new event-loop primitive. Here is what matters for day-to-day work.

Partial Function Application

PHP 8.5 gave us the pipe operator (|>). PHP 8.6 gives us a natural companion: partial function application (PFA). Instead of writing arrow functions to bind some arguments and defer others, you use ? for a single missing argument and ... for the remaining ones.

// Before: arrow function boilerplate
$filtered = array_map(fn($s) => in_array($s, $allowed, true), $input);

// After: PFA with the ? placeholder
$filtered = array_map(in_array(?, $allowed, true), $input);

The ? placeholder binds exactly one argument. The ... placeholder binds zero or more remaining arguments, preserving their names and types.

function buildQuery(string $driver, string $table, array $where = [], array $orderBy = []): string { ... }

// Bind the first two arguments; the rest become a variadic closure
$usersQuery = buildQuery('mysql', 'users', ?, ...);
// $usersQuery is: fn(array $where = [], array $orderBy = []) => buildQuery('mysql', 'users', $where, $orderBy)

$sql = $usersQuery(['status' => 'active'], ['created_at' => 'DESC']);

You can mix positional and named arguments, and combine ? with ...:

// Named arguments work too
$withDefaults = someFunc(?, default: true, ...);
// fn($first, ...$rest) => someFunc($first, default: true, ...$rest)

The returned value is always a Closure with a proper signature, so type hints and reflection work as expected. This is not syntactic sugar over fn() — the engine builds the closure directly, which is slightly faster and preserves parameter metadata.

Where it shines: callbacks for array functions, middleware pipelines, route groups, and anywhere you currently reach for fn(...) => $callable(..., $fixedArgs). It pairs naturally with the pipe operator:

$clean = $raw
    |> trim(...)
    |> strtolower(...)
    |> filter_var(?, FILTER_VALIDATE_EMAIL);

Time\Duration: Nanosecond Precision Without Calendar Baggage

DateInterval couples a duration to calendar semantics (months, days, DST transitions). That makes it awkward for timeouts, retries, benchmarks, and rate limiting. Time\Duration is a final, readonly class that represents a fixed number of nanoseconds — no calendar awareness, just arithmetic.

use Time\Duration;

$timeout = Duration::fromMilliseconds(1500);
$backoff = $timeout->multiplyBy(2)->add(Duration::fromSeconds(1));
// 4 seconds exactly, no DST surprises

$limit = Duration::fromIso8601('PT1H30M');
Duration::compare($backoff, $limit); // -1 (backoff < limit)

Factories cover the common cases:

FactoryExample
fromNanoseconds(int $ns)Duration::fromNanoseconds(1_500_000_000)
fromMicroseconds(int $us)Duration::fromMicroseconds(1_500_000)
fromMilliseconds(int $ms)Duration::fromMilliseconds(1500)
fromSeconds(int $s)Duration::fromSeconds(4)
fromMinutes(int $m)Duration::fromMinutes(5)
fromHours(int $h)Duration::fromHours(1)
fromIso8601(string $iso)Duration::fromIso8601('PT1H30M')

Operations return new instances (immutable):

$d = Duration::fromSeconds(10);
$d->add(Duration::fromSeconds(5));       // 15s
$d->sub(Duration::fromSeconds(3));       // 7s
$d->multiplyBy(2);                       // 20s
$d->divideBy(4);                         // 2.5s (rounded to nanoseconds)
$d->neg();                               // -10s
$d->abs();                               // 10s

Comparison uses the static compare() method or the spaceship operator:

Duration::compare($a, $b); // -1, 0, 1
$a <=> $b;                 // same

Output properties give you the decomposed view:

$d = Duration::fromMilliseconds(1_500_000);
$d->seconds;        // 1500
$d->milliseconds;   // 1500000
$d->microseconds;   // 1500000000
$d->nanoseconds;    // 1500000000000

When to use it: timeouts, circuit breakers, retry backoff, benchmarking, rate limiters, scheduler intervals. When not to: anything involving calendar math (adding a month, handling DST) — stick with DateTime and DateInterval there.

clamp(): Constrain a Value to a Range

A small but surprisingly frequent utility: ensure a value sits between a floor and a ceiling.

clamp(5, 0, 100);     // 5
clamp(-5, 0, 100);    // 0
clamp(105, 0, 100);   // 100
clamp(10.0, 1.6, 4.2); // 4.2

It works with any types that support comparison, including objects:

$start = new DateTimeImmutable('2026-01-01');
$end   = new DateTimeImmutable('2026-12-31');
$input = new DateTimeImmutable('2026-06-15');

clamp($input, $start, $end); // returns $input unchanged
clamp(new DateTimeImmutable('2025-01-01'), $start, $end); // returns $start

If $min > $max or either bound is NAN, a ValueError is thrown. This fails fast rather than silently returning nonsense.

Common uses: pagination limits, image dimension clamping, coordinate bounding boxes, sanitizing user input ranges, progress percentages.

Extended #[Override] Attribute

Since PHP 8.3, #[Override] has protected you from accidentally breaking a parent method signature. PHP 8.6 extends it to class constants and enum cases:

class Base {
    public const string DEFAULT_LOCALE = 'en';
    public const int MAX_ITEMS = 50;
}

class Child extends Base {
    #[Override]
    public const string DEFAULT_LOCALE = 'de'; // OK

    #[Override]
    public const int MAX_ITEMS = 'fifty'; // Fatal error: type mismatch
}

For enums:

enum Status: string {
    case Draft = 'draft';
    case Published = 'published';
}

enum ExtendedStatus: string {
    #[Override]
    case Draft = 'draft'; // OK

    #[Override]
    case Archived = 'archived'; // Fatal: no such case in parent
}

This catches refactoring mistakes early — rename or remove a constant in the parent, and the child's #[Override] will error.

Readonly Properties with Default Values

Readonly properties could not have default values before. Now they can, and the default counts as the single initialization:

class Config {
    public readonly string $environment = 'production';
    public readonly int $timeout = 30;
}

$c = new Config();
// $c->environment === 'production'
// $c->timeout === 30

// Still immutable after construction
$c->environment = 'staging'; // Error: readonly property

You can still override the default in the constructor:

class Config {
    public function __construct(
        public readonly string $environment = 'production',
        public readonly int $timeout = 30,
    ) {}
}

new Config(timeout: 60); // timeout = 60, environment = 'production'

This removes the need for private properties with public getters when you want a sensible default but still want immutability.

Io\Poll: A Native Event Loop Primitive

Io\Poll is a low-level, object-oriented event loop abstraction. It selects the best backend automatically (epoll, kqueue, poll, event ports, WSAPoll) and exposes typed watchers for read, write, signal, and timer events.

use Io\Poll\Context;
use Io\Poll\Watcher\Readable;
use Time\Duration;

$ctx = new Context();

$watcher = new Readable(STDIN, function () {
    echo "Input ready\n";
});

$ctx->add($watcher);
$ctx->wait(Duration::fromSeconds(5));

This is not a full async framework — it's the primitive that async frameworks (ReactPHP, Amp, Swoole) can build on, or that you can use directly for simple event-driven scripts without pulling in a heavy dependency. The Duration integration is a nice touch: timeouts are type-safe and nanosecond-precise.

Other Notable Changes

SortDirection enum — a global, unbacked enum with Ascending and Descending cases. Useful for type-hinting sort direction in query builders and repository methods without string constants.

URI extension improvements — fluent builders for RFC 3986 and WHATWG URLs, with proper percent-encoding and host inspection. If you parse or build URLs manually, this is cleaner than parse_url().

Session INI defaults tightened — session.use_strict_mode=1, session.cookie_httponly=1, session.cookie_samesite=Lax are now the defaults. Most applications won't notice; if you rely on lax session handling, check your test suite.

Performance — stateless closure caching, compiled printf() and array_map() calls, faster JSON encoding, and a faster TAILCALL VM on Windows with Clang. These are free wins on upgrade.

Deprecations — NUL bytes in more functions now throw ValueError instead of truncating silently. The error_include_args INI setting is disabled by default (it could leak sensitive data in traces).

Upgrade Checklist

  • Test your test suite with error_reporting=E_ALL — stricter argument validation may surface latent bugs.

  • Verify session behavior if you override the new defaults.

  • Check for NUL-byte handling in file paths, headers, or database inputs.

  • If you maintain a library, add #[Override] to child constants and enum cases for forward compatibility.

  • Consider Time\Duration for any timeout/interval logic currently using DateInterval or raw integers.

What Didn't Land

True async (fibers-based) was cancelled. Automatic static closure inference was not merged — only stateless closure caching made it. The Time\Duration class does not yet integrate with DateTime/DateInterval; conversion is manual.

Bottom Line

PHP 8.6 is a "quality of life" release. Partial function application reduces callback boilerplate. Time\Duration gives you a proper type for timeouts and intervals. clamp() eliminates a common inline helper. The override extension and readonly defaults close long-standing gaps in the type system. None of these require rewriting code — they just make the code you write next cleaner.

RC4 is expected October 22, GA November 19. Now is the time to run your suite against RC3 and catch any regressions before they reach production.

Sources