From 10254ee6e8398ee8b5806b50c0b673c309782241 Mon Sep 17 00:00:00 2001 From: Ori Livneh Date: Fri, 23 Nov 2012 13:51:15 -0800 Subject: [PATCH] Fix misleading param name in FormatJson::encode signature As the FIXME notes, $isHtml has nothing to do with HTML; it simply controls whether the resultant JSON should be formatted for readability by inserting whitespace as appropriate. Change-Id: I90d46d6624d683f18a39c98500bd71bbd0ca3800 --- includes/json/FormatJson.php | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/includes/json/FormatJson.php b/includes/json/FormatJson.php index f67700c94f..75da5c7e72 100644 --- a/includes/json/FormatJson.php +++ b/includes/json/FormatJson.php @@ -31,21 +31,16 @@ class FormatJson { * Returns the JSON representation of a value. * * @param $value Mixed: the value being encoded. Can be any type except a resource. - * @param $isHtml Boolean - * - * @todo FIXME: "$isHtml" parameter's purpose is not documented. It appears to - * map to a parameter labeled "pretty-print output with indents and - * newlines" in Services_JSON::encode(), which has no string relation - * to HTML output. + * @param $pretty Boolean: If true, adds non-significant whitespace to improve readability. * * @return string */ - public static function encode( $value, $isHtml = false ) { - if ( !function_exists( 'json_encode' ) || ( $isHtml && version_compare( PHP_VERSION, '5.4.0', '<' ) ) ) { + public static function encode( $value, $pretty = false ) { + if ( !function_exists( 'json_encode' ) || ( $pretty && version_compare( PHP_VERSION, '5.4.0', '<' ) ) ) { $json = new Services_JSON(); - return $json->encode( $value, $isHtml ); + return $json->encode( $value, $pretty ); } else { - return json_encode( $value, $isHtml ? JSON_PRETTY_PRINT : 0 ); + return json_encode( $value, $pretty ? JSON_PRETTY_PRINT : 0 ); } } -- 2.20.1