r70928 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70927‎ | r70928 | r70929 >
Date:07:27, 12 August 2010
Author:jeroendedauw
Status:ok
Tags:
Comment:
Documentation o_O
Modified paths:
  • /trunk/phase3/includes/json/FormatJson.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/json/FormatJson.php
@@ -7,6 +7,15 @@
88 }
99
1010 class FormatJson {
 11+
 12+ /**
 13+ * Returns the JSON representation of a value.
 14+ *
 15+ * @param $value Mixed: the value being encoded. Can be any type except a resource.
 16+ * @param $isHtml Boolean
 17+ *
 18+ * @return string
 19+ */
1120 public static function encode( $value, $isHtml = false ) {
1221 // Some versions of PHP have a broken json_encode, see PHP bug
1322 // 46944. Test encoding an affected character (U+20000) to
@@ -19,6 +28,17 @@
2029 }
2130 }
2231
 32+ /**
 33+ * Decodes a JSON string.
 34+ *
 35+ * @param $value String: the json string being decoded.
 36+ * @param $assoc Boolean: when true, returned objects will be converted into associative arrays.
 37+ *
 38+ * @return Mixed: the value encoded in json in appropriate PHP type.
 39+ * Values true, false and null (case-insensitive) are returned as true, false
 40+ * and &null; respectively. &null; is returned if the json cannot be
 41+ * decoded or if the encoded data is deeper than the recursion limit.
 42+ */
2343 public static function decode( $value, $assoc = false ) {
2444 if ( !function_exists( 'json_decode' ) ) {
2545 $json = new Services_JSON();
@@ -31,4 +51,5 @@
3252 return json_decode( $value, $assoc );
3353 }
3454 }
35 -}
 55+
 56+}
\ No newline at end of file

Status & tagging log