Partial application, clamp(), Duration, readonly defaults and the polling API, with before-and-after examples for the code you already have.
Picture a helpers file that has sat in your Laravel app since 2019. Four lines, function clamp($value, $min, $max), wrapped in nothing, because nobody expected PHP to ship its own. On November 19, PHP 8.6 did. Your Dockerfile moves from php:8.5-fpm to php:8.6-fpm in a routine base-image bump, and the app dies at boot with a redeclare error before it has used a single feature of the release. One write-up of the release puts the rule plainly: clamp is now a reserved function name, so a global function with that name has to be renamed or guarded.
That’s the less glamorous half of this release, and it’s worth having in your head before the feature tour. PHP 8.6 brings partial function application, a built-in clamp(), a Time\Duration class, default values for readonly properties and a native polling API. Some of them will change how you write everyday Laravel code. One will change nothing in your app directly, and one overlaps with something Laravel already ships. I’ll say which is which, because “five features that will change how you write code” is true of some of them, and the useful part of a post like this is the sorting.
What this is built from. The feature descriptions and the before-and-after examples come from the official release page on php.net and the RFCs it links. The Laravel-specific claims come from Laravel’s docs, its release notes and pull requests. The quotes are from named people in public RFCs, a mailing-list reply, and blog posts, and each is short and labeled with where it came from. I haven’t run the code below on PHP 8.6, so treat the Laravel examples as sketches to check against your own app, and I’ve marked the places where I couldn’t confirm something.
Where Laravel Stands, and Why Not to Upgrade for Speed
Two facts frame everything else. First, Laravel doesn’t officially support PHP 8.6 yet as far as I could tell. The Laravel 13 documentation lists PHP 8.3 through 8.5, and one write-up reports that the framework’s support pull request (#61771) was ready for review on November 20 but not merged. Check its current state before you point production at 8.6. Laravel’s composer.json allows ^8.3, so Composer won’t stop you from installing on 8.6, which is exactly why you shouldn’t treat “it installs” as “it’s supported.”
Second, 8.6 won’t make your app faster. Tideways’ framework benchmark ran Laravel 13 at 15 concurrent users and measured 778.5 requests per second on PHP 8.4, 792.7 on 8.5 and 792.3 on 8.6. That’s flat between the last two versions. The release page does list engine work, including faster printf() calls, cached stateless closures, and compiling array_map() calls that use first-class callables or partial application into loops. Those help microbenchmarks. A request that spends its time waiting on MySQL doesn’t notice.
So the case for 8.6 is code clarity, not throughput. Here is how the five features sort for a Laravel codebase:
| Feature | What it replaces | Laravel impact | Adopt when |
|---|---|---|---|
| Partial function application | Tiny wrapper closures | Daily, in array_map, pipes, callbacks | After CI passes on 8.6 |
clamp() | max(min()) nesting | Smaller than the headline: Number::clamp() already exists | Immediately for non-numeric values; check the name collision first |
Time\Duration | Integers in mixed units | Useful in your own domain code, not yet in Laravel’s own APIs | New code, with edge conversions |
| Readonly property defaults | Constructors that only assign constants | Value objects, contract implementations | New code, but not blindly |
Polling API (Io\Poll) | stream_select() loops | None directly; library authors benefit | When your libraries adopt it |
1. Partial Function Application
Partial function application lets you call a function with some arguments filled in and get back a closure that waits for the rest. You mark each missing argument with ?, or the remaining ones with .... Larry Garfield and Arnaud Le Blanc’s RFC passed 33 to 0, and the language now has it.
// ❌ Before: a wrapper closure whose only job is to forward an argument
$slugs = array_map(fn (string $title) => Str::slug($title, '_'), $titles);
// ✅ PHP 8.6: the same thing, with the gap marked
$slugs = array_map(Str::slug(?, '_'), $titles);
The RFC’s own pitch, in Garfield’s words on the PHP Foundation’s blog, is that it finishes a job another feature started:
“FCC has clearly shown itself to be a huge boon to the language” — Larry Garfield, The PHP Foundation blog, December 2025, on first-class callable syntax and why partial application was the natural next step
The concept is old, and the plainest definition I found is Garfield’s from a 2021 episode of Derick Rethans’ PHP Internals News, discussing an earlier version of the proposal:
“making a new function that pre fills some of those parameters” — Larry Garfield, PHP Internals News episode 89 (transcript), 2021
It pairs naturally with the pipe operator from PHP 8.5, because a pipe stage needs a callable that takes exactly one argument, and ? produces one on demand:
// ❌ Before
$slug = Str::slug(trim($title), '_');
// ✅ PHP 8.6: reads in the order things happen
$slug = $title
|> trim(...)
|> Str::slug(?, '_');
Placeholders can be named, which the release page uses to preconfigure everything except one argument:
$waitBeforeRetry = backoff(
Duration::fromSeconds(1),
Duration::fromMilliseconds(100),
attempt: ?,
);
$waitBeforeRetry($attempt);
The Laravel Gotchas
Collections hand your callback two arguments. Collection::map() calls its callback with the value and the key. That’s why ->map(trim(...)) has always been a trap: trim() treats the key as its list of characters to strip, and the call quietly does nothing useful. A partial like trim(?) pins the call shape, and that may well behave better here, but I haven’t verified how a partial’s closure handles surplus arguments. Test it on a collection before you refactor a pile of callbacks.
foo(?, 1) and foo($x, 1) differ by one character. That’s the real readability risk. In review, a placeholder is easy to read past, so establish a habit early, such as naming the closure variable ($slugify = Str::slug(?, '_')) rather than passing partials inline everywhere.
The optional-parameter rules were still being adjusted. The original design had a placeholder inherit whether its parameter was optional. A follow-up RFC from Tim Düsterhus, Arnaud Le Blanc and Garfield argued that approach was flawed:
“inconsistent user-facing behavior” — the authors of the follow-up RFC on optional placeholder parameters, wiki.php.net
That RFC was in a vote in the version I could read (April 2026), and I couldn’t confirm the outcome. If you partially apply functions that have optional parameters, read the manual’s page on partial application for how 8.6.0 actually behaves, instead of assuming.
2. clamp(): Smaller for Laravel Than the Headline Suggests
clamp() returns a value if it’s within bounds, and otherwise the nearest bound. It works with any comparable values, which the release page demonstrates with the new Duration class.
// ❌ Before: easy to nest the wrong way round
$perPage = max(1, min(100, $request->integer('per_page', 15)));
// ✅ PHP 8.6
$perPage = clamp($request->integer('per_page', 15), min: 1, max: 100);
The honest Laravel take is that you already had this for numbers. Number::clamp() has shipped since Laravel 10.40, and a pull request (#58608) added a clamp() method to request input handling, so check your version’s docs for that one. For plain numbers, nothing forces a change:
use Illuminate\Support\Number;
$perPage = Number::clamp($request->integer('per_page', 15), min: 1, max: 100);
Where native clamp() earns its place is non-numeric values, since it follows PHP’s normal comparison rules:
// Keep a requested date range inside what the report supports
$from = clamp($requestedFrom, min: $reportStart, max: $reportEnd);
It returns one of the values you passed in. With objects, that’s the same instance, not a copy. If $requestedFrom is a mutable Carbon, mutating the result can mutate your boundary. Use CarbonImmutable, or copy before you change anything.
The Name Collision From the Top of This Post
grep -rn "function clamp" app/ bootstrap/ routes/ database/
grep -rln "function clamp" vendor --include=*.php
If either finds something, think twice before wrapping it in if (! function_exists('clamp')). On 8.6 that guard is always true, so your helper is skipped and the native function takes over. That’s fine if your helper had the same parameter order. If it was clamp($min, $max, $value) or anything else, every call now silently computes something different. Rename it. And per the sources I read, Laravel already depends on symfony/polyfill-php86, which backports clamp() for older PHP; check with composer why symfony/polyfill-php86 before you rely on that.
3. Time\Duration: One Type for the Three Units You Keep Mixing Up
Time\Duration is an immutable value object representing elapsed time as a stopwatch would measure it, with nanosecond precision and a range of more than 250 years. It carries no timezone and no calendar. You create one with a factory and combine it with methods:
use Time\Duration;
function retryDelay(int $attempt): Duration
{
$delay = Duration::fromMilliseconds(200)->multiplyBy(2 ** $attempt);
// Durations are comparable, so min() works directly
return min($delay, Duration::fromSeconds(30));
}
The problem it solves is one every Laravel codebase has:
// ❌ Before: three call sites, three units
usleep(min($delayMicros, 30_000_000)); // microseconds
retry(5, $send, min(intdiv($delayMicros, 1000), 30_000)); // milliseconds
public $backoff = [10, 30, 60]; // seconds, in a queued job
Nothing in those lines tells you which unit a value is in. Mix them up and a retry waits 1,000 times too long or too short, and no test notices until production does.
Laravel’s own APIs still take plain numbers or CarbonInterval, so Duration doesn’t plug into retry() directly. Use it inside your own domain code and convert at the edge, using the seconds and nanoseconds properties the release page documents:
// ✅ Keep durations as Duration internally; convert where Laravel wants a number
function toMilliseconds(Duration $duration): int
{
return $duration->seconds * 1000 + intdiv($duration->nanoseconds, 1_000_000);
}
retry(5, $send, fn (int $attempt) => toMilliseconds(retryDelay($attempt)));
That helper is my sketch. Check the manual for any convenience methods before you write your own.
It doesn’t replace CarbonInterval. Duration is deliberately calendar-free, so “one month” isn’t something it can express, while CarbonInterval can. Laravel keeps using CarbonInterval in APIs such as the slow-job callbacks added in 13.40. Think of Duration as the right type for timeouts, delays and benchmarks, and Carbon as the right one for anything tied to a calendar.
4. Readonly Property Defaults
Until now, a readonly property couldn’t have a default value, which forced fixed values into constructors. PHP 8.6 lifts that restriction. The author of the RFC, Nick Sdot, put the intent this way:
“constant-like behaviour with contract” — Nick Sdot, author of the Readonly Property Defaults RFC
It’s most useful when you implement an interface whose properties are get-only, which PHP 8.4’s property hooks made possible:
interface ExportFormat
{
public string $extension { get; }
public string $mimeType { get; }
}
// ❌ Before: a constructor that exists only to assign constants
final readonly class CsvFormat implements ExportFormat
{
public string $extension;
public string $mimeType;
public function __construct()
{
$this->extension = 'csv';
$this->mimeType = 'text/csv';
}
}
// ✅ PHP 8.6
final readonly class CsvFormat implements ExportFormat
{
public string $extension = 'csv';
public string $mimeType = 'text/csv';
}
The Trap: The Default Is the Initialization
The release page says it explicitly: the default counts as the property’s initialization, so the constructor cannot overwrite it. That means this code is now an error, not a configurable default:
// ❌ Fatal: the default already initialized it
final class ExportLimits
{
public readonly int $rows = 5000;
public function __construct(int $rows)
{
$this->rows = $rows; // Error: Cannot modify readonly property
}
}
// ✅ If it should be configurable, use a promoted constructor parameter
final class ExportLimits
{
public function __construct(
public readonly int $rows = 5000,
) {}
}
A readonly default is for values that never vary, like the format constants above. A value that’s merely a sensible starting point belongs in a promoted constructor parameter. One of the automated refactoring sets I saw mentioned for 8.6 reportedly moves constructor assignments into readonly defaults, so review what an automated tool proposes against this rule before you accept it in bulk.
Eloquent models are mutable by design, so this is for the objects around them: value objects, DTOs, rule and strategy classes, and anything implementing a hooked interface.
5. The Polling API: A Foundation, Not a Feature You’ll Call
Io\Poll watches many streams at once using the best mechanism each platform offers (epoll, kqueue, event ports or WSAPoll), without the connection limit that stream_select() is known for. The release page positions it as a base for event-loop libraries such as ReactPHP and AMPHP. Here is the shape of the API, trimmed from the release page’s example:
use Io\Poll\{Context, Event, StreamPollHandle};
$poll = new Context(); // picks epoll, kqueue, event ports or WSAPoll
$poll->add(new StreamPollHandle($server), [Event::Read]);
while (true) {
foreach ($poll->wait() as $watcher) {
// handle readable streams
}
}
Its author, Jakub Zelenka, was explicit in the RFC about what it isn’t:
“it provides polling capabilities, not a complete event loop” — Jakub Zelenka, author of the Polling API RFC
Brent Roose, in his tour of the release on stitcher.io, drew the practical conclusion:
“doesn’t come with a built-in event loop” — Brent Roose, stitcher.io, on the new polling API
So a typical Laravel request handler has no reason to call it. The effect shows up one layer down. The Revolt event loop’s 1.1.0 release added a driver on Io\Poll that’s used automatically on 8.6 when the uv, ev and event extensions aren’t installed, which removes the stream_select() file-descriptor limit. Laravel’s Reverb WebSocket server runs on ReactPHP’s event loop, and I couldn’t confirm whether ReactPHP has adopted Io\Poll yet, so I won’t claim Reverb gets faster. To see what sits under your own stack:
composer why react/event-loop
composer why revolt/event-loop
The API is also still growing. Zelenka has proposed follow-up additions (timer, signal and process handles, and handles that don’t keep a stream alive), which were under discussion when I read them, so they aren’t part of 8.6. Sebastian Bergmann, the creator of PHPUnit, replied on the php.internals list to that follow-up proposal, not to what shipped:
“an amazing improvement” — Sebastian Bergmann, replying to the Polling API Additions RFC on php.internals
The Upgrade Checklist for a Laravel App
Run through these in order, and do them in CI, not on production.
- Check what pins PHP.
composer why-not php 8.6.0lists the packages holding you back. - Hunt for the
clamp()collision. Use the two greps in section 2, includingvendor. - Grep for the deprecations most likely to hit you. The release page lists these among the deprecated or changed functions:
spl_object_hash(), theis_integer(),is_long(),is_double()anddoubleval()aliases, themb_ereg*family,metaphone(), andstrcoll().grep -rnE "spl_object_hash|is_integer\(|is_long\(|is_double\(|doubleval\(|mb_ereg|mb_split|metaphone\(|strcoll\(" app/ src/ - Check the behavior changes that don’t raise notices.
trim(),ltrim()andrtrim()now also strip form feed characters by default, andfclose(),file_put_contents()andcopy()now returnfalsewhen flushing or closing fails. Anything that compares trimmed input, or ignores those return values, deserves a look. - Read the session change with Laravel in mind. PHP 8.6 makes
session.use_strict_modeandsession.cookie_httponlydefault to on andsession.cookie_samesitedefault toLax. Laravel sets its session cookie fromconfig/session.phprather than from PHP’s native session settings, so these defaults mostly shouldn’t touch a stock Laravel session. That’s my reading of the architecture, so verify it in a test. Packages or code that call nativesession_start()are the ones to look at. - Run the suite on the official image (
php:8.6-cli), and wait for Laravel’s support to land before production.
What to Adopt, and When
PHP 8.6 CI is green and Laravel support is merged?
├─ No → Stay on 8.5 in production. Fix deprecations and the clamp() collision now.
└─ Yes → New code first, then refactor deliberately:
├─ Partial application → pipes and array_map first; test Collection callbacks
├─ clamp() → dates, durations, strings; Number::clamp() is fine for numbers
├─ Time\Duration → your own retry, timeout and delay code; convert at Laravel's edges
├─ Readonly defaults → fixed-value classes only; configurable values stay in constructors
└─ Io\Poll → do nothing; watch your event-loop libraries' release notes
The Verdict
The headline here isn’t speed and it isn’t a rewrite. It’s a handful of things you were already writing by hand, now with names: the forwarding closure, the nested max(min()), the integer that might be milliseconds or microseconds, the constructor that only assigns constants. Three of the five change what you type this month, one overlaps with a Laravel helper you may already use, and the polling API changes your code not at all. The risk in this release isn’t the features. It’s the quiet stuff around them: a reserved function name that turns a four-line helper into a fatal error, a readonly default that silently stops a constructor from configuring it, and a framework that doesn’t officially support the new version yet. Upgrade CI first, find your clamp() before it finds you, adopt the features in new code, and leave production on the version Laravel supports until Laravel says otherwise.
