/** * replacement for Util::raiseError * * Avoids the necessity to always require * PEAR.php * * @param string $msg error message * @param int $code error code * * @return PEAR_Error * @access public * @static * @todo PEAR CS - should this use include_once instead? */ function raiseError($msg, $code) { return PEAR::raiseError($msg, $code); }
/** * unserialize data * * @param mixed $data data to unserialize (string, filename or resource) * @param boolean $isFile data should be treated as a file * @param array $options options that will override * the global options for this call * * @return boolean $success * @access public */ function unserialize($data, $isFile = false, $options = null) { $this->_unserializedData = null; $this->_root = null; // if options have been specified, use them instead // of the previously defined ones if (is_array($options)) { $optionsBak = $this->options; if (isset($options[XML_UNSERIALIZER_OPTION_OVERRIDE_OPTIONS]) && $options[XML_UNSERIALIZER_OPTION_OVERRIDE_OPTIONS] == true) { $this->options = array_merge($this->_defaultOptions, $options); } else { $this->options = array_merge($this->options, $options); } } else { $optionsBak = null; } $this->_valStack = array(); $this->_dataStack = array(); $this->_depth = 0; $this->_createParser(); if (is_string($data)) { if ($isFile) { $result = $this->_parser->setInputFile($data); if (PEAR::isError($result)) { return $result; } $result = $this->_parser->parse(); } else { $result = $this->_parser->parseString($data, true); } } else { $this->_parser->setInput($data); $result = $this->_parser->parse(); } if ($this->options[XML_UNSERIALIZER_OPTION_RETURN_RESULT] === true) { $return = $this->_unserializedData; } else { $return = true; } if ($optionsBak !== null) { $this->options = $optionsBak; } if (PEAR::isError($result)) { return $result; } return $return; }