From: Ori Livneh Date: Fri, 23 Nov 2012 21:51:15 +0000 (-0800) Subject: Fix misleading param name in FormatJson::encode signature X-Git-Tag: 1.31.0-rc.0~21489^2~1 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/membres/message.php?a=commitdiff_plain;h=10254ee6e8398ee8b5806b50c0b673c309782241;p=lhc%2Fweb%2Fwiklou.git 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 --- 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 ); } }