What's new in PHP 8.6 | Stitcher.io
stitcher.io
Blog
Newsletter
Feed
Books
Tempest
In this post
Partial function application<br>Readonly property defaults<br>Polling API<br>A new clamp function<br>New isReadable and isWriteable reflection functions<br>Function parameter doc comments<br>A new SortDirection enum<br>Improved security for session defaults<br>Debugable enums<br>Deprecations
Sponsors
Deploy your next server in a few clicks: ploi.io
Oh Dear: Health checks, scheduled tasks, uptime and SSL — all checked every minute, in one dashboard. Start monitoring →
Tideways : Performance insights for every request. Start trial →
What's new in PHP 8.6
Written on 2026-07-29
PHP 8.6 will be released on November 19, 2026. It includes partial function application, a new polling API, function parameter doc comments, a bunch of deprecations, and more.
By the way! If you haven't yet participated in the State of PHP survey, maybe this is a very good time to spend 15-20 minutes on it. This survey is a joint effort between the PHP Foundation and JetBrains; our goal is to get the best picture possible of "the PHP community". Over 8000 developers have already participated, but we'd like to see more.
Partial function application
Partial function application — PFA for short — allows you to create a reference to a closure with some of its parameters prefilled. A simple example is a function to replace all spaces in a string with dashes:
$makeSlug = str_replace(' ', '-', ?);Once a closure is created, you can call it like so:
$makeSlug('Hello World');
// Hello-WorldPFA is especially useful when combined with the pipe operator, because the pipe operator always requires a callable with exactly one parameter.
$output = 'Hello World'<br>|> str_replace(' ', '-', ?)<br>|> strtolower(...);
// hello-worldYou can read all about partial function application in this post.
Readonly property defaults
With the addition of property hooks in PHP 8.4, you can define property hooks on interfaces:
interface MigratesUp<br>public string $name { get; }
public function up(): QueryStatement;<br>}Because of this change though, readonly properties with default values would make sense in many cases:
final class CreateBooksTable implements MigratesUp<br>public readonly string $name = '2026-01-01_create_books_table';
public function up(): QueryStatement<br>{ /* … */ }<br>}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<br>// ✅<br>public readonly string $name = '2026-01-01_create_books_table';
// …
Polling API
The new Polling API was created first and foremost to facilitate easier internal development. Features like PHP-FPM and singal-handling in ZTS (Zend Thread Safety) mode will benefit from a unified platform to build upon. However, the new polling API is also exposed to userland, which could lead to lower-level frameworks like ReactPHP or Amp to make use of them:
use Io\Poll\Context;<br>use Io\Poll\Event;<br>use Io\Poll\StreamPollHandle;
// Create a poll context with automatic backend selection<br>$context = new Context();
// Create a non-blocking socket, just like before<br>$stream = stream_socket_server('tcp://0.0.0.0:8080', $errno, $errstr);<br>stream_set_blocking($stream, false);
// Wrap that stream in a new `StreamPollHandle` so that it can make use of the new API<br>$handle = new StreamPollHandle($stream);
// Add the handle to the context<br>$context->add($handle, [Event::Read], ['type' => 'server']);
while (true) {<br>// Wait for one second, polling for new events<br>$watchers = $context->wait(1);
// …<br>}It's imortant to note that this new polling API won't introduce any new async features to PHP. It's another (and easier) way to interact with async features — previously PHP only had stream_select() as an option for I/O multiplexing. Because the new API also works with several backends when available like epoll or WSAPoll, performance will be better compared to stream_select() at a certain scale.
The new polling API also doesn't come with a built-in event loop, so wrapping it into a higher-level abstraction is still up to userland libraries.
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`<br>clamp(101, min: 0, max: 100); // Will return `100`<br>clamp(-1, min: 0, max: 100); // Will return `0`clamp() works on more than integers. For example strings:
clamp("y", "x", "z") //...