Skip to content
armanazij.com

PHP 8.6 lands this week: what matters for Laravel apps and WordPress sites

PHP 8.6 is out on November 19. Partial function application, clamp(), Time\Duration, tighter session cookies and 26 deprecations, seen from both the Laravel and the WordPress Core side, with a straight answer on when to upgrade.

Rejaul Alom Khan (Arman Azij), Laravel and WordPress developer in Dhaka, Bangladesh Arman Azij 8 min read
PHP 8.6 lands this week: what matters for Laravel apps and WordPress sites, by Rejaul Alom Khan (Arman Azij)

The release in one paragraph

PHP 8.6 reaches general availability on November 19, 2026. It is a smaller release than 8.0 or 8.1: no new type system features, no attributes that change how you structure a class. What it brings is a handful of language conveniences, a new Time\Duration class, tighter session cookie defaults, and a long list of deprecations. Under the current release process it gets two years of active support and two more of security fixes, which makes it the version most new projects started in 2027 will run on.

I work in both PHP worlds: Laravel applications by day, and WordPress Core, where I have props in every release from 6.6 to 7.1. The two communities adopt new PHP versions at very different speeds, so this post looks at 8.6 from both sides, and ends with a concrete answer to the question everyone asks this week: should I upgrade now?

Partial function application

This is the headline feature, and it has history. A first version of the RFC was declined in 2021. The second version passed 33 to 0. The syntax uses ? as a placeholder for one argument you will supply later, and ... for all remaining arguments:

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

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

The resulting closure keeps the original parameter names, types and defaults, and the arguments you supplied are evaluated once, when the partial is created. One follow-up change is worth knowing: every ? becomes a required parameter of the new closure, even if the original parameter had a default.

The reason this matters more than it looks is the pipe operator from 8.5. The pipe needs a callable that takes exactly one argument, which was awkward for most built-in functions. Now the two compose:

$slug = 'Hello World'
    |> str_replace(' ', '-', ?)
    |> strtolower(...);
// hello-world

In Laravel code this is a cleaner replacement for fn ($x) => str_replace(' ', '-', $x) inside collect()->map(). In WordPress it mostly cannot be used yet, because plugins ship to sites on older PHP, and a ? placeholder is a parse error there. Feature-detect at the plugin level, not the function level.

clamp(): WordPress had it before PHP did

clamp() does what every framework's helper of the same name does, with named arguments for readability:

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

It works with strings and DateTime objects, as long as the values are directly comparable, and a $min greater than $max throws a ValueError.

The WordPress angle here is a nice one. Core added a polyfill for clamp() in compat.php under Trac ticket #65143, with milestone 7.1. That means plugin and theme authors can call clamp() today on any PHP version WordPress supports, and when the site moves to 8.6 the native function takes over. This is the pattern Core has used for years with str_contains() and friends, and it is the easiest way to start writing 8.6-style code without waiting for your hosts.

Time\Duration

Time\Duration is a final readonly class for elapsed time with nanosecond precision. It is not a replacement for DateInterval, which models calendar intervals; it is for stopwatch-style values such as timeouts, delays and retry backoff:

use Time\Duration;

$delay = Duration::fromMilliseconds(100)->multiplyBy(2 ** $attempt);
$total = Duration::fromSeconds(1)->add(Duration::fromMilliseconds(500));

if ($delay > $total) { // comparison operators work
    // ...
}

Nothing in Laravel accepts a Duration yet, but queue retry backoff, rate limiters and HTTP client timeouts are the obvious places where it will eventually replace bare integers that nobody can tell are seconds or milliseconds.

Readonly property defaults

Before 8.6, public readonly string $name = 'x'; was a compile-time error. The motivation for lifting it is property hooks on interfaces from 8.4. If an interface declares public string $name { get; }, an implementation can now satisfy it with a readonly property and a default:

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

Readonly semantics are unchanged: the default counts as the single assignment, so the property cannot be reassigned later.

The smaller additions

  • SortDirection is a new built-in enum with Ascending and Descending cases. Nothing in core accepts it yet; the sort functions are expected to follow.
  • Enums can implement __debugInfo(), so var_dump(Status::Ok) can show something more useful than a case name.
  • Parameters can carry doc comments, before or after the parameter but before the comma, readable via ReflectionParameter::getDocComment().
  • Io\Poll is a low-level I/O multiplexing API over epoll, kqueue, event ports and WSAPoll. It was built primarily for PHP-FPM and signal handling, but it is exposed to userland as an easier alternative to stream_select(). There is no event loop in it.
  • Streams get an opt-in error_mode context option (warnings, exceptions or silence) and stream_last_errors() for structured errors.
  • #[\Override] now works on class constants.

Session cookie defaults

New php.ini defaults set session.use_strict_mode to 1, session.cookie_httponly to 1 and session.cookie_samesite to Lax. Together they close session fixation, cookie theft through document.cookie, and CSRF through cross-site POSTs.

For Laravel this is mostly a non-event: the framework manages its own session cookie through its own config, and already defaults to http_only and lax. WordPress Core does not use PHP sessions at all, so a vanilla site is unaffected. Where it bites is custom code: a plugin or a legacy app that relies on PHP sessions and an SP-initiated SAML or OAuth flow that POSTs back cross-site will need SameSite=None; Secure or a token-based flow.

Deprecations that will actually hit code

Twenty-six deprecations were voted in. Most are obscure. These are the ones I expect to see in real Laravel and WordPress codebases:

  • Returning a value from __construct() or __destruct(). WordPress Core already fixed its own instances under Trac #65637. This becomes an error in PHP 9.0.
  • is_a() and is_subclass_of() with a string class name while $allow_string is false. Core has an open ticket, #66418, for exactly this in XML-RPC, where the multicall tests fail on 8.6.
  • spl_object_hash(): use spl_object_id().
  • is_double(), is_integer(), is_long() and doubleval(): use is_float(), is_int() and floatval().
  • The CSV methods of SplFileObject (fgetcsv, fputcsv, setCsvControl, getCsvControl).
  • mysqli::stmt_init() and mysqli_get_charset(). WordPress sites with old database drop-ins should check.
  • strcoll(), the SORT_LOCALE_STRING flag and metaphone().
  • The whole mb_ereg*() family and mb_split(), because Oniguruma reached end of maintenance. Removal is planned for 9.0; the replacement is PCRE with the /u modifier.
  • Returning from a finally block.
  • Passing invalid handlers to session_set_save_handler(); a handler now needs create_sid() and validateId().

There is also a new limit of 16 chained php://filter filters by default, which is a security hardening rather than a deprecation, but it can break deliberately clever code.

The practical move is to run your test suite on 8.6 with error_reporting(E_ALL) and deprecations turned into exceptions. Laravel's default exception handler surfaces them; in WordPress, WP_DEBUG with WP_DEBUG_LOG collects them in debug.log.

Should you upgrade this week?

  • Laravel. As I write this, the official support table for Laravel 13 lists PHP 8.3 through 8.5. Check it after the 19th before touching production, because the framework's own test matrix is the real signal. Development machines, CI and staging can move now; that is where the deprecation notices are useful.
  • WordPress. Core's PHPUnit matrix has a PHP 8.6 job, but it is still allowed to fail while the remaining compatibility issues are closed. WordPress 7.2, due December 8, aims to be compatible with 8.6. A plugin or theme can be tested on 8.6 today; a production site should wait for 7.2 and for its plugins to declare support.
  • Hosting. Most managed hosts add a new PHP version weeks after GA, so the question is rarely urgent on day one. Use the time to fix deprecations.

Takeaways

  • PHP 8.6 is additive and the upgrade is usually easy; the deprecations are the real work.
  • Partial function application plus the 8.5 pipe operator finally makes |> pleasant with built-in functions.
  • clamp() is usable in WordPress already through Core's polyfill from 7.1.
  • Session cookie defaults tighten security; Laravel and vanilla WordPress are unaffected, custom session code is not.
  • Move dev, CI and staging to 8.6 now; move production when Laravel's support table and WordPress 7.2 say so.
Tags: #PHP #Laravel #WordPress

More articles

All posts
Abilities and MCP: making your WordPress plugin callable by AI agents, by Rejaul Alom Khan (Arman Azij)

6 min read

Abilities and MCP: making your WordPress plugin callable by AI agents

The Abilities API has been in WordPress Core since 6.9, and the MCP Adapter is now a WordPress.org plugin. How to register typed, permission-checked abilities, expose them over REST and MCP, and keep AI clients safely limited.

  • #WordPress
  • #AI
  • #Security
Rejaul Alom Khan (Arman Azij), Laravel and WordPress developer in Dhaka, Bangladesh

Let’s talk

Arman Azij