protected static function getCaller($index, $offset = 1): array
    {
        Assert::greaterThanEq($index, 0);

        $index += $offset + 1;

        $stack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, $index + 1);
        if (! isset($stack[$index])) {
            throw new \OutOfBoundsException(sprintf('%s is greater than the current call stack', $index - $offset - 1));
        }
        $frame = $stack[$index];

        if (! isset($frame['class'])) {
            // Assert the function isn't called directly from a script,
            // else we would be saying "require() is deprecated" lol.
            if (! function_exists($frame['function'])) {
                $frame = $stack[$index - $offset];
                throw new \InvalidArgumentException(
                    sprintf('%s::%s() must be called from within a function/method.', $frame['class'], $frame['function'])
                );
            }

            return [
                $frame['function'],
                $frame['function'],
                false,
                false,
            ];
        }

        $class = $frame['class'];
        $function = $frame['function'];
        $constructor = $function === '__construct';

        if ($function === '__call' || $function === '__callStatic') {
            $frame = debug_backtrace(0, $index + 1)[$index]; // with args
            $function = $frame['args'][0];
        }

        return [
            $class . (! $constructor ? '::' . $function : ''),
            $function,
            $constructor,
        ];
    }