]> granicus.if.org Git - php/commitdiff
Remove set() object handler
authorNikita Popov <nikita.ppv@gmail.com>
Tue, 28 May 2019 14:55:52 +0000 (16:55 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Wed, 29 May 2019 08:00:06 +0000 (10:00 +0200)
UPGRADING.INTERNALS
Zend/zend_execute.h
Zend/zend_iterators.c
Zend/zend_object_handlers.c
Zend/zend_object_handlers.h
Zend/zend_operators.c
Zend/zend_operators.h
ext/com_dotnet/com_handlers.c
ext/com_dotnet/com_saproxy.c

index 5280128b82f9613d575481a6ef216319c9aa7117..6c17fdbb5256bd928cf056c26f6db3c11facb5ba 100644 (file)
@@ -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
index 044b0c71f5f7259b15264ba14d98d7ca7d8a065f..1bc984a90b3297cd095f987df9e0456a2499faa5 100644 (file)
@@ -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)) {
index 7e920c00d83ba26bca1d861ae863b30c8492bd11..4691d8218e2c7ae2d2f86df1dc4d34f5f50bbf4b 100644 (file)
@@ -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 */
index a526c3804448387deeadd4e73d7e74e1a85b5947..4a4822687e2ce30f3605fd9edc1aede6237657cc 100644 (file)
@@ -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 */
index e59d7c8fcff405813bb072418ec47da9d4b510e5..b6bdcae99c593002e01f21651e0ecbf3097ea262 100644 (file)
@@ -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 */
index fd784b753455c008fb711356f4714c9982342a97..5b134e46b7fa6d0190dc29279e18bdc2e3d62f8c 100644 (file)
@@ -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;
 
index 829d5be9c873c4c91c63fe5063d2ee11579fc0b7..c0caebfa6983c12edc2ca55928328187178325be 100644 (file)
@@ -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;                                                                                \
index d00cb14f14bfa914031171c3de8ff45edba98b63..feda1a96436a443b9981ff8b886a6b886668ad25 100644 (file)
@@ -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,
index a60d025a681b28ea6b730937aa059f2cd83fecb8..8d76af3830ffda884edc696db44872325ff7dc14 100644 (file)
@@ -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,