尝试调用 Response->getInfo() 失败,即使它存在于 API

Trying to call Response->getInfo() fails even though it exist in the API

我正在尝试使用 Guzzle (~5.0) 来获得 php curl_getinfo 的等效项。 api 表示 it exists here,但在拨打电话时我收到一条错误消息:

Call to undefined method GuzzleHttp\Message\Response::getInfo() in ...

我可以 getBody()getStatusCode()Response 中的许多其他功能,但 getInfo() 不起作用。它被弃用了吗?这是一个错误吗?我打错电话了吗?

use GuzzleHttp\Client;
use GuzzleHttp\Message\Response;

class GuzzleCommand extends Command {

    public function fire()
    {

        $client = new Client();

        //equivalent of echo:
        $this->info($client->get('http://google.com')->getInfo());

    }
}

您正在阅读已弃用的 API、as noted in this issue with the getInfo() method, this issue involving the API version and these upgrade documents as of v4.x

GuzzleHttp\Message\Response::getInfo() and GuzzleHttp\Message\Response::setInfo() have been removed. Use the event system to retrieve this type of information.

docs on the event system is here.