What's new in PHP 8.6
Written on 2026-08-05Join 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
We're nearing feature freeze for PHP 8.6, which will be released on November 19th if all goes to schedule. As is tradition, this is usually the time where I compile my list of what's to expect, and share my opinion here and there. If you want, you can head to the blog post, but you can also stay here to read a little more about my personal highlights.
PFA — partial function application
This is — I would think — quite a game changer for PHP. PFA allows you to create a reference to a function, with some of its parameters already filled in:
$makeSlug = str_replace(' ', '-', ?);
One case where this is extremely useful is when combined with the pipe operator, since the pipe operator requires you to pass in a closure with exactly one parameter at all times:
$output = 'Hello World' |> str_replace(' ', '-', ?) |> strtolower(...); // hello-world
Apart from the pipe operator though, I think PFA may lead PHP developers to think more functionally about their code. Now I don't mean to start a debate on which is the best; I think there's merit in both OO and functional programming. However, I know that many developers do like a functional approach, and PFA combined with the pipe operator makes that now actually viable in PHP. I'll have to use it for a while to get a proper feeling about it, but I'm definitely excited.
Readonly property defaults
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. We've been using this pattern all throughout Tempest, and honestly we love it:
interface MigratesUp { public string $name { get; } public function up(): QueryStatement; }
In this context, readonly properies with default values make sense because you're working with them on the interface level; within that context, their value can and will change between implementations:
final class CreateBooksTable implements MigratesUp { public readonly string $name = '2026-01-01_01_create_books_table'; // … } final class CreateAuthorsTable implements MigratesUp { public readonly string $name = '2026-01-01_02_create_authors_table'; // … }
This is one of these annoyances I've run into multiple times, so I'm really glad it'll be fixed.
A new clamp function
clamp() is a pretty common function in many frameworks already, which will now ship built-in with PHP 8.6. This function ensures a given value (numeric or other) is within a given bound. If not, the nearest edge value is returned.
clamp(10, min: 0, max: 100); // Will return `10` clamp(101, min: 0, max: 100); // Will return `100` clamp(-1, min: 0, max: 100); // Will return `0`
clamp() works on more than integers. For example strings:
clamp("y", "x", "z") // Will return "y" clamp("a", "x", "z") // Will return "x"
Or DateTime objects:
clamp( value: new DateTimeImmutable('2025-01-01'), min: new DateTimeImmutable('2026-01-01'), max: new DateTimeImmutable('2026-12-31'), ); // Will return `DateTimeImmutable('2026-01-01')`
I've seen people especially excited about being able to clamp DateTime objects, which is a really great thing to do indeed.
Deprecations
I won't list all deprecations here, especially because there are so many in PHP 8.6. And that's exactly what I wanted to talk about: there are a lot of deprecations this time.
Personally, I really don't mind. I think deprecations are a good way of moving a language forward. In the past though, deprecations have always been a source of annoyance to developers, so I'm curious what their impact will be this time. A while ago, I wrote a post about how to deal with deprecations; so if you'd run into any and get annoyed, I suggest reading that one 😁
Those are my highlights of the upcoming release, but of course there's a lot more to tell. Give the blog post a read when you have the chance.
One more very important thing I want to mention is the State of PHP 2026 survey. This is a joint effort between JetBrains and the PHP Foundation, trying to get the best insights into the PHP community as possible. We have over 8000 people who filled it in, but we'd like to see even more. So if you haven't already, I would encourage you to fill it in (it takes 15-20 minutes). It would be really helpful, not just to JetBrains and the Foundation, but most importantly to the PHP community, because we intend to use this data to determine focus for PHPs internal development as well.
Have a great day!
Brent