This makes the property HttpClientException->response nullable, and avoids a PHP error, because the response is not always known or given. By making response nullable we can catch the real exception.
Here is an example trace:
Cannot assign null to property Firstred\\PostNL\\Exception\\HttpClientException::$response of type Psr\\Http\\Message\\ResponseInterface
#0 /var/www/html/vendor/firstred/postnl-api-php/src/HttpClient/SymfonyHttpClient.php(193): Firstred\\PostNL\\Exception\\HttpClientException->__construct('Response factor...', 0, Object(Firstred\\PostNL\\Exception\\NotSupportedException))
#1 /var/www/html/vendor/firstred/postnl-api-php/src/Service/LabellingService.php(120): Firstred\\PostNL\\HttpClient\\SymfonyHttpClient->doRequest(Object(GuzzleHttp\\Psr7\\Request))
#2 /var/www/html/vendor/firstred/postnl-api-php/src/PostNL.php(1455): Firstred\\PostNL\\Service\\LabellingService->generateLabel(Object(Firstred\\PostNL\\Entity\\Request\\GenerateLabel), false)
This makes the property
HttpClientException->response
nullable, and avoids a PHP error, because the response is not always known or given. By makingresponse
nullable we can catch the real exception.Here is an example trace: