fiber-interop

Scope

The identity of the request or job that code belongs to, kept across fibers. Global class \Scope, from ext-scope or the polyfill.

new Scope()A new scope, starting with copies of its creator's (the current scope's) superglobals.
run(callable $callback, mixed ...$args): mixedCall $callback with this scope as the current scope and return its result.
static getCurrent(): ScopeThe current scope: the innermost run() of this fiber, else the root scope in {main} or the active scope in a fiber without a run() of its own.
static getRootScope(): ScopeThe root scope: one object for the whole request, current in {main} outside any run().

Scopes cannot be cloned or serialized. fiber_interop\scope\IS_POLYFILL tells whether the class is the polyfill. See the Scope page and scoped services.