WorkerStateHelper
class WorkerStateHelper
Collects the boot-independent facts of the checks that judge code by the request, job or operation it runs in, and builds the shared model the rules apply the booted lifetimes with.
Traits
Constants
| JOB_METHODS |
The lowercase names of the methods that run a queued class as a job. |
| private STATE_TYPES |
The values that belong to one request or operation, keyed by the label diagnostics use. |
| private RESOLVING_FUNCTIONS |
The resolving helpers, each with its abstract's parameter name and whether parameters follow. |
| private RESOLVING_METHODS |
The resolving container methods, each with its abstract's parameter name and whether parameters follow. |
| private LIFETIME_ATTRIBUTES |
The attributes that restrict a method to boot time or tests. |
| private CONFIG_WRITES |
The lowercase repository methods that change configuration. |
Properties
| protected Container|null | $container | from HasContainer |
Methods
Create a new worker state helper instance.
Determine whether any check that judges code by the operation it runs in is enabled, so the shared model's facts are collected.
Determine whether any check of the state code keeps for the worker is enabled.
Get the worker-state model of the collected data, built once for all the rules that share it.
Get the facts of the function the scope's code at the node runs in, or null when it is a flushState() method or one marked as boot-time or test-only.
Get the attribute marking the function as running only while the application boots or in tests.
Determine whether the type is always a configuration repository, which the rule may prove to be the global one.
Determine whether the call is the global config() helper.
Determine whether the call changes configuration: config() with an array, a Config facade write, or a repository write method.
Describe the expression a configuration write goes through when it may be the global repository: config() without arguments, a constant resolution from the application container (its names, which the rule resolves with the booted aliases), a parameter of the innermost function typed as a repository (its name, which the rule checks the container injects), or a repository property the constructor promotes (which the rule checks the same way). Null for any other expression.
Get the constructor's declaring class and the property name when the expression reads $this's readonly property that constructor promotes, outside closures. The property then holds what the container injected into the constructor, when the container built the instance.
Get the parameters of the scope's innermost function.
Get the abstracts a container resolution without parameters requests, or null for any other call.
Get the abstracts a resolution without parameters requests from a receiver known to be the container, such as the container a #[BindWhen] condition receives, or null for any other call.
Get the abstracts a resolution from the application container requests, or null for any other call: the resolving helpers, the App facade, or the framework's resolving method called on the application, such as app() or an injected application, or on Container::getInstance().
Determine whether the call runs the framework container's own method on the application: any application instance, such as app() or an injected application, or Container::getInstance().
Get the label of the request or operation value the type always holds, ignoring null.
Determine whether the expression reads the current request or user, without entering closures.
Determine whether a key of the type can only take a bounded set of values.
Details
in
HasContainer at line 19
void
setContainer(Container $container)
Set the container used for resolution.
in
HasContainer at line 27
Container
getContainer()
Return the current container.
in
HasContainer at line 35
mixed
resolve(string $abstract)
Resolve the given type from the container.
at line 122
__construct(ReflectionProvider $reflectionProvider, CoroutineRuleHelper $coroutineRuleHelper, RuntimeInputs $runtimeInputs, bool $checkWorkerSharedState, bool $checkStaticStateMutation, bool $checkUnboundedWorkerCaches, bool $noRuntimeConfigMutation, bool $checkRestrictedCalls, bool $checkCancellationHandling)
Create a new worker state helper instance.
at line 145
bool
isEnabled()
Determine whether any check that judges code by the operation it runs in is enabled, so the shared model's facts are collected.
at line 153
bool
hasStateChecks()
Determine whether any check of the state code keeps for the worker is enabled.
at line 164
WorkerStateAnalysis
analyze(CollectedDataNode $node)
Get the worker-state model of the collected data, built once for all the rules that share it.
at line 188
array|null
getFunctionFacts(Scope $scope, Node $node)
Get the facts of the function the scope's code at the node runs in, or null when it is a flushState() method or one marked as boot-time or test-only.
The context is the operation the code always runs in when the class alone decides it: a queued class's handle(), __invoke() or failed(), or a form request's method. The rule adds booted middleware and controller actions, the helpers those methods call on their own instance, and route closures by the node's position.
at line 219
AttributeReflection|null
getLifetimeAttribute(FunctionReflection|ExtendedMethodReflection $function)
Get the attribute marking the function as running only while the application boots or in tests.
at line 231
bool
isConfigRepositoryType(Type $type)
Determine whether the type is always a configuration repository, which the rule may prove to be the global one.
at line 239
bool
isConfigFunction(FuncCall $call, Scope $scope)
Determine whether the call is the global config() helper.
at line 249
bool
isConfigWrite(CallLike $call, Scope $scope)
Determine whether the call changes configuration: config() with an array, a Config facade write, or a repository write method.
at line 281
array|null
getConfigReceiver(Expr $expr, Scope $scope)
Describe the expression a configuration write goes through when it may be the global repository: config() without arguments, a constant resolution from the application container (its names, which the rule resolves with the booted aliases), a parameter of the innermost function typed as a repository (its name, which the rule checks the container injects), or a repository property the constructor promotes (which the rule checks the same way). Null for any other expression.
at line 313
array|null
getPromotedProperty(Expr $expr, Scope $scope)
Get the constructor's declaring class and the property name when the expression reads $this's readonly property that constructor promotes, outside closures. The property then holds what the container injected into the constructor, when the container built the instance.
at line 344
array
getParameters(Scope $scope)
Get the parameters of the scope's innermost function.
at line 356
array|null
getResolvedAbstracts(CallLike $call, Scope $scope)
Get the abstracts a container resolution without parameters requests, or null for any other call.
at line 383
array|null
getContainerResolvedAbstracts(MethodCall $call, Scope $scope)
Get the abstracts a resolution without parameters requests from a receiver known to be the container, such as the container a #[BindWhen] condition receives, or null for any other call.
at line 426
array|null
getApplicationResolvedAbstracts(CallLike $call, Scope $scope)
Get the abstracts a resolution from the application container requests, or null for any other call: the resolving helpers, the App facade, or the framework's resolving method called on the application, such as app() or an injected application, or on Container::getInstance().
Another container, or one overriding the method, may hold other bindings than the booted ones.
at line 441
bool
isApplicationContainerCall(MethodCall $call, Scope $scope)
Determine whether the call runs the framework container's own method on the application: any application instance, such as app() or an injected application, or Container::getInstance().
Another container, or one overriding the method, may hold other bindings than the booted ones.
at line 464
string|null
getState(Type $type)
Get the label of the request or operation value the type always holds, ignoring null.
at line 486
bool
readsRequestState(Expr $expr, Scope $scope)
Determine whether the expression reads the current request or user, without entering closures.
at line 528
bool
isBoundedKey(Type $type)
Determine whether a key of the type can only take a bounded set of values.