src/SellerLabs/Nucleus/Support/Std.php
public static function curryArgs(callable $function, $args)
    {
        Arguments::define(Boa::func(), Boa::arr())->check($function, $args);

        // Counts required parameters.
        $required = function () use ($function) {
            return (new ReflectionFunction($function))
                ->getNumberOfRequiredParameters();
        };

        $isFulfilled = function (callable $function, $args) use ($required) {
            return count($args) >= $required($function);
        };

        if ($isFulfilled($function, $args)) {
            return static::apply($function, $args);
        }

        return function (...$funcArgs) use (
            $function,
            $args,
            $required,
            $isFulfilled
        ) {
            $newArgs = ArrayList::of($args)
                ->append(ArrayList::of($funcArgs))
                ->toArray();

            if ($isFulfilled($function, $newArgs)) {
                return static::apply($function, $newArgs);
            }

            return static::curryArgs($function, $newArgs);
        };
    }
public static function curryArgs(callable $function, $args)
    {
        Arguments::define(Boa::func(), Boa::arr())->check($function, $args);

        // Counts required parameters.
        $required = function () use ($function) {
            return (new ReflectionFunction($function))
                ->getNumberOfRequiredParameters();
        };

        $isFulfilled = function (callable $function, $args) use ($required) {
            return count($args) >= $required($function);
        };

        if ($isFulfilled($function, $args)) {
            return static::apply($function, $args);
        }

        return function (...$funcArgs) use (
            $function,
            $args,
            $required,
            $isFulfilled
        ) {
            $newArgs = ArrayList::of($args)
                ->append(ArrayList::of($funcArgs))
                ->toArray();

            if ($isFulfilled($function, $newArgs)) {
                return static::apply($function, $newArgs);
            }

            return static::curryArgs($function, $newArgs);
        };
    }
public static function curryArgs ( callable $ function , $ args ) { Arguments :: define ( Boa :: func ( ) , Boa :: arr ( ) ) -> check ( $ function , $ args ) ; // Counts required parameters. $ required = function ( ) use ( $ function ) { return ( new ReflectionFunction ( $ function ) ) -> getNumberOfRequiredParameters ( ) ; } ; $ isFulfilled = function ( callable $ function , $ args ) use ( $ required ) { return count ( $ args ) >= $ required ( $ function ) ; } ; if ( $ isFulfilled ( $ function , $ args ) ) { return static :: apply ( $ function , $ args ) ; } return function ( ... $ funcArgs ) use ( $ function , $ args , $ required , $ isFulfilled ) { $ newArgs = ArrayList :: of ( $ args ) -> append ( ArrayList :: of ( $ funcArgs ) ) -> toArray ( ) ; if ( $ isFulfilled ( $ function , $ newArgs ) ) { return static :: apply ( $ function , $ newArgs ) ; } return static :: curryArgs ( $ function , $ newArgs ) ; } ; }
Left-curry the provided function with the provided array of arguments.

@param callable $function
@param mixed[] $args

@return Closure|mixed
Left - curry the provided function with the provided array of arguments .