mini\Mini::inject()
public
Documentation
Create a closure that invokes a callable or constructs a class with dependency injection.
Returns a closure that, when called, resolves dependencies and invokes the target:
- For class-string: constructs the class via its constructor
- For callable: invokes the callable directly
Parameter resolution priority:
- Named arguments from $namedArguments (trusted as correct type)
- Service from container if registered for the parameter's type
- DependencyInjectionException if neither is available
Signature
public function inject(callable|string $target, array $namedArguments = array (
)): Closure
Parameters
| Name | Type | Default |
|---|---|---|
$target
|
callable|string |
required |
$namedArguments
|
array |
array (
)
|
Returns
Closure