src/frogsystem/spawn/Container.php
public function invoke(Callable $callable, array $args = [])
    {
        // object/class method
        if (is_string($callable) && false !== strpos($callable, '::')) {
            $callable = explode('::', $callable);
        }
        if (is_array($callable)) {
            $reflection = new \ReflectionMethod($callable[0], $callable[1]);
        }

        // closures, functions and any other callable
        if (!isset($reflection)) {
            $reflection = new \ReflectionFunction($callable);
        }

        // inject arguments
        $arguments = $this->inject($reflection, $args);
        return $callable(...$arguments);
    }
public function invoke(Callable $callable, array $args = [])
    {
        // object/class method
        if (is_string($callable) && false !== strpos($callable, '::')) {
            $callable = explode('::', $callable);
        }
        if (is_array($callable)) {
            $reflection = new \ReflectionMethod($callable[0], $callable[1]);
        }

        // closures, functions and any other callable
        if (!isset($reflection)) {
            $reflection = new \ReflectionFunction($callable);
        }

        // inject arguments
        $arguments = $this->inject($reflection, $args);
        return $callable(...$arguments);
    }
public function invoke ( Callable $ callable , array $ args = [ ] ) { // object/class method if ( is_string ( $ callable ) && false !== strpos ( $ callable , '::' ) ) { $ callable = explode ( '::' , $ callable ) ; } if ( is_array ( $ callable ) ) { $ reflection = new \ ReflectionMethod ( $ callable [ 0 ] , $ callable [ 1 ] ) ; } // closures, functions and any other callable if ( ! isset ( $ reflection ) ) { $ reflection = new \ ReflectionFunction ( $ callable ) ; } // inject arguments $ arguments = $ this -> inject ( $ reflection , $ args ) ; return $ callable ( ... $ arguments ) ; }
Invoke the given Closure with DI.
@param callable $callable
@param array $args
@return mixed
@throws Exceptions\ContainerException
Invoke the given Closure with DI .