http://www.mediawiki.org/wiki/Special:Code/MediaWiki/66463
Revision: 66463 Author: ashley Date: 2010-05-15 10:39:41 +0000 (Sat, 15 May 2010) Log Message: ----------- coding style tweaks Modified Paths: -------------- trunk/phase3/includes/json/FormatJson.php Modified: trunk/phase3/includes/json/FormatJson.php =================================================================== --- trunk/phase3/includes/json/FormatJson.php 2010-05-15 10:35:54 UTC (rev 66462) +++ trunk/phase3/includes/json/FormatJson.php 2010-05-15 10:39:41 UTC (rev 66463) @@ -1,29 +1,31 @@ <?php -/* - * simple wrapper for json_econde and json_decode that falls back on Services_JSON class +/** + * Simple wrapper for json_econde and json_decode that falls back on Services_JSON class */ -if( !(defined( 'MEDIAWIKI' ) ) ) { +if ( !defined( 'MEDIAWIKI' ) ) { die( 1 ); } class FormatJson { - public static function encode($value, $isHtml=false){ + public static function encode( $value, $isHtml = false ) { // Some versions of PHP have a broken json_encode, see PHP bug // 46944. Test encoding an affected character (U+20000) to // avoid this. - if (!function_exists('json_encode') || $isHtml || strtolower(json_encode("\xf0\xa0\x80\x80")) != '\ud840\udc00') { + if ( !function_exists( 'json_encode' ) || $isHtml || strtolower( json_encode( "\xf0\xa0\x80\x80" ) ) != '\ud840\udc00' ) { $json = new Services_JSON(); - return $json->encode($value, $isHtml) ; + return $json->encode( $value, $isHtml ); } else { - return json_encode($value); + return json_encode( $value ); } } - public static function decode( $value, $assoc=false ){ - if (!function_exists('json_decode') ) { + + public static function decode( $value, $assoc = false ) { + if ( !function_exists( 'json_decode' ) ) { $json = new Services_JSON(); $jsonDec = $json->decode( $value ); - if( $assoc ) + if( $assoc ) { $jsonDec = wfObjectToArray( $jsonDec ); + } return $jsonDec; } else { return json_decode( $value, $assoc ); _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs