Check if string is something in the DIC
that's callable or is a class name which has an __invoke() method.

@param string $class
@param string $method

@return callable

@throws RuntimeException if the callable does not exist
429260
protected function resolveCallable($class, $method = '__invoke')
    {
        if ($this->container->has($class)) {
            return [$this->container->get($class), $method];
        }

        if (!class_exists($class)) {
            throw new RuntimeException(sprintf('Callable %s does not exist', $class));
        }

        return [new $class($this->container), $method];
    }
1263521
public static function call($object, string $method, array $parameters)
    {
        $reflectionClass = new \ReflectionClass($object);
        $reflectionMethod = $reflectionClass->getMethod($method);
        $arguments = [];

        foreach ($reflectionMethod->getParameters() as $i => $reflectionParameter) {
            $argument = null;

            if (array_key_exists($reflectionParameter->name, $parameters) || array_key_exists($i, $parameters)) {
                $argument = $parameters[$reflectionParameter->name] ?? $parameters[$i] ?? null;
            } elseif ($reflectionParameter->isDefaultValueAvailable()) {
                $argument = $reflectionParameter->getDefaultValue();
            }

            if ($reflectionType = $reflectionParameter->getType()) {
                if ($reflectionType->isBuiltin()) {
                    if ($argument !== null || !$reflectionType->allowsNull()) {
                        settype($argument, $reflectionType->getName());
                    }
                } elseif ($argument === null && !$reflectionType->allowsNull()) {
                    return null;
                }
            }

            $arguments[] = $argument;
        }

        if ($reflectionMethod->isConstructor()) {
            return $reflectionClass->newInstanceArgs($arguments);
        }

        $reflectionMethod->setAccessible(true);

        return $reflectionMethod->invokeArgs($reflectionMethod->isStatic() ? null : $object, $arguments);
    }
1120078
public function isMethodAllowed($class, $method = null)
    {
        if (is_array($class)) {
            list($class, $method) = $class;
        }
        foreach ($this->allowedMethods as $allowedClass => $methods) {
            if (!isset($methods[$method])) {
                continue;
            }
            if ($class === $allowedClass || is_subclass_of($class, $allowedClass)) {
                return true;
            }
        }

        return false;
    }
351379
public function callInaccessibleMethod($entity, string $method)
    {
        $rc = new \ReflectionClass($entity);

        if ($rc->hasMethod($method)) {
            $method = $rc->getMethod($method);
            $method->setAccessible(true);

            return $method->invoke($entity);
        }

        return null;
    }
893267
protected function executeStatic(string $class) : string
    {
        list($class, $method) = explode('::', $class);
        if (!class_exists($class)) {
            throw new \RuntimeException('could not find class: ' . $class);
        }
        if (!method_exists($class, $method)) {
            throw new \RuntimeException('could not find method in class: ' . $method);
        }
        ob_start();
        $class::$method();
        return (string)ob_get_clean();
    }
1166886
protected function createQueuedHandlerCallable($className, $method)
    {
        return function () use ($className, $method)
        {
            // Clone the given arguments for queueing.
            $arguments = array_map(function ($a)
            {
                return is_object($a) ? clone $a : $a;

            }, func_get_args());

            if (method_exists($className, 'queue')) {
                $this->callQueueMethodOnHandler($className, $method, $arguments);
            } else {
                $this->resolveQueue()->push('Nova\Events\CallQueuedHandler@call', array(
                    'class'  => $className,
                    'method' => $method,
                    'data'   => serialize($arguments),
                ));
            }
        };
    }
345901
public static function assertMethodExists(string $method, string $class, string $msg = '')
    {
        if ($msg === '') {
            $msg = "Expected the class '$class' to have method '$method'.";
        }

        static::assertTrue(method_exists($class, $method), $msg);
    }
772697
protected function useMethod($class, $method)
    {
        $class = "\\OxApp\\controllers\\" . $class;
        try {
            $controller = new  $class();
        } catch (\Exception $e) {
            throw new \Exception($e);
        }
        if (is_subclass_of($controller, 'Ox\App')) {
            if (!empty($method)) {
                $result = $this->tryRunMethod($controller, $method);
            } else {
                $request = Router::$requestDriver;
                if (!empty($request)) {
                    $result = $this->tryRunMethod($controller, strtolower($request->server->get("REQUEST_METHOD")));
                } else {
                    $result = $this->tryRunMethod($controller, strtolower($_SERVER["REQUEST_METHOD"]));
                }
            }
            $response = new Response(
                $result,
                Response::HTTP_OK
            );
            $response->send();
        } else {
            $this->sandResponseCode(Response::HTTP_METHOD_NOT_ALLOWED);
        }
    }
79064
protected function findClass($method)
	{
		if (!preg_match("/^add([a-zA-Z]+)/", $method, $matches)) {
			return false;
		}

		$className = "\\HtmlForm\\Elements\\{$matches[1]}";

		if (!class_exists($className)) {
			return false;
		}

		return $className;
	}
151885
private function invokeClassMethod($class, $method, $namedParams, $classParams)
    {
        if (!class_exists($class)) {
            throw new \InvalidArgumentException("Class $class does not exist.");
        }

        $object = new $class();

        return $this->invokeObjectMethod($object, $method, $namedParams, $classParams);
    }
69813
private function explodeCallable(callable $method)
    {
        if (is_array($method)) {
            return $method;
        }

        if (is_string($method)) {
            return explode('::', $method);
        }

        return [$method];
    }
1052
public function call($class)
    {
        //argument 1 must be a string
        Argument::i()->test(1, 'string');

        $args = func_get_args();
        $class = array_shift($args);

        return $this->callArray($class, $args);
    }
820530
protected function callOnceAfterHooks($classInstance, $method, array $args = [])
    {
        $return = $this->callOnceAfterAllHooks($classInstance, $method, $args);

        if ($return !== null) {
            return $return;
        }

        $return = $this->callOnceAfterMethodHooks($classInstance, $method, $args);

        if ($return !== null) {
            return $return;
        }
    }
572487
private function readMethodCallees($class, ReflectionMethod $method)
    {
        $callees = array();

        // read parent annotations
        try {
            $prototype = $method->getPrototype();
            // error occurs on every second PHP stable release - getPrototype() returns itself
            if ($prototype->getDeclaringClass()->getName() !== $method->getDeclaringClass()->getName()) {
                $callees = array_merge($callees, $this->readMethodCallees($class, $prototype));
            }
        } catch (ReflectionException $e) {
        }

        if ($docBlock = $method->getDocComment()) {
            $callees = array_merge($callees, $this->readDocBlockCallees($class, $method, $docBlock));
        }

        return $callees;
    }
741540
private function reflectionParams(string $method)
    {
        $class = new ReflectionClass($this);

        if (! is_string($method)) {
            return;
        }

        if (! $class->hasMethod($method)) {
            return;
        }

        $parameters = $class->getMethod($method)->getParameters();

        $arguments = [];

        foreach ($parameters as $key => $parameter) {
            $arguments[] = $this->bind($key, $parameter);
        }

        $this->arguments = $arguments;
    }
19497
public function addMethod(Method $method)
    {
        if (isset($this->methods[$method->getName()])) {
            throw new RuntimeException(sprintf(
                'The method "%s" exists already.',
                $method->getName()
            ));
        }

        $this->methods[$method->getName()] = $method;

        $method->setClass($this);

        return $this;
    }
934491
public static function findFieldClass($method)
    {
        // If alias exists.
        if (isset(static::$fieldAlias[$method])) {
            $method = static::$fieldAlias[$method];
        }

        $class = Arr::get(static::$availableFields, $method);

        if (class_exists($class)) {
            return $class;
        }

        return false;
    }