@@ -162,14 +162,14 @@ function normalize_request_headers(array $headers):array{
162162}
163163
164164/**
165- * @param mixed $data
165+ * @param string|array $data
166166 *
167- * @return mixed
167+ * @return string|array
168168 */
169- function raw_urlencode ($data){
169+ function r_rawurlencode ($data){
170170
171171 if(is_array($data)){
172- return array_map(__NAMESPACE__.'\\raw_urlencode ', $data);
172+ return array_map(__NAMESPACE__.'\\r_rawurlencode ', $data);
173173 }
174174
175175 return rawurlencode($data);
@@ -194,8 +194,8 @@ function build_http_query(array $params, bool $urlencode = null, string $delimit
194194 // urlencode both keys and values
195195 if($urlencode ?? true){
196196 $params = array_combine(
197- raw_urlencode (array_keys($params)),
198- raw_urlencode (array_values($params))
197+ r_rawurlencode (array_keys($params)),
198+ r_rawurlencode (array_values($params))
199199 );
200200 }
201201
@@ -246,7 +246,7 @@ function build_http_query(array $params, bool $urlencode = null, string $delimit
246246 *
247247 * @return array
248248 */
249- function clean_query_params(iterable $params, int $bool_cast = null, bool $remove_empty = null):array {
249+ function clean_query_params(iterable $params, int $bool_cast = null, bool $remove_empty = null):iterable {
250250 $p = [];
251251 $bool_cast = $bool_cast ?? BOOLEANS_AS_BOOL;
252252 $remove_empty = $remove_empty ?? true;
@@ -269,6 +269,9 @@ function clean_query_params(iterable $params, int $bool_cast = null, bool $remov
269269 }
270270
271271 }
272+ elseif(is_iterable($value)){
273+ $p[$key] = call_user_func_array(__NAMESPACE__.'\\clean_query_params', [$value, $bool_cast, $remove_empty]);
274+ }
272275 elseif($remove_empty === true && ($value === null || (!is_numeric($value) && empty($value)))){
273276 continue;
274277 }
@@ -410,7 +413,7 @@ function get_xml(ResponseInterface $response){
410413 *
411414 * @return string
412415 */
413- function message_to_string(MessageInterface $message){
416+ function message_to_string(MessageInterface $message):string {
414417
415418 if($message instanceof RequestInterface){
416419 $msg = trim($message->getMethod().' '.$message->getRequestTarget()).' HTTP/'.$message->getProtocolVersion();
@@ -423,13 +426,10 @@ function message_to_string(MessageInterface $message){
423426 elseif($message instanceof ResponseInterface){
424427 $msg = 'HTTP/'.$message->getProtocolVersion().' '.$message->getStatusCode().' '.$message->getReasonPhrase();
425428 }
426- else{
427- throw new \InvalidArgumentException('Unknown message type');
428- }
429429
430430 foreach($message->getHeaders() as $name => $values){
431- $msg .= "\r\n{ $name}: " .implode(', ', $values);
431+ $msg .= "\r\n". $name.': ' .implode(', ', $values);
432432 }
433433
434- return "{ $msg} \r\n\r\n".$message->getBody();
434+ return $msg." \r\n\r\n".$message->getBody();
435435}
0 commit comments