public static function getReflection(callable $f)
    {
        if (is_string($f)) {
            if (strpos($f, '::', 1) !== false) {
                return new \ReflectionMethod($f);
            } else {
                return new \ReflectionFunction($f);
            }
        } elseif (is_array($f) && count($f) == 2) {
            return new \ReflectionMethod($f[0], $f[1]);
        } elseif ($f instanceof \Closure) {
            return new \ReflectionFunction($f);
        } elseif (is_object($f) && method_exists($f, '__invoke')) {
            return new \ReflectionMethod($f, '__invoke');
        }
        // if the tests above are exhaustive, we should never hit the next line.
        throw new AnnotationException("Unable to determine callable type.");
    }