diff --git a/src/Curl/ArrayUtil.php b/src/Curl/ArrayUtil.php index c93af5167c..f73eedc4f7 100644 --- a/src/Curl/ArrayUtil.php +++ b/src/Curl/ArrayUtil.php @@ -12,11 +12,25 @@ class ArrayUtil * * @return boolean */ - public static function is_array_assoc($array) + public static function isArrayAssoc($array) { return (bool)count(array_filter(array_keys($array), 'is_string')); } + /** + * Is Array Assoc + * + * @deprecated Use ArrayUtil::isArrayAssoc(). + * @access public + * @param $array + * + * @return boolean + */ + public static function is_array_assoc($array) + { + return $this->isArrayAssoc($array); + } + /** * Is Array Multidim * @@ -25,7 +39,7 @@ public static function is_array_assoc($array) * * @return boolean */ - public static function is_array_multidim($array) + public static function isArrayMultidim($array) { if (!is_array($array)) { return false; @@ -34,6 +48,20 @@ public static function is_array_multidim($array) return (bool)count(array_filter($array, 'is_array')); } + /** + * Is Array Multidim + * + * @deprecated Use ArrayUtil::isArrayMultidim(). + * @access public + * @param $array + * + * @return boolean + */ + public static function is_array_multidim($array) + { + return $this->isArrayMultidim($array); + } + /** * Array Flatten Multidim * @@ -43,7 +71,7 @@ public static function is_array_multidim($array) * * @return array */ - public static function array_flatten_multidim($array, $prefix = false) + public static function arrayFlattenMultidim($array, $prefix = false) { $return = array(); if (is_array($array) || is_object($array)) { @@ -63,7 +91,7 @@ public static function array_flatten_multidim($array, $prefix = false) } else { $return = array_merge( $return, - self::array_flatten_multidim( + self::arrayFlattenMultidim( $value, $prefix ? $prefix . '[' . $key . ']' : $key ) @@ -78,6 +106,21 @@ public static function array_flatten_multidim($array, $prefix = false) return $return; } + /** + * Array Flatten Multidim + * + * @deprecated Use ArrayUtil::arrayFlattenMultidim(). + * @access public + * @param $array + * @param $prefix + * + * @return array + */ + public static function array_flatten_multidim($array, $prefix = false) + { + return $this->arrayFlattenMultidim($array, $prefix); + } + /** * Array Random * @@ -86,8 +129,22 @@ public static function array_flatten_multidim($array, $prefix = false) * * @return mixed */ - public static function array_random($array) + public static function arrayRandom($array) { return $array[mt_rand(0, count($array) - 1)]; } + + /** + * Array Random + * + * @deprecated Use ArrayUtil::arrayRandom(). + * @access public + * @param $array + * + * @return mixed + */ + public static function array_random($array) + { + return $this->arrayRandom($array); + } } diff --git a/src/Curl/Curl.php b/src/Curl/Curl.php index 8003cd3448..fd4836fa9c 100644 --- a/src/Curl/Curl.php +++ b/src/Curl/Curl.php @@ -157,8 +157,8 @@ interface_exists('JsonSerializable', false) && // Manually build a single-dimensional array from a multi-dimensional array as using curl_setopt($ch, // CURLOPT_POSTFIELDS, $data) doesn't correctly handle multi-dimensional arrays when files are // referenced. - if (ArrayUtil::is_array_multidim($data)) { - $data = ArrayUtil::array_flatten_multidim($data); + if (ArrayUtil::isArrayMultidim($data)) { + $data = ArrayUtil::arrayFlattenMultidim($data); } // Modify array values to ensure any referenced files are properly handled depending on the support of diff --git a/src/Curl/MultiCurl.php b/src/Curl/MultiCurl.php index e35a39bc78..5deddb2a8a 100644 --- a/src/Curl/MultiCurl.php +++ b/src/Curl/MultiCurl.php @@ -952,7 +952,7 @@ private function initHandle($curl) // Use a random proxy for the curl instance when proxies have been set // and the curl instance doesn't already have a proxy set. if (is_array($this->proxies) && $curl->getOpt(CURLOPT_PROXY) === null) { - $random_proxy = ArrayUtil::array_random($this->proxies); + $random_proxy = ArrayUtil::arrayRandom($this->proxies); $curl->setProxy($random_proxy); } diff --git a/tests/PHPCurlClass/PHPCurlClassTest.php b/tests/PHPCurlClass/PHPCurlClassTest.php index ae0c06f093..50ce07f497 100644 --- a/tests/PHPCurlClass/PHPCurlClassTest.php +++ b/tests/PHPCurlClass/PHPCurlClassTest.php @@ -18,7 +18,7 @@ public function testExtensionsLoaded() public function testArrayAssociative() { - $this->assertTrue(\Curl\ArrayUtil::is_array_assoc(array( + $this->assertTrue(\Curl\ArrayUtil::isArrayAssoc(array( 'foo' => 'wibble', 'bar' => 'wubble', 'baz' => 'wobble', @@ -27,7 +27,7 @@ public function testArrayAssociative() public function testArrayIndexed() { - $this->assertFalse(\Curl\ArrayUtil::is_array_assoc(array( + $this->assertFalse(\Curl\ArrayUtil::isArrayAssoc(array( 'wibble', 'wubble', 'wobble', @@ -3457,6 +3457,18 @@ public function testUnsetHeader() $this->assertEquals('', $curl->response); } + public function testRemoveHeader() + { + $curl = new Curl(); + $curl->get(Test::TEST_URL); + $this->assertEquals('127.0.0.1:8000', $curl->requestHeaders['host']); + + $curl = new Curl(); + $curl->removeHeader('HOST'); + $curl->get(Test::TEST_URL); + $this->assertEquals('', $curl->requestHeaders['host']); + } + public function testGetInfo() { $test = new Test();