class Container

The dependency injection container default implementation.

Properties

array deprecated $parameters
protected string[] $types
protected string[] $aliases
protected array[] $tags
protected array[] $wiring

Methods

__construct(array $params = [])

No description

array
getParameters()

No description

mixed
getParameter(string|int $key)

No description

array
getStaticParameters()

No description

mixed
getDynamicParameter(string|int $key)

No description

addService(string $name, object $service)

Adds the service to the container.

void
removeService(string $name)

Removes the service from the container.

object
getService(string $name)

Gets the service object by name.

object
getByName(string $name)

Gets the service object by name.

string
getServiceType(string $name)

Gets the service type by name.

bool
hasService(string $name)

Does the service exist?

bool
isCreated(string $name)

Is the service created?

object
createService(string $name)

Creates new instance of the service.

object|null
getByType(string $type, bool $throw = true)

Resolves service by type.

array
findAutowired(string $type)

Gets the autowired service names of the specified type.

array
findByType(string $type)

Gets the service names of the specified type.

array
findByTag(string $tag)

Gets the service names of the specified tag.

object
createInstance(string $class, array $args = [])

Creates new instance using autowiring.

void
callInjects(object $service)

Calls all methods starting with "inject" using autowiring.

mixed
callMethod(callable $function, array $args = [])

Calls method using autowiring.

static string
getMethodName(string $name)

No description

void
initialize()

No description

Details

at line 48
__construct(array $params = [])

No description

Parameters

array $params

at line 58
array getParameters()

No description

Return Value

array

at line 64
mixed getParameter(string|int $key)

No description

Parameters

string|int $key

Return Value

mixed

at line 73
protected array getStaticParameters()

No description

Return Value

array

at line 79
protected mixed getDynamicParameter(string|int $key)

No description

Parameters

string|int $key

Return Value

mixed

at line 89
Container addService(string $name, object $service)

Adds the service to the container.

Parameters

string $name
object $service

service or its factory

Return Value

Container

at line 129
void removeService(string $name)

Removes the service from the container.

Parameters

string $name

Return Value

void

at line 140
object getService(string $name)

Gets the service object by name.

Parameters

string $name

Return Value

object

Exceptions

MissingServiceException

at line 158
object getByName(string $name)

Gets the service object by name.

Parameters

string $name

Return Value

object

Exceptions

MissingServiceException

at line 168
string getServiceType(string $name)

Gets the service type by name.

Parameters

string $name

Return Value

string

Exceptions

MissingServiceException

at line 189
bool hasService(string $name)

Does the service exist?

Parameters

string $name

Return Value

bool

at line 199
bool isCreated(string $name)

Is the service created?

Parameters

string $name

Return Value

bool

at line 214
object createService(string $name)

Creates new instance of the service.

Parameters

string $name

Return Value

object

Exceptions

MissingServiceException

at line 245
object|null getByType(string $type, bool $throw = true)

Resolves service by type.

Parameters

string $type
bool $throw

Return Value

object|null

Exceptions

MissingServiceException

at line 286
array findAutowired(string $type)

internal  
 

Gets the autowired service names of the specified type.

Parameters

string $type

Return Value

array

at line 297
array findByType(string $type)

Gets the service names of the specified type.

Parameters

string $type

Return Value

array

at line 310
array findByTag(string $tag)

Gets the service names of the specified tag.

Parameters

string $tag

Return Value

array

of [service name => tag attributes]

at line 336
object createInstance(string $class, array $args = [])

Creates new instance using autowiring.

Parameters

string $class
array $args

Return Value

object

at line 356
void callInjects(object $service)

Calls all methods starting with "inject" using autowiring.

Parameters

object $service

Return Value

void

at line 365
mixed callMethod(callable $function, array $args = [])

Calls method using autowiring.

Parameters

callable $function
array $args

Return Value

mixed

at line 379
static string getMethodName(string $name)

No description

Parameters

string $name

Return Value

string

at line 389
void initialize()

No description

Return Value

void