Skip to content

WorkerRuntimeInfo

“Which runtime are we on, and what can it do?” — the process-wide query surface for code outside the Runtime namespace that needs to behave differently in a persistent worker.

Kernel installs the selected runtime here before starting it. Anything asking earlier than that still gets a usable answer: boot-time listeners run inside Kernel::bootstrap(), which happens before runtime selection, so a query with nothing installed falls back to auto-detection over the registry and caches the result. Plugins have already registered their aliases by then, so detection sees the full set.

final class WorkerRuntimeInfo

SourceRuntime/Worker/WorkerRuntimeInfo.php
MethodDescription
alias(): stringThe installed runtime’s alias, or the detected one’s when nothing is installed yet.
capabilities(): WorkerRuntimeCapabilitiesWhat the hosting runtime does for itself: persistence, superglobals, SAPI output, streaming, forking.
install(WorkerRuntimeInterface $runtime): voidRecords the runtime that is about to serve this process, process-wide.
isInstalled(): boolWhether WorkerRuntimeInfo::install() has already run.
isPersistent(): boolThe question almost every caller actually has: is this process going to handle more than one request?
reset(): voidTest isolation.

public static function alias(): string

The installed runtime’s alias, or the detected one’s when nothing is installed yet.

Returns string

public static function capabilities(): WorkerRuntimeCapabilities

What the hosting runtime does for itself: persistence, superglobals, SAPI output, streaming, forking.

Answers from the installed runtime when there is one. Otherwise the registry is auto-detected and the detected runtime is instantiated to ask it; that answer is cached for the process and invalidated by WorkerRuntimeInfo::install() or WorkerRuntimeInfo::reset(). A detected runtime whose constructor cannot run here still yields a usable answer, with persistent derived from whether it is SapiRuntime.

Returns WorkerRuntimeCapabilities

public static function install(WorkerRuntimeInterface $runtime): void

Records the runtime that is about to serve this process, process-wide.

Called by the Kernel once selection is done, before the runtime starts. Every later query answers from this instance instead of auto-detecting, and any capabilities cached from an earlier detection are dropped.

ParameterTypeDescription
$runtimeWorkerRuntimeInterface

public static function isInstalled(): bool

Whether WorkerRuntimeInfo::install() has already run.

False means queries below are still answering from auto-detection rather than from the runtime the Kernel actually selected.

Returns bool

public static function isPersistent(): bool

The question almost every caller actually has: is this process going to handle more than one request?

Drives batch-vs-simple telemetry export, shutdown-function registration, and so on.

Returns bool

public static function reset(): void

Test isolation.