diff --git a/src/Twilio/Http/CurlClient.php b/src/Twilio/Http/CurlClient.php index 000564f32..f64a79c75 100644 --- a/src/Twilio/Http/CurlClient.php +++ b/src/Twilio/Http/CurlClient.php @@ -62,7 +62,9 @@ public function request(string $method, string $url, $responseHeaders[$key] = $value; } - \curl_close($curl); + if (PHP_MAJOR_VERSION < 8) { + \curl_close($curl); + } if (isset($options[CURLOPT_INFILE]) && \is_resource($options[CURLOPT_INFILE])) { \fclose($options[CURLOPT_INFILE]); @@ -72,7 +74,7 @@ public function request(string $method, string $url, return $this->lastResponse; } catch (\ErrorException $e) { - if (isset($curl) && \is_resource($curl)) { + if (PHP_MAJOR_VERSION < 8 && isset($curl) && \is_resource($curl)) { \curl_close($curl); }