deniz.in

Markets

Weather

Loading weather

· via Hacker News – Front Page (native)

PHP 8.6 arrives with partial function application, Duration class and a polling API

PHP 8.6 lands with partial function application, a nanosecond-precision Duration class, a scalable polling API that moves beyond stream_select, plus clamp() and readonly property defaults.

PHP 8.6 arrives with partial function application, Duration class and a polling API

PHP 8.6, the newest major version of the language, lands on November 19, 2026, according to the official release notes at php.net, which reached the Hacker News front page the same day. The release page organises the update around expressive syntax, stronger typing and I/O that scales, with partial function application, a Duration class and a polling API as the headline features.

Partial function application

The marquee change lets a developer fix some of a function's arguments up front and receive a Closure in return. A question mark stands in for a single argument still to be supplied, an ellipsis for the remaining ones, and the underlying function only runs once those slots are filled.

The release notes demonstrate with a routine chore: filtering version strings. Where earlier PHP needs an arrow function wrapping version_compare(), 8.6 accepts the expression with placeholders directly as the callback. The pattern removes a category of throwaway closures that tend to accumulate around array helpers.

A Duration type for elapsed time

The new Time\Duration class models elapsed time the way a stopwatch measures it: a span, independent of any clock or timezone. The notes say it can represent more than 250 years at nanosecond precision, which suits it to timeouts and benchmark figures.

Durations are also comparable, so built-ins like min() operate on them without conversion — the notes' example caps a retry delay at Duration::fromSeconds(30) instead of a raw microsecond count. The class composes with partial application as well: a backoff routine can be pre-bound with fixed delays and later invoked with just the attempt number.

Polling that scales past select()

The new Io\Poll API watches many streams at once and, per the release notes, automatically uses the strongest mechanism the host platform offers — epoll, kqueue, event ports or WSAPoll. The motivation is spelled out alongside the old approach: stream_select() is typically limited to roughly 1024 connections.

Notably, the API is positioned as plumbing rather than a finished event loop. ReactPHP and AMPHP are named as intended consumers, giving the async ecosystem a shared native primitive instead of each library working around the limits of select() on its own.

Structured errors for stream operations

Stream operations can now be configured to throw a StreamException — or to fail silently — rather than emit warnings. Failures arrive as structured StreamError objects carrying a StreamErrorCode enum case, the wrapper involved and the affected path or URL. Errors can also be collected later through stream_last_errors() or routed to a custom handler, retiring the traditional dance of fishing a message string out of error_get_last() after a failed file_get_contents().

The rest of the release

A new clamp() function keeps a value inside a range and returns the nearest boundary when it strays outside, replacing the familiar max(min(...)) idiom; it works with any comparable value, Duration included. A SortDirection enum offers a common, type-safe vocabulary for sort direction that packages can share. Readonly properties can now declare default values, so constant values no longer need a constructor line of their own.

Why it matters

The release tightens seams left open by PHP's earlier type-system work. Partial application and Duration push everyday code toward fewer wrapper closures and fewer bare integers doubling as time spans, while clamp() and SortDirection standardise small patterns nearly every project reinvents.

The polling API is the structural change. PHP's async frameworks have long contended with stream_select()'s ceiling, and a native, scalable multiplexing primitive in the standard library changes what those frameworks — and any server juggling many simultaneous connections — can safely assume. Structured stream errors tackle the older problem of warnings serving as an error channel, making I/O failures inspectable rather than something to suppress and reconstruct. For teams tracking the language's trajectory, 8.6 reads less like a rewrite and more like a steady widening of what core PHP handles well.

  • #php
  • #programming-languages
  • #open-source
  • #release-notes
  • #backend

Related posts