From 31a516cf967e7558f0e06c2390fa9521309ed8b4 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Tue, 28 May 2019 16:55:52 +0200 Subject: [PATCH] Remove set() object handler --- UPGRADING.INTERNALS | 5 +++++ Zend/zend_execute.h | 5 ----- Zend/zend_iterators.c | 1 - Zend/zend_object_handlers.c | 1 - Zend/zend_object_handlers.h | 5 ----- Zend/zend_operators.c | 26 ++------------------------ Zend/zend_operators.h | 14 +------------- ext/com_dotnet/com_handlers.c | 6 ------ ext/com_dotnet/com_saproxy.c | 5 ----- 9 files changed, 8 insertions(+), 60 deletions(-) diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index 5280128b82..6c17fdbb52 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -4,6 +4,7 @@ PHP 8.0 INTERNALS UPGRADE NOTES a. Object Handlers API b. ZEND_OVERLOADED_FUNCTION and corresponding call_method() object handler c. TSRM changes + d. set() object handler 2. Build system changes a. Abstract @@ -39,6 +40,10 @@ PHP 8.0 INTERNALS UPGRADE NOTES - tsrm_free_interpreter_context - support for GNUPTH, SGI ST, and BETHREADS + d. The set() object handler, which allowed overloading the assignment + operator, has been removed. There is no direct replacement for this + functionality, though some use-cases may be replaced by do_operation(). + ======================== 2. Build system changes diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h index 044b0c71f5..1bc984a90b 100644 --- a/Zend/zend_execute.h +++ b/Zend/zend_execute.h @@ -116,11 +116,6 @@ static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval break; } } - if (Z_TYPE_P(variable_ptr) == IS_OBJECT && - UNEXPECTED(Z_OBJ_HANDLER_P(variable_ptr, set) != NULL)) { - Z_OBJ_HANDLER_P(variable_ptr, set)(Z_OBJ_P(variable_ptr), value); - return variable_ptr; - } garbage = Z_COUNTED_P(variable_ptr); ZVAL_COPY_VALUE(variable_ptr, value); if (ZEND_CONST_COND(value_type == IS_CONST, 0)) { diff --git a/Zend/zend_iterators.c b/Zend/zend_iterators.c index 7e920c00d8..4691d8218e 100644 --- a/Zend/zend_iterators.c +++ b/Zend/zend_iterators.c @@ -37,7 +37,6 @@ static const zend_object_handlers iterator_object_handlers = { NULL, /* write dim */ NULL, NULL, /* get */ - NULL, /* set */ NULL, /* has prop */ NULL, /* unset prop */ NULL, /* has dim */ diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index a526c38044..4a4822687e 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -1838,7 +1838,6 @@ ZEND_API const zend_object_handlers std_object_handlers = { zend_std_write_dimension, /* write_dimension */ zend_std_get_property_ptr_ptr, /* get_property_ptr_ptr */ NULL, /* get */ - NULL, /* set */ zend_std_has_property, /* has_property */ zend_std_unset_property, /* unset_property */ zend_std_has_dimension, /* has_dimension */ diff --git a/Zend/zend_object_handlers.h b/Zend/zend_object_handlers.h index e59d7c8fcf..b6bdcae99c 100644 --- a/Zend/zend_object_handlers.h +++ b/Zend/zend_object_handlers.h @@ -63,10 +63,6 @@ typedef void (*zend_object_write_dimension_t)(zend_object *object, zval *offset, /* Used to create pointer to the property of the object, for future direct r/w access */ typedef zval *(*zend_object_get_property_ptr_ptr_t)(zend_object *object, zend_string *member, int type, void **cache_slot); -/* Used to set object value. Can be used to override assignments and scalar - write ops (like ++, +=) on the object */ -typedef void (*zend_object_set_t)(zend_object *object, zval *value); - /* Used to get object value. Can be used when converting object value to * one of the basic types and when using scalar ops (like ++, +=) on the object */ @@ -163,7 +159,6 @@ struct _zend_object_handlers { zend_object_write_dimension_t write_dimension; /* required */ zend_object_get_property_ptr_ptr_t get_property_ptr_ptr; /* required */ zend_object_get_t get; /* optional */ - zend_object_set_t set; /* optional */ zend_object_has_property_t has_property; /* required */ zend_object_unset_property_t unset_property; /* required */ zend_object_has_dimension_t has_dimension; /* required */ diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index fd784b7534..5b134e46b7 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -2456,18 +2456,7 @@ try_again: } break; case IS_OBJECT: - if (Z_OBJ_HANDLER_P(op1, get) - && Z_OBJ_HANDLER_P(op1, set)) { - /* proxy object */ - zval rv; - zval *val; - - val = Z_OBJ_HANDLER_P(op1, get)(Z_OBJ_P(op1), &rv); - Z_TRY_ADDREF_P(val); - increment_function(val); - Z_OBJ_HANDLER_P(op1, set)(Z_OBJ_P(op1), val); - zval_ptr_dtor(val); - } else if (Z_OBJ_HANDLER_P(op1, do_operation)) { + if (Z_OBJ_HANDLER_P(op1, do_operation)) { zval op2; int res; @@ -2523,18 +2512,7 @@ try_again: } break; case IS_OBJECT: - if (Z_OBJ_HANDLER_P(op1, get) - && Z_OBJ_HANDLER_P(op1, set)) { - /* proxy object */ - zval rv; - zval *val; - - val = Z_OBJ_HANDLER_P(op1, get)(Z_OBJ_P(op1), &rv); - Z_TRY_ADDREF_P(val); - decrement_function(val); - Z_OBJ_HANDLER_P(op1, set)(Z_OBJ_P(op1), val); - zval_ptr_dtor(val); - } else if (Z_OBJ_HANDLER_P(op1, do_operation)) { + if (Z_OBJ_HANDLER_P(op1, do_operation)) { zval op2; int res; diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index 829d5be9c8..c0caebfa69 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -865,19 +865,7 @@ static zend_always_inline zend_bool fast_is_not_identical_function(zval *op1, zv } #define ZEND_TRY_BINARY_OP1_OBJECT_OPERATION(opcode, binary_op) \ - if (UNEXPECTED(Z_TYPE_P(op1) == IS_OBJECT) \ - && op1 == result \ - && UNEXPECTED(Z_OBJ_HANDLER_P(op1, get)) \ - && EXPECTED(Z_OBJ_HANDLER_P(op1, set))) { \ - int ret; \ - zval rv; \ - zval *objval = Z_OBJ_HANDLER_P(op1, get)(Z_OBJ_P(op1), &rv); \ - Z_TRY_ADDREF_P(objval); \ - ret = binary_op(objval, objval, op2); \ - Z_OBJ_HANDLER_P(op1, set)(Z_OBJ_P(op1), objval); \ - zval_ptr_dtor(objval); \ - return ret; \ - } else if (UNEXPECTED(Z_TYPE_P(op1) == IS_OBJECT) \ + if (UNEXPECTED(Z_TYPE_P(op1) == IS_OBJECT) \ && UNEXPECTED(Z_OBJ_HANDLER_P(op1, do_operation))) { \ if (EXPECTED(SUCCESS == Z_OBJ_HANDLER_P(op1, do_operation)(opcode, result, op1, op2))) { \ return SUCCESS; \ diff --git a/ext/com_dotnet/com_handlers.c b/ext/com_dotnet/com_handlers.c index d00cb14f14..feda1a9643 100644 --- a/ext/com_dotnet/com_handlers.c +++ b/ext/com_dotnet/com_handlers.c @@ -175,11 +175,6 @@ static void com_write_dimension(zend_object *object, zval *offset, zval *value) } #if 0 -static void com_object_set(zval **property, zval *value) -{ - /* Not yet implemented in the engine */ -} - static zval *com_object_get(zval *property) { /* Not yet implemented in the engine */ @@ -546,7 +541,6 @@ zend_object_handlers php_com_object_handlers = { com_write_dimension, NULL, NULL, /* com_object_get, */ - NULL, /* com_object_set, */ com_property_exists, com_property_delete, com_dimension_exists, diff --git a/ext/com_dotnet/com_saproxy.c b/ext/com_dotnet/com_saproxy.c index a60d025a68..8d76af3830 100644 --- a/ext/com_dotnet/com_saproxy.c +++ b/ext/com_dotnet/com_saproxy.c @@ -275,10 +275,6 @@ static void saproxy_write_dimension(zend_object *object, zval *offset, zval *val } #if 0 -static void saproxy_object_set(zval **property, zval *value) -{ -} - static zval *saproxy_object_get(zval *property) { /* Not yet implemented in the engine */ @@ -402,7 +398,6 @@ zend_object_handlers php_com_saproxy_handlers = { saproxy_write_dimension, NULL, NULL, /* saproxy_object_get, */ - NULL, /* saproxy_object_set, */ saproxy_property_exists, saproxy_property_delete, saproxy_dimension_exists, -- 2.40.0