Skip to content

Instantly share code, notes, and snippets.

@Sean-Der
Created June 1, 2015 04:13
Show Gist options
  • Save Sean-Der/4a07a044dab4dd23e46b to your computer and use it in GitHub Desktop.
Save Sean-Der/4a07a044dab4dd23e46b to your computer and use it in GitHub Desktop.
static ZEND_FUNCTION(msgpack_unserialize)
{
zval *object, ref_val;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &object) == FAILURE) {
return;
}
array_init(&ref_val);
ZVAL_MAKE_REF(&ref_val);
Z_TRY_ADDREF_P(&ref_val);
zend_update_property(Z_OBJCE_P(object), object, "ref_val", sizeof("ref_val"), &ref_val);
}
<?php
error_reporting(0);
class Obj {
}
$obj = new Obj();
msgpack_unserialize($obj);
var_dump($obj);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment