File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed
lib/Gitlab/HttpClient/Message
test/Gitlab/Tests/HttpClient/Message Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ final class QueryStringBuilder
1515 public static function build ($ query )
1616 {
1717 if (!is_array ($ query )) {
18- return rawurlencode ($ query );
18+ return static :: rawurlencode ($ query );
1919 }
2020 return implode ('& ' , array_map (function ($ value , $ key ) {
2121 return static ::encode ($ value , $ key );
@@ -32,7 +32,7 @@ public static function build($query)
3232 private static function encode ($ query , $ prefix )
3333 {
3434 if (!is_array ($ query )) {
35- return rawurlencode ($ prefix ).'= ' .rawurlencode ($ query );
35+ return static :: rawurlencode ($ prefix ).'= ' .static :: rawurlencode ($ query );
3636 }
3737
3838 $ isIndexedArray = static ::isIndexedArray ($ query );
@@ -57,4 +57,20 @@ public static function isIndexedArray(array $query)
5757
5858 return array_keys ($ query ) === range (0 , count ($ query ) - 1 );
5959 }
60+
61+ /**
62+ * Encode a value like rawurlencode, but return "0" when false is given.
63+ *
64+ * @param mixed $value
65+ *
66+ * @return string
67+ */
68+ private static function rawurlencode ($ value )
69+ {
70+ if ($ value === false ) {
71+ return '0 ' ;
72+ }
73+
74+ return rawurlencode ($ value );
75+ }
6076}
Original file line number Diff line number Diff line change @@ -40,6 +40,12 @@ public function queryStringProvider()
4040 'iids%5B0%5D=88&iids%5B2%5D=86 '
4141 ];
4242
43+ //Boolean encoding
44+ yield [
45+ ['push_events ' => false , 'merge_requests_events ' => 1 ],
46+ 'push_events=0&merge_requests_events=1 '
47+ ];
48+
4349 //A deeply nested array.
4450 yield [
4551 [
You can’t perform that action at this time.
0 commit comments