DI
in package
Dependency Injector
PHP Mini Framework
Tags
Table of Contents
- instantiate() : object
- Instantiate class with dependencies
- resolveCallableDependencies() : array<string|int, mixed>
- Resolve dependendies for class method
- resolveMethodDependencies() : array<string|int, mixed>
- Resolve dependendies for class method
- instatiatable() : bool
- Check if type can be instantiated
- resolveDependencies() : array<string|int, mixed>
- Resolve dependendies
- __construct() : mixed
Methods
instantiate()
Instantiate class with dependencies
public
static instantiate(string $class[, Closure|null $resolver = null ][, Closure|null $callback = null ][, array<string|int, mixed> $params = [] ]) : object
Parameters
- $class : string
- $resolver : Closure|null = null
-
Custom resolver to extend class resolution. e.g
fn($class) => $class == MyCustomClass::class ? MyCustomClass::init() : null - $callback : Closure|null = null
-
Custom callback to customize resolution. e.g 'fn(&$instance) => $instance->load(...)`
- $params : array<string|int, mixed> = []
-
List of Custom params. (name => value) E.g [ 'request' => $request ]
Tags
Return values
object —resolveCallableDependencies()
Resolve dependendies for class method
public
static resolveCallableDependencies(Closure $callable[, Closure|null $resolver = null ][, Closure|null $callback = null ][, array<string|int, mixed> $params = [] ]) : array<string|int, mixed>
Parameters
- $callable : Closure
- $resolver : Closure|null = null
-
Custom resolver to extend class resolution. e.g
fn($class) => $class == MyCustomClass::class ? MyCustomClass::init() : null - $callback : Closure|null = null
-
Custom callback to customize resolution. e.g 'fn(&$instance) => $instance->load(...)`
- $params : array<string|int, mixed> = []
-
List of Custom params. (name => value) E.g [ 'request' => $request ]
Tags
Return values
array<string|int, mixed> —resolveMethodDependencies()
Resolve dependendies for class method
public
static resolveMethodDependencies(string $class, string $method[, Closure|null $resolver = null ][, Closure|null $callback = null ][, array<string|int, mixed> $params = [] ]) : array<string|int, mixed>
Parameters
- $class : string
- $method : string
- $resolver : Closure|null = null
-
Custom resolver to extend class resolution. e.g
fn($class) => $class == MyCustomClass::class ? MyCustomClass::init() : null - $callback : Closure|null = null
-
Custom callback to customize resolution. e.g 'fn(&$instance) => $instance->load(...)`
- $params : array<string|int, mixed> = []
-
List of Custom params. (name => value) E.g [ 'request' => $request ]
Tags
Return values
array<string|int, mixed> —instatiatable()
Check if type can be instantiated
protected
static instatiatable(ReflectionType|ReflectionNamedType|string $type) : bool
Parameters
- $type : ReflectionType|ReflectionNamedType|string
Tags
Return values
bool —resolveDependencies()
Resolve dependendies
protected
static resolveDependencies(ReflectionParameter $parameters[, Closure|null $resolver = null ][, Closure|null $callback = null ][, array<string|int, mixed> $params = [] ]) : array<string|int, mixed>
Parameters
- $parameters : ReflectionParameter
- $resolver : Closure|null = null
- $callback : Closure|null = null
- $params : array<string|int, mixed> = []
Tags
Return values
array<string|int, mixed> —__construct()
private
final __construct() : mixed