LOCAL void php_ion_unserialize_object_enum(php_ion_unserializer *ser, zval *return_value)
{
zend_string *zs_case = zval_get_string(return_value);
+ zend_hash_next_index_insert(ser->tmp, return_value);
+ ZVAL_NULL(return_value);
ION_CATCH();
zend_class_entry *ce = zend_lookup_class(ser->annotations.object_class);
zend_class_entry *ce = zend_lookup_class(ser->annotations.object_class);
if (can_call_iface_unserialize(ser, ce)) {
zend_string *s = zval_get_string(return_value);
+ zend_hash_next_index_insert(ser->tmp, return_value);
ZVAL_NULL(return_value);
zval *backref = zend_hash_next_index_insert(ser->ids, return_value);
if (SUCCESS == ce->unserialize(backref, ce, (BYTE *) s->val, s->len, NULL)) {
{
// backup possible backref to array returned by magic/custom __serialize()
zval *input = zend_hash_next_index_insert(ser->tmp, return_value);
-
+ ZVAL_NULL(return_value);
php_ion_unserialize_class(ser, return_value);
ION_CATCH();
ION_CHECK(ion_reader_read_ion_symbol(ser->reader, &sym));
php_ion_symbol_zval(&sym, return_value);
if (ser->annotations.object_type) {
- zend_hash_next_index_insert(ser->tmp, return_value);
goto unserialize_struct;
}
zend_hash_next_index_insert(ser->ids, return_value);
ION_CHECK(ion_reader_read_string(ser->reader, &str));
RETVAL_STRINGL((char *) str.value, str.length);
if (ser->annotations.object_type) {
- zend_hash_next_index_insert(ser->tmp, return_value);
goto unserialize_struct;
}
zend_hash_next_index_insert(ser->ids, return_value);
case tid_BLOB_INT:
php_ion_reader_read_lob(ser->reader, return_value);
if (ser->annotations.object_type) {
- zend_hash_next_index_insert(ser->tmp, return_value);
goto unserialize_struct;
}
zend_hash_next_index_insert(ser->ids, return_value);
reader->buffer = zval_get_string(zdata);
} else {
zend_throw_exception_ex(spl_ce_InvalidArgumentException, IERR_INVALID_ARG,
- "Invalid source to unserialize; expected string or resource");
+ "Invalid source to unserialize: expected string or resource, got %s",
+ zend_zval_type_name(zdata));
if (zo_ser) {
OBJ_RELEASE(zo_ser);
}
--- /dev/null
+--TEST--
+ion\Symbol\Enum
+--EXTENSIONS--
+ion
+--FILE--
+TEST
+<?php
+$t = ion\Symbol\Table\PHP::PHP;
+var_dump($t instanceof ion\Symbol\Enum);
+var_dump($t->toSymbol(), $t->toSID(), $t->toString());
+?>
+DONE
+--EXPECTF--
+TEST
+bool(true)
+object(ion\Symbol)#2 (3) {
+ ["value"]=>
+ string(3) "PHP"
+ ["sid"]=>
+ int(10)
+ ["importLocation"]=>
+ NULL
+}
+int(10)
+string(3) "PHP"
+DONE
--- /dev/null
+--TEST--
+ion\Symbol\ImportLocation
+--EXTENSIONS--
+ion
+--FILE--
+TEST
+<?php
+var_dump($iloc = new ion\Symbol\ImportLocation("table", 123));
+var_dump(clone $iloc);
+unset($iloc);
+var_dump(clone new ion\Symbol\ImportLocation("table", 123));
+?>
+DONE
+--EXPECTF--
+TEST
+object(ion\Symbol\ImportLocation)#%d (2) {
+ ["name"]=>
+ string(5) "table"
+ ["location"]=>
+ int(123)
+}
+object(ion\Symbol\ImportLocation)#%d (2) {
+ ["name"]=>
+ string(5) "table"
+ ["location"]=>
+ int(123)
+}
+object(ion\Symbol\ImportLocation)#%d (2) {
+ ["name"]=>
+ string(5) "table"
+ ["location"]=>
+ int(123)
+}
+DONE
var_dump($local->add("sym4"));
var_dump($local->find("sym4"));
var_dump($local->findLocal("sym4"));
+var_dump($local->getMaxId());
?>
DONE
--EXPECTF--
["importLocation"]=>
NULL
}
+int(23)
DONE
--TEST--
-Symbol\Table\Shared/roundtrip
+ion\Symbol\Table\Shared/roundtrip
--EXTENSIONS--
ion
--FILE--
--- /dev/null
+--TEST--
+ion\unserialize/argtype
+--EXTENSIONS--
+ion
+--FILE--
+TEST
+<?php
+$a=[];
+foreach ([&$a, $a, (object) $a] as $s) {
+ try { var_dump(ion\unserialize($s)); }
+ catch (Throwable $e) { printf("caught %s: %s\n", get_class($e), $e->getMessage()); }
+}
+?>
+DONE
+--EXPECT--
+TEST
+caught InvalidArgumentException: Invalid source to unserialize: expected string or resource, got array
+caught InvalidArgumentException: Invalid source to unserialize: expected string or resource, got array
+caught InvalidArgumentException: Invalid source to unserialize: expected string or resource, got stdClass
+DONE
--- /dev/null
+--TEST--
+ion\unserialize/invalid annotation
+--EXTENSIONS--
+ion
+--FILE--
+TEST
+<?php
+foreach (["r::r::1", "R::R::1", "p::p::1", "p::foo::p::1", "c::c::1", "c::1", "E::foo::E::1",
+ "E::1", "S::1", "S::S::foo123", "O::O::O::1", "O::1", "C::C::C::1", "C::1"] as $s) {
+ try { var_dump(ion\unserialize($s)); }
+ catch (Throwable $e) { printf("caught %s: %s\n", get_class($e), $e->getMessage()); }
+}
+?>
+DONE
+--EXPECT--
+TEST
+caught RuntimeException: Invalid multiple back reference annotations
+caught RuntimeException: Invalid multiple reference annotations
+int(1)
+caught RuntimeException: Invalid multiple object property annotations
+caught RuntimeException: Invalid object type annotation: c::1
+caught RuntimeException: IERR_INVALID_ARG: ion_reader_get_an_annotation(ser->reader, ++i, &class_name)
+caught RuntimeException: Invalid multiple object type annotations: E::E
+caught RuntimeException: IERR_INVALID_ARG: ion_reader_get_an_annotation(ser->reader, ++i, &class_name)
+caught RuntimeException: IERR_INVALID_ARG: ion_reader_get_an_annotation(ser->reader, ++i, &class_name)
+caught RuntimeException: Class S does not implement Serializable
+caught RuntimeException: Invalid multiple object type annotations: O::O
+caught RuntimeException: IERR_INVALID_ARG: ion_reader_get_an_annotation(ser->reader, ++i, &class_name)
+caught RuntimeException: Invalid multiple object type annotations: C::C
+caught RuntimeException: IERR_INVALID_ARG: ion_reader_get_an_annotation(ser->reader, ++i, &class_name)
+DONE