* did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
*
* @author Stephane Huther <shuther1@free.fr>
+ * @author Michael Slusarz <slusarz@curecanti.org>
* @package Horde_Serialize
* @category Horde
*/
* requires.
*
* @return string The serialized data.
- * Returns PEAR_Error on error.
+ * @throws Horde_Serialize_Exception
*/
static public function serialize($data, $mode = array(self::BASIC),
$params = null)
foreach ($mode as $val) {
/* Check to make sure the mode is supported. */
if (!self::hasCapability($val)) {
- return PEAR::raiseError('Unsupported serialization type');
+ throw new Horde_Serialize_Exception('Unsupported serialization type');
}
$data = self::_serialize($data, $val, $params);
- if ($data instanceOf PEAR_Error) {
- break;
- }
}
return $data;
* method requires.
*
* @return string The unserialized data.
- * Returns PEAR_Error on error.
+ * @throws Horde_Serialize_Exception
*/
static public function unserialize($data, $mode = self::BASIC,
$params = null)
foreach ($mode as $val) {
/* Check to make sure the mode is supported. */
if (!self::hasCapability($val)) {
- return PEAR::raiseError('Unsupported unserialization type');
+ throw new Horde_Serialize_Exception('Unsupported unserialization type');
}
$data = self::_unserialize($data, $val, $params);
- if (is_a($data, 'PEAR_Error')) {
- break;
- }
}
return $data;
* @param mixed $params Any additional parameters the serialization method
* requires.
*
- * @return string A serialized string or PEAR_Error on error.
+ * @return string A serialized string.
+ * @throws Horde_Serialize_Exception
*/
static protected function _serialize($data, $mode, $params = null)
{
}
if ($data === false) {
- return PEAR::raiseError('Serialization failed.');
+ throw new Horde_Serialize_Exception('Serialization failed.');
}
return $data;
}
* @param mixed $params Any additional parameters the unserialization
* method requires.
*
- * @return mixed Unserialized data on success or PEAR_Error on error.
+ * @return mixed Unserialized data.
+ * @throws Horde_Serialize_Exception
*/
static protected function _unserialize(&$data, $mode, $params = null)
{
}
if ($data === false) {
- return PEAR::raiseError('Unserialization failed.');
+ throw new Horde_Serialize_Exception('Unserialization failed.');
}
+
return $data;
}
<api>beta</api>
</stability>
<license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
- <notes>* Add support for limited error handling for json encoding errors
+ <notes>* Throw exceptions rather than returning PEAR_Errors.
+ * Add support for limited error handling for json encoding errors
(requires PHP 5.3+).
* Initial Horde 4 package.</notes>
<contents>
<dir name="/">
<dir name="lib">
<dir name="Horde">
+ <dir name="Serialize">
+ <file name="Exception.php" role="php" />
+ </dir> <!-- /lib/Horde/Serialize -->
<file name="Serialize.php" role="php" />
</dir> <!-- /lib/Horde -->
</dir> <!-- /lib/ -->
<min>1.5.0</min>
</pearinstaller>
<package>
+ <name>Exception</name>
+ <channel>pear.horde.org</channel>
+ </package>
+ <package>
<name>Util</name>
<channel>pear.horde.org</channel>
</package>
</dependencies>
<phprelease>
<filelist>
+ <install name="lib/Horde/Serialize/Exception.php" as="Horde/Serialize/Exception.php" />
<install name="lib/Horde/Serialize.php" as="Horde/Serialize.php" />
</filelist>
</phprelease>