Skip to content

Commit a1412a8

Browse files
authored
Merge pull request #74 from DubbaThony/chore/php85-curl_close-call
Fix deprecation warning in 8.5
2 parents 1c56976 + cba69f4 commit a1412a8

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/cURL.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,13 +285,13 @@ public function sendRequest(Request $request)
285285
$errno = curl_errno($this->ch);
286286
$errmsg = curl_error($this->ch);
287287
$msg = "cURL request failed with error [$errno]: $errmsg";
288-
curl_close($this->ch);
288+
$this->curlClose();
289289
throw new cURLException($request, $msg, $errno);
290290
}
291291

292292
$response = $this->createResponseObject($result, $request);
293293

294-
curl_close($this->ch);
294+
$this->curlClose();
295295

296296
return $response;
297297
}
@@ -371,4 +371,16 @@ public function __call($func, $args)
371371

372372
return $this->sendRequest($request);
373373
}
374+
375+
/**
376+
* Closes curl.
377+
* Calls curl_close($this->ch) in php versions when it's relevant
378+
*
379+
* @return void
380+
*/
381+
private function curlClose() {
382+
if (version_compare(PHP_VERSION, "8.0.0", ">="))
383+
return;
384+
curl_close($this->ch);
385+
}
374386
}

0 commit comments

Comments
 (0)