Amp\Mysql\Stmt::conn PHP Method

conn() private method

private conn ( )
    private function conn()
    {
        if ($this->conn->alive()) {
            return $this->conn;
        }
        $restore = $this->conn->getConfig()->restore;
        if (isset($restore)) {
            $restore()->prepare($this->query)->when(function ($error, $stmt) {
                if ($error) {
                    while (list(, $args) = $this->virtualConn->getCall()) {
                        end($args)->fail($error);
                    }
                } else {
                    $this->conn = $stmt->conn;
                    $this->stmtId = $stmt->stmtId;
                    foreach ($this->prebound as $paramId => $msg) {
                        $this->conn->bindParam($this->stmtId, $paramId, $msg);
                    }
                    while (list($deferred, $method, $args) = $this->virtualConn->getCall()) {
                        if (isset($args[0])) {
                            $args[0] = $this->stmtId;
                        }
                        if ($method == "execute") {
                            $args[1] =& $this->result->params;
                        }
                        call_user_func_array([$this->conn(), $method], $args)->when(function ($error, $result) use($deferred) {
                            if ($error) {
                                $deferred->fail($error);
                            } else {
                                $deferred->succeed($result);
                            }
                        });
                    }
                }
            });
            return $this->virtualConn = new VirtualConnection();
        }
        throw new \Exception("Connection went away, no way provided to restore connection via callable in ConnectionConfig::ready");
    }