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