interface Container implements ContainerInterface

Methods

mixed
get(string $id)

No description

bool
bound(string $abstract)

Determine if the given abstract type has been bound.

void
alias(string $abstract, string $alias)

Alias a type to a different name.

void
tag(array|string $abstracts, array|string $tags)

Assign a set of tags to a given binding.

iterable
tagged(string $tag)

Resolve all of the bindings for a given tag.

void
bind(Closure|string $abstract, Closure|string|null $concrete = null, bool $shared = false)

Register a binding with the container.

void
bindMethod(array|string $method, Closure $callback)

Bind a callback to resolve with Container::call.

void
bindIf(Closure|string $abstract, Closure|string|null $concrete = null, bool $shared = false)

Register a binding if it hasn't already been registered.

void
singleton(Closure|string $abstract, Closure|string|null $concrete = null)

Register a shared binding in the container.

void
singletonIf(Closure|string $abstract, Closure|string|null $concrete = null)

Register a shared binding if it hasn't already been registered.

void
scoped(Closure|string $abstract, Closure|string|null $concrete = null)

Register a scoped binding in the container.

void
scopedIf(Closure|string $abstract, Closure|string|null $concrete = null)

Register a scoped binding if it hasn't already been registered.

bool
isScoped(string $abstract)

Determine if a given abstract is a scoped binding.

bool
isScopedInstance(mixed $instance)

Determine if the object is a resolved scoped instance in this coroutine.

bool
resolvedShared(string $abstract)

Determine if the container holds a worker-shared instance for the given type.

void
extend(string $abstract, Closure $closure)

"Extend" an abstract type in the container.

mixed
instance(string $abstract, mixed $instance)

Register an existing instance as shared in the container.

void
forgetInstance(string $abstract)

Remove a resolved instance from the instance cache.

void
addContextualBinding(string $concrete, string $abstract, mixed $implementation)

Add a contextual binding to the container.

when(string|array $concrete)

Define a contextual binding.

factory(string $abstract)

Get a closure to resolve the given type from the container.

void
flush()

Flush the container of all bindings and resolved instances.

mixed
make(string $abstract, array $parameters = [])

Resolve the given type from the container.

mixed
makeTransient(string $abstract)

Resolve the given type with a transient implicit lifetime.

mixed
build(Closure|string $concrete)

Instantiate a concrete instance of the given type.

mixed
buildWith(Closure|string $concrete, array $parameters = [])

Instantiate a concrete instance with the given parameter overrides.

array
resolveContextualParameters(string $concrete, array|null $names = null)

Resolve the contextual constructor parameters of a class within its build context.

mixed
call(callable|string $callback, array $parameters = [], string|null $defaultMethod = null)

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

bool
resolved(string $abstract)

Determine if the given abstract type has been resolved.

mixed
rebinding(string $abstract, Closure $callback)

Register a new rebinding callback for an abstract type.

void
beforeResolving(Closure|string $abstract, Closure|null $callback = null)

Register a new before resolving callback.

void
resolving(Closure|string $abstract, Closure|null $callback = null)

Register a new resolving callback.

void
afterResolving(Closure|string $abstract, Closure|null $callback = null)

Register a new after resolving callback.

Details

at line 23
mixed get(string $id)

No description

Parameters

string $id

Return Value

mixed

at line 28
bool bound(string $abstract)

Determine if the given abstract type has been bound.

Parameters

string $abstract

Return Value

bool

at line 35
void alias(string $abstract, string $alias)

Alias a type to a different name.

Parameters

string $abstract
string $alias

Return Value

void

Exceptions

LogicException

at line 41
void tag(array|string $abstracts, array|string $tags)

Assign a set of tags to a given binding.

Parameters

array|string $abstracts
array|string $tags

Return Value

void

at line 47
iterable tagged(string $tag)

Resolve all of the bindings for a given tag.

Parameters

string $tag

Return Value

iterable

at line 52
void bind(Closure|string $abstract, Closure|string|null $concrete = null, bool $shared = false)

Register a binding with the container.

Parameters

Closure|string $abstract
Closure|string|null $concrete
bool $shared

Return Value

void

at line 58
void bindMethod(array|string $method, Closure $callback)

Bind a callback to resolve with Container::call.

Parameters

array|string $method
Closure $callback

Return Value

void

at line 64
void bindIf(Closure|string $abstract, Closure|string|null $concrete = null, bool $shared = false)

Register a binding if it hasn't already been registered.

Parameters

Closure|string $abstract
Closure|string|null $concrete
bool $shared

Return Value

void

at line 70
void singleton(Closure|string $abstract, Closure|string|null $concrete = null)

Register a shared binding in the container.

Parameters

Closure|string $abstract
Closure|string|null $concrete

Return Value

void

at line 76
void singletonIf(Closure|string $abstract, Closure|string|null $concrete = null)

Register a shared binding if it hasn't already been registered.

Parameters

Closure|string $abstract
Closure|string|null $concrete

Return Value

void

at line 82
void scoped(Closure|string $abstract, Closure|string|null $concrete = null)

Register a scoped binding in the container.

Parameters

Closure|string $abstract
Closure|string|null $concrete

Return Value

void

at line 88
void scopedIf(Closure|string $abstract, Closure|string|null $concrete = null)

Register a scoped binding if it hasn't already been registered.

Parameters

Closure|string $abstract
Closure|string|null $concrete

Return Value

void

at line 94
bool isScoped(string $abstract)

Determine if a given abstract is a scoped binding.

Parameters

string $abstract

Return Value

bool

at line 99
bool isScopedInstance(mixed $instance)

Determine if the object is a resolved scoped instance in this coroutine.

Parameters

mixed $instance

Return Value

bool

at line 104
bool resolvedShared(string $abstract)

Determine if the container holds a worker-shared instance for the given type.

Parameters

string $abstract

Return Value

bool

at line 111
void extend(string $abstract, Closure $closure)

"Extend" an abstract type in the container.

Parameters

string $abstract
Closure $closure

Return Value

void

Exceptions

InvalidArgumentException

at line 122
mixed instance(string $abstract, mixed $instance)

Register an existing instance as shared in the container.

Parameters

string $abstract
mixed $instance

Return Value

mixed

at line 128
void forgetInstance(string $abstract)

Remove a resolved instance from the instance cache.

Parameters

string $abstract

Return Value

void

at line 134
void addContextualBinding(string $concrete, string $abstract, mixed $implementation)

Add a contextual binding to the container.

Parameters

string $concrete
string $abstract
mixed $implementation

Return Value

void

at line 140
ContextualBindingBuilder when(string|array $concrete)

Define a contextual binding.

Parameters

string|array $concrete

Return Value

ContextualBindingBuilder

at line 150
Closure factory(string $abstract)

Get a closure to resolve the given type from the container.

Parameters

string $abstract

Return Value

Closure

at line 155
void flush()

Flush the container of all bindings and resolved instances.

Return Value

void

at line 168
mixed make(string $abstract, array $parameters = [])

Resolve the given type from the container.

Parameters

string $abstract
array $parameters

Return Value

mixed

Exceptions

BindingResolutionException

at line 182
mixed makeTransient(string $abstract)

Resolve the given type with a transient implicit lifetime.

Explicit lifetimes remain authoritative.

Parameters

string $abstract

Return Value

mixed

Exceptions

BindingResolutionException

at line 192
mixed build(Closure|string $concrete)

Instantiate a concrete instance of the given type.

Unlike make(), this always creates a fresh instance — it bypasses bindings, aliases, and singleton/auto-singleton caching.

Parameters

Closure|string $concrete

Return Value

mixed

Exceptions

BindingResolutionException

at line 202
mixed buildWith(Closure|string $concrete, array $parameters = [])

Instantiate a concrete instance with the given parameter overrides.

Unlike make(), this always creates a fresh instance — it bypasses bindings, aliases, and singleton/auto-singleton caching.

Parameters

Closure|string $concrete
array $parameters

Return Value

mixed

Exceptions

BindingResolutionException

at line 217
array resolveContextualParameters(string $concrete, array|null $names = null)

Resolve the contextual constructor parameters of a class within its build context.

Pass the values to buildWith() as overrides so they are not resolved again. Variadic parameters are skipped, because an override is passed as one argument; the container resolves them when the class is built.

Parameters

string $concrete
array|null $names

the parameters to resolve, or null for every contextual parameter

Return Value

array

Exceptions

BindingResolutionException

at line 222
mixed call(callable|string $callback, array $parameters = [], string|null $defaultMethod = null)

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

Parameters

callable|string $callback
array $parameters
string|null $defaultMethod

Return Value

mixed

at line 227
bool resolved(string $abstract)

Determine if the given abstract type has been resolved.

Parameters

string $abstract

Return Value

bool

at line 232
mixed rebinding(string $abstract, Closure $callback)

Register a new rebinding callback for an abstract type.

Parameters

string $abstract
Closure $callback

Return Value

mixed

at line 238
void beforeResolving(Closure|string $abstract, Closure|null $callback = null)

Register a new before resolving callback.

Parameters

Closure|string $abstract
Closure|null $callback

Return Value

void

at line 244
void resolving(Closure|string $abstract, Closure|null $callback = null)

Register a new resolving callback.

Parameters

Closure|string $abstract
Closure|null $callback

Return Value

void

at line 250
void afterResolving(Closure|string $abstract, Closure|null $callback = null)

Register a new after resolving callback.

Parameters

Closure|string $abstract
Closure|null $callback

Return Value

void