namespace ion;
function serialize(mixed $data, ?Serializer $serializer = null) : string {}
/** @param string|resource $data */
-function unserialize(mixed $data, ?Unserializer $unserializer = null) : mixed {}
+function unserialize($data, ?Unserializer $unserializer = null) : mixed {}
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: f2b34e7e90a3fcb65ad470c6acce7cc31b804716 */
+ * Stub hash: 5dc8abb809cd14ed4c542ca5114bd4ceda42d70b */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ion_serialize, 0, 1, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, data, IS_MIXED, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ion_unserialize, 0, 1, IS_MIXED, 0)
- ZEND_ARG_TYPE_INFO(0, data, IS_MIXED, 0)
+ ZEND_ARG_INFO(0, data)
ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, unserializer, ion\\Unserializer, 1, "null")
ZEND_END_ARG_INFO()
zend_object *zo_reader;
php_ion_reader *reader;
ZVAL_DEREF(zdata);
- switch (Z_TYPE_P(zdata)) {
- case IS_STRING:
- zo_reader = create_ion_Reader_Reader(ce_Reader_Buffer_Reader);
- reader = php_ion_obj(reader, zo_reader);
- reader->type = BUFFER_READER;
- reader->buffer = zend_string_copy(Z_STR_P(zdata));
- break;
- case IS_RESOURCE:
+ if (Z_TYPE_P(zdata) == IS_RESOURCE) {
zo_reader = create_ion_Reader_Reader(ce_Reader_Stream_Reader);
reader = php_ion_obj(reader, zo_reader);
reader->type = STREAM_READER;
php_stream_from_zval_no_verify(reader->stream.ptr, zdata);
- break;
-
- default:
- ZEND_ASSERT(!IS_STRING && !IS_RESOURCE);
+ } else if (Z_TYPE_P(zdata) <= IS_STRING) {
+ zo_reader = create_ion_Reader_Reader(ce_Reader_Buffer_Reader);
+ reader = php_ion_obj(reader, zo_reader);
+ reader->type = BUFFER_READER;
+ 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");
+ if (zo_ser) {
+ OBJ_RELEASE(zo_ser);
+ }
+ return;
}
if (ser->options) {