WorkerLifetimes
class WorkerLifetimes
The worker lifetimes of one analysis: which classes the booted container shares across requests, which methods handle a request or run a job, and which parameters it fills with fresh or shared values.
Roots come from the booted routes, middleware, listeners and Bus handlers, and from the collected resolutions, singletons and jobs. Each class they build is walked the way the container resolves it. Classes are read through PHPStan reflection and factories are never called: resolving or loading an analyzed class at runtime would run its code.
Constants
| private SHARED |
|
| private SCOPED |
|
| private FRESH |
|
| private DEFAULT |
|
| private UNKNOWN |
|
| private COPY_CLONE |
The clone of the container's queued listener that CallQueuedListener runs a job on, which keeps what its
constructor was given. |
| private COPY_WITHOUT_CONSTRUCTOR |
The instance the dispatcher makes of a queued listener without its constructor to read the job's options. |
| private LISTENER_OPTION_METHODS |
The option methods the dispatcher calls on that instance whenever it queues a listener
(Dispatcher::queueHandler() and propagateListenerOptions()). |
| private EVENT_CONTEXTS |
The framework events dispatched for one request, job or server operation, with the context
their listeners run in. |
Methods
Discover the worker lifetimes of the booted application and the collected roots.
Determine whether the container shares the class, or a subclass of it, across requests.
Determine whether resolving the abstract without parameters returns the instance the container shares for the worker.
Get the operation a booted middleware, controller action, job, listener or observer method handles, or null.
Determine whether a worker-shared instance handles the booted handler method, rather than only scoped or fresh ones.
Determine whether only copies of a queued listener run the method: the clone CallQueuedListener makes of the container's instance for each job, or the instance the dispatcher makes without its constructor to read the job's options. Each has its own properties and arrays, but a clone shares the objects they hold, so only writes that replace them stay with the copy.
Determine whether the container injects the global configuration repository into the parameter of a booted controller action, a job's handler or a constructor it runs.
Determine whether the container injects the instance it shares for the worker into the parameter of a booted controller action, a job's handler or a constructor it runs.
Determine whether the container built every instance the method handles an operation for, so the properties its constructor promotes hold what the container injected.
Determine whether the container name resolves the global configuration repository, which the framework registers as "config" with its contract and class as aliases.
Determine whether every shared instance built with the class's constructor gets the parameter's default or a fresh value from the container.
Determine whether the class is a job whose handler the container calls with injected parameters.
Get the classes whose declarations the lifetimes were read from.
Get the classes whose property defaults the lifetimes were read from, which aren't declarations.
Get the class a binding's closure builds when it was registered with a class name.
Determine whether the container builds the class itself: an instantiable class without its own Bind or BindWhen attributes.
Details
at line 237
__construct(ReflectionProvider $reflectionProvider, Container $container, array $abstracts, array $singletons, array $queued, array $helperCalls, array $observers)
Discover the worker lifetimes of the booted application and the collected roots.
at line 300
bool
isShared(string $class)
Determine whether the container shares the class, or a subclass of it, across requests.
at line 323
TrinaryLogic
sharesAbstract(string $abstract)
Determine whether resolving the abstract without parameters returns the instance the container shares for the worker.
A bind() factory may return a shared object, so its resolution is unknown.
at line 336
string|null
getContext(string $class, string $method)
Get the operation a booted middleware, controller action, job, listener or observer method handles, or null.
at line 345
bool
isContextShared(string $class, string $method)
Determine whether a worker-shared instance handles the booted handler method, rather than only scoped or fresh ones.
at line 356
bool
runsOnCopy(string $class, string $method)
Determine whether only copies of a queued listener run the method: the clone CallQueuedListener makes of the container's instance for each job, or the instance the dispatcher makes without its constructor to read the job's options. Each has its own properties and arrays, but a clone shares the objects they hold, so only writes that replace them stay with the copy.
at line 365
bool
isConfigParameter(string $class, string $method, string $parameter)
Determine whether the container injects the global configuration repository into the parameter of a booted controller action, a job's handler or a constructor it runs.
at line 376
TrinaryLogic
sharesInjectedParameter(string $class, string $method, string $parameter)
Determine whether the container injects the instance it shares for the worker into the parameter of a booted controller action, a job's handler or a constructor it runs.
at line 395
bool
isContainerBuilt(string $class, string $method)
Determine whether the container built every instance the method handles an operation for, so the properties its constructor promotes hold what the container injected.
A queued class is restored from its payload, except one the dispatcher resolves as a listener or observer. A method no booted handler reaches is judged by its own class. One that a queued listener's instance made without its constructor runs may initialize a readonly promoted property itself.
at line 417
bool
isGlobalConfig(string $abstract)
Determine whether the container name resolves the global configuration repository, which the framework registers as "config" with its contract and class as aliases.
at line 426
bool
isFreshParameter(string $class, string $parameter)
Determine whether every shared instance built with the class's constructor gets the parameter's default or a fresh value from the container.
at line 434
bool
isJob(string $class)
Determine whether the class is a job whose handler the container calls with injected parameters.
at line 448
array
getClasses()
Get the classes whose declarations the lifetimes were read from.
at line 458
array
getDefaultSources()
Get the classes whose property defaults the lifetimes were read from, which aren't declarations.
at line 1243
static string|null
getBindingConcrete(Closure $closure)
Get the class a binding's closure builds when it was registered with a class name.
at line 1258
static bool
isBuildableClass(ClassReflection $class)
Determine whether the container builds the class itself: an instantiable class without its own Bind or BindWhen attributes.