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));
    }
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));
    }
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 ) ) ; }
Bind a function to a class, meaning that whenever the function is called, the value of self or static will be
the class. Optionally, pass arguments to the function to pre-fill them, also known as partial application.

@category Function (uh, ahem) Functions

@param closure $function the function
@param object,string $class the object or classname to bind the closure to

@throws InvalidArgumentException if $class does not exists
@throws RuntimeException if the closure cannot be bound to $class

@return closure
Bind a function to a class meaning that whenever the function is called the value of self or static will be the class . Optionally pass arguments to the function to pre - fill them also known as partial application .