phpstorm.dev

PHP ecosystem insights

PHP knowledge

Versioned PHP knowledge with primary sources and explicit verification dates.

Source checks through 2026-10-27 · 57 sources · This published snapshot is over 48 hours old.

Verified 2026-10-27 discussion Permanent entry

Scope: an operation identity for long-running PHP (proposal)

Under discussion; not accepted. The RFC page, version 0.9.3 (dated 2026-10-27, last modified 11:51 UTC, author Frode Børli), reads Status: Under Discussion, with the discussion thread linked and the voting thread "tbd". The official RFC index collected at 17:01 UTC on 27 October also lists it under discussion (index date 2026-10-23). Version 0.9.1 (26 October) had read Draft (which edit changed the header was not recorded) although the author had already started the discussion on internals at about 16:04 UTC that day, so the earlier conflict between the page header and the thread is resolved. RFC karma was requested on 13 October and granted on 25 October. The proposed version is "Next PHP 8.x (PHP 8.7)".

Proposal

The RFC adds a final class Scope that identifies a unit of work, such as an HTTP request, queue job or CLI command, for servers that handle several, possibly overlapping, operations in one process:

The RFC contrasts this with per-coroutine state in the separate Concurrency Support RFC, which it says could assign its coroutines to scopes, and cites Java ScopedValue, .NET ExecutionContext/AsyncLocal<T>, Python contextvars, Go context.Context and Node AsyncLocalStorage as prior art.

Votes as proposed

Output buffers, error handlers and ini values are left for later RFCs. No vote dates are set.

Version 0.9.3 adds one rule to vote A: session_start() throws a RuntimeException, instead of blocking the process, when a locking save handler's session ID is already active in another scope of the same process (ext-scope 0.4.4). The RFC lists this as its only open issue; the alternative named there is to let both scopes share one $_SESSION and one lock, which avoids the error but gives up vote A's isolation. Version 0.9.2 rewrote the introduction without changing the proposal, and an implementation note on 27 October says ext-scope 0.4.3 was tested on ZTS builds with threads (the parallel extension).

Compatibility and implementation

The only listed BC break is that a global class named Scope can no longer be declared; namespaced classes such as PHPStan's PHPStan\Analyser\Scope are unaffected. The RFC's own sample found a global Scope class in 3 of 100 GitHub PHP files; that sample was not reproduced here. Code that never creates a scope is described as behaving as today.

The reference implementation is the fiber-interop/ext-scope extension (0.4.2, PHP 8.2–8.5, installable with PIE), which implements both secondary votes behind scope.superglobals and scope.locale_timezone ini switches, and a userland polyfill fiber-interop/scope (0.4.0). A php-src pull request is planned before the vote. The extension, its tests and the polyfill were not checked here.

Limitations

This summarises versions 0.9.1–0.9.3; the design can change. The middle of the 0.9.3 page (about 27,000 characters) was not re-read, so only the changelog-listed changes are recorded for it. Whether vote A's per-scope superglobals are sound for all SAPIs and event loops is the subject of the discussion, not established fact.

Related: karma request coverage in the 25 October digest; discussion start in the 26 October digest.