src/Core/Rest.php
private function response(Closure $process_closure, array $params = array())
    {
        try {
            $ref = new ReflectionFunction($process_closure);
            $closure_params = array();
            $parameters = $ref->getParameters();
            if (!empty($parameters)) {
                foreach ($parameters as $p) {
                    if (!isset($params[$p->name])) {
                        throw new CoreException("未指定的参数: {$p->name}");
                    }

                    $closure_params[$p->name] = $params[$p->name];
                }
            }

            $content = call_user_func_array($process_closure, $closure_params);
            if (null != $content) {
                $this->delegate->getResponse()->display($content);
            }
        } catch (\Exception $e) {
            throw new CoreException('Reflection ' . $e->getMessage());
        }
    }
private function response(Closure $process_closure, array $params = array())
    {
        try {
            $ref = new ReflectionFunction($process_closure);
            $closure_params = array();
            $parameters = $ref->getParameters();
            if (!empty($parameters)) {
                foreach ($parameters as $p) {
                    if (!isset($params[$p->name])) {
                        throw new CoreException("未指定的参数: {$p->name}");
                    }

                    $closure_params[$p->name] = $params[$p->name];
                }
            }

            $content = call_user_func_array($process_closure, $closure_params);
            if (null != $content) {
                $this->delegate->getResponse()->display($content);
            }
        } catch (\Exception $e) {
            throw new CoreException('Reflection ' . $e->getMessage());
        }
    }
输出结果

@param Closure $process_closure
@param array $params
@throws CoreException