Skip to content

Commit 0c675a8

Browse files
authored
Merge pull request php-curl-class#446 from zachborboa/master
Clean up namespacing
2 parents b754ebf + 316e18d commit 0c675a8

File tree

7 files changed

+93
-90
lines changed

7 files changed

+93
-90
lines changed

examples/custom.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
use \Curl\Curl;
55

6-
76
$curl = new Curl();
87
$curl->setOpt(CURLOPT_CUSTOMREQUEST, 'GET');
98
$curl->setOpt(CURLOPT_NOBODY, true);

src/Curl/MultiCurl.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,6 @@ public function start()
643643
}
644644

645645
do {
646-
647646
// Wait for activity on any curl_multi connection when curl_multi_select (libcurl) fails to correctly block.
648647
// https://bugs.php.net/bug.php?id=63411
649648
if (curl_multi_select($this->multiCurl) === -1) {

tests/PHPCurlClass/Helper.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function server($test, $request_method, $query_parameters = array(), $dat
3333
* previously forced method might be inherited.
3434
* Especially, POSTs must be configured to not perform post-redirect-get.
3535
*/
36-
private function chained_request($request_method)
36+
private function chainedRequest($request_method)
3737
{
3838
if ($request_method === 'POST') {
3939
$this->server('request_method', $request_method, array(), true);
@@ -43,10 +43,10 @@ private function chained_request($request_method)
4343
\PHPUnit\Framework\Assert::assertEquals($request_method, $this->curl->responseHeaders['X-REQUEST-METHOD']);
4444
}
4545

46-
public function chain_requests($first, $second)
46+
public function chainRequests($first, $second)
4747
{
48-
$this->chained_request($first);
49-
$this->chained_request($second);
48+
$this->chainedRequest($first);
49+
$this->chainedRequest($second);
5050
}
5151
}
5252

tests/PHPCurlClass/PHPCurlClassTest.php

Lines changed: 74 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
namespace CurlTest;
4+
35
use \Curl\Curl;
46
use \Curl\CaseInsensitiveArray;
57
use \Helper\Test;
@@ -283,7 +285,7 @@ public function testPostContinueResponseHeader()
283285
'Connection: keep-alive' . "\r\n" .
284286
"\r\n";
285287

286-
$reflector = new ReflectionClass('\Curl\Curl');
288+
$reflector = new \ReflectionClass('\Curl\Curl');
287289
$reflection_method = $reflector->getMethod('parseResponseHeaders');
288290
$reflection_method->setAccessible(true);
289291

@@ -366,17 +368,17 @@ public function testPostMultidimensionalDataWithFile()
366368
{
367369
$tests = array();
368370

369-
$file_path_1 = Helper\get_png();
371+
$file_path_1 = \Helper\get_png();
370372
$tests[] = array(
371373
'file_path' => $file_path_1,
372374
'post_data_image' => '@' . $file_path_1,
373375
);
374376

375377
if (class_exists('CURLFile')) {
376-
$file_path_2 = Helper\get_png();
378+
$file_path_2 = \Helper\get_png();
377379
$tests[] = array(
378380
'file_path' => $file_path_2,
379-
'post_data_image' => new CURLFile($file_path_2),
381+
'post_data_image' => new \CURLFile($file_path_2),
380382
);
381383
}
382384

@@ -426,7 +428,7 @@ public function testPostMultidimensionalDataWithFile()
426428

427429
public function testPostFilePathUpload()
428430
{
429-
$file_path = Helper\get_png();
431+
$file_path = \Helper\get_png();
430432

431433
$test = new Test();
432434
$this->assertEquals('image/png', $test->server('post_file_path_upload', 'POST', array(
@@ -441,12 +443,12 @@ public function testPostFilePathUpload()
441443
public function testPostCurlFileUpload()
442444
{
443445
if (class_exists('CURLFile')) {
444-
$file_path = Helper\get_png();
446+
$file_path = \Helper\get_png();
445447

446448
$test = new Test();
447449
$this->assertEquals('image/png', $test->server('post_file_path_upload', 'POST', array(
448450
'key' => 'image',
449-
'image' => new CURLFile($file_path),
451+
'image' => new \CURLFile($file_path),
450452
)));
451453

452454
unlink($file_path);
@@ -486,7 +488,7 @@ public function testPostRedirectGet()
486488
public function testPostRedirectGetReuseObjectIncompatibleEngine()
487489
{
488490
if ((version_compare(PHP_VERSION, '5.5.11') > 0) && !defined('HHVM_VERSION')) {
489-
$this->markTestSkipped('This test is not applicable to this platform.');
491+
$this->markTestSkipped();
490492
}
491493

492494
try {
@@ -503,7 +505,7 @@ public function testPostRedirectGetReuseObjectIncompatibleEngine()
503505
false,
504506
'Reusing an existing Curl object on incompatible PHP engines shall trigger an error.'
505507
);
506-
} catch (PHPUnit_Framework_Error $e) {
508+
} catch (\PHPUnit_Framework_Error $e) {
507509
$this->assertTrue(true);
508510
}
509511
}
@@ -529,8 +531,8 @@ public function testPutData()
529531

530532
public function testPutFileHandle()
531533
{
532-
$png = Helper\create_png();
533-
$tmp_file = Helper\create_tmp_file($png);
534+
$png = \Helper\create_png();
535+
$tmp_file = \Helper\create_tmp_file($png);
534536

535537
$test = new Test();
536538
$test->curl->setHeader('X-DEBUG-TEST', 'put_file_handle');
@@ -610,8 +612,8 @@ public function testOptionsRequestMethod()
610612
public function testDownload()
611613
{
612614
// Create and upload a file.
613-
$upload_file_path = Helper\get_png();
614-
$uploaded_file_path = Helper\upload_file_to_server($upload_file_path);
615+
$upload_file_path = \Helper\get_png();
616+
$uploaded_file_path = \Helper\upload_file_to_server($upload_file_path);
615617

616618
// Download the file.
617619
$downloaded_file_path = tempnam('/tmp', 'php-curl-class.');
@@ -632,7 +634,7 @@ public function testDownload()
632634
$this->assertFalse(is_bool($download_test->curl->rawResponse));
633635

634636
// Remove server file.
635-
Helper\remove_file_from_server($uploaded_file_path);
637+
\Helper\remove_file_from_server($uploaded_file_path);
636638

637639
unlink($upload_file_path);
638640
unlink($downloaded_file_path);
@@ -643,8 +645,8 @@ public function testDownload()
643645
public function testDownloadCallback()
644646
{
645647
// Create and upload a file.
646-
$upload_file_path = Helper\get_png();
647-
$uploaded_file_path = Helper\upload_file_to_server($upload_file_path);
648+
$upload_file_path = \Helper\get_png();
649+
$uploaded_file_path = \Helper\upload_file_to_server($upload_file_path);
648650

649651
// Download the file.
650652
$callback_called = false;
@@ -665,7 +667,7 @@ public function testDownloadCallback()
665667
$this->assertTrue($callback_called);
666668

667669
// Remove server file.
668-
Helper\remove_file_from_server($uploaded_file_path);
670+
\Helper\remove_file_from_server($uploaded_file_path);
669671

670672
unlink($upload_file_path);
671673
$this->assertFalse(file_exists($upload_file_path));
@@ -674,8 +676,8 @@ public function testDownloadCallback()
674676
public function testDownloadRange()
675677
{
676678
// Create and upload a file.
677-
$filename = Helper\get_png();
678-
$uploaded_file_path = Helper\upload_file_to_server($filename);
679+
$filename = \Helper\get_png();
680+
$uploaded_file_path = \Helper\upload_file_to_server($filename);
679681

680682
$filesize = filesize($filename);
681683

@@ -712,7 +714,7 @@ public function testDownloadRange()
712714

713715
) as $length) {
714716
$source = Test::TEST_URL;
715-
$destination = Helper\get_tmp_file_path();
717+
$destination = \Helper\get_tmp_file_path();
716718

717719
// Start with no file.
718720
if ($length === false) {
@@ -774,7 +776,7 @@ public function testDownloadRange()
774776
}
775777

776778
// Remove server file.
777-
Helper\remove_file_from_server($uploaded_file_path);
779+
\Helper\remove_file_from_server($uploaded_file_path);
778780

779781
unlink($filename);
780782
$this->assertFalse(file_exists($filename));
@@ -1123,7 +1125,7 @@ public function testRequestHeaderCaseSensitivity()
11231125
$curl = new Curl();
11241126
$curl->setHeader('Content-Type', $content_type);
11251127

1126-
$reflector = new ReflectionClass('\Curl\Curl');
1128+
$reflector = new \ReflectionClass('\Curl\Curl');
11271129
$property = $reflector->getProperty('headers');
11281130
$property->setAccessible(true);
11291131
$headers = $property->getValue($curl);
@@ -1248,7 +1250,7 @@ public function testPostArrayUrlEncodedContentType()
12481250

12491251
public function testPostFileFormDataContentType()
12501252
{
1251-
$file_path = Helper\get_png();
1253+
$file_path = \Helper\get_png();
12521254

12531255
$test = new Test();
12541256
$test->server('server', 'POST', array(
@@ -1268,11 +1270,11 @@ public function testPostCurlFileFormDataContentType()
12681270
$this->markTestSkipped();
12691271
}
12701272

1271-
$file_path = Helper\get_png();
1273+
$file_path = \Helper\get_png();
12721274

12731275
$test = new Test();
12741276
$test->server('server', 'POST', array(
1275-
'image' => new CURLFile($file_path),
1277+
'image' => new \CURLFile($file_path),
12761278
));
12771279
$this->assertEquals('100-continue', $test->curl->requestHeaders['Expect']);
12781280
preg_match('/^multipart\/form-data; boundary=/', $test->curl->requestHeaders['Content-Type'], $content_type);
@@ -1481,7 +1483,7 @@ public function testJsonContentTypeDetection()
14811483
'text/x-json',
14821484
);
14831485

1484-
$class = new ReflectionClass('\Curl\Curl');
1486+
$class = new \ReflectionClass('\Curl\Curl');
14851487
$property = $class->getProperty('jsonPattern');
14861488
$property->setAccessible(true);
14871489
$json_pattern = $property->getValue(new Curl);
@@ -2595,7 +2597,7 @@ public function testXMLResponse()
25952597

25962598
$this->assertInstanceOf('SimpleXMLElement', $test->curl->response);
25972599

2598-
$doc = new DOMDocument();
2600+
$doc = new \DOMDocument();
25992601
$doc->formatOutput = true;
26002602
$rss = $doc->appendChild($doc->createElement('rss'));
26012603
$rss->setAttribute('version', '2.0');
@@ -2620,7 +2622,7 @@ public function testEmptyResponse()
26202622
{
26212623
$response = "\r\n\r\n";
26222624

2623-
$reflector = new ReflectionClass('\Curl\Curl');
2625+
$reflector = new \ReflectionClass('\Curl\Curl');
26242626
$reflection_method = $reflector->getMethod('parseResponseHeaders');
26252627
$reflection_method->setAccessible(true);
26262628

@@ -2817,78 +2819,78 @@ public function testRequiredOptionCurlOptReturnTransferEmitsWarning()
28172819
public function testRequestMethodSuccessiveGetRequests()
28182820
{
28192821
$test = new Test();
2820-
$test->chain_requests('GET', 'POST');
2821-
$test->chain_requests('GET', 'PUT');
2822-
$test->chain_requests('GET', 'PATCH');
2823-
$test->chain_requests('GET', 'DELETE');
2824-
$test->chain_requests('GET', 'HEAD');
2825-
$test->chain_requests('GET', 'OPTIONS');
2822+
$test->chainRequests('GET', 'POST');
2823+
$test->chainRequests('GET', 'PUT');
2824+
$test->chainRequests('GET', 'PATCH');
2825+
$test->chainRequests('GET', 'DELETE');
2826+
$test->chainRequests('GET', 'HEAD');
2827+
$test->chainRequests('GET', 'OPTIONS');
28262828
}
28272829

28282830
public function testRequestMethodSuccessivePostRequests()
28292831
{
28302832
$test = new Test();
2831-
$test->chain_requests('POST', 'GET');
2832-
$test->chain_requests('POST', 'PUT');
2833-
$test->chain_requests('POST', 'PATCH');
2834-
$test->chain_requests('POST', 'DELETE');
2835-
$test->chain_requests('POST', 'HEAD');
2836-
$test->chain_requests('POST', 'OPTIONS');
2833+
$test->chainRequests('POST', 'GET');
2834+
$test->chainRequests('POST', 'PUT');
2835+
$test->chainRequests('POST', 'PATCH');
2836+
$test->chainRequests('POST', 'DELETE');
2837+
$test->chainRequests('POST', 'HEAD');
2838+
$test->chainRequests('POST', 'OPTIONS');
28372839
}
28382840

28392841
public function testRequestMethodSuccessivePutRequests()
28402842
{
28412843
$test = new Test();
2842-
$test->chain_requests('PUT', 'GET');
2843-
$test->chain_requests('PUT', 'POST');
2844-
$test->chain_requests('PUT', 'PATCH');
2845-
$test->chain_requests('PUT', 'DELETE');
2846-
$test->chain_requests('PUT', 'HEAD');
2847-
$test->chain_requests('PUT', 'OPTIONS');
2844+
$test->chainRequests('PUT', 'GET');
2845+
$test->chainRequests('PUT', 'POST');
2846+
$test->chainRequests('PUT', 'PATCH');
2847+
$test->chainRequests('PUT', 'DELETE');
2848+
$test->chainRequests('PUT', 'HEAD');
2849+
$test->chainRequests('PUT', 'OPTIONS');
28482850
}
28492851

28502852
public function testRequestMethodSuccessivePatchRequests()
28512853
{
28522854
$test = new Test();
2853-
$test->chain_requests('PATCH', 'GET');
2854-
$test->chain_requests('PATCH', 'POST');
2855-
$test->chain_requests('PATCH', 'PUT');
2856-
$test->chain_requests('PATCH', 'DELETE');
2857-
$test->chain_requests('PATCH', 'HEAD');
2858-
$test->chain_requests('PATCH', 'OPTIONS');
2855+
$test->chainRequests('PATCH', 'GET');
2856+
$test->chainRequests('PATCH', 'POST');
2857+
$test->chainRequests('PATCH', 'PUT');
2858+
$test->chainRequests('PATCH', 'DELETE');
2859+
$test->chainRequests('PATCH', 'HEAD');
2860+
$test->chainRequests('PATCH', 'OPTIONS');
28592861
}
28602862

28612863
public function testRequestMethodSuccessiveDeleteRequests()
28622864
{
28632865
$test = new Test();
2864-
$test->chain_requests('DELETE', 'GET');
2865-
$test->chain_requests('DELETE', 'POST');
2866-
$test->chain_requests('DELETE', 'PUT');
2867-
$test->chain_requests('DELETE', 'PATCH');
2868-
$test->chain_requests('DELETE', 'HEAD');
2869-
$test->chain_requests('DELETE', 'OPTIONS');
2866+
$test->chainRequests('DELETE', 'GET');
2867+
$test->chainRequests('DELETE', 'POST');
2868+
$test->chainRequests('DELETE', 'PUT');
2869+
$test->chainRequests('DELETE', 'PATCH');
2870+
$test->chainRequests('DELETE', 'HEAD');
2871+
$test->chainRequests('DELETE', 'OPTIONS');
28702872
}
28712873

28722874
public function testRequestMethodSuccessiveHeadRequests()
28732875
{
28742876
$test = new Test();
2875-
$test->chain_requests('HEAD', 'GET');
2876-
$test->chain_requests('HEAD', 'POST');
2877-
$test->chain_requests('HEAD', 'PUT');
2878-
$test->chain_requests('HEAD', 'PATCH');
2879-
$test->chain_requests('HEAD', 'DELETE');
2880-
$test->chain_requests('HEAD', 'OPTIONS');
2877+
$test->chainRequests('HEAD', 'GET');
2878+
$test->chainRequests('HEAD', 'POST');
2879+
$test->chainRequests('HEAD', 'PUT');
2880+
$test->chainRequests('HEAD', 'PATCH');
2881+
$test->chainRequests('HEAD', 'DELETE');
2882+
$test->chainRequests('HEAD', 'OPTIONS');
28812883
}
28822884

28832885
public function testRequestMethodSuccessiveOptionsRequests()
28842886
{
28852887
$test = new Test();
2886-
$test->chain_requests('OPTIONS', 'GET');
2887-
$test->chain_requests('OPTIONS', 'POST');
2888-
$test->chain_requests('OPTIONS', 'PUT');
2889-
$test->chain_requests('OPTIONS', 'PATCH');
2890-
$test->chain_requests('OPTIONS', 'DELETE');
2891-
$test->chain_requests('OPTIONS', 'HEAD');
2888+
$test->chainRequests('OPTIONS', 'GET');
2889+
$test->chainRequests('OPTIONS', 'POST');
2890+
$test->chainRequests('OPTIONS', 'PUT');
2891+
$test->chainRequests('OPTIONS', 'PATCH');
2892+
$test->chainRequests('OPTIONS', 'DELETE');
2893+
$test->chainRequests('OPTIONS', 'HEAD');
28922894
}
28932895

28942896
public function testMemoryLeak()
@@ -3121,7 +3123,7 @@ public function testBuildUrlArgs()
31213123
);
31223124
foreach ($tests as $test) {
31233125
$curl_1 = new Curl();
3124-
$reflector = new ReflectionObject($curl_1);
3126+
$reflector = new \ReflectionObject($curl_1);
31253127
$method = $reflector->getMethod('buildURL');
31263128
$method->setAccessible(true);
31273129
$actual_url = $method->invoke($curl_1, $test['args']['url'], $test['args']['mixed_data']);
@@ -3149,7 +3151,7 @@ public function testBuildUrlArgSeparator()
31493151

31503152
$curl = new Curl();
31513153

3152-
$reflector = new ReflectionObject($curl);
3154+
$reflector = new \ReflectionObject($curl);
31533155
$method = $reflector->getMethod('buildURL');
31543156
$method->setAccessible(true);
31553157

0 commit comments

Comments
 (0)