/** * @param string $func * @param mixed $args * * @return mixed * @throws Exception\RequestErrorException */ public function send($func, $args) { $host = $this->host; $port = $this->port; $code = 0; $call = $this->back->clientCallObject($code, $func, $args); $send = $this->back->clientConnection($host, $port, $call, $this->socketTimeout, $this->socketReadTimeout); $future = $this->back->clientRecvObject($send); $result = $future->getResult(); $errors = $future->getErrors(); if ($errors !== null) { if (is_array($errors)) { $errors = '[' . implode(', ', $errors) . ']'; } else { if (is_object($errors)) { if (method_exists($errors, '__toString')) { $errors = $errors->__toString(); } else { $errors = print_r($errors, true); } } } throw new RequestErrorException("{$errors}"); } return $result; }