Documentation

Container
in package
implements ArrayAccess, Container

Interfaces, Classes and Traits

ArrayAccess
Container
Describes the interface of a container that exposes methods to read its entries.

Table of Contents

$contextual  : array<string|int, mixed>
The contextual binding map.
$abstractAliases  : array<string|int, mixed>
The registered aliases keyed by the abstract name.
$afterResolvingCallbacks  : array<string|int, mixed>
All of the after resolving callbacks by class type.
$aliases  : array<string|int, mixed>
The registered type aliases.
$bindings  : array<string|int, mixed>
The container's bindings.
$buildStack  : array<string|int, mixed>
The stack of concretions currently being built.
$extenders  : array<string|int, mixed>
The extension closures for services.
$globalAfterResolvingCallbacks  : array<string|int, mixed>
All of the global after resolving callbacks.
$globalResolvingCallbacks  : array<string|int, mixed>
All of the global resolving callbacks.
$instance  : static
The current globally available container (if any).
$instances  : array<string|int, mixed>
The container's shared instances.
$methodBindings  : array<string|int, mixed>
The container's method bindings.
$reboundCallbacks  : array<string|int, mixed>
All of the registered rebound callbacks.
$resolved  : array<string|int, mixed>
An array of the types that have been resolved.
$resolvingCallbacks  : array<string|int, mixed>
All of the resolving callbacks by class type.
$tags  : array<string|int, mixed>
All of the registered tags.
$with  : array<string|int, mixed>
The parameter override stack.
__get()  : mixed
Dynamically access container services.
__set()  : void
Dynamically set container services.
addContextualBinding()  : void
Add a contextual binding to the container.
afterResolving()  : void
Register a new after resolving callback for all types.
alias()  : void
Alias a type to a different name.
bind()  : void
Register a binding with the container.
bindIf()  : void
Register a binding if it hasn't already been registered.
bindMethod()  : void
Bind a callback to resolve with Container::call.
bound()  : bool
Determine if the given abstract type has been bound.
build()  : mixed
Instantiate a concrete instance of the given type.
call()  : mixed
Call the given Closure / class@method and inject its dependencies.
callMethodBinding()  : mixed
Get the method binding for the given method.
extend()  : void
"Extend" an abstract type in the container.
factory()  : Closure
Get a closure to resolve the given type from the container.
flush()  : void
Flush the container of all bindings and resolved instances.
forgetExtenders()  : void
Remove all of the extender callbacks for a given type.
forgetInstance()  : void
Remove a resolved instance from the instance cache.
forgetInstances()  : void
Clear all of the instances from the container.
get()  : mixed
{@inheritdoc}
getAlias()  : string
Get the alias for an abstract if available.
getBindings()  : array<string|int, mixed>
Get the container's bindings.
getInstance()  : static
Set the globally available instance of the container.
has()  : mixed
{@inheritdoc}
hasMethodBinding()  : bool
Determine if the container has a method binding.
instance()  : mixed
Register an existing instance as shared in the container.
isAlias()  : bool
Determine if a given string is an alias.
isShared()  : bool
Determine if a given type is shared.
make()  : mixed
Resolve the given type from the container.
makeWith()  : mixed
An alias function name for make().
offsetExists()  : bool
Determine if a given offset exists.
offsetGet()  : mixed
Get the value at a given offset.
offsetSet()  : void
Set the value at a given offset.
offsetUnset()  : void
Unset the value at a given offset.
rebinding()  : mixed
Bind a new callback to an abstract's rebind event.
refresh()  : mixed
Refresh an instance on the given target and method.
resolved()  : bool
Determine if the given abstract type has been resolved.
resolving()  : void
Register a new resolving callback.
setInstance()  : static
Set the shared instance of the container.
singleton()  : void
Register a shared binding in the container.
tag()  : void
Assign a set of tags to a given binding.
tagged()  : array<string|int, mixed>
Resolve all of the bindings for a given tag.
when()  : ContextualBindingBuilder
Define a contextual binding.
wrap()  : Closure
Wrap the given closure such that its dependencies will be injected when executed.
dropStaleInstances()  : void
Drop all of the stale instances and aliases.
findInContextualBindings()  : string|null
Find the concrete binding for the given abstract in the contextual binding array.
fireAfterResolvingCallbacks()  : void
Fire all of the after resolving callbacks.
fireCallbackArray()  : void
Fire an array of callbacks with an object.
fireResolvingCallbacks()  : void
Fire all of the resolving callbacks.
getCallbacksForType()  : array<string|int, mixed>
Get all callbacks for a given type.
getClosure()  : Closure
Get the Closure to be used when building a type.
getConcrete()  : mixed
Get the concrete type for a given abstract.
getContextualConcrete()  : string|null
Get the contextual concrete binding for the given abstract.
getExtenders()  : array<string|int, mixed>
Get the extender callbacks for a given type.
getLastParameterOverride()  : array<string|int, mixed>
Get the last parameter override.
getParameterOverride()  : mixed
Get a parameter override for a dependency.
getReboundCallbacks()  : array<string|int, mixed>
Get the rebound callbacks for a given type.
hasParameterOverride()  : bool
Determine if the given dependency has a parameter override.
isBuildable()  : bool
Determine if the given concrete is buildable.
notInstantiable()  : void
Throw an exception that the concrete is not instantiable.
rebound()  : void
Fire the "rebound" callbacks for the given abstract type.
removeAbstractAlias()  : void
Remove an alias from the contextual binding alias cache.
resolve()  : mixed
Resolve the given type from the container.
resolveClass()  : mixed
Resolve a class based dependency from the container.
resolveDependencies()  : array<string|int, mixed>
Resolve all of the dependencies from the ReflectionParameters.
resolvePrimitive()  : mixed
Resolve a non-class hinted primitive dependency.
unresolvablePrimitive()  : void
Throw an exception for an unresolvable primitive.

Properties

$contextual

The contextual binding map.

public array<string|int, mixed> $contextual = []

$abstractAliases

The registered aliases keyed by the abstract name.

protected array<string|int, mixed> $abstractAliases = []

$afterResolvingCallbacks

All of the after resolving callbacks by class type.

protected array<string|int, mixed> $afterResolvingCallbacks = []

$aliases

The registered type aliases.

protected array<string|int, mixed> $aliases = []

$bindings

The container's bindings.

protected array<string|int, mixed> $bindings = []

$buildStack

The stack of concretions currently being built.

protected array<string|int, mixed> $buildStack = []

$extenders

The extension closures for services.

protected array<string|int, mixed> $extenders = []

$globalAfterResolvingCallbacks

All of the global after resolving callbacks.

protected array<string|int, mixed> $globalAfterResolvingCallbacks = []

$globalResolvingCallbacks

All of the global resolving callbacks.

protected array<string|int, mixed> $globalResolvingCallbacks = []

$instance

The current globally available container (if any).

protected static static $instance

$instances

The container's shared instances.

protected array<string|int, mixed> $instances = []

$methodBindings

The container's method bindings.

protected array<string|int, mixed> $methodBindings = []

$reboundCallbacks

All of the registered rebound callbacks.

protected array<string|int, mixed> $reboundCallbacks = []

$resolved

An array of the types that have been resolved.

protected array<string|int, mixed> $resolved = []

$resolvingCallbacks

All of the resolving callbacks by class type.

protected array<string|int, mixed> $resolvingCallbacks = []

$tags

All of the registered tags.

protected array<string|int, mixed> $tags = []

$with

The parameter override stack.

protected array<string|int, mixed> $with = []

Methods

__get()

Dynamically access container services.

public __get(string $key) : mixed
Parameters
$key : string
Return values
mixed

__set()

Dynamically set container services.

public __set(string $key, mixed $value) : void
Parameters
$key : string
$value : mixed
Return values
void

addContextualBinding()

Add a contextual binding to the container.

public addContextualBinding(string $concrete, string $abstract, Closure|string $implementation) : void
Parameters
$concrete : string
$abstract : string
$implementation : Closure|string
Return values
void

afterResolving()

Register a new after resolving callback for all types.

public afterResolving(Closure|string $abstract[, Closure|null $callback = null ]) : void
Parameters
$abstract : Closure|string
$callback : Closure|null = null
Return values
void

alias()

Alias a type to a different name.

public alias(string $abstract, string $alias) : void
Parameters
$abstract : string
$alias : string
Return values
void

bind()

Register a binding with the container.

public bind(string $abstract[, Closure|string|null $concrete = null ][, bool $shared = false ]) : void
Parameters
$abstract : string
$concrete : Closure|string|null = null
$shared : bool = false
Return values
void

bindIf()

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

public bindIf(string $abstract[, Closure|string|null $concrete = null ][, bool $shared = false ]) : void
Parameters
$abstract : string
$concrete : Closure|string|null = null
$shared : bool = false
Return values
void

bindMethod()

Bind a callback to resolve with Container::call.

public bindMethod(string $method, Closure $callback) : void
Parameters
$method : string
$callback : Closure
Return values
void

bound()

Determine if the given abstract type has been bound.

public bound(string $abstract) : bool
Parameters
$abstract : string
Return values
bool

build()

Instantiate a concrete instance of the given type.

public build(string $concrete) : mixed
Parameters
$concrete : string
Tags
throws
BindingResolutionException
Return values
mixed

call()

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

public call(callable|string $callback[, array<string|int, mixed> $parameters = [] ][, string|null $defaultMethod = null ]) : mixed
Parameters
$callback : callable|string
$parameters : array<string|int, mixed> = []
$defaultMethod : string|null = null
Return values
mixed

callMethodBinding()

Get the method binding for the given method.

public callMethodBinding(string $method, mixed $instance) : mixed
Parameters
$method : string
$instance : mixed
Return values
mixed

extend()

"Extend" an abstract type in the container.

public extend(string $abstract, Closure $closure) : void
Parameters
$abstract : string
$closure : Closure
Tags
throws
InvalidArgumentException
Return values
void

factory()

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

public factory(string $abstract) : Closure
Parameters
$abstract : string
Return values
Closure

flush()

Flush the container of all bindings and resolved instances.

public flush() : void
Return values
void

forgetExtenders()

Remove all of the extender callbacks for a given type.

public forgetExtenders(string $abstract) : void
Parameters
$abstract : string
Return values
void

forgetInstance()

Remove a resolved instance from the instance cache.

public forgetInstance(string $abstract) : void
Parameters
$abstract : string
Return values
void

forgetInstances()

Clear all of the instances from the container.

public forgetInstances() : void
Return values
void

get()

{@inheritdoc}

public get(mixed $id) : mixed
Parameters
$id : mixed
Return values
mixed

getAlias()

Get the alias for an abstract if available.

public getAlias(string $abstract) : string
Parameters
$abstract : string
Tags
throws
LogicException
Return values
string

getBindings()

Get the container's bindings.

public getBindings() : array<string|int, mixed>
Return values
array<string|int, mixed>

getInstance()

Set the globally available instance of the container.

public static getInstance() : static
Return values
static

has()

{@inheritdoc}

public has(mixed $id) : mixed
Parameters
$id : mixed
Return values
mixed

hasMethodBinding()

Determine if the container has a method binding.

public hasMethodBinding(string $method) : bool
Parameters
$method : string
Return values
bool

instance()

Register an existing instance as shared in the container.

public instance(string $abstract, mixed $instance) : mixed
Parameters
$abstract : string
$instance : mixed
Return values
mixed

isAlias()

Determine if a given string is an alias.

public isAlias(string $name) : bool
Parameters
$name : string
Return values
bool

isShared()

Determine if a given type is shared.

public isShared(string $abstract) : bool
Parameters
$abstract : string
Return values
bool

make()

Resolve the given type from the container.

public make(string $abstract[, array<string|int, mixed> $parameters = [] ]) : mixed
Parameters
$abstract : string
$parameters : array<string|int, mixed> = []
Return values
mixed

makeWith()

An alias function name for make().

public makeWith(string $abstract[, array<string|int, mixed> $parameters = [] ]) : mixed
Parameters
$abstract : string
$parameters : array<string|int, mixed> = []
Return values
mixed

offsetExists()

Determine if a given offset exists.

public offsetExists(string $key) : bool
Parameters
$key : string
Return values
bool

offsetGet()

Get the value at a given offset.

public offsetGet(string $key) : mixed
Parameters
$key : string
Return values
mixed

offsetSet()

Set the value at a given offset.

public offsetSet(string $key, mixed $value) : void
Parameters
$key : string
$value : mixed
Return values
void

offsetUnset()

Unset the value at a given offset.

public offsetUnset(string $key) : void
Parameters
$key : string
Return values
void

rebinding()

Bind a new callback to an abstract's rebind event.

public rebinding(string $abstract, Closure $callback) : mixed
Parameters
$abstract : string
$callback : Closure
Return values
mixed

refresh()

Refresh an instance on the given target and method.

public refresh(string $abstract, mixed $target, string $method) : mixed
Parameters
$abstract : string
$target : mixed
$method : string
Return values
mixed

resolved()

Determine if the given abstract type has been resolved.

public resolved(string $abstract) : bool
Parameters
$abstract : string
Return values
bool

resolving()

Register a new resolving callback.

public resolving(Closure|string $abstract[, Closure|null $callback = null ]) : void
Parameters
$abstract : Closure|string
$callback : Closure|null = null
Return values
void

setInstance()

Set the shared instance of the container.

public static setInstance([Container|null $container = null ]) : static
Parameters
$container : Container|null = null
Return values
static

singleton()

Register a shared binding in the container.

public singleton(string $abstract[, Closure|string|null $concrete = null ]) : void
Parameters
$abstract : string
$concrete : Closure|string|null = null
Return values
void

tag()

Assign a set of tags to a given binding.

public tag(array<string|int, mixed>|string $abstracts, array<string|int, mixed>|mixed ...$tags) : void
Parameters
$abstracts : array<string|int, mixed>|string
$tags : array<string|int, mixed>|mixed
Return values
void

tagged()

Resolve all of the bindings for a given tag.

public tagged(string $tag) : array<string|int, mixed>
Parameters
$tag : string
Return values
array<string|int, mixed>

wrap()

Wrap the given closure such that its dependencies will be injected when executed.

public wrap(Closure $callback[, array<string|int, mixed> $parameters = [] ]) : Closure
Parameters
$callback : Closure
$parameters : array<string|int, mixed> = []
Return values
Closure

dropStaleInstances()

Drop all of the stale instances and aliases.

protected dropStaleInstances(string $abstract) : void
Parameters
$abstract : string
Return values
void

findInContextualBindings()

Find the concrete binding for the given abstract in the contextual binding array.

protected findInContextualBindings(string $abstract) : string|null
Parameters
$abstract : string
Return values
string|null

fireAfterResolvingCallbacks()

Fire all of the after resolving callbacks.

protected fireAfterResolvingCallbacks(string $abstract, mixed $object) : void
Parameters
$abstract : string
$object : mixed
Return values
void

fireCallbackArray()

Fire an array of callbacks with an object.

protected fireCallbackArray(mixed $object, array<string|int, mixed> $callbacks) : void
Parameters
$object : mixed
$callbacks : array<string|int, mixed>
Return values
void

fireResolvingCallbacks()

Fire all of the resolving callbacks.

protected fireResolvingCallbacks(string $abstract, mixed $object) : void
Parameters
$abstract : string
$object : mixed
Return values
void

getCallbacksForType()

Get all callbacks for a given type.

protected getCallbacksForType(string $abstract, object $object, array<string|int, mixed> $callbacksPerType) : array<string|int, mixed>
Parameters
$abstract : string
$object : object
$callbacksPerType : array<string|int, mixed>
Return values
array<string|int, mixed>

getClosure()

Get the Closure to be used when building a type.

protected getClosure(string $abstract, string $concrete) : Closure
Parameters
$abstract : string
$concrete : string
Return values
Closure

getConcrete()

Get the concrete type for a given abstract.

protected getConcrete(string $abstract) : mixed
Parameters
$abstract : string
Return values
mixed

$concrete

getContextualConcrete()

Get the contextual concrete binding for the given abstract.

protected getContextualConcrete(string $abstract) : string|null
Parameters
$abstract : string
Return values
string|null

getExtenders()

Get the extender callbacks for a given type.

protected getExtenders(string $abstract) : array<string|int, mixed>
Parameters
$abstract : string
Return values
array<string|int, mixed>

getLastParameterOverride()

Get the last parameter override.

protected getLastParameterOverride() : array<string|int, mixed>
Return values
array<string|int, mixed>

getParameterOverride()

Get a parameter override for a dependency.

protected getParameterOverride(ReflectionParameter $dependency) : mixed
Parameters
$dependency : ReflectionParameter
Return values
mixed

getReboundCallbacks()

Get the rebound callbacks for a given type.

protected getReboundCallbacks(string $abstract) : array<string|int, mixed>
Parameters
$abstract : string
Return values
array<string|int, mixed>

hasParameterOverride()

Determine if the given dependency has a parameter override.

protected hasParameterOverride(ReflectionParameter $dependency) : bool
Parameters
$dependency : ReflectionParameter
Return values
bool

isBuildable()

Determine if the given concrete is buildable.

protected isBuildable(mixed $concrete, string $abstract) : bool
Parameters
$concrete : mixed
$abstract : string
Return values
bool

notInstantiable()

Throw an exception that the concrete is not instantiable.

protected notInstantiable(string $concrete) : void
Parameters
$concrete : string
Tags
throws
BindingResolutionException
Return values
void

rebound()

Fire the "rebound" callbacks for the given abstract type.

protected rebound(string $abstract) : void
Parameters
$abstract : string
Return values
void

removeAbstractAlias()

Remove an alias from the contextual binding alias cache.

protected removeAbstractAlias(string $searched) : void
Parameters
$searched : string
Return values
void

resolve()

Resolve the given type from the container.

protected resolve(string $abstract[, array<string|int, mixed> $parameters = [] ]) : mixed
Parameters
$abstract : string
$parameters : array<string|int, mixed> = []
Return values
mixed

resolveClass()

Resolve a class based dependency from the container.

protected resolveClass(ReflectionParameter $parameter) : mixed
Parameters
$parameter : ReflectionParameter
Tags
throws
BindingResolutionException
Return values
mixed

resolveDependencies()

Resolve all of the dependencies from the ReflectionParameters.

protected resolveDependencies(array<string|int, mixed> $dependencies) : array<string|int, mixed>
Parameters
$dependencies : array<string|int, mixed>
Return values
array<string|int, mixed>

resolvePrimitive()

Resolve a non-class hinted primitive dependency.

protected resolvePrimitive(ReflectionParameter $parameter) : mixed
Parameters
$parameter : ReflectionParameter
Tags
throws
BindingResolutionException
Return values
mixed

unresolvablePrimitive()

Throw an exception for an unresolvable primitive.

protected unresolvablePrimitive(ReflectionParameter $parameter) : void
Parameters
$parameter : ReflectionParameter
Tags
throws
BindingResolutionException
Return values
void

Search results