r66463 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r66462‎ | r66463 | r66464 >
Date:10:39, 15 May 2010
Author:ashley
Status:ok
Tags:
Comment:
coding style tweaks
Modified paths:
  • /trunk/phase3/includes/json/FormatJson.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/json/FormatJson.php
@@ -1,29 +1,31 @@
22 <?php
3 -/*
4 - * simple wrapper for json_econde and json_decode that falls back on Services_JSON class
 3+/**
 4+ * Simple wrapper for json_econde and json_decode that falls back on Services_JSON class
55 */
6 -if( !(defined( 'MEDIAWIKI' ) ) ) {
 6+if ( !defined( 'MEDIAWIKI' ) ) {
77 die( 1 );
88 }
99
1010 class FormatJson {
11 - public static function encode($value, $isHtml=false){
 11+ public static function encode( $value, $isHtml = false ) {
1212 // Some versions of PHP have a broken json_encode, see PHP bug
1313 // 46944. Test encoding an affected character (U+20000) to
1414 // avoid this.
15 - if (!function_exists('json_encode') || $isHtml || strtolower(json_encode("\xf0\xa0\x80\x80")) != '\ud840\udc00') {
 15+ if ( !function_exists( 'json_encode' ) || $isHtml || strtolower( json_encode( "\xf0\xa0\x80\x80" ) ) != '\ud840\udc00' ) {
1616 $json = new Services_JSON();
17 - return $json->encode($value, $isHtml) ;
 17+ return $json->encode( $value, $isHtml );
1818 } else {
19 - return json_encode($value);
 19+ return json_encode( $value );
2020 }
2121 }
22 - public static function decode( $value, $assoc=false ){
23 - if (!function_exists('json_decode') ) {
 22+
 23+ public static function decode( $value, $assoc = false ) {
 24+ if ( !function_exists( 'json_decode' ) ) {
2425 $json = new Services_JSON();
2526 $jsonDec = $json->decode( $value );
26 - if( $assoc )
 27+ if( $assoc ) {
2728 $jsonDec = wfObjectToArray( $jsonDec );
 29+ }
2830 return $jsonDec;
2931 } else {
3032 return json_decode( $value, $assoc );

Status & tagging log