public static function bindClass(\Closure $function, $class)
    {
        if (!class_exists($class))
            throw new \InvalidArgumentException("no such class $class");

        // assigning a class context for a closure is never an issue
        $function = \Closure::bind($function, null, $class);

        if (func_num_args() <= 2)
            return $function;

        $args = func_get_args();
        return static::partial($function, is_array($args[2]) ? $args[2] : array_slice($args, 2));
    }