Methods |
public
|
__construct(array $values = [])
Instantiates the container.
Instantiates the container.
Objects and parameters can be passed as argument to the constructor.
Parameters
$values |
The parameters or objects
|
|
#
|
public
|
offsetSet(string $id, mixed $value): void
Sets a parameter or an object.
Sets a parameter or an object.
Objects must be defined as Closures.
Allowing any PHP callable leads to difficult to debug problems
as function names (strings) are callable (creating a function with
the same name as an existing parameter would break your container).
Parameters
$id |
The unique identifier for the parameter or object
|
$value |
The value of the parameter or a closure to define an object
|
Throws
Implements
|
#
|
public
|
offsetGet(string $id): mixed
Gets a parameter or an object.
Gets a parameter or an object.
Parameters
$id |
The unique identifier for the parameter or object
|
Returns
The value of the parameter or an object
Throws
Implements
|
#
|
public
|
offsetExists(string $id): bool
Checks if a parameter or an object is set.
Checks if a parameter or an object is set.
Parameters
$id |
The unique identifier for the parameter or object
|
Implements
|
#
|
public
|
offsetUnset(string $id): void
Unsets a parameter or an object.
Unsets a parameter or an object.
Parameters
$id |
The unique identifier for the parameter or object
|
Implements
|
#
|
public
|
factory(callable $callable): callable
Marks a callable as being a factory service.
Marks a callable as being a factory service.
Parameters
$callable |
A service definition to be used as a factory
|
Returns
Throws
|
#
|
public
|
protect(callable $callable): callable
Protects a callable from being interpreted as a service.
Protects a callable from being interpreted as a service.
This is useful when you want to store a callable as a parameter.
Parameters
$callable |
A callable to protect from being evaluated
|
Returns
Throws
|
#
|
public
|
raw(string $id): mixed
Gets a parameter or the closure defining an object.
Gets a parameter or the closure defining an object.
Parameters
$id |
The unique identifier for the parameter or object
|
Returns
The value of the parameter or the closure defining an object
Throws
|
#
|
public
|
extend(string $id, callable $callable): callable
Extends an object definition.
Extends an object definition.
Useful when you want to extend an existing object definition,
without necessarily loading that object.
Parameters
$id |
The unique identifier for the object
|
$callable |
A service definition to extend the original
|
Returns
Throws
|
#
|
public
|
keys(): array
Returns all defined value names.
Returns all defined value names.
Returns
|
#
|
public
|
register(ServiceProviderInterface $provider, array $values = []): static
Registers a service provider.
Registers a service provider.
Parameters
$values |
An array of values that customizes the provider
|
|
#
|