Skip to content

Commit

Permalink
Fix JSONSerializableXMLElement::jsonSerialize for a node with only '0…
Browse files Browse the repository at this point in the history
…' content
  • Loading branch information
niels-nijens committed Feb 12, 2016
1 parent a865f37 commit 593f9ac
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Configuration/JSONSerializableXMLElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function jsonSerialize()
}
}

if (empty($data)) {
if ((is_array($data) && count($data) === 0) || (is_scalar($data) && strlen($data) === 0)) {
$data = null;
}

Expand Down
1 change: 1 addition & 0 deletions tests/Configuration/JSONSerializableXMLElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public function provideTestJsonSerialize()
return array(
array('<node></node>', null),
array('<node>Text</node>', 'Text'),
array('<node>0</node>', '0'),
array("<node attribute='attributeValue'>Text</node>", array('attribute' => 'attributeValue', '#value' => 'Text')),
array("<node attribute='attributeValue'><childnode/>Text</node>", array('attribute' => 'attributeValue', 'childnode' => null, '#value' => 'Text')),
array("<node attribute='attributeValue'><childnode attribute='attributeValue'/>Text</node>", array('attribute' => 'attributeValue', 'childnode' => array('attribute' => 'attributeValue'), '#value' => 'Text')),
Expand Down

0 comments on commit 593f9ac

Please sign in to comment.