I'm having an issue passing a PSR-7 message response (generated by Guzzle) into a class constructor.
The message is generated by:
$client = new \GuzzleHttp\Client();
$res = $client->request('GET', 'http://pagecrawler/cache.html');
Class Test {
protected $response;
public function __construct($response, $db = null)
{
$this->$response = $response; /* Line 18 */
}
}
PHP Catchable fatal error: Object of class GuzzleHttp\Psr7\Response could not be converted to string
$this->response
It's just a typo. With $this->$response
you cast the Response object to a string. Instead you should do $this->response
.