Container
class Container implements ArrayAccess (View source)
Properties
protected array | $resolved | An array of the types that have been resolved. |
|
protected array | $bindings | The container's bindings. |
|
protected array | $instances | The container's shared instances. |
|
protected array | $aliases | The registered type aliases. |
|
protected array | $reboundCallbacks | All of the registered rebound callbacks. |
|
protected array | $resolvingCallbacks | All of the registered resolving callbacks. |
|
protected array | $globalResolvingCallbacks | All of the global resolving callbacks. |
Methods
Determine if a given string is resolvable.
Determine if the given abstract type has been bound.
Determine if the given abstract type has been resolved.
Determine if a given string is an alias.
Get the Closure to be used when building a type.
Register an existing instance as shared in the container.
Alias a type to a shorter name.
Extract the type and alias from a given definition.
Refresh an instance on the given target and method.
Fire the "rebound" callbacks for the given abstract type.
Get the rebound callbacks for a given type.
Resolve the given type from the container.
Get the concrete type for a given abstract.
Determine if the given abstract has a leading slash.
Instantiate a concrete instance of the given type.
Resolve all of the dependencies from the ReflectionParameters.
If extra parameters are passed by numeric ID, rekey them by argument name.
Fire all of the resolving callbacks.
Fire an array of callbacks with an object.
Determine if a given type is shared.
Determine if the given concrete is buildable.
Get the alias for an abstract if available.
Get the container's bindings.
Drop all of the stale instances and aliases.
Remove a resolved instance from the instance cache.
Clear all of the instances from the container.
Determine if a given offset exists.
Get the value at a given offset.
Set the value at a given offset.
Unset the value at a given offset.
Dynamically access container services.
Dynamically set container services.
Details
protected bool
resolvable(string $abstract)
Determine if a given string is resolvable.
bool
bound(string $abstract)
Determine if the given abstract type has been bound.
bool
resolved(string $abstract)
Determine if the given abstract type has been resolved.
bool
isAlias(string $name)
Determine if a given string is an alias.
void
bind(string|array $abstract, Closure|string|null $concrete = null, bool $shared = false)
Register a binding with the container.
protected Closure
getClosure(string $abstract, string $concrete)
Get the Closure to be used when building a type.
void
bindIf(string $abstract, Closure|string|null $concrete = null, bool $shared = false)
Register a binding if it hasn't already been registered.
void
singleton(string $abstract, Closure|string|null $concrete = null)
Register a shared binding in the container.
void
bindShared(string $abstract, Closure $closure)
Bind a shared Closure into the container.
void
extend(string $abstract, Closure $closure)
"Extend" an abstract type in the container.
protected Closure
getExtender(string $abstract, Closure $closure)
Get an extender Closure for resolving a type.
void
instance(string $abstract, mixed $instance)
Register an existing instance as shared in the container.
void
alias(string $abstract, string $alias)
Alias a type to a shorter name.
protected array
extractAlias(array $definition)
Extract the type and alias from a given definition.
mixed
rebinding(string $abstract, Closure $callback)
Bind a new callback to an abstract's rebind event.
mixed
refresh(string $abstract, mixed $target, string $method)
Refresh an instance on the given target and method.
protected void
rebound(string $abstract)
Fire the "rebound" callbacks for the given abstract type.
protected array
getReboundCallbacks(string $abstract)
Get the rebound callbacks for a given type.
mixed
make(string $abstract, array $parameters = array())
Resolve the given type from the container.
protected mixed
getConcrete(string $abstract)
Get the concrete type for a given abstract.
protected bool
missingLeadingSlash(string $abstract)
Determine if the given abstract has a leading slash.
mixed
build(string $concrete, array $parameters = array())
Instantiate a concrete instance of the given type.
protected array
getDependencies(array $parameters, array $primitives = array())
Resolve all of the dependencies from the ReflectionParameters.
protected mixed
resolveNonClass(ReflectionParameter $parameter)
Resolve a non-class hinted dependency.
protected mixed
resolveClass(ReflectionParameter $parameter)
Resolve a class based dependency from the container.
protected array
keyParametersByArgument(array $dependencies, array $parameters)
If extra parameters are passed by numeric ID, rekey them by argument name.
void
resolving(string $abstract, Closure $callback)
Register a new resolving callback.
void
resolvingAny(Closure $callback)
Register a new resolving callback for all types.
protected void
fireResolvingCallbacks(string $abstract, mixed $object)
Fire all of the resolving callbacks.
protected
fireCallbackArray(mixed $object, array $callbacks)
Fire an array of callbacks with an object.
bool
isShared(string $abstract)
Determine if a given type is shared.
protected bool
isBuildable(mixed $concrete, string $abstract)
Determine if the given concrete is buildable.
protected string
getAlias(string $abstract)
Get the alias for an abstract if available.
array
getBindings()
Get the container's bindings.
protected void
dropStaleInstances(string $abstract)
Drop all of the stale instances and aliases.
void
forgetInstance(string $abstract)
Remove a resolved instance from the instance cache.
void
forgetInstances()
Clear all of the instances from the container.
bool
offsetExists(string $key)
Determine if a given offset exists.
mixed
offsetGet(string $key)
Get the value at a given offset.
void
offsetSet(string $key, mixed $value)
Set the value at a given offset.
void
offsetUnset(string $key)
Unset the value at a given offset.
mixed
__get(string $key)
Dynamically access container services.
void
__set(string $key, mixed $value)
Dynamically set container services.