瀏覽代碼

Format booleans as "1"/"0" in query params

Currently, `boolean` types in query params are either ``"1"` or `""`, the later case should be `"0"`, this PR fixes that
stelar7 3 年之前
父節點
當前提交
14fbc295fe
共有 1 個文件被更改,包括 2 次插入1 次删除
  1. 2 1
      src/Tools/WritingUtils.php

+ 2 - 1
src/Tools/WritingUtils.php

@@ -102,7 +102,8 @@ class WritingUtils
             if (!is_array($value)) {
                 $output .= str_repeat(" ", $spacesIndentation);
                 // Example: -----"param_name": "value"----
-                $output .= "$startLinesWith$quote$parameter$quote$delimiter $quote$value$quote$endLinesWith\n";
+                $formattedValue = gettype($value) === "boolean" ? ($value ? 1 : 0) : $value;
+                $output .= "$startLinesWith$quote$parameter$quote$delimiter $quote$formattedValue$quote$endLinesWith\n";
             } else {
                 if (count($value) == 0) {
                     continue;