Fix a problem of tag values which is not taken into account

(when equal to zero) when passing an XML object to an array.
This commit is contained in:
Derbois Aymeric 2013-04-17 05:13:19 +02:00
parent d01d291d13
commit ca6612bc8b
2 changed files with 11 additions and 1 deletions

View file

@ -644,6 +644,16 @@ XML;
)
);
$this->assertEquals($expected, Xml::toArray($obj));
$xml = '<tag type="myType">0</tag>';
$obj = Xml::build($xml);
$expected = array(
'tag' => array(
'@type' => 'myType',
'@' => 0
)
);
$this->assertEquals($expected, Xml::toArray($obj));
}
/**

View file

@ -360,7 +360,7 @@ class Xml {
$asString = trim((string)$xml);
if (empty($data)) {
$data = $asString;
} elseif (!empty($asString)) {
} elseif (strlen($asString) > 0) {
$data['@'] = $asString;
}