mini\Mini::inject() Method

public

Signature

public function inject(callable|string $target, array $namedArguments = array (
)): Closure

Parameters

Name Type Default Description
$target callable|string required Documentation missing
$namedArguments array array ( ) Documentation missing

Returns

Closure

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:

  1. Named arguments from $namedArguments (trusted as correct type)
  2. Service from container if registered for the parameter's type
  3. DependencyInjectionException if neither is available

Source

src/Mini.php:522-552