src/Injector.php
public function inject(...$injects) : void
    {
        $container = new Container;
        $requested = [];
        foreach ($injects as $inject) {
            if (is_string($inject)) {
                $requested[] = $inject;
            } elseif (is_callable($inject)) {
                $reflection = new ReflectionFunction($inject);
                foreach ($reflection->getParameters() as $param) {
                    $requested[] = $param->name;
                }
            }
        }
        foreach ($requested as $dependency) {
            $this->$dependency = $container->get($dependency);
        }
    }
public function inject(...$injects) : void
    {
        $container = new Container;
        $requested = [];
        foreach ($injects as $inject) {
            if (is_string($inject)) {
                $requested[] = $inject;
            } elseif (is_callable($inject)) {
                $reflection = new ReflectionFunction($inject);
                foreach ($reflection->getParameters() as $param) {
                    $requested[] = $param->name;
                }
            }
        }
        foreach ($requested as $dependency) {
            $this->$dependency = $container->get($dependency);
        }
    }
public function inject ( ... $ injects ) : void { $ container = new Container ; $ requested = [ ] ; foreach ( $ injects as $ inject ) { if ( is_string ( $ inject ) ) { $ requested [ ] = $ inject ; } elseif ( is_callable ( $ inject ) ) { $ reflection = new ReflectionFunction ( $ inject ) ; foreach ( $ reflection -> getParameters ( ) as $ param ) { $ requested [ ] = $ param -> name ; } } } foreach ( $ requested as $ dependency ) { $ this -> $ dependency = $ container -> get ( $ dependency ) ; } }
Inject the specified dependencies into this object. Each argument can be
either a string containing the name of the dependency, or a callable
where each argument defines that name.

@param string|callable ...$injects What to inject.
@return void
@throws Psr\Container\Exception\NotFoundExceptionInterface if _any_ of
the requested dependencies could not be resolved.
Inject the specified dependencies into this object . Each argument can be either a string containing the name of the dependency or a callable where each argument defines that name .