src/Functions.php
public static function partial($function, $arg)
    {
        $bound = func_get_args();
        array_shift($bound); // remove $function

        $placeholder = static::p();

        return function () use ($function, $bound, $placeholder) {
            $inject = func_get_args();

            $args = [];
            foreach ($bound as $value) {
                if ($value === $placeholder) {
                    $args[] = array_shift($inject);
                } else {
                    $args[] = $value;
                }
            }

            // Append any remaining arguments
            $args = array_merge($args, $inject);

            return call_user_func_array($function, $args);
        };
    }
public static function partial($function, $arg)
    {
        $bound = func_get_args();
        array_shift($bound); // remove $function

        $placeholder = static::p();

        return function () use ($function, $bound, $placeholder) {
            $inject = func_get_args();

            $args = [];
            foreach ($bound as $value) {
                if ($value === $placeholder) {
                    $args[] = array_shift($inject);
                } else {
                    $args[] = $value;
                }
            }

            // Append any remaining arguments
            $args = array_merge($args, $inject);

            return call_user_func_array($function, $args);
        };
    }
public static function partial ( $ function , $ arg ) { $ bound = func_get_args ( ) ; array_shift ( $ bound ) ; // remove $function $ placeholder = static :: p ( ) ; return function ( ) use ( $ function , $ bound , $ placeholder ) { $ inject = func_get_args ( ) ; $ args = [ ] ; foreach ( $ bound as $ value ) { if ( $ value === $ placeholder ) { $ args [ ] = array_shift ( $ inject ) ; } else { $ args [ ] = $ value ; } } // Append any remaining arguments $ args = array_merge ( $ args , $ inject ) ; return call_user_func_array ( $ function , $ args ) ; } ; }
Partially apply a function by filling in any number of its arguments.

You may pass p() in your list of arguments to specify an argument that
should not be pre-filled, but left open to supply at call-time.

@param callable $function
@param mixed    $arg
@param          mixed ...
@return \Closure
Partially apply a function by filling in any number of its arguments .