mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-09-12 19:36:31 +00:00
Fix #13: Remove pass by reference usage; Add "Array to string conversion" test
This commit is contained in:
+2
-2
@@ -135,9 +135,9 @@ class Curl {
|
||||
// Fix "Notice: Array to string conversion" when $value in
|
||||
// curl_setopt($ch, CURLOPT_POSTFIELDS, $value) is an array
|
||||
// that contains an empty array.
|
||||
foreach ($data as &$value) {
|
||||
foreach ($data as $key => $value) {
|
||||
if (is_array($value) && empty($value)) {
|
||||
$value = '';
|
||||
$data[$key] = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,4 +241,14 @@ class CurlTest extends PHPUnit_Framework_TestCase {
|
||||
$test->curl->request_headers);
|
||||
$this->assertTrue(!empty($content_type));
|
||||
}
|
||||
|
||||
public function testArrayToStringConversion() {
|
||||
$test = new Test();
|
||||
$test->server('post', 'POST', array(
|
||||
'foo' => 'bar',
|
||||
'baz' => array(
|
||||
),
|
||||
));
|
||||
$this->assertTrue($test->curl->response === 'foo=bar&baz=');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user