class ControllerDispatcher implements ControllerDispatcher

Traits

Properties

static protected array<string, bool> $enumCache

Cached isEnum results keyed by class name.

from  ResolvesRouteDependencies
static protected ReflectionParameter>> $reflectionCache

Cached ReflectionParameter arrays keyed by "class::method".

protected Container $container

The container instance.

protected PrecognitionControllerDispatcher|null $precognitionDispatcher

The cached precognition dispatcher instance.

Methods

static bool
methodExcludedByOptions(string $method, array $options)

Determine if the given options exclude a particular method.

static void
flushEnumCache()

Flush the static enum cache.

array
resolveClassMethodDependencies(array $parameters, object $instance, string $method)

Resolve the object method's type-hinted dependencies.

array
resolveMethodDependencies(array $parameters, array $reflectedParameters)

Resolve the given method's type-hinted dependencies.

mixed
transformDependency(ReflectionParameter $parameter, array $parameters, object $skippableValue)

Attempt to transform the given parameter into a class instance.

bool
alreadyInParameters(string $class, array $parameters)

Determine if an object of the given class is in a list of parameters.

void
spliceIntoParameters(array $parameters, int $offset, mixed $value)

Splice the given value into the parameter list.

__construct(Container $container)

Create a new controller dispatcher instance.

mixed
dispatch(Route $route, mixed $controller, string $method)

Dispatch a request to a given controller and method.

array
resolveParameters(Route $route, mixed $controller, string $method)

Resolve the parameters for the controller.

static void
warmReflection(string $class, string $method)

Pre-warm the reflection parameter cache for a controller action.

static void
flushCache()

Flush the static reflection cache.

array
getMiddleware(mixed $controller, string $method)

Get the middleware for the controller instance.

static void
flushState()

Flush all static state.

Details

static bool methodExcludedByOptions(string $method, array $options)

Determine if the given options exclude a particular method.

Parameters

string $method
array $options

Return Value

bool

static void flushEnumCache()

Flush the static enum cache.

Boot or tests only. Clears the process-wide enum lookup cache shared by every coroutine; next resolution re-resolves.

Return Value

void

at line 86
protected array resolveClassMethodDependencies(array $parameters, object $instance, string $method)

Resolve the object method's type-hinted dependencies.

Overrides ResolvesRouteDependencies to use a static parameter cache.

Parameters

array $parameters
object $instance
string $method

Return Value

array

array resolveMethodDependencies(array $parameters, array $reflectedParameters)

Resolve the given method's type-hinted dependencies.

Parameters

array $parameters
array $reflectedParameters

Return Value

array

protected mixed transformDependency(ReflectionParameter $parameter, array $parameters, object $skippableValue)

Attempt to transform the given parameter into a class instance.

Parameters

ReflectionParameter $parameter
array $parameters
object $skippableValue

Return Value

mixed

protected bool alreadyInParameters(string $class, array $parameters)

Determine if an object of the given class is in a list of parameters.

Parameters

string $class
array $parameters

Return Value

bool

protected void spliceIntoParameters(array $parameters, int $offset, mixed $value)

Splice the given value into the parameter list.

Parameters

array $parameters
int $offset
mixed $value

Return Value

void

at line 43
__construct(Container $container)

Create a new controller dispatcher instance.

Parameters

Container $container

at line 51
mixed dispatch(Route $route, mixed $controller, string $method)

Dispatch a request to a given controller and method.

Parameters

Route $route
mixed $controller
string $method

Return Value

mixed

at line 72
protected array resolveParameters(Route $route, mixed $controller, string $method)

Resolve the parameters for the controller.

Parameters

Route $route
mixed $controller
string $method

Return Value

array

at line 105
static void warmReflection(string $class, string $method)

Pre-warm the reflection parameter cache for a controller action.

Boot-only. Called during server boot to populate reflection data in a process-wide cache before fork so workers inherit it copy-on-write.

Parameters

string $class
string $method

Return Value

void

at line 117
static void flushCache()

Flush the static reflection cache.

Boot or tests only. Clears the process-wide reflection cache shared by every coroutine; next dispatch re-reflects.

Return Value

void

at line 125
array getMiddleware(mixed $controller, string $method)

Get the middleware for the controller instance.

Parameters

mixed $controller
string $method

Return Value

array

at line 140
static void flushState()

Flush all static state.

Return Value

void