protected function handleAsCallable(
        $action,
        array $arguments
    ) {
        if (is_array($action)
            && isset($action[0])
            && isset($action[1])
            && is_string($action[0])
            && is_string($action[1])
            && class_exists($action[0])
        ) {
            // ["SomeClass", "someMethod"] but not static
            $refl = new \ReflectionMethod($action[0], $action[1]);
            if ($refl->isPublic() && !$refl->isStatic()) {
                $obj = new $action[0]();
                return $obj->{$action[1]}(...$arguments);
            }
        }

        // Add $di to param list, if defined by the callback
        $refl = is_array($action)
            ? new \ReflectionMethod($action[0], $action[1])
            : new \ReflectionFunction($action);
        $params = $refl->getParameters();
        if (isset($params[0]) && $params[0]->getName() === "di") {
            array_unshift($arguments, $this->di);
        }

        return call_user_func($action, ...$arguments);
    }
protected function handleAsCallable(
        $action,
        array $arguments
    ) {
        if (is_array($action)
            && isset($action[0])
            && isset($action[1])
            && is_string($action[0])
            && is_string($action[1])
            && class_exists($action[0])
        ) {
            // ["SomeClass", "someMethod"] but not static
            $refl = new \ReflectionMethod($action[0], $action[1]);
            if ($refl->isPublic() && !$refl->isStatic()) {
                $obj = new $action[0]();
                return $obj->{$action[1]}(...$arguments);
            }
        }

        // Add $di to param list, if defined by the callback
        $refl = is_array($action)
            ? new \ReflectionMethod($action[0], $action[1])
            : new \ReflectionFunction($action);
        $params = $refl->getParameters();
        if (isset($params[0]) && $params[0]->getName() === "di") {
            array_unshift($arguments, $this->di);
        }

        return call_user_func($action, ...$arguments);
    }
protected function handleAsCallable ( $ action , array $ arguments ) { if ( is_array ( $ action ) && isset ( $ action [ 0 ] ) && isset ( $ action [ 1 ] ) && is_string ( $ action [ 0 ] ) && is_string ( $ action [ 1 ] ) && class_exists ( $ action [ 0 ] ) ) { // ["SomeClass", "someMethod"] but not static $ refl = new \ ReflectionMethod ( $ action [ 0 ] , $ action [ 1 ] ) ; if ( $ refl -> isPublic ( ) && ! $ refl -> isStatic ( ) ) { $ obj = new $ action [ 0 ] ( ) ; return $ obj -> { $ action [ 1 ] } ( ... $ arguments ) ; } } // Add $di to param list, if defined by the callback $ refl = is_array ( $ action ) ? new \ ReflectionMethod ( $ action [ 0 ] , $ action [ 1 ] ) : new \ ReflectionFunction ( $ action ) ; $ params = $ refl -> getParameters ( ) ; if ( isset ( $ params [ 0 ] ) && $ params [ 0 ] -> getName ( ) === "di" ) { array_unshift ( $ arguments , $ this -> di ) ; } return call_user_func ( $ action , ... $ arguments ) ; }
Handle as callable support callables where the method is not static.

@param string|array                 $action    base for the callable
@param array                        $arguments optional arguments
@param ContainerInjectableInterface $di        container with services

@return mixed as the result from the route handler.
Handle as callable support callables where the method is not static .