src/PEAR/PackageFile/Generator/v2.php
function serialize($data, $options = null)
    {
        // if options have been specified, use them instead
        // of the previously defined ones
        if (is_array($options)) {
            $optionsBak = $this->options;
            if (isset($options['overrideOptions']) && $options['overrideOptions'] == true) {
                $this->options = array_merge($this->_defaultOptions, $options);
            } else {
                $this->options = array_merge($this->options, $options);
            }
        } else {
            $optionsBak = null;
        }

        //  start depth is zero
        $this->_tagDepth = 0;
        $this->_serializedData = '';
        // serialize an array
        if (is_array($data)) {
            $tagName = isset($this->options['rootName']) ? $this->options['rootName'] : 'array';
            $this->_serializedData .= $this->_serializeArray($data, $tagName, $this->options['rootAttributes']);
        }

        // add doctype declaration
        if ($this->options['addDoctype'] === true) {
            $this->_serializedData = XML_Util::getDoctypeDeclaration($tagName, $this->options['doctype'])
                                   . $this->options['linebreak']
                                   . $this->_serializedData;
        }

        //  build xml declaration
        if ($this->options['addDecl']) {
            $atts = array();
            $encoding = isset($this->options['encoding']) ? $this->options['encoding'] : null;
            $this->_serializedData = XML_Util::getXMLDeclaration('1.0', $encoding)
                                   . $this->options['linebreak']
                                   . $this->_serializedData;
        }


        if ($optionsBak !== null) {
            $this->options = $optionsBak;
        }

        return  true;
    }
function serialize($data, $options = null)
    {
        // if options have been specified, use them instead
        // of the previously defined ones
        if (is_array($options)) {
            $optionsBak = $this->options;
            if (isset($options['overrideOptions']) && $options['overrideOptions'] == true) {
                $this->options = array_merge($this->_defaultOptions, $options);
            } else {
                $this->options = array_merge($this->options, $options);
            }
        } else {
            $optionsBak = null;
        }

        //  start depth is zero
        $this->_tagDepth = 0;
        $this->_serializedData = '';
        // serialize an array
        if (is_array($data)) {
            $tagName = isset($this->options['rootName']) ? $this->options['rootName'] : 'array';
            $this->_serializedData .= $this->_serializeArray($data, $tagName, $this->options['rootAttributes']);
        }

        // add doctype declaration
        if ($this->options['addDoctype'] === true) {
            $this->_serializedData = XML_Util::getDoctypeDeclaration($tagName, $this->options['doctype'])
                                   . $this->options['linebreak']
                                   . $this->_serializedData;
        }

        //  build xml declaration
        if ($this->options['addDecl']) {
            $atts = array();
            $encoding = isset($this->options['encoding']) ? $this->options['encoding'] : null;
            $this->_serializedData = XML_Util::getXMLDeclaration('1.0', $encoding)
                                   . $this->options['linebreak']
                                   . $this->_serializedData;
        }


        if ($optionsBak !== null) {
            $this->options = $optionsBak;
        }

        return  true;
    }
serialize data

@access   public
@param    mixed    $data data to serialize
@return   boolean  true on success, pear error on failure