return php_http_message_class_entry;
}
-static zval *php_http_message_object_read_prop(zend_object *object, zend_string *member, int type, void **cache_slot, zval *rv);
-static zval *php_http_message_object_write_prop(zend_object *object, zend_string *member, zval *value, void **cache_slot);
+static zval *php_http_message_object_read_prop(zval *object, zval *member, int type, void **cache_slot, zval *rv);
+
+static PHP_WRITE_PROP_HANDLER_TYPE php_http_message_object_write_prop(zval *object, zval *member, zval *value, void **cache_slot);
static zend_object_handlers php_http_message_object_handlers;
static HashTable php_http_message_object_prophandlers;
}
}
static void php_http_message_object_prophandler_get_body(php_http_message_object_t *obj, zval *return_value) {
- if (obj->body) {
- zval tmp;
+ zval tmp;
- ZVAL_COPY_VALUE(&tmp, return_value);
- RETVAL_OBJECT(&obj->body->zo, 1);
- zval_ptr_dtor(&tmp);
- } else {
- RETVAL_NULL();
+ if (!obj->body) {
+ RETURN_NULL();
}
+
+ ZVAL_COPY_VALUE(&tmp, return_value);
+ RETVAL_OBJECT(&obj->body->zo, 1);
+ zval_ptr_dtor(&tmp);
}
static void php_http_message_object_prophandler_set_body(php_http_message_object_t *obj, zval *value) {
php_http_message_object_set_body(obj, value);
do { \
if (!obj->message) { \
obj->message = php_http_message_init(NULL, 0, NULL); \
+ } else if (!obj->body && php_http_message_body_size(obj->message->body)) { \
+ php_http_message_object_init_body_object(obj); \
} \
} while(0)
return o;
}
-zend_object *php_http_message_object_clone(zend_object *this_ptr)
+zend_object *php_http_message_object_clone(zval *this_ptr)
{
php_http_message_object_t *new_obj;
- php_http_message_object_t *old_obj = PHP_HTTP_OBJ(this_ptr, NULL);
+ php_http_message_object_t *old_obj = PHP_HTTP_OBJ(NULL, this_ptr);
new_obj = php_http_message_object_new_ex(old_obj->zo.ce, php_http_message_copy(old_obj->message, NULL));
zend_objects_clone_members(&new_obj->zo, &old_obj->zo);
zend_object_std_dtor(object);
}
-static zval *php_http_message_object_get_prop_ptr(zend_object *object, zend_string *member, int type, void **cache_slot)
+#if PHP_VERSION_ID >= 70400
+static zval *php_http_message_object_get_prop_ptr(zval *object, zval *member, int type, void **cache_slot)
{
return NULL;
}
+#endif
-static zval *php_http_message_object_read_prop(zend_object *object, zend_string *member, int type, void **cache_slot, zval *tmp)
+static zval *php_http_message_object_read_prop(zval *object, zval *member, int type, void **cache_slot, zval *tmp)
{
zval *return_value;
- php_http_message_object_prophandler_t *handler = php_http_message_object_get_prophandler(member);
+ zend_string *member_name = zval_get_string(member);
+ php_http_message_object_prophandler_t *handler = php_http_message_object_get_prophandler(member_name);
return_value = zend_get_std_object_handlers()->read_property(object, member, type, cache_slot, tmp);
if (handler && handler->read) {
- php_http_message_object_t *obj = PHP_HTTP_OBJ(object, NULL);
+ if (type == BP_VAR_R || type == BP_VAR_IS) {
+ php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, object);
+
+ handler->read(obj, return_value);
+ } else {
+ php_property_proxy_t *proxy;
+ php_property_proxy_object_t *proxy_obj;
- handler->read(obj, return_value);
+ proxy = php_property_proxy_init(object, member_name);
+ proxy_obj = php_property_proxy_object_new_ex(NULL, proxy);
+
+ ZVAL_OBJ(tmp, &proxy_obj->zo);
+ return_value = tmp;
+ }
}
+
+ zend_string_release(member_name);
return return_value;
}
-static zval *php_http_message_object_write_prop(zend_object *object, zend_string *member, zval *value, void **cache_slot)
+static PHP_WRITE_PROP_HANDLER_TYPE php_http_message_object_write_prop(zval *object, zval *member, zval *value, void **cache_slot)
{
- php_http_message_object_t *obj = PHP_HTTP_OBJ(object, NULL);
+ php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, object);
php_http_message_object_prophandler_t *handler;
+ zend_string *member_name = zval_get_string(member);
PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
- if ((handler = php_http_message_object_get_prophandler(member))) {
+ if ((handler = php_http_message_object_get_prophandler(member_name))) {
handler->write(obj, value);
} else {
zend_get_std_object_handlers()->write_property(object, member, value, cache_slot);
}
- return value;
+
+ zend_string_release(member_name);
+ PHP_WRITE_PROP_HANDLER_RETURN(value);
}
-static HashTable *php_http_message_object_get_debug_info(zend_object *object, int *is_temp)
+static HashTable *php_http_message_object_get_debug_info(zval *object, int *is_temp)
{
zval tmp;
- php_http_message_object_t *obj = PHP_HTTP_OBJ(object, NULL);
+ php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, object);
HashTable *props = zend_get_std_object_handlers()->get_properties(object);
char *ver_str, *url_str = NULL;
size_t ver_len, url_len = 0;
PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
- *is_temp = 0;
+ if (is_temp) {
+ *is_temp = 0;
+ }
#define UPDATE_PROP(name_str, action_with_tmp) \
do { \
return props;
}
-static HashTable *php_http_message_object_get_gc(zend_object *object, zval **table, int *n)
+static HashTable *php_http_message_object_get_gc(zval *object, zval **table, int *n)
{
- php_http_message_object_t *obj = PHP_HTTP_OBJ(object, NULL);
- HashTable *props = object->handlers->get_properties(object);
+ php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, object);
+ HashTable *props = Z_OBJPROP_P(object);
uint32_t count = 2 + zend_hash_num_elements(props);
zval *val;
return NULL;
}
-static int php_http_message_object_cast(zend_object *object, zval *return_value, int type)
-{
- php_http_message_object_t *obj = PHP_HTTP_OBJ(object, NULL);
- char *string;
- size_t length;
-
- switch (type) {
- case IS_STRING:
- PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
- php_http_message_to_string(obj->message, &string, &length);
- if (string) {
- RETVAL_STR(php_http_cs2zs(string, length));
- } else {
- RETVAL_EMPTY_STRING();
- }
- return SUCCESS;
- case _IS_BOOL:
- RETVAL_TRUE;
- return SUCCESS;
- default:
- return FAILURE;
- }
-}
-
ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage___construct, 0, 0, 0)
ZEND_ARG_INFO(0, message)
ZEND_ARG_INFO(0, greedy)
php_http_message_object_handlers.get_property_ptr_ptr = NULL;
#endif
php_http_message_object_handlers.get_gc = php_http_message_object_get_gc;
- php_http_message_object_handlers.cast_object = php_http_message_object_cast;
zend_class_implements(php_http_message_class_entry, 3, spl_ce_Countable, zend_ce_serializable, zend_ce_iterator);