From 0988e3129940b62ff84c8c9f316882642e739db7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Sato=C5=82a?= Date: Thu, 1 Oct 2026 09:21:24 +0200 Subject: [PATCH] Fix PHP 8.5 curl_close() deprecation and TypeError on failed curl_init() - call curl_close() only on PHP < 8.0 (no-op since 8.0, deprecated since 8.5) - do not pass false to curl_error() when curl_init() fails, which threw TypeError instead of NetworkException on PHP 8 --- src/Curl/HttpClient.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Curl/HttpClient.php b/src/Curl/HttpClient.php index 7bfadcb..2c03b3c 100644 --- a/src/Curl/HttpClient.php +++ b/src/Curl/HttpClient.php @@ -45,7 +45,7 @@ private function prepareRequestHttpClient(RequestInterface $request) if ($httpClient === false) { throw NetworkException::withRequest( - 'Cannot prepare HTTP client: ' . curl_error($httpClient), + 'Cannot prepare HTTP client', $request ); } @@ -103,6 +103,9 @@ private function execute(RequestInterface $request, $httpClient): ResponseInterf private function closeHttpClient($httpClient) { - curl_close($httpClient); + // curl_close() has no effect since PHP 8.0 and is deprecated since PHP 8.5 + if (PHP_VERSION_ID < 80000) { + curl_close($httpClient); + } } }