diff --git a/examples/custom.php b/examples/custom.php index 3029bde..32e770a 100644 --- a/examples/custom.php +++ b/examples/custom.php @@ -3,7 +3,6 @@ require __DIR__ . '/vendor/autoload.php'; use \Curl\Curl; - $curl = new Curl(); $curl->setOpt(CURLOPT_CUSTOMREQUEST, 'GET'); $curl->setOpt(CURLOPT_NOBODY, true); diff --git a/src/Curl/MultiCurl.php b/src/Curl/MultiCurl.php index f94dc0e..7e2297b 100644 --- a/src/Curl/MultiCurl.php +++ b/src/Curl/MultiCurl.php @@ -643,7 +643,6 @@ class MultiCurl } do { - // Wait for activity on any curl_multi connection when curl_multi_select (libcurl) fails to correctly block. // https://bugs.php.net/bug.php?id=63411 if (curl_multi_select($this->multiCurl) === -1) { diff --git a/tests/PHPCurlClass/Helper.php b/tests/PHPCurlClass/Helper.php index cc2b39f..da01229 100644 --- a/tests/PHPCurlClass/Helper.php +++ b/tests/PHPCurlClass/Helper.php @@ -33,7 +33,7 @@ class Test * previously forced method might be inherited. * Especially, POSTs must be configured to not perform post-redirect-get. */ - private function chained_request($request_method) + private function chainedRequest($request_method) { if ($request_method === 'POST') { $this->server('request_method', $request_method, array(), true); @@ -43,10 +43,10 @@ class Test \PHPUnit\Framework\Assert::assertEquals($request_method, $this->curl->responseHeaders['X-REQUEST-METHOD']); } - public function chain_requests($first, $second) + public function chainRequests($first, $second) { - $this->chained_request($first); - $this->chained_request($second); + $this->chainedRequest($first); + $this->chainedRequest($second); } } diff --git a/tests/PHPCurlClass/PHPCurlClassTest.php b/tests/PHPCurlClass/PHPCurlClassTest.php index 5e20c5a..22b42f9 100644 --- a/tests/PHPCurlClass/PHPCurlClassTest.php +++ b/tests/PHPCurlClass/PHPCurlClassTest.php @@ -1,5 +1,7 @@ getMethod('parseResponseHeaders'); $reflection_method->setAccessible(true); @@ -366,17 +368,17 @@ class CurlTest extends \PHPUnit\Framework\TestCase { $tests = array(); - $file_path_1 = Helper\get_png(); + $file_path_1 = \Helper\get_png(); $tests[] = array( 'file_path' => $file_path_1, 'post_data_image' => '@' . $file_path_1, ); if (class_exists('CURLFile')) { - $file_path_2 = Helper\get_png(); + $file_path_2 = \Helper\get_png(); $tests[] = array( 'file_path' => $file_path_2, - 'post_data_image' => new CURLFile($file_path_2), + 'post_data_image' => new \CURLFile($file_path_2), ); } @@ -426,7 +428,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase public function testPostFilePathUpload() { - $file_path = Helper\get_png(); + $file_path = \Helper\get_png(); $test = new Test(); $this->assertEquals('image/png', $test->server('post_file_path_upload', 'POST', array( @@ -441,12 +443,12 @@ class CurlTest extends \PHPUnit\Framework\TestCase public function testPostCurlFileUpload() { if (class_exists('CURLFile')) { - $file_path = Helper\get_png(); + $file_path = \Helper\get_png(); $test = new Test(); $this->assertEquals('image/png', $test->server('post_file_path_upload', 'POST', array( 'key' => 'image', - 'image' => new CURLFile($file_path), + 'image' => new \CURLFile($file_path), ))); unlink($file_path); @@ -529,8 +531,8 @@ class CurlTest extends \PHPUnit\Framework\TestCase public function testPutFileHandle() { - $png = Helper\create_png(); - $tmp_file = Helper\create_tmp_file($png); + $png = \Helper\create_png(); + $tmp_file = \Helper\create_tmp_file($png); $test = new Test(); $test->curl->setHeader('X-DEBUG-TEST', 'put_file_handle'); @@ -610,8 +612,8 @@ class CurlTest extends \PHPUnit\Framework\TestCase public function testDownload() { // Create and upload a file. - $upload_file_path = Helper\get_png(); - $uploaded_file_path = Helper\upload_file_to_server($upload_file_path); + $upload_file_path = \Helper\get_png(); + $uploaded_file_path = \Helper\upload_file_to_server($upload_file_path); // Download the file. $downloaded_file_path = tempnam('/tmp', 'php-curl-class.'); @@ -632,7 +634,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase $this->assertFalse(is_bool($download_test->curl->rawResponse)); // Remove server file. - Helper\remove_file_from_server($uploaded_file_path); + \Helper\remove_file_from_server($uploaded_file_path); unlink($upload_file_path); unlink($downloaded_file_path); @@ -643,8 +645,8 @@ class CurlTest extends \PHPUnit\Framework\TestCase public function testDownloadCallback() { // Create and upload a file. - $upload_file_path = Helper\get_png(); - $uploaded_file_path = Helper\upload_file_to_server($upload_file_path); + $upload_file_path = \Helper\get_png(); + $uploaded_file_path = \Helper\upload_file_to_server($upload_file_path); // Download the file. $callback_called = false; @@ -665,7 +667,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase $this->assertTrue($callback_called); // Remove server file. - Helper\remove_file_from_server($uploaded_file_path); + \Helper\remove_file_from_server($uploaded_file_path); unlink($upload_file_path); $this->assertFalse(file_exists($upload_file_path)); @@ -674,8 +676,8 @@ class CurlTest extends \PHPUnit\Framework\TestCase public function testDownloadRange() { // Create and upload a file. - $filename = Helper\get_png(); - $uploaded_file_path = Helper\upload_file_to_server($filename); + $filename = \Helper\get_png(); + $uploaded_file_path = \Helper\upload_file_to_server($filename); $filesize = filesize($filename); @@ -712,7 +714,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase ) as $length) { $source = Test::TEST_URL; - $destination = Helper\get_tmp_file_path(); + $destination = \Helper\get_tmp_file_path(); // Start with no file. if ($length === false) { @@ -774,7 +776,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase } // Remove server file. - Helper\remove_file_from_server($uploaded_file_path); + \Helper\remove_file_from_server($uploaded_file_path); unlink($filename); $this->assertFalse(file_exists($filename)); @@ -1123,7 +1125,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase $curl = new Curl(); $curl->setHeader('Content-Type', $content_type); - $reflector = new ReflectionClass('\Curl\Curl'); + $reflector = new \ReflectionClass('\Curl\Curl'); $property = $reflector->getProperty('headers'); $property->setAccessible(true); $headers = $property->getValue($curl); @@ -1248,7 +1250,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase public function testPostFileFormDataContentType() { - $file_path = Helper\get_png(); + $file_path = \Helper\get_png(); $test = new Test(); $test->server('server', 'POST', array( @@ -1268,11 +1270,11 @@ class CurlTest extends \PHPUnit\Framework\TestCase $this->markTestSkipped(); } - $file_path = Helper\get_png(); + $file_path = \Helper\get_png(); $test = new Test(); $test->server('server', 'POST', array( - 'image' => new CURLFile($file_path), + 'image' => new \CURLFile($file_path), )); $this->assertEquals('100-continue', $test->curl->requestHeaders['Expect']); preg_match('/^multipart\/form-data; boundary=/', $test->curl->requestHeaders['Content-Type'], $content_type); @@ -1481,7 +1483,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase 'text/x-json', ); - $class = new ReflectionClass('\Curl\Curl'); + $class = new \ReflectionClass('\Curl\Curl'); $property = $class->getProperty('jsonPattern'); $property->setAccessible(true); $json_pattern = $property->getValue(new Curl); @@ -2595,7 +2597,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase $this->assertInstanceOf('SimpleXMLElement', $test->curl->response); - $doc = new DOMDocument(); + $doc = new \DOMDocument(); $doc->formatOutput = true; $rss = $doc->appendChild($doc->createElement('rss')); $rss->setAttribute('version', '2.0'); @@ -2620,7 +2622,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase { $response = "\r\n\r\n"; - $reflector = new ReflectionClass('\Curl\Curl'); + $reflector = new \ReflectionClass('\Curl\Curl'); $reflection_method = $reflector->getMethod('parseResponseHeaders'); $reflection_method->setAccessible(true); @@ -2817,78 +2819,78 @@ class CurlTest extends \PHPUnit\Framework\TestCase public function testRequestMethodSuccessiveGetRequests() { $test = new Test(); - $test->chain_requests('GET', 'POST'); - $test->chain_requests('GET', 'PUT'); - $test->chain_requests('GET', 'PATCH'); - $test->chain_requests('GET', 'DELETE'); - $test->chain_requests('GET', 'HEAD'); - $test->chain_requests('GET', 'OPTIONS'); + $test->chainRequests('GET', 'POST'); + $test->chainRequests('GET', 'PUT'); + $test->chainRequests('GET', 'PATCH'); + $test->chainRequests('GET', 'DELETE'); + $test->chainRequests('GET', 'HEAD'); + $test->chainRequests('GET', 'OPTIONS'); } public function testRequestMethodSuccessivePostRequests() { $test = new Test(); - $test->chain_requests('POST', 'GET'); - $test->chain_requests('POST', 'PUT'); - $test->chain_requests('POST', 'PATCH'); - $test->chain_requests('POST', 'DELETE'); - $test->chain_requests('POST', 'HEAD'); - $test->chain_requests('POST', 'OPTIONS'); + $test->chainRequests('POST', 'GET'); + $test->chainRequests('POST', 'PUT'); + $test->chainRequests('POST', 'PATCH'); + $test->chainRequests('POST', 'DELETE'); + $test->chainRequests('POST', 'HEAD'); + $test->chainRequests('POST', 'OPTIONS'); } public function testRequestMethodSuccessivePutRequests() { $test = new Test(); - $test->chain_requests('PUT', 'GET'); - $test->chain_requests('PUT', 'POST'); - $test->chain_requests('PUT', 'PATCH'); - $test->chain_requests('PUT', 'DELETE'); - $test->chain_requests('PUT', 'HEAD'); - $test->chain_requests('PUT', 'OPTIONS'); + $test->chainRequests('PUT', 'GET'); + $test->chainRequests('PUT', 'POST'); + $test->chainRequests('PUT', 'PATCH'); + $test->chainRequests('PUT', 'DELETE'); + $test->chainRequests('PUT', 'HEAD'); + $test->chainRequests('PUT', 'OPTIONS'); } public function testRequestMethodSuccessivePatchRequests() { $test = new Test(); - $test->chain_requests('PATCH', 'GET'); - $test->chain_requests('PATCH', 'POST'); - $test->chain_requests('PATCH', 'PUT'); - $test->chain_requests('PATCH', 'DELETE'); - $test->chain_requests('PATCH', 'HEAD'); - $test->chain_requests('PATCH', 'OPTIONS'); + $test->chainRequests('PATCH', 'GET'); + $test->chainRequests('PATCH', 'POST'); + $test->chainRequests('PATCH', 'PUT'); + $test->chainRequests('PATCH', 'DELETE'); + $test->chainRequests('PATCH', 'HEAD'); + $test->chainRequests('PATCH', 'OPTIONS'); } public function testRequestMethodSuccessiveDeleteRequests() { $test = new Test(); - $test->chain_requests('DELETE', 'GET'); - $test->chain_requests('DELETE', 'POST'); - $test->chain_requests('DELETE', 'PUT'); - $test->chain_requests('DELETE', 'PATCH'); - $test->chain_requests('DELETE', 'HEAD'); - $test->chain_requests('DELETE', 'OPTIONS'); + $test->chainRequests('DELETE', 'GET'); + $test->chainRequests('DELETE', 'POST'); + $test->chainRequests('DELETE', 'PUT'); + $test->chainRequests('DELETE', 'PATCH'); + $test->chainRequests('DELETE', 'HEAD'); + $test->chainRequests('DELETE', 'OPTIONS'); } public function testRequestMethodSuccessiveHeadRequests() { $test = new Test(); - $test->chain_requests('HEAD', 'GET'); - $test->chain_requests('HEAD', 'POST'); - $test->chain_requests('HEAD', 'PUT'); - $test->chain_requests('HEAD', 'PATCH'); - $test->chain_requests('HEAD', 'DELETE'); - $test->chain_requests('HEAD', 'OPTIONS'); + $test->chainRequests('HEAD', 'GET'); + $test->chainRequests('HEAD', 'POST'); + $test->chainRequests('HEAD', 'PUT'); + $test->chainRequests('HEAD', 'PATCH'); + $test->chainRequests('HEAD', 'DELETE'); + $test->chainRequests('HEAD', 'OPTIONS'); } public function testRequestMethodSuccessiveOptionsRequests() { $test = new Test(); - $test->chain_requests('OPTIONS', 'GET'); - $test->chain_requests('OPTIONS', 'POST'); - $test->chain_requests('OPTIONS', 'PUT'); - $test->chain_requests('OPTIONS', 'PATCH'); - $test->chain_requests('OPTIONS', 'DELETE'); - $test->chain_requests('OPTIONS', 'HEAD'); + $test->chainRequests('OPTIONS', 'GET'); + $test->chainRequests('OPTIONS', 'POST'); + $test->chainRequests('OPTIONS', 'PUT'); + $test->chainRequests('OPTIONS', 'PATCH'); + $test->chainRequests('OPTIONS', 'DELETE'); + $test->chainRequests('OPTIONS', 'HEAD'); } public function testMemoryLeak() @@ -3121,7 +3123,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase ); foreach ($tests as $test) { $curl_1 = new Curl(); - $reflector = new ReflectionObject($curl_1); + $reflector = new \ReflectionObject($curl_1); $method = $reflector->getMethod('buildURL'); $method->setAccessible(true); $actual_url = $method->invoke($curl_1, $test['args']['url'], $test['args']['mixed_data']); @@ -3149,7 +3151,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase $curl = new Curl(); - $reflector = new ReflectionObject($curl); + $reflector = new \ReflectionObject($curl); $method = $reflector->getMethod('buildURL'); $method->setAccessible(true); diff --git a/tests/PHPCurlClass/PHPMultiCurlClassTest.php b/tests/PHPCurlClass/PHPMultiCurlClassTest.php index a9da87d..ef15634 100644 --- a/tests/PHPCurlClass/PHPMultiCurlClassTest.php +++ b/tests/PHPCurlClass/PHPMultiCurlClassTest.php @@ -1,5 +1,8 @@ server('upload_response', 'POST', array( 'image' => '@' . $upload_file_path, @@ -2547,7 +2550,7 @@ class MultiCurlTest extends \PHPUnit\Framework\TestCase public function testAddCurl() { - $curl = new Curl\Curl(); + $curl = new Curl(); $curl->setUrl(Test::TEST_URL); $curl->setOpt(CURLOPT_CUSTOMREQUEST, 'GET'); $curl->setOpt(CURLOPT_HTTPGET, true); diff --git a/tests/ruleset.xml b/tests/ruleset.xml index b682619..11c4eba 100644 --- a/tests/ruleset.xml +++ b/tests/ruleset.xml @@ -7,4 +7,9 @@ + + + + 0 +