Documentation

Container implements ContainerContract

Interfaces, Classes and Traits

ContainerContract

Table of Contents

$aliases  : array<string|int, mixed>
Aliases.
$contextualDependencies  : array<string|int, mixed>
Contextual dependencies.
$hints  : array<string|int, mixed>
Registered type hints.
$instances  : array<string|int, mixed>
Singleton instances.
$replacers  : array<string|int, mixed>
Instance replacers.
closureFactory()  : object
Creates a class instance using closure.
exec()  : object
Execute a callable and inject its dependencies.
factory()  : object
Creates a class instance.
get()  : object
Returns a class instance.
has()  : bool
Checks if a class is registered in the container.
isSingleton()  : bool
Returns TRUE if a class has been registered as a singleton and FALSE if not.
reflectionFactory()  : object
Creates a class instance using reflection.
register()  : void
Register a type hint.
registerContextualDependency()  : void
Registers a contextual dependency.
registerInstance()  : void
Register a singleton instance.
registerSingleton()  : mixed
Register a type hint and return the same instance every time.
getDeclaringFunction()  : string
Returns the name of function.
mergeParameters()  : array<string|int, mixed>
Merges the provided parameters with the reflection parameters into one array.
parseHint()  : string
Parse the hint parameter.
resolveAlias()  : string
Return the name based on its alias.
resolveContextualDependency()  : string
Resolves a contextual dependency.
resolveHint()  : string|Closure
Resolves a type hint.
resolveParameter()  : mixed
Resolve a parameter.
resolveParameters()  : array<string|int, mixed>
Resolve parameters.

Properties

$aliases

Aliases.

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

$contextualDependencies

Contextual dependencies.

protected array<string|int, mixed> $contextualDependencies = []
Tags
since
1.0.0

$hints

Registered type hints.

protected array<string|int, mixed> $hints = []
Tags
since
1.0.0

$instances

Singleton instances.

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

$replacers

Instance replacers.

protected array<string|int, mixed> $replacers = []
Tags
since
1.0.0

Methods

closureFactory()

Creates a class instance using closure.

public closureFactory(closure $factory, array<string|int, mixed> $parameters) : object
Parameters
$factory : closure

Closuare.

$parameters : array<string|int, mixed>

Constructor parameters.

Tags
since
1.0.0
Return values
object

exec()

Execute a callable and inject its dependencies.

public exec(callable $callable[, array<string|int, mixed> $parameters = [] ]) : object
Parameters
$callable : callable

Callable.

$parameters : array<string|int, mixed> = []

Parameters.

Tags
since
1.0.0
Return values
object

factory()

Creates a class instance.

public factory(string|Closure $class[, array<string|int, mixed> $parameters = [] ]) : object
Parameters
$class : string|Closure

Class name or closure.

$parameters : array<string|int, mixed> = []

Constructor parameters.

Tags
since
1.0.0
Return values
object

get()

Returns a class instance.

public get(string $class[, array<string|int, mixed> $parameters = [] ]) : object
Parameters
$class : string

Class name.

$parameters : array<string|int, mixed> = []

Constructor parameters.

Tags
since
1.0.0
Return values
object

has()

Checks if a class is registered in the container.

public has(string $class) : bool
Parameters
$class : string

Class name.

Tags
since
1.0.0
Return values
bool

isSingleton()

Returns TRUE if a class has been registered as a singleton and FALSE if not.

public isSingleton(string $class) : bool
Parameters
$class : string

Class name.

Tags
since
1.0.0
Return values
bool

reflectionFactory()

Creates a class instance using reflection.

public reflectionFactory(mixed $class[, array<string|int, mixed> $parameters = [] ]) : object
Parameters
$class : mixed

Class name.

$parameters : array<string|int, mixed> = []

Constructor parameters.

Tags
since
1.0.0
Return values
object

register()

Register a type hint.

public register(string|array<string|int, mixed> $hint, string|Closure $class[, bool $singleton = false ]) : void
Parameters
$hint : string|array<string|int, mixed>

Type hint or array contaning both type hint and alias.

$class : string|Closure

Class name or closure.

$singleton : bool = false

Should we return the same instance every time?

Tags
since
1.0.0
Return values
void

registerContextualDependency()

Registers a contextual dependency.

public registerContextualDependency(string $class, string $interface, string $implementation) : void
Parameters
$class : string

Class.

$interface : string

Interface.

$implementation : string

Implementation.

Tags
since
1.0.0
Return values
void

registerInstance()

Register a singleton instance.

public registerInstance(string|array<string|int, mixed> $hint, object $instance) : void
Parameters
$hint : string|array<string|int, mixed>

Type hint or array contaning both type hint and alias.

$instance : object

Class instance.

Tags
since
1.0.0
Return values
void

registerSingleton()

Register a type hint and return the same instance every time.

public registerSingleton(string|array<string|int, mixed> $hint, string|Closure $class) : mixed
Parameters
$hint : string|array<string|int, mixed>

Type hint or array contaning both type hint and alias.

$class : string|Closure

Class name or closure.

Tags
since
1.0.0
Return values
mixed

getDeclaringFunction()

Returns the name of function.

protected getDeclaringFunction(ReflectionParameter $parameter) : string
Parameters
$parameter : ReflectionParameter

ReflectionParameter instance.

Tags
since
1.0.0
Return values
string

mergeParameters()

Merges the provided parameters with the reflection parameters into one array.

protected mergeParameters(array<string|int, mixed> $reflectionParameters, array<string|int, mixed> $providedParameters) : array<string|int, mixed>
Parameters
$reflectionParameters : array<string|int, mixed>

Reflection parameters.

$providedParameters : array<string|int, mixed>

Provided parameters.

Tags
since
1.0.0
Return values
array<string|int, mixed>

parseHint()

Parse the hint parameter.

protected parseHint(string|array<string|int, mixed> $hint) : string
Parameters
$hint : string|array<string|int, mixed>

Type hint or array contaning both type hint and alias

Tags
since
1.0.0
Return values
string

resolveAlias()

Return the name based on its alias.

protected resolveAlias(string $alias) : string
Parameters
$alias : string

Alias.

Tags
since
1.0.0
Return values
string

resolveContextualDependency()

Resolves a contextual dependency.

protected resolveContextualDependency(string $class, string $interface) : string
Parameters
$class : string

Class.

$interface : string

Interface.

Tags
since
1.0.0
Return values
string

resolveHint()

Resolves a type hint.

protected resolveHint(string $hint) : string|Closure
Parameters
$hint : string

Type hint

Tags
since
1.0.0
Return values
string|Closure

resolveParameter()

Resolve a parameter.

protected resolveParameter(ReflectionParameter $parameter[, ReflectionClass|null $class = null ]) : mixed
Parameters
$parameter : ReflectionParameter

ReflectionParameter instance.

$class : ReflectionClass|null = null

ReflectionClass instance.

Tags
since
1.0.0
Return values
mixed

resolveParameters()

Resolve parameters.

protected resolveParameters(array<string|int, mixed> $reflectionParameters, array<string|int, mixed> $providedParameters[, ReflectionClass|null $class = null ]) : array<string|int, mixed>
Parameters
$reflectionParameters : array<string|int, mixed>

Reflection parameters.

$providedParameters : array<string|int, mixed>

Provided Parameters.

$class : ReflectionClass|null = null

ReflectionClass instance.

Tags
since
1.0.0
Return values
array<string|int, mixed>

Search results