From 6ebbb369a69a0c8cd05caf11ae05caf7e096512d Mon Sep 17 00:00:00 2001 From: Krinkle Date: Mon, 30 Jan 2012 19:40:20 +0000 Subject: [PATCH] [Xml::encodeJsVar] Change to match FormatJson::encode output - Pure whitespace change - In preparation to deprecate it in favor of FormatJson / json_encode --- includes/Xml.php | 6 +++--- tests/phpunit/includes/XmlTest.php | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/includes/Xml.php b/includes/Xml.php index 010c0b2b70..7e5b3cdba9 100644 --- a/includes/Xml.php +++ b/includes/Xml.php @@ -630,7 +630,7 @@ class Xml { $s = '['; foreach ( $value as $elt ) { if ( $s != '[' ) { - $s .= ', '; + $s .= ','; } $s .= self::encodeJsVar( $elt ); } @@ -642,10 +642,10 @@ class Xml { $s = '{'; foreach ( (array)$value as $name => $elt ) { if ( $s != '{' ) { - $s .= ', '; + $s .= ','; } - $s .= '"' . self::escapeJsString( $name ) . '": ' . + $s .= '"' . self::escapeJsString( $name ) . '":' . self::encodeJsVar( $elt ); } $s .= '}'; diff --git a/tests/phpunit/includes/XmlTest.php b/tests/phpunit/includes/XmlTest.php index ea5ae48a9b..e9c531cc89 100644 --- a/tests/phpunit/includes/XmlTest.php +++ b/tests/phpunit/includes/XmlTest.php @@ -325,12 +325,12 @@ class XmlTest extends MediaWikiTestCase { function testEncodeJsVarArray() { $this->assertEquals( - '["a", 1]', + '["a",1]', Xml::encodeJsVar( array( 'a', 1 ) ), 'encodeJsVar() with array' ); $this->assertEquals( - '{"a": "a", "b": 1}', + '{"a":"a","b":1}', Xml::encodeJsVar( array( 'a' => 'a', 'b' => 1 ) ), 'encodeJsVar() with associative array' ); @@ -338,7 +338,7 @@ class XmlTest extends MediaWikiTestCase { function testEncodeJsVarObject() { $this->assertEquals( - '{"a": "a", "b": 1}', + '{"a":"a","b":1}', Xml::encodeJsVar( (object)array( 'a' => 'a', 'b' => 1 ) ), 'encodeJsVar() with object' ); -- 2.20.1