PHP 8.6

Written on 2026-11-22

Join over 14k subscribers on my mailing list. I write about PHP news, share programming content from across the web, keep you up to date about what's happening on this blog, my work on Tempest, and more.

You can subscribe by sending an email to brendt@stitcher.io.

Hi

PHP 8.6 was released a couple of days ago! I was in the midst of repainting parts of my house and moving my home office, so I'm a bit late. Not to worry: there's plenty of time to update still.

Speaking of updating, I want to start this email with a general thought: these days more than ever, it is so important to keep your PHP projects up to date. And not just PHP: we're seeing new security issues almost daily now across all programming languages and technologies. It seems to be a new reality we'll have to come to term with. Luckily, modern tooling makes it easy to keep your codebase healthy, both in deterministic (Rector, PhpStorm, etc.) and non-deterministic (AI) ways.

When it comes to major versions, my advice it to hold off to the first or second patch release to push to production, which makes this the perfect time to prepare your codebases. For Tempest, we usually bump the minimal required version to the latest major around mid-January, and plan to do so as well this time around.

So, what's new in PHP 8.6? You can read and watch the full summary on my blog, but here are my highlights:

Partial function application

Partial function application is a game-changer when using the pipe operator, and has many other uses as well. PFA allows you to create a reference to a closure with some of its parameters prefilled. Here's an example:

$output = 'Hello World' 
    |> str_replace(' ', '-', ...)
    |> strtolower(...);

// hello-world

You can read all about PFA in this post.

Function parameter doc comments

This one will need some getting used to, but I think it'll be very useful when it comes to code readability: PHP's reflection API has been extended with a getDocComment() method on ReflectionParameter. In practice that means that you can rewrite this:

/** @param Book[] $books */
function store(array $books): void { /* … */ }

As this:

function store(
    /** @param Book[] */
    array $books,
): void { /* … */ }

Of course, you can also write a shorter one-line version by adding the doc block on either side of the parameter:

function store(/** @param Book[] */ array $books): void { /* … */ }
function store(array $books /** @param Book[] */): void { /* … */ }

Readonly property defaults

My final highlight is the addition of readonly property defaults. Especially for Tempest projects, who rely heavily on interfaces; it's a really convenient change. With the addition of property hooks in PHP 8.4, you can define property hooks on interfaces:

interface MigratesUp
{
    public string $name { get; }

    public function up(): QueryStatement;
}

Because of this change though, readonly properties with default values would make sense in many cases:

final class CreateBooksTable implements MigratesUp
{
    public readonly string $name = '2026-01-01_create_books_table';
    
    public function up(): QueryStatement
    { /* … */ }
}

However, prior to PHP 8.6, you could not assign default values to readonly properties. This was a deliberate design choice when readonly properties were added because a readonly property with a default value is essentially a constant. Of course that was before property hooks could be defined on interfaces, because now a default, unchangeable value does make sense if it's part of a bigger contract.

And that's why default values for readonly properties is now allowed!

final class CreateBooksTable implements MigratesUp
{
    // ✅
    public readonly string $name = '2026-01-01_create_books_table';
    
    // …
}

In closing

As I mentioned there's a lot more to talk about when it comes to PHP 8.6, so check out the blog post for more.

Finally, I want to mention my hobby project one last time: I finished my Return to RuneScape series, and you can watch it as a full-length video now: https://www.youtube.com/watch?v=z_PZET5Mut8. It was really fun project for me, and I'm happy I got to share it with at least a handful of people.

With that, I wish you a good week ahead, and talk to you soon!

Brent

PS: I'll be at SymfonyCon on Thursday and Friday, if you happen to be there as well, don't hesitate to come say hi at the PhpStorm booth!

Join over 14k subscribers on my mailing list. I write about PHP news, share programming content from across the web, keep you up to date about what's happening on this blog, my work on Tempest, and more.

You can subscribe by sending an email to brendt@stitcher.io.

Noticed a tpyo? You can submit a PR to fix it.
Home RSS Newsletter Discord © 2026 stitcher.io Login