Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.21.0

Request #2019 defaultTagName and Arrays
Submitted: 2004-07-30 00:02 UTC
From: djimenez at conduit-it dot com Assigned: schst
Status: Closed Package: XML_Serializer
PHP Version: 5.0.0 OS: Windows and Linux
Roadmaps: (Not assigned)    
Subscription  


 [2004-07-30 00:02 UTC] djimenez at conduit-it dot com
Description: ------------ In your Serializer you use a defaultTagName for array elements that are auto indexed by a numerical key. This is fine for data primitives in the array, but when I construct an array of objects I would prefer that the class name be used for the tag instead of the defaultTagName option. I've made the simple change (two lines) in my copy of your package, but I thought to provide this feedback in case it might be a useful permanent change to your code. I put the code inside of the typeHints if block since I'll always be using typeHints with the serializer, but the key change might be more appropriate up further in the code Reproduce code: --------------- From the _serializeArray(..) function in Serializer.php: ... if ($this->options["typeHints"] === true) { $atts[$this->options["typeAttribute"]] = gettype($value); if ($key !== $origKey) { $atts[$this->options["keyAttribute"]] = (string)$origKey; } //ADDED CODE if(gettype($value) == 'object') { $key = get_class($value); } //END ADDED CODE } ...

Comments

 [2004-08-24 13:34 UTC] schst
Thank you for your bug report. This issue has been fixed in the latest released version of the package, which you can download at http://pear.php.net/get/XML_Serializer