src/CallableArgsResolver.php
static function resolveCallableWithArgs(callable $callable, $parameters)
    {
        if ($parameters instanceof \Traversable)
            $parameters = \Poirot\Std\cast($parameters)->toArray();


        $reflection       = self::makeReflectFromCallable($callable);
        $matchedArguments = self::resolveArgsForReflection($reflection, $parameters);

        if (!empty($parameters) && empty($matchedArguments))
            // In Case That Fun Has No Any Argument.
            // exp. func() { $args = func_get_args() ..
            $matchedArguments = $parameters;

        $callbackResolved = function() use ($callable, $matchedArguments) {
            return call_user_func_array($callable, $matchedArguments);
        };

        return $callbackResolved;
    }
static function resolveCallableWithArgs(callable $callable, $parameters)
    {
        if ($parameters instanceof \Traversable)
            $parameters = \Poirot\Std\cast($parameters)->toArray();


        $reflection       = self::makeReflectFromCallable($callable);
        $matchedArguments = self::resolveArgsForReflection($reflection, $parameters);

        if (!empty($parameters) && empty($matchedArguments))
            // In Case That Fun Has No Any Argument.
            // exp. func() { $args = func_get_args() ..
            $matchedArguments = $parameters;

        $callbackResolved = function() use ($callable, $matchedArguments) {
            return call_user_func_array($callable, $matchedArguments);
        };

        return $callbackResolved;
    }
static function resolveCallableWithArgs ( callable $ callable , $ parameters ) { if ( $ parameters instanceof \ Traversable ) $ parameters = \ Poirot \ Std \ cast ( $ parameters ) -> toArray ( ) ; $ reflection = self :: makeReflectFromCallable ( $ callable ) ; $ matchedArguments = self :: resolveArgsForReflection ( $ reflection , $ parameters ) ; if ( ! empty ( $ parameters ) && empty ( $ matchedArguments ) ) // In Case That Fun Has No Any Argument. // exp. func() { $args = func_get_args() .. $ matchedArguments = $ parameters ; $ callbackResolved = function ( ) use ( $ callable , $ matchedArguments ) { return call_user_func_array ( $ callable , $ matchedArguments ) ; } ; return $ callbackResolved ; }
Resolve Arguments Matched With Callable Arguments

@param callable           $callable
@param array|\Traversable $parameters Params to match with function arguments

@return \Closure
@throws \InvalidArgumentException
Resolve Arguments Matched With Callable Arguments