r110320 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110319‎ | r110320 | r110321 >
Date:19:40, 30 January 2012
Author:krinkle
Status:ok
Tags:core 
Comment:
[Xml::encodeJsVar] Change to match FormatJson::encode output
- Pure whitespace change
- In preparation to deprecate it in favor of FormatJson / json_encode
Modified paths:
  • /trunk/phase3/includes/Xml.php (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/XmlTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/XmlTest.php
@@ -325,12 +325,12 @@
326326
327327 function testEncodeJsVarArray() {
328328 $this->assertEquals(
329 - '["a", 1]',
 329+ '["a",1]',
330330 Xml::encodeJsVar( array( 'a', 1 ) ),
331331 'encodeJsVar() with array'
332332 );
333333 $this->assertEquals(
334 - '{"a": "a", "b": 1}',
 334+ '{"a":"a","b":1}',
335335 Xml::encodeJsVar( array( 'a' => 'a', 'b' => 1 ) ),
336336 'encodeJsVar() with associative array'
337337 );
@@ -338,7 +338,7 @@
339339
340340 function testEncodeJsVarObject() {
341341 $this->assertEquals(
342 - '{"a": "a", "b": 1}',
 342+ '{"a":"a","b":1}',
343343 Xml::encodeJsVar( (object)array( 'a' => 'a', 'b' => 1 ) ),
344344 'encodeJsVar() with object'
345345 );
Index: trunk/phase3/includes/Xml.php
@@ -630,7 +630,7 @@
631631 $s = '[';
632632 foreach ( $value as $elt ) {
633633 if ( $s != '[' ) {
634 - $s .= ', ';
 634+ $s .= ',';
635635 }
636636 $s .= self::encodeJsVar( $elt );
637637 }
@@ -642,10 +642,10 @@
643643 $s = '{';
644644 foreach ( (array)$value as $name => $elt ) {
645645 if ( $s != '{' ) {
646 - $s .= ', ';
 646+ $s .= ',';
647647 }
648648
649 - $s .= '"' . self::escapeJsString( $name ) . '": ' .
 649+ $s .= '"' . self::escapeJsString( $name ) . '":' .
650650 self::encodeJsVar( $elt );
651651 }
652652 $s .= '}';

Follow-up revisions

RevisionCommit summaryAuthorDate
r110321[Xml::encodeJsVar] Use FormatJson::encode / native json_encode instead...krinkle19:45, 30 January 2012

Status & tagging log