Check the planks before you cross

A lot of PHP code is made of tiny helpers. Each one calls a function with a setting or two already filled in. One pads every name to an identical width, another sorts a list in a fixed order and a third waits a set time before a retry. They wrap one useful statement in a few lines of fuss, and every wrapper is a new place for a typo to hide.

PHP 8.6 came out on November 19, 2026, and its biggest feature cuts most of that clutter away. You can now call a function with some arguments filled in and a question mark where the rest go. Instead of running it, PHP hands you back a shortcut you can use later. The release adds a proper type for lengths of time and a short way to keep a number inside a range. And it turns a list of old habits into warnings, so the upgrade needs a plan.

Fill In the Arguments You Know Now

Partial function application means supplying some arguments ahead of time and leaving blanks for the rest. In PHP 8.6, a call with a ? placeholder in it doesn’t execute right away. You get back a closure, PHP’s name for a function you can store in a variable and use later, and the original code runs once you pass in the missing pieces. A ? stands for exactly one value, while ... covers “any arguments that are left.”

Here’s the kind of callback almost every PHP project has:

$names = ['Ada', 'grace', 'LINUS'];

// Before: an arrow function whose only job is to fix two arguments
$padded = array_map(fn($s) => str_pad($s, 8, '.'), $names);

// After: the ? marks the one argument array_map() will supply
$padded = array_map(str_pad(?, 8, '.'), $names);

Both lines produce the same array. The second one drops the made-up $s variable, and the call reads exactly like the function it wraps, so the eye goes straight to the part that matters: pad to 8 with dots.

Placeholders work with named arguments, so you can fill in the ones whose order you never remember:

$toCsvLine = implode(separator: ',', array: ?);
echo $toCsvLine(['id', 'name', 'email']); // id,name,email

A trailing ... leaves the rest of the list open and forwards however many inputs you hand over. Here it layers any number of overrides on top of a base config:

$config = array_replace(['timeout' => 30, 'retries' => 3], ...);

echo json_encode($config(['retries' => 5]));
echo json_encode($config(['timeout' => 10], ['retries' => 1]));
{"timeout":30,"retries":5}
{"timeout":10,"retries":1}

Partials Make Pipes Easier to Read

PHP 8.5, released in November 2025, added the pipe operator |>. It takes the value on its left and passes it to the function on its right, so you can list a series of steps from top to bottom instead of nesting them inside each other.

The catch is that a pipe delivers only one input, and str_replace() needs three: the text to find, its replacement and the string to search. In 8.5 you had to wrap it in an arrow function that held the first two:

$title = ' PHP 8.6 Released ';

$slug = $title
    |> trim(...)
    |> (fn($s) => str_replace(' ', '-', $s))
    |> (fn($s) => str_replace('.', '', $s))
    |> strtolower(...);

With 8.6 you write those two settings directly into the call and put a ? where the piped string belongs:

$slug = $title
    |> trim(...)
    |> str_replace(' ', '-', ?)
    |> str_replace('.', '', ?)
    |> strtolower(...);

var_dump($slug);
string(15) "php-86-released"

Each line now names one step: trim the ends, swap spaces for hyphens, drop the dot and lowercase everything. PHP compiles partials like these into direct calls, so the tidier version costs nothing extra to run.

Know When Your Arguments Run

The two styles differ in timing. An arrow function runs everything in its body each time you call it.

A partial runs the expressions you filled in right away, on the line that creates it, and saves the results for later.

Share One Value Across a Batch

Every row in an import should carry the same batch ID, so you can find or undo the whole thing later:

function newBatchId(): string {
    return bin2hex(random_bytes(4));
}
function tagRow(string $name, string $batch): string {
    return "$batch:$name";
}
$names = ['Ada', 'Grace', 'Linus'];

// Arrow function: a new ID for every row
echo implode(', ', array_map(fn($name) => tagRow($name, newBatchId()), $names));

// Partial: one ID for the whole import
echo implode(', ', array_map(tagRow(?, newBatchId()), $names));
9f1c2a7e:Ada, 03bd8e51:Grace, c47a90f2:Linus
5e88d1b4:Ada, 5e88d1b4:Grace, 5e88d1b4:Linus

Your IDs will differ, but only the second line keeps them identical.

You could get the same result by storing the ID in a variable before writing the arrow function. The partial does the capturing for you.

Count How Often the Value Is Fetched

The number of times newBatchId() runs depends on how often you create the callback and how often you call it:

How the callback is used Partial Arrow function
Created once, called for 1,000 rows Once 1,000 times
Created and called on each of 1,000 loop passes 1,000 times 1,000 times
Created for an empty list, so never called Once Never

Building a partial inside a loop is no worse than calling an arrow function there. The empty list is where a partial does extra work, because it fetches a value nothing uses.

Arguments are evaluated while your script is running, and calling a partial costs about the same as calling the equivalent hand-written closure.

Keep Fresh Values in Arrow Functions

Some values need to be new on every call, like a one-time token or the time on a log entry, and I’d keep those in an arrow function.

Before you convert a callback, ask whether each value should be captured up front or fetched every time.

Choose Which Callbacks to Convert

The best candidates for conversion are arrow functions that only hand their input to something else with fixed settings, and the main payoff is code that’s easier to read. array_map() calls with a partial callback now compile into plain loops, so you pick up a little speed along the way.

Without a trailing ..., PHP ignores any extra arguments you pass and raises no error. You can’t use the syntax with new to build objects, though static factory methods work.

Duration Says Which Unit You Mean

PHP’s built-in functions take lengths of time as plain numbers, and you have to remember whether each one wants seconds, microseconds or something else. Some split the value across two parameters, and others accept a decimal that can lose precision. The older DateInterval can’t help, because a “day” isn’t a fixed length once daylight saving gets involved. The new Time\Duration class measures a span the way a stopwatch does, with no zone attached and accurate to the nanosecond.

You create one from the unit you mean, and you can add, subtract, multiply and compare them:

use Time\Duration;

$timeout = Duration::fromMinutes(1)->add(Duration::fromMilliseconds(1500));
printf("%d.%03d seconds\n", $timeout->seconds, intdiv($timeout->nanoseconds, 1_000_000));
// 61.500 seconds

A method parameter typed as Duration can’t receive milliseconds by mistake, because the caller has to write fromSeconds() or fromMilliseconds(). Config values for timeouts, cache lifetimes and retry delays are the obvious first candidates. Older built-ins such as sleep() still expect integers, so for now you pass along the seconds and nanoseconds properties where needed.

The new Io\Poll API watches many network connections at once, and libraries such as ReactPHP and AMPHP can build on it to let one PHP process juggle lots of clients. Its wait timeout takes a Duration from day one.

clamp() Ends the min(max()) Puzzle

Keeping a number inside a range used to look like max(1, min(100, $perPage)), and that min/max technique has tripped me up basically every time for the last 30 years. The lower limit goes into max() and the upper one into min(), which is hard to read at a glance. PHP 8.6 adds clamp($value, $min, $max), which gives you the input if it fits and the nearest edge if it doesn’t. It throws a ValueError if the lower bound is bigger than the upper one, so a swapped pair fails loudly instead of returning nonsense.

Use it for page sizes from a query string, percentages, retry counts and user-supplied image dimensions. It works on anything PHP can compare, including Duration, which makes “back off, but never wait more than 30 seconds” a single line.

An Upgrade Checklist From the Deprecations List

A deprecation is PHP’s warning that something still works today but will be removed later, usually in the next major version. Nothing on the 8.6 list breaks your site on upgrade day. Code that uses anything on it fills your logs with notices, though, and PHP 9.0 will remove some of those features or turn them into errors.

  1. Know your deadline. PHP 8.2 stops getting security fixes on December 31, 2026, the same day 8.4 leaves active support. Version 8.6 is covered until the end of 2030. A server stuck on an unsupported release can’t take the next emergency patch, and the flaws disclosed in October and November 2026 showed how quickly one can become urgent.

  2. Lint your code with PHP 8.6. Some deprecations show up at compile time, before anything runs. A return inside a finally block is the big one, because exceptions from the matching try disappear and the caller never finds out. A syntax check catches it:

    php -d error_reporting=-1 -l src/Config.php
    
    Deprecated: Returning from a finally block is deprecated in src/Config.php on line 6
    No syntax errors detected in src/Config.php
    

    Other notices only appear during execution, so run your test suite on 8.6 with deprecation reporting turned on.

  3. Search for the renamed and retired functions. A one-liner finds the most common ones outside your vendor folder:

    grep -rnE --include='*.php' --exclude-dir=vendor \
      '\b(mb_ereg[a-z_]*|mb_eregi[a-z_]*|mb_split|mb_regex_encoding|is_double|is_long|is_integer|doubleval|spl_object_hash|strcoll|metaphone)\s*\(|SORT_LOCALE_STRING' .
    

    The fixes are mostly mechanical:

    • is_double() becomes is_float(), is_long() and is_integer() turn into is_int(), and doubleval() is now floatval().
    • Swap spl_object_hash() for spl_object_id().
    • The mb_ereg() family and mb_split() move to preg_* functions with the u flag, because the library behind them has gone unmaintained.
    • Replace strcoll() and SORT_LOCALE_STRING with the Collator class from the intl extension.
    • metaphone() has no built-in successor, so you’ll need a library such as Double Metaphone.
  4. Check your sessions. If your app relies on PHP’s built-in handling, three defaults changed. Strict mode now rejects IDs the server never issued, JavaScript can no longer read the cookie, and it carries SameSite=Lax, so browsers leave it off form submissions from other sites. A checkout flow where a payment page posts back to you can arrive without a session. Custom handlers need create_sid() and validateId() to keep working cleanly under the new rules.

  5. Watch for stricter inputs. trim() now strips form feed characters. Functions such as sleep(), number_format() and file_exists() throw a ValueError for out-of-range numbers or stray NUL bytes, where they used to shrug it off.

  6. Let your framework set the pace. If you build on Laravel, its support table decides when you can move. As of December 1, 2026, it shows PHP 8.3 to 8.5 for Laravel 13 and 8.2 to 8.5 for 12, with no mention of 8.6. A new major ships around the first quarter of each year, so watch that page rather than PHP’s calendar. If you’re still on 12, its security fixes end on February 24, 2027, which is the more urgent date.

Less Guesswork in Everyday PHP

Partial application won’t change what your PHP does, but it cuts how much you have to read to find out. Duration and clamp() take rules that used to depend on a comment or a careful reader and put them where the language can check them.

The deprecations are the chore that comes with those gains. A test job that’s allowed to fail, plus the lint and grep checks, is enough to show how much cleanup is waiting while frameworks catch up, and a busy file full of small callbacks is a low-risk place to get a feel for partials.