phprs\BindReturns::bind PHP Method

bind() public method

绑定到函数调用的参数上去
public bind ( $req, &$res, array &$args )
$req
$res
$args array
    public function bind($req, &$res, &$args)
    {
        //params保存的数据
        // [
        //   'body'=>[// 输出方法
        //                      [arg1, arg2, arg3], //调用列表
        //                      [arg1, arg2, arg3]
        //                 ],
        //    ]
        // ]
        //没有指定body输出, 默认使用返回值作为输出
        foreach ($this->params as $fun_name => $calls) {
            //
            foreach ($calls as $id => $call) {
                foreach ($call as $num => $arg) {
                    // 方法
                    list($is_const, $value, $pos, $info) = $arg;
                    if ($is_const) {
                        // 常量,直接输出
                        $res[$fun_name][$id][$num] = $value;
                    } else {
                        if ($pos === -1) {
                            // 返回值作为变量输出
                            $res[$fun_name][$id][$num] =& $this->return_val;
                        } else {
                            if (!array_key_exists($pos, $args)) {
                                // 没有输入,只有输出
                                list(, $is_ref, $is_optional, $default) = $info;
                                if ($is_optional) {
                                    $args[$pos] = $default;
                                } else {
                                    $args[$pos] = null;
                                }
                            }
                            $res[$fun_name][$id][$num] =& $args[$pos];
                        }
                    }
                }
            }
        }
    }