diff --git a/src/Curl/Curl.php b/src/Curl/Curl.php index 75cc4e3..f0b5295 100644 --- a/src/Curl/Curl.php +++ b/src/Curl/Curl.php @@ -212,10 +212,10 @@ class Curl */ public function close() { - if ($this->curl !== null) { + if (is_resource($this->curl) || $this->curl instanceof \CurlHandle) { curl_close($this->curl); - $this->curl = null; } + $this->curl = null; $this->options = null; $this->jsonDecoder = null; $this->jsonDecoderArgs = null; @@ -1459,7 +1459,7 @@ class Curl */ public function reset() { - if (function_exists('curl_reset') && $this->curl !== null) { + if (function_exists('curl_reset') && (is_resource($this->curl) || $this->curl instanceof \CurlHandle)) { curl_reset($this->curl); } else { $this->curl = curl_init(); diff --git a/src/Curl/MultiCurl.php b/src/Curl/MultiCurl.php index d1dcf75..7d760fe 100644 --- a/src/Curl/MultiCurl.php +++ b/src/Curl/MultiCurl.php @@ -393,10 +393,10 @@ class MultiCurl $curl->close(); } - if ($this->multiCurl !== null) { + if (is_resource($this->multiCurl) || $this->multiCurl instanceof \CurlMultiHandle) { curl_multi_close($this->multiCurl); - $this->multiCurl = null; } + $this->multiCurl = null; } /** diff --git a/tests/PHPCurlClass/PHPCurlClassTest.php b/tests/PHPCurlClass/PHPCurlClassTest.php index 4fc1ddf..3daed6d 100644 --- a/tests/PHPCurlClass/PHPCurlClassTest.php +++ b/tests/PHPCurlClass/PHPCurlClassTest.php @@ -3023,11 +3023,9 @@ class CurlTest extends \PHPUnit\Framework\TestCase public function testClose() { - $test = new Test(); - $curl = $test->curl; - $curl->setHeader('X-DEBUG-TEST', 'post'); + $curl = new Curl(); $curl->post(Test::TEST_URL); - $this->assertNotNull($curl->curl); + $this->assertTrue(is_object($curl->curl) || is_resource($curl->curl)); $curl->close(); $this->assertNull($curl->curl); } diff --git a/tests/PHPCurlClass/PHPMultiCurlClassTest.php b/tests/PHPCurlClass/PHPMultiCurlClassTest.php index ae79ca6..bc42c77 100644 --- a/tests/PHPCurlClass/PHPMultiCurlClassTest.php +++ b/tests/PHPCurlClass/PHPMultiCurlClassTest.php @@ -2977,7 +2977,7 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase $multi_curl = new MultiCurl(); $multi_curl->addGet(Test::TEST_URL); $multi_curl->start(); - $this->assertNotNull($multi_curl->multiCurl); + $this->assertTrue(is_object($multi_curl->multiCurl) || is_resource($multi_curl->multiCurl)); $multi_curl->close(); $this->assertNull($multi_curl->multiCurl); }