public function injectorForClosure(callable $closure)
    {
        $reflection = new \ReflectionFunction($closure);
        $parameters = $reflection->getParameters();
        $params = [];

        foreach ($parameters as $parameter) {
            $type = $parameter->getType();

            if (is_null($type)) {
                continue;
            }

            $class = trim($type->getName());

            if (! class_exists($class, true)) {
                continue;
            }

            if (!in_array(strtolower($class), $this->getInjectorExceptedType())) {
                if (method_exists($class, 'getInstance')) {
                    $params[] = $class::getInstance();
                } else {
                    $params[] = new $class();
                }
            }
        }

        return $params;
    }
public function injectorForClosure(callable $closure)
    {
        $reflection = new \ReflectionFunction($closure);
        $parameters = $reflection->getParameters();
        $params = [];

        foreach ($parameters as $parameter) {
            $type = $parameter->getType();

            if (is_null($type)) {
                continue;
            }

            $class = trim($type->getName());

            if (! class_exists($class, true)) {
                continue;
            }

            if (!in_array(strtolower($class), $this->getInjectorExceptedType())) {
                if (method_exists($class, 'getInstance')) {
                    $params[] = $class::getInstance();
                } else {
                    $params[] = new $class();
                }
            }
        }

        return $params;
    }
public function injectorForClosure ( callable $ closure ) { $ reflection = new \ ReflectionFunction ( $ closure ) ; $ parameters = $ reflection -> getParameters ( ) ; $ params = [ ] ; foreach ( $ parameters as $ parameter ) { $ type = $ parameter -> getType ( ) ; if ( is_null ( $ type ) ) { continue ; } $ class = trim ( $ type -> getName ( ) ) ; if ( ! class_exists ( $ class , true ) ) { continue ; } if ( ! in_array ( strtolower ( $ class ) , $ this -> getInjectorExceptedType ( ) ) ) { if ( method_exists ( $ class , 'getInstance' ) ) { $ params [ ] = $ class :: getInstance ( ) ; } else { $ params [ ] = new $ class ( ) ; } } } return $ params ; }
Injection for closure

@param callable $closure

@return array

@throws
Injection for closure