Skip to content

Commit 469710d

Browse files
committed
:octocat:
1 parent 1d20680 commit 469710d

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/Psr7/message_helpers.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,27 +115,30 @@ function build_http_query(array $params, bool $urlencode = null, string $delimit
115115
}
116116

117117
/**
118-
* @param array $params
118+
* @param iterable $params
119119
* @param bool|null $booleans_as_string - converts booleans to "true"/"false" strings if set to true, "0"/"1" otherwise.
120120
*
121121
* @return array
122122
*/
123-
function clean_query_params(array $params, bool $booleans_as_string = null):array{
123+
function clean_query_params(iterable $params, bool $booleans_as_string = null):array{
124+
$p = [];
124125

125126
foreach($params as $key => $value){
126127

127128
if(is_bool($value)){
128-
$params[$key] = $booleans_as_string === true
129+
$p[$key] = $booleans_as_string === true
129130
? ($value ? 'true' : 'false')
130131
: (string)(int)$value;
131132
}
132133
elseif($value === null || (!is_numeric($value) && empty($value))){
133-
unset($params[$key]);
134+
continue;
135+
}
136+
else{
137+
$p[$key] = $value;
134138
}
135-
136139
}
137140

138-
return $params;
141+
return $p;
139142
}
140143

141144
/**

0 commit comments

Comments
 (0)