mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-08-30 20:20:53 +00:00
Fix building post data for object
PHP 8 error messages:
TypeError: array_keys(): Argument #1 ($array) must be of type array, stdClass given
TypeError: array_values(): Argument #1 ($array) must be of type array, stdClass given
PHP 7 error messages:
TypeError: array_keys() expects parameter 1 to be array, object given
TypeError: array_values() expects parameter 1 to be array, object given
This commit is contained in:
+1
-1
@@ -208,7 +208,7 @@ class Curl
|
||||
// php_url_encode()
|
||||
// https://github.com/php/php-src/blob/master/ext/standard/http.c
|
||||
return urlencode(strval($k)) . '=' . urlencode(strval($v));
|
||||
}, array_keys($data), array_values($data)));
|
||||
}, array_keys((array)$data), array_values((array)$data)));
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
||||
@@ -81,6 +81,15 @@ class CurlTest extends \PHPUnit\Framework\TestCase
|
||||
]));
|
||||
}
|
||||
|
||||
public function testBuildPostDataObject()
|
||||
{
|
||||
$data = new \stdClass();
|
||||
$data->{'abc'} = 'foo';
|
||||
$data->{'123'} = 'bar';
|
||||
$curl = new Curl();
|
||||
$curl->buildPostData($data);
|
||||
}
|
||||
|
||||
public function testUserAgent()
|
||||
{
|
||||
$php_version = preg_replace('/([\.\+\?\*\(\)\[\]\^\$\/])/', '\\\\\1', 'PHP/' . PHP_VERSION);
|
||||
|
||||
Reference in New Issue
Block a user