public static function run(callable $function)
    {
        set_error_handler(static function($severity, $message, $file, $line) {
            throw new \ErrorException($message, 0, $severity, $file, $line);
        });

        try {
            $result = $function();
        } finally {
            restore_error_handler();
        }

        return $result;
    }