PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » XML » XML_Serializer » Bug #785

Some data types being evaluated incorrectly

Details

Submitted2004-02-18 11:37 UTC
Fromchris at accurate dot com
StatusBogus
PackageXML_Serializer
PHP Version4.3.4
OSWIN32 XP
Roadmaps(Not assigned)

Comments

[2004-02-18 11:37 UTC] chris at accurate dot com

Description:
------------
If a node value of zero(0) is passed to createTagFromArray it is evaluated as an empty string and an empty node is returned rather than a node containing the value zero (0).

This can be fixed by moving/correcting the check to see if the value is an empty string:-

if (is_scalar($tag["content"])) {
if ((string)$tag["content"] === '') {
$tag["content"] = '';
}
// blah...
}

(Not sure of the line number, sorry, I've edited the page!)

Reproduce code:
---------------
$tag = array('qname' => 'foo', 'content' => 0);
$serializer = new XML_Serializer();
$bar = $serializer->_createXMLTag($tag);

Expected result:
----------------
$bar = '<foo>0</foo>';

Actual result:
--------------
$bar = '<foo />';