With Io\Poll, PHP 8.6 Waits for Events Across Multiple Streams

With Io\Poll, PHP 8.6 Waits for Events Across Multiple Streams

PHP 8.6.0 is now available: the PHP development team announced the release on November 19, 2026. The update introduces partial function application and the Io\Poll API, along with changes to sessions, I/O, performance, and compatibility that teams will need to review before migrating.

The official PHP page confirms that the release is available immediately. The announcement also lists a class for durations, the clamp() function, the SortDirection enumeration, and default values for readonly properties; binaries and source code are available from the project's download pages.

Functions that can wait for arguments

Partial function application lets you fix some arguments in a call and get a closure in return that waits for the remaining ones. In the syntax described for PHP 8.6, the ? symbol marks each pending argument, and ... allows zero or more arguments in that position. This makes it possible to create callbacks without writing a separate anonymous function for every case.

Laravel News summarizes the mechanism as a call with some of its arguments already supplied that returns a closure for the rest. Linuxiac notes that it is especially useful when working with callbacks and higher-order functions. The polling API proposal mentions event loop libraries such as ReactPHP and AMPHP among its potential use cases; partial function application, in turn, is presented as a language feature for building and passing callables.

PHP also adds clamp(), which returns the original value if it falls within the specified bounds and, otherwise, the nearest bound. Help Net Security illustrates the behavior with clamp(110, 0, 100), which returns 100. The new SortDirection enumeration provides standardized ascending and descending sort options.

Readonly properties now support default values. Laravel News explains that before PHP 8.6, declaring them was a compile-time error, a limitation that made it difficult to satisfy with a fixed value readonly properties required by interfaces introduced in PHP 8.4.

Io\Poll expands stream monitoring

The new Io\Poll API lets you wait for events on multiple I/O resources, such as streams, and aims to overcome the scalability limits of stream_select(). According to Help Net Security, PHP can use epoll on Linux, kqueue on BSD and macOS, event ports on Solaris and illumos, and WSAPoll on Windows; the API RFC also considers poll as an alternative for other POSIX systems.

The PHP RFC describes a polling context where monitored resources are added and the caller waits for events to occur or for a timeout to expire. The monitored items are represented by watchers, which let you check triggered events, change which events are watched, or remove the registration. The API exposes read and write events, among others; errors and connection closure appear as output events that are monitored automatically.

The API automatically selects a suitable backend for the platform, although the design allows one to be specified. Its first implementation provides StreamPollHandle for stream resources. The RFC leaves open the possibility of integrating other resource types later, such as sockets or libcurl descriptors, but presents these as future work, not as part of the initial implementation.

The document also states that userland code cannot directly implement the Io\Poll\Handle interface: only PHP internal classes or extensions written in C can do so. To use a custom resource, it says to use a stream or another compatible handle source. The RFC places the user-facing API alongside an internal goal: to provide a shared foundation for the core and extensions to take advantage of polling, without turning it into a full event loop.

Con Io\Poll, PHP 8.6 espera eventos en varios flujos
© PHP.net

Stricter sessions and more visible I/O errors

PHP 8.6 changes three session defaults: it enables strict mode and HttpOnly cookies, and sets SameSite to Lax. Help Net Security warns that applications relying on the previous configuration should test their login flows before upgrading.

Custom session handlers that do not implement both create_sid() and validateId() are also deprecated. For those maintaining one, the specific change is to check that both methods are present; the deprecation notice is part of the release's documented compatibility changes.

For file operations, fclose(), file_put_contents(), and copy() return false if flushing or closing the file fails. Help Net Security notes that earlier versions could ignore this failure, meaning a write interrupted at the end could appear to succeed. The release also lets you configure stream operations to throw StreamException, with StreamError objects providing structured information about the wrapper and the path or URL involved.

Deprecations and behavior adjustments

The deprecation list covers mbstring regular expression functions, including mb_ereg() and mb_split(). Help Net Security attributes the change to the fact that Oniguruma, the regular expression library behind them, is no longer maintained, and notes the recommendation to use PCRE with the u modifier.

Several type-checking and conversion aliases are also deprecated, along with spl_object_hash(). The alternatives cited by Help Net Security are is_float(), is_int(), floatval(), and spl_object_id(), respectively. Linuxiac also highlights is_integer() and is_double() among the affected aliases.

Deprecated itemSuggested alternative
mb_ereg() and mb_split()PCRE with the u modifier
is_double() and doubleval()is_float() and floatval()
is_integer() and is_long()is_int()
spl_object_hash()spl_object_id()
return inside a finally blockThe release marks it as deprecated

There is also an immediate change to the behavior of trim(), ltrim(), and rtrim(): they now remove form feed characters (\f) by default. Help Net Security also notes that several functions now throw ValueError for out-of-range values, invalid flags, or strings containing NUL bytes.

More performance and cryptographic support

Performance improvements include faster JSON encoding and faster printf() operations. Linuxiac adds caching of stateless closures and optimization of certain array_map() calls, which are compiled as more efficient loops. JSON parsing errors now indicate the location of the problem within the input.

Help Net Security lists two additional additions: post-quantum key encapsulation in Sodium using X-Wing and ML-KEM-768, and support for early TLS 1.3 data in TLS streams. The official page includes partial functions, Io\Poll, Time\Duration, clamp(), SortDirection, and default values for readonly properties among the main new features.

The Time\Duration class measures elapsed time without associating it with a date or time zone. It has nanosecond precision and covers durations longer than 250 years. Laravel News adds that it is a final, readonly class, with factory methods for each unit, arithmetic operations, and comparisons; Linuxiac points to uses such as timeouts, pauses between retries, and performance measurements.

The PHP team released the version as PHP 8.6.0 and linked to the downloads, changelog, and migration guide. The official announcement thanks those who contributed to and supported the release; the manual's guide brings together the new features and backward-incompatible changes.

Sources: Linuxiac, Laravel News, Help Net Security, PHP.net, PHP mailing list, PHP Wiki, PHP Wiki