class BoundMethod

Properties

static protected ParameterRecipe[]> $methodRecipes

Cache of method parameter recipes, keyed by "ClassName::methodName".

static protected ParameterRecipe[]> $functionRecipes

Cache of function parameter recipes, keyed by fully-qualified function name.

Methods

static mixed
call(Container $container, callable|string $callback, array $parameters = [], string|null $defaultMethod = null, ReflectionFunction|null $reflection = null)

Call the given Closure / class@method and inject its dependencies.

static mixed
callClass(Container $container, string $target, array $parameters = [], string|null $defaultMethod = null)

Call a string reference to a class using Class@method syntax.

static mixed
callBoundMethod(Container $container, callable|string $callback, mixed $default)

Call a method that has been bound to the container.

static string
normalizeMethod(array $callback)

Normalize the given callback into a Class@method string.

static array
getMethodRecipe(string $className, string $methodName)

Get cached parameter recipes for a method, computing on first access.

static array
computeMethodRecipe(string $className, string $methodName)

Compute parameter recipes for a method via reflection.

static array
getFunctionRecipe(string $functionName)

Get cached parameter recipes for a global function, computing on first access.

static array
computeFunctionRecipe(string $functionName)

Compute parameter recipes for a global function via reflection.

static void
flushState()

Flush all static state.

static array
resolveMethodRecipeParameters(Container $container, array $recipes, array $parameters)

Resolve method parameters using cached recipe metadata.

static array
getMethodDependencies(Container $container, callable|string $callback, array $parameters = [], ReflectionFunction|null $reflection = null)

Get all dependencies for a given method.

static void
addDependencyForCallParameter(Container $container, ReflectionParameter $parameter, array $parameters, array $dependencies)

Get the dependency for the given call parameter.

static bool
isCallableWithAtSign(mixed $callback)

Determine if the given string is in Class@method syntax.

Details

at line 48
static mixed call(Container $container, callable|string $callback, array $parameters = [], string|null $defaultMethod = null, ReflectionFunction|null $reflection = null)

Call the given Closure / class@method and inject its dependencies.

Parameters

Container $container
callable|string $callback
array $parameters
string|null $defaultMethod
ReflectionFunction|null $reflection

Return Value

mixed

Exceptions

ReflectionException
InvalidArgumentException

at line 68
static protected mixed callClass(Container $container, string $target, array $parameters = [], string|null $defaultMethod = null)

Call a string reference to a class using Class@method syntax.

Parameters

Container $container
string $target
array $parameters
string|null $defaultMethod

Return Value

mixed

Exceptions

InvalidArgumentException

at line 93
static protected mixed callBoundMethod(Container $container, callable|string $callback, mixed $default)

Call a method that has been bound to the container.

Parameters

Container $container
callable|string $callback
mixed $default

Return Value

mixed

at line 114
static protected string normalizeMethod(array $callback)

Normalize the given callback into a Class@method string.

Parameters

array $callback

Return Value

string

at line 126
static protected array getMethodRecipe(string $className, string $methodName)

Get cached parameter recipes for a method, computing on first access.

Parameters

string $className
string $methodName

Return Value

array

at line 138
static protected array computeMethodRecipe(string $className, string $methodName)

Compute parameter recipes for a method via reflection.

Parameters

string $className
string $methodName

Return Value

array

at line 159
static protected array getFunctionRecipe(string $functionName)

Get cached parameter recipes for a global function, computing on first access.

Parameters

string $functionName

Return Value

array

at line 169
static protected array computeFunctionRecipe(string $functionName)

Compute parameter recipes for a global function via reflection.

Parameters

string $functionName

Return Value

array

at line 188
static void flushState()

Flush all static state.

Return Value

void

at line 201
static protected array resolveMethodRecipeParameters(Container $container, array $recipes, array $parameters)

Resolve method parameters using cached recipe metadata.

Parameters

Container $container
array $recipes
array $parameters

Return Value

array

Exceptions

BindingResolutionException

at line 259
static protected array getMethodDependencies(Container $container, callable|string $callback, array $parameters = [], ReflectionFunction|null $reflection = null)

Get all dependencies for a given method.

Deterministic callables (array callables, Class::method strings, invocable objects, global function strings) use cached ParameterRecipe metadata. Closures use per-call reflection via addDependencyForCallParameter, with an optional pre-built ReflectionFunction to avoid redundant allocation.

Parameters

Container $container
callable|string $callback
array $parameters
ReflectionFunction|null $reflection

Return Value

array

Exceptions

ReflectionException

at line 309
static protected void addDependencyForCallParameter(Container $container, ReflectionParameter $parameter, array $parameters, array $dependencies)

Get the dependency for the given call parameter.

Parameters

Container $container
ReflectionParameter $parameter
array $parameters
array $dependencies

Return Value

void

Exceptions

BindingResolutionException

at line 366
static protected bool isCallableWithAtSign(mixed $callback)

Determine if the given string is in Class@method syntax.

Parameters

mixed $callback

Return Value

bool