Fix a bug in Xml::fromArray()

When creating from an array with elements like this: `[ "a" => [ 0 ] ]` or `[ "a" => [ '0' ] ]` it fails and produces XML like this `<a/>` instant of `<a>0</a>`.

The problem is that in PHP `empty('0')` is true, so an exception to this case is needed.
This commit is contained in:
domingues 2016-12-13 16:16:12 +00:00 committed by GitHub
parent cdef76eeda
commit 4d77cb059d

View file

@ -312,7 +312,7 @@ class Xml {
$childNS = $value['xmlns:']; $childNS = $value['xmlns:'];
unset($value['xmlns:']); unset($value['xmlns:']);
} }
} elseif (!empty($value) || $value === 0) { } elseif (!empty($value) || $value === 0 || $value === '0') {
$childValue = (string)$value; $childValue = (string)$value;
} }