if (Z_TYPE_P(value) != IS_ARRAY && Z_TYPE_P(value) != IS_OBJECT) {
convert_to_array_ex(value);
- } else {
- headers = HASH_OF(value);
}
+ headers = HASH_OF(value);
zend_hash_clean(&obj->message->hdrs);
array_copy(headers, &obj->message->hdrs);
/* add ref, because we previously have not been a parent message */
Z_ADDREF_P(zmsg);
- RETVAL_OBJ(&objects[last]->zo);
+ RETVAL_OBJECT(&objects[last]->zo, 1);
efree(objects);
} else {
{
php_http_message_object_t *o;
- o = ecalloc(1, sizeof(php_http_message_object_t) + (ce->default_properties_count - 1) * sizeof(zval));
+ o = ecalloc(1, sizeof(*o) + zend_object_properties_size(ce));
zend_object_std_init(&o->zo, ce);
object_properties_init(&o->zo, ce);
zend_object_std_dtor(object);
}
-static zval *php_http_message_object_read_prop(zval *object, zval *member, int type, void **cache_slot, zval *return_value)
+static zval *php_http_message_object_read_prop(zval *object, zval *member, int type, void **cache_slot, zval *tmp)
{
- php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, object);
- php_http_message_object_prophandler_t *handler;
+ zval *return_value;
zend_string *member_name = zval_get_string(member);
+ php_http_message_object_prophandler_t *handler = php_http_message_object_get_prophandler(member_name);
- PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
+ if (!handler || type == BP_VAR_R || type == BP_VAR_IS) {
+ return_value = zend_get_std_object_handlers()->read_property(object, member, type, cache_slot, tmp);
- if ((handler = php_http_message_object_get_prophandler(member_name))) {
- if (type == BP_VAR_R) {
- handler->read(obj, return_value);
- } else {
- php_property_proxy_t *proxy = php_property_proxy_init(object, member_name);
- RETVAL_OBJ(&php_property_proxy_object_new_ex(php_property_proxy_get_class_entry(), proxy)->zo);
+ if (handler) {
+ php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, object);
+
+ PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
+ handler->read(obj, tmp);
+
+ zval_ptr_dtor(return_value);
+ ZVAL_COPY_VALUE(return_value, tmp);
}
} else {
- zend_get_std_object_handlers()->read_property(object, member, type, cache_slot, return_value);
+ return_value = php_property_proxy_zval(object, member_name);
}
zend_string_release(member_name);
if (!header_ce) {
RETURN_ZVAL(header, 1, 1);
} else if (instanceof_function(header_ce, php_http_header_class_entry)) {
+ php_http_object_method_t cb;
zval argv[2];
ZVAL_STRINGL(&argv[0], header_str, header_len);
ZVAL_COPY(&argv[1], header);
object_init_ex(return_value, header_ce);
- php_http_method_call(return_value, ZEND_STRL("__construct"), 2, argv, NULL);
+ php_http_object_method_init(&cb, return_value, ZEND_STRL("__construct"));
+ php_http_object_method_call(&cb, return_value, NULL, 2, argv);
+ php_http_object_method_dtor(&cb);
zval_ptr_dtor(&argv[0]);
zval_ptr_dtor(&argv[1]);