mini\Mini::getScope() public

Documentation

An object that uniquely identifies the current scope.

"Scope" here means the same as in the Scope RFC (\Scope): the unit of lifetime that Scoped services belong to. In Mini a scope is typically one request. This function is intended to be used for caching in WeakMap, instances that are request specific and should survive for the duration of the request only.

Returns:

  • The current \Scope when the runtime provides one (ext-scope, or the fiber-interop/scope polyfill a runtime such as phasync/Swerve installs). Mini does not depend on it; it is used when present. A request's Scope follows it into every fiber the request starts.
  • Current Fiber if in fiber context without a request Scope (Swoole, ReactPHP, RoadRunner)
  • $this if in traditional PHP-FPM request (after bootstrap() called)

Signature

public function getScope(): object

Returns

object

Source

src/Mini.php:233-259