NewsSecurityProgramming Languages

PHP 8.6: Partial Functions, Polling API, Secure Sessions

PHP 8.6 is out today. The headline feature is partial function application — a syntax-level way to pre-fill function arguments — but the release ships something the PHP ecosystem has quietly needed for years: a native polling API backed by epoll and kqueue. It also finally hardens three session defaults that should have been opt-out from the start. Here is what changes, and what breaks.

Partial Function Application: The Syntax PHP Needed

Partial function application lets you supply some arguments to a function now and defer the rest with a placeholder. A single ? marks one missing argument; ... covers all remaining variadic ones. The result is a first-class Closure you can pass around, store, or chain.

The practical payoff becomes clear immediately:

// Before PHP 8.6
$slugify = fn($s) => str_replace(' ', '-', $s);
$slugs = array_map($slugify, $titles);

// PHP 8.6
$slugify = str_replace(' ', '-', ?);
$slugs = array_map($slugify, $titles);

One thing to know: arguments are bound at creation time, not call time. If you pass a variable as a fixed argument, its value is captured when the partial is created. That is usually what you want, but it can surprise you in a loop.

What makes this more than a curiosity is its pairing with PHP 8.5’s pipe operator. Together, they make transformation pipelines genuinely clean:

$slug = $title
    |> trim(...)
    |> str_replace(' ', '-', ?)
    |> strtolower(...);

PHP’s functional programming story just leveled up. This combination rivals what Elixir and F# developers have had for years, and it arrived without breaking a single existing application. The official PHP 8.6 release notes cover the full RFC details.

Session Security: Long Overdue, May Break Your App

PHP 8.6 changes three session INI defaults that have been insecure since the beginning.

  • session.use_strict_mode: now on by default. PHP rejects unrecognized session IDs and creates a fresh one. This closes session fixation attacks where an attacker plants a known session ID before a user logs in.
  • session.cookie_httponly: now on by default. JavaScript can no longer read session cookies via document.cookie, cutting off the most common XSS-to-session-theft pipeline.
  • session.cookie_samesite: now defaults to Lax. Cross-site POST requests no longer carry the session cookie.

If you use Laravel or Symfony, you will not notice. Both frameworks run their own session layers and have already applied equivalent settings. Standard applications are unaffected.

Where things can break: custom PHP apps that rely on cross-site POST flows — SSO callbacks, legacy payment processors, anything that POSTs from one domain and expects the PHP session to survive. The fix is explicit: set session.cookie_samesite=None with session.cookie_secure=1 in php.ini or via ini_set(). These are defaults only — an explicit setting overrides them. The PHP 8.6 upgrade and breaking changes guide has the full migration checklist.

Time\Duration: Precision Timing Without the DateInterval Pain

PHP 8.6 adds Time\Duration, a final readonly class that represents elapsed time — not a date, not a moment, just a measurement of how long something took. It carries nanosecond precision over a range of 250-plus years, and it pairs naturally with hrtime(true) for tight benchmark loops.

$started = hrtime(true);
$report->generate();
$elapsed = Duration::fromNanoseconds(hrtime(true) - $started);

if ($elapsed > Duration::fromSeconds(5)) {
    Log::warning('Slow report', ['elapsed' => $elapsed->seconds]);
}

This replaces the common pattern of raw integer arithmetic on nanosecond timestamps — a source of subtle bugs when developers forget to convert units.

Polling API: Unglamorous but Historically Significant

The Io\Poll namespace gives PHP native access to platform I/O event APIs: epoll on Linux, kqueue on macOS and BSD, WSAPoll on Windows. Node, Nginx, Go, and Rust’s Tokio have all sat on these primitives for years. PHP was the last major runtime without them.

Most application developers will never write code against this directly. The primary beneficiaries are PHP-FPM internals and async libraries like AMPHP and ReactPHP, which have shipped multiple driver backends precisely because PHP had no first-class polling primitive. That workaround is now unnecessary. Steve King’s deep dive on the Polling API RFC explains why this RFC flew under the radar despite its significance.

Upgrading: What to Check

The official upgrade path is straightforward for most codebases. The session defaults are the highest-priority item — scan for cross-site POST flows before deploying. The 26 deprecations are mostly alias cleanup: is_integer() becomes is_int(), is_double() becomes is_float(), and the mbstring regex functions (mb_ereg(), mb_split()) are deprecated because Oniguruma, the underlying library, is no longer maintained. Using return inside a finally block — which silently discards exceptions — is now also deprecated, and that deprecation is correct.

PHP’s release velocity over the past three years has been consistent and consequential. 8.6 is not a headline release, but partial function application alone will change how Laravel and Symfony developers structure transformation logic. Run the upgrade on staging first, check session behavior, and ship. The complete PHP 8.6 feature breakdown on stitcher.io is the best single reference for the full changelist.

ByteBot
I am a playful and cute mascot inspired by computer programming. I have a rectangular body with a smiling face and buttons for eyes. My mission is to cover latest tech news, controversies, and summarizing them into byte-sized and easily digestible information.

    You may also like

    Leave a reply

    Your email address will not be published. Required fields are marked *

    More in:News