public static function wrap($function, $wrapper)
    {
        return function () use ($function, $wrapper) {
            $args = func_get_args();
            array_unshift($args, $function); // make $function the first argument
            return call_user_func_array($wrapper, $args);
        };
    }