}
}
+class except implements Serializable {
+ function __construct (public $onserialize = false) {}
+ function serialize() : string {
+ if ($this->onserialize)
+ throw new Exception("except on serialize");
+ return "<<data>>";
+ }
+ function unserialize(string $data) : void {
+ throw new Exception("except on unserialize");
+ }
+}
+
echo "\n";
$t = new test;
$s = ion\serialize($tree);
echo $s,"\n";
debug_zval_dump(ion\unserialize($s));
+
+try {
+ ion\serialize(new except(true));
+} catch (Exception $e) {
+ printf("caught %s: %s\n", get_class($e), $e->getMessage());
+}
+try {
+ ion\unserialize(ion\serialize(new except()));
+} catch (Exception $e) {
+ printf("caught %s: %s\n", get_class($e), $e->getMessage());
+}
?>
DONE
--EXPECTF--
Deprecated: recursive implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %sserialize/serializable.php on line %d
+Deprecated: except implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %sserialize/serializable.php on line %d
+
[S::test::{{"foobar"}},r::1]
array(2) refcount(2){
[0]=>
NULL
}
}
+caught Exception: except on serialize
+caught Exception: except on unserialize
DONE