+
+ // sanity checks
+ if (ser->annotations.object_type && ser->annotations.object_type != 'o' && !ser->annotations.object_class) {
+ zend_throw_exception_ex(spl_ce_RuntimeException, IERR_INVALID_SYNTAX,
+ "Invalid object annotation without class name: %c::", ser->annotations.object_type);
+ return;
+ }
+ if (ser->annotations.object_type == 'o' && ser->annotations.object_class) {
+ zend_throw_exception_ex(spl_ce_RuntimeException, IERR_INVALID_SYNTAX,
+ "Invalid object annotation with class name: o::%s", ser->annotations.object_class->val);
+ return;
+ }
+ }
+}
+
+static inline void php_ion_unserialize_zval(php_ion_unserializer *ser, zval *return_value, ION_TYPE *typ)
+{
+ if (typ) {
+ memcpy(&ser->type, typ, sizeof(ser->type));
+ } else {
+ typ = &ser->type;
+ ION_CHECK(ion_reader_next(ser->reader, typ));
+ }
+
+ php_ion_unserialize_annotations(ser);
+ ION_CATCH();
+
+ if (ser->annotations.makeref) {
+ ZVAL_MAKE_REF(return_value);
+ zend_hash_next_index_insert(ser->ids, return_value);
+ ZVAL_DEREF(return_value);