The Spectrum Dispatch News

technology

PHP 8.6 Adds Partial Functions, Duration Class, and Polling API

The upcoming major language update, arriving November 2026, introduces features for more expressive code, stronger typing, and scalable I/O operations.

PHP 8.6 Adds Partial Functions, Duration Class, and Polling API

PHP 8.6, scheduled for release on November 19, 2026, introduces several significant features designed to improve code expressiveness, type safety, and input/output scalability, according to the official PHP release notes.

PHP 8.6 Adds Partial Functions, Duration Class, and Polling API

Partial Function Application allows developers to provide some arguments to a function in advance, returning a Closure that accepts the remaining arguments. This feature uses ? and ... placeholders for unprovided arguments. For example, a backoff function configured with base delay and step values can be pre-configured, with the attempt parameter supplied later when the function is called.

A new Time\Duration class represents elapsed time with nanosecond precision, independent of timezone considerations. It can represent durations exceeding 250 years. The class makes timing operations more expressive—for instance, timeout values and benchmark timings can be expressed directly as Duration objects rather than raw microsecond integers. Duration objects are comparable, allowing them to work with functions like min() and max().

The Io\Poll API provides scalable I/O multiplexing by automatically using platform-specific mechanisms including epoll, kqueue, event ports, or WSAPoll. This addresses limitations of stream_select(), which typically cannot handle more than 1024 connections. The API is designed as a foundation for event loop libraries like ReactPHP and AMPHP.

A new clamp() function ensures a given value falls within a specified range, returning the nearest boundary value if it exceeds the limits. The function works with any comparable value, including the new Duration class.

The SortDirection enum provides a type-safe, standardized way to express sort order with Ascending and Descending cases. This replaces previous library-specific approaches using incompatible integers, strings, booleans, or custom enums, allowing libraries to accept it in public APIs without adapter code.

Additional improvements include the ability for readonly properties to declare default values without constructor assignment, enhanced stream error handling with structured StreamError objects and an StreamErrorCode enum, and support for DocComments on function and method parameters via ReflectionParameter::getDocComment().

Key facts

  • PHP 8.6 releases November 19, 2026
  • Partial Function Application lets you pre-configure functions with some arguments
  • Duration class represents elapsed time with nanosecond precision
  • Polling API replaces stream_select() for handling thousands of connections
  • clamp() function constrains values to a specified range
  • SortDirection enum standardizes sort order across libraries

Sources

← All posts