private function _callWithParams($func, $params)
    {
        if (empty($params)) {
            return $func();
        }

        $ref = new ReflectionFunction($func);
        $args = [];

        foreach ($ref->getParameters() as $param) {
            $name = $param->getName();

            if (isset($params[$name])) {
                if ($param->isArray()) {
                    $args[] = is_array($params[$name]) ? $params[$name] : [$params[$name]];
                } else if (!is_array($params[$name])) {
                    $args[] = $params[$name];
                } else {
                    return false;
                }
            } else if ($param->isDefaultValueAvailable()) {
                $args[] = $param->getDefaultValue();
            } else {
                return false;
            }
        }

        return $ref->invokeArgs($args);
    }
private function _callWithParams($func, $params)
    {
        if (empty($params)) {
            return $func();
        }

        $ref = new ReflectionFunction($func);
        $args = [];

        foreach ($ref->getParameters() as $param) {
            $name = $param->getName();

            if (isset($params[$name])) {
                if ($param->isArray()) {
                    $args[] = is_array($params[$name]) ? $params[$name] : [$params[$name]];
                } else if (!is_array($params[$name])) {
                    $args[] = $params[$name];
                } else {
                    return false;
                }
            } else if ($param->isDefaultValueAvailable()) {
                $args[] = $param->getDefaultValue();
            } else {
                return false;
            }
        }

        return $ref->invokeArgs($args);
    }
private function _callWithParams ( $ func , $ params ) { if ( empty ( $ params ) ) { return $ func ( ) ; } $ ref = new ReflectionFunction ( $ func ) ; $ args = [ ] ; foreach ( $ ref -> getParameters ( ) as $ param ) { $ name = $ param -> getName ( ) ; if ( isset ( $ params [ $ name ] ) ) { if ( $ param -> isArray ( ) ) { $ args [ ] = is_array ( $ params [ $ name ] ) ? $ params [ $ name ] : [ $ params [ $ name ] ] ; } else if ( ! is_array ( $ params [ $ name ] ) ) { $ args [ ] = $ params [ $ name ] ; } else { return false ; } } else if ( $ param -> isDefaultValueAvailable ( ) ) { $ args [ ] = $ param -> getDefaultValue ( ) ; } else { return false ; } } return $ ref -> invokeArgs ( $ args ) ; }
Calls a given function. If any params are given, they will be mapped to the function's arguments.

@param callable $func The function to call
@param array $params Any params that should be mapped to function arguments
@return mixed The result of the function
Calls a given function . If any params are given they will be mapped to the function s arguments .