src/ReflectionContainer.php
public function call(callable $callable, array $args = [])
    {
        if (is_string($callable) && strpos($callable, '::') !== false) {
            $callable = explode('::', $callable);
        }

        if (is_array($callable)) {
            if (is_string($callable[0])) {
                $callable[0] = $this->getContainer()->get($callable[0]);
            }

            $reflection = new ReflectionMethod($callable[0], $callable[1]);

            if ($reflection->isStatic()) {
                $callable[0] = null;
            }

            return $reflection->invokeArgs($callable[0], $this->reflectArguments($reflection, $args));
        }

        if (is_object($callable)) {
            $reflection = new ReflectionMethod($callable, '__invoke');

            return $reflection->invokeArgs($callable, $this->reflectArguments($reflection, $args));
        }

        $reflection = new ReflectionFunction($callable);

        return $reflection->invokeArgs($this->reflectArguments($reflection, $args));
    }
public function call(callable $callable, array $args = [])
    {
        if (is_string($callable) && strpos($callable, '::') !== false) {
            $callable = explode('::', $callable);
        }

        if (is_array($callable)) {
            if (is_string($callable[0])) {
                $callable[0] = $this->getContainer()->get($callable[0]);
            }

            $reflection = new ReflectionMethod($callable[0], $callable[1]);

            if ($reflection->isStatic()) {
                $callable[0] = null;
            }

            return $reflection->invokeArgs($callable[0], $this->reflectArguments($reflection, $args));
        }

        if (is_object($callable)) {
            $reflection = new ReflectionMethod($callable, '__invoke');

            return $reflection->invokeArgs($callable, $this->reflectArguments($reflection, $args));
        }

        $reflection = new ReflectionFunction($callable);

        return $reflection->invokeArgs($this->reflectArguments($reflection, $args));
    }
public function call ( callable $ callable , array $ args = [ ] ) { if ( is_string ( $ callable ) && strpos ( $ callable , '::' ) !== false ) { $ callable = explode ( '::' , $ callable ) ; } if ( is_array ( $ callable ) ) { if ( is_string ( $ callable [ 0 ] ) ) { $ callable [ 0 ] = $ this -> getContainer ( ) -> get ( $ callable [ 0 ] ) ; } $ reflection = new ReflectionMethod ( $ callable [ 0 ] , $ callable [ 1 ] ) ; if ( $ reflection -> isStatic ( ) ) { $ callable [ 0 ] = null ; } return $ reflection -> invokeArgs ( $ callable [ 0 ] , $ this -> reflectArguments ( $ reflection , $ args ) ) ; } if ( is_object ( $ callable ) ) { $ reflection = new ReflectionMethod ( $ callable , '__invoke' ) ; return $ reflection -> invokeArgs ( $ callable , $ this -> reflectArguments ( $ reflection , $ args ) ) ; } $ reflection = new ReflectionFunction ( $ callable ) ; return $ reflection -> invokeArgs ( $ this -> reflectArguments ( $ reflection , $ args ) ) ; }
Invoke a callable via the container.

@param callable $callable
@param array    $args

@return mixed
Invoke a callable via the container .