PHP Class ManaPHP\Di

Inheritance: implements manaphp\DiInterface
Show file Open project: manaphp/manaphp Class Usage Examples

Protected Properties

Property Type Description
$_aliases array
$_default Di First DI build
$_services array
$_sharedInstances array

Public Methods

Method Description
__call ( string $method, array $arguments = [] ) : void Magic method to get or set services using setters/getters
__construct ( )
__debugInfo ( ) : array
__get ( string $propertyName ) : mixed Magic method __get
__isset ( string $name ) : boolean
__set ( string $name, mixed $value )
get ( string $_name, array $parameters = [] ) : mixed Resolves the service based on its configuration
getDefault ( ) : static Return the First DI created
getShared ( string $name, array $parameters = [] ) : mixed Resolves a service, the resolved service is stored in the DI, subsequent requests for this service will return the same instance
has ( string $name ) : boolean Check whether the DI contains a service by a name
remove ( string $name ) : static Removes a service in the services container
set ( string $name, mixed $definition, boolean $shared = false, array $aliases = [] ) : static Registers a service in the services container
setShared ( string $name, mixed $definition, array $aliases = [] ) : static Registers an "always shared" service in the services container

Method Details

__call() public method

Magic method to get or set services using setters/getters
public __call ( string $method, array $arguments = [] ) : void
$method string
$arguments array
return void

__construct() public method

public __construct ( )

__debugInfo() public method

public __debugInfo ( ) : array
return array

__get() public method

Magic method __get
public __get ( string $propertyName ) : mixed
$propertyName string
return mixed

__isset() public method

public __isset ( string $name ) : boolean
$name string
return boolean

__set() public method

public __set ( string $name, mixed $value )
$name string
$value mixed

get() public method

Resolves the service based on its configuration
public get ( string $_name, array $parameters = [] ) : mixed
$_name string
$parameters array
return mixed

getDefault() public static method

Return the First DI created
public static getDefault ( ) : static
return static

getShared() public method

Resolves a service, the resolved service is stored in the DI, subsequent requests for this service will return the same instance
public getShared ( string $name, array $parameters = [] ) : mixed
$name string
$parameters array
return mixed

has() public method

Check whether the DI contains a service by a name
public has ( string $name ) : boolean
$name string
return boolean

remove() public method

Removes a service in the services container
public remove ( string $name ) : static
$name string
return static

set() public method

Registers a service in the services container
public set ( string $name, mixed $definition, boolean $shared = false, array $aliases = [] ) : static
$name string
$definition mixed
$shared boolean
$aliases array
return static

setShared() public method

Registers an "always shared" service in the services container
public setShared ( string $name, mixed $definition, array $aliases = [] ) : static
$name string
$definition mixed
$aliases array
return static

Property Details

$_aliases protected property

protected array $_aliases
return array

$_default protected static property

First DI build
protected static Di,ManaPHP $_default
return Di

$_services protected property

protected array $_services
return array

$_sharedInstances protected property

protected array $_sharedInstances
return array