Skip to content

Commit 31a516c

Browse files
committed
Remove set() object handler
1 parent cf61034 commit 31a516c

9 files changed

+8
-60
lines changed

UPGRADING.INTERNALS

+5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ PHP 8.0 INTERNALS UPGRADE NOTES
44
a. Object Handlers API
55
b. ZEND_OVERLOADED_FUNCTION and corresponding call_method() object handler
66
c. TSRM changes
7+
d. set() object handler
78

89
2. Build system changes
910
a. Abstract
@@ -39,6 +40,10 @@ PHP 8.0 INTERNALS UPGRADE NOTES
3940
- tsrm_free_interpreter_context
4041
- support for GNUPTH, SGI ST, and BETHREADS
4142

43+
d. The set() object handler, which allowed overloading the assignment
44+
operator, has been removed. There is no direct replacement for this
45+
functionality, though some use-cases may be replaced by do_operation().
46+
4247

4348
========================
4449
2. Build system changes

Zend/zend_execute.h

-5
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,6 @@ static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval
116116
break;
117117
}
118118
}
119-
if (Z_TYPE_P(variable_ptr) == IS_OBJECT &&
120-
UNEXPECTED(Z_OBJ_HANDLER_P(variable_ptr, set) != NULL)) {
121-
Z_OBJ_HANDLER_P(variable_ptr, set)(Z_OBJ_P(variable_ptr), value);
122-
return variable_ptr;
123-
}
124119
garbage = Z_COUNTED_P(variable_ptr);
125120
ZVAL_COPY_VALUE(variable_ptr, value);
126121
if (ZEND_CONST_COND(value_type == IS_CONST, 0)) {

Zend/zend_iterators.c

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ static const zend_object_handlers iterator_object_handlers = {
3737
NULL, /* write dim */
3838
NULL,
3939
NULL, /* get */
40-
NULL, /* set */
4140
NULL, /* has prop */
4241
NULL, /* unset prop */
4342
NULL, /* has dim */

Zend/zend_object_handlers.c

-1
Original file line numberDiff line numberDiff line change
@@ -1838,7 +1838,6 @@ ZEND_API const zend_object_handlers std_object_handlers = {
18381838
zend_std_write_dimension, /* write_dimension */
18391839
zend_std_get_property_ptr_ptr, /* get_property_ptr_ptr */
18401840
NULL, /* get */
1841-
NULL, /* set */
18421841
zend_std_has_property, /* has_property */
18431842
zend_std_unset_property, /* unset_property */
18441843
zend_std_has_dimension, /* has_dimension */

Zend/zend_object_handlers.h

-5
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@ typedef void (*zend_object_write_dimension_t)(zend_object *object, zval *offset,
6363
/* Used to create pointer to the property of the object, for future direct r/w access */
6464
typedef zval *(*zend_object_get_property_ptr_ptr_t)(zend_object *object, zend_string *member, int type, void **cache_slot);
6565

66-
/* Used to set object value. Can be used to override assignments and scalar
67-
write ops (like ++, +=) on the object */
68-
typedef void (*zend_object_set_t)(zend_object *object, zval *value);
69-
7066
/* Used to get object value. Can be used when converting object value to
7167
* one of the basic types and when using scalar ops (like ++, +=) on the object
7268
*/
@@ -163,7 +159,6 @@ struct _zend_object_handlers {
163159
zend_object_write_dimension_t write_dimension; /* required */
164160
zend_object_get_property_ptr_ptr_t get_property_ptr_ptr; /* required */
165161
zend_object_get_t get; /* optional */
166-
zend_object_set_t set; /* optional */
167162
zend_object_has_property_t has_property; /* required */
168163
zend_object_unset_property_t unset_property; /* required */
169164
zend_object_has_dimension_t has_dimension; /* required */

Zend/zend_operators.c

+2-24
Original file line numberDiff line numberDiff line change
@@ -2456,18 +2456,7 @@ ZEND_API int ZEND_FASTCALL increment_function(zval *op1) /* {{{ */
24562456
}
24572457
break;
24582458
case IS_OBJECT:
2459-
if (Z_OBJ_HANDLER_P(op1, get)
2460-
&& Z_OBJ_HANDLER_P(op1, set)) {
2461-
/* proxy object */
2462-
zval rv;
2463-
zval *val;
2464-
2465-
val = Z_OBJ_HANDLER_P(op1, get)(Z_OBJ_P(op1), &rv);
2466-
Z_TRY_ADDREF_P(val);
2467-
increment_function(val);
2468-
Z_OBJ_HANDLER_P(op1, set)(Z_OBJ_P(op1), val);
2469-
zval_ptr_dtor(val);
2470-
} else if (Z_OBJ_HANDLER_P(op1, do_operation)) {
2459+
if (Z_OBJ_HANDLER_P(op1, do_operation)) {
24712460
zval op2;
24722461
int res;
24732462

@@ -2523,18 +2512,7 @@ ZEND_API int ZEND_FASTCALL decrement_function(zval *op1) /* {{{ */
25232512
}
25242513
break;
25252514
case IS_OBJECT:
2526-
if (Z_OBJ_HANDLER_P(op1, get)
2527-
&& Z_OBJ_HANDLER_P(op1, set)) {
2528-
/* proxy object */
2529-
zval rv;
2530-
zval *val;
2531-
2532-
val = Z_OBJ_HANDLER_P(op1, get)(Z_OBJ_P(op1), &rv);
2533-
Z_TRY_ADDREF_P(val);
2534-
decrement_function(val);
2535-
Z_OBJ_HANDLER_P(op1, set)(Z_OBJ_P(op1), val);
2536-
zval_ptr_dtor(val);
2537-
} else if (Z_OBJ_HANDLER_P(op1, do_operation)) {
2515+
if (Z_OBJ_HANDLER_P(op1, do_operation)) {
25382516
zval op2;
25392517
int res;
25402518

Zend/zend_operators.h

+1-13
Original file line numberDiff line numberDiff line change
@@ -865,19 +865,7 @@ static zend_always_inline zend_bool fast_is_not_identical_function(zval *op1, zv
865865
}
866866

867867
#define ZEND_TRY_BINARY_OP1_OBJECT_OPERATION(opcode, binary_op) \
868-
if (UNEXPECTED(Z_TYPE_P(op1) == IS_OBJECT) \
869-
&& op1 == result \
870-
&& UNEXPECTED(Z_OBJ_HANDLER_P(op1, get)) \
871-
&& EXPECTED(Z_OBJ_HANDLER_P(op1, set))) { \
872-
int ret; \
873-
zval rv; \
874-
zval *objval = Z_OBJ_HANDLER_P(op1, get)(Z_OBJ_P(op1), &rv); \
875-
Z_TRY_ADDREF_P(objval); \
876-
ret = binary_op(objval, objval, op2); \
877-
Z_OBJ_HANDLER_P(op1, set)(Z_OBJ_P(op1), objval); \
878-
zval_ptr_dtor(objval); \
879-
return ret; \
880-
} else if (UNEXPECTED(Z_TYPE_P(op1) == IS_OBJECT) \
868+
if (UNEXPECTED(Z_TYPE_P(op1) == IS_OBJECT) \
881869
&& UNEXPECTED(Z_OBJ_HANDLER_P(op1, do_operation))) { \
882870
if (EXPECTED(SUCCESS == Z_OBJ_HANDLER_P(op1, do_operation)(opcode, result, op1, op2))) { \
883871
return SUCCESS; \

ext/com_dotnet/com_handlers.c

-6
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,6 @@ static void com_write_dimension(zend_object *object, zval *offset, zval *value)
175175
}
176176

177177
#if 0
178-
static void com_object_set(zval **property, zval *value)
179-
{
180-
/* Not yet implemented in the engine */
181-
}
182-
183178
static zval *com_object_get(zval *property)
184179
{
185180
/* Not yet implemented in the engine */
@@ -546,7 +541,6 @@ zend_object_handlers php_com_object_handlers = {
546541
com_write_dimension,
547542
NULL,
548543
NULL, /* com_object_get, */
549-
NULL, /* com_object_set, */
550544
com_property_exists,
551545
com_property_delete,
552546
com_dimension_exists,

ext/com_dotnet/com_saproxy.c

-5
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,6 @@ static void saproxy_write_dimension(zend_object *object, zval *offset, zval *val
275275
}
276276

277277
#if 0
278-
static void saproxy_object_set(zval **property, zval *value)
279-
{
280-
}
281-
282278
static zval *saproxy_object_get(zval *property)
283279
{
284280
/* Not yet implemented in the engine */
@@ -402,7 +398,6 @@ zend_object_handlers php_com_saproxy_handlers = {
402398
saproxy_write_dimension,
403399
NULL,
404400
NULL, /* saproxy_object_get, */
405-
NULL, /* saproxy_object_set, */
406401
saproxy_property_exists,
407402
saproxy_property_delete,
408403
saproxy_dimension_exists,

0 commit comments

Comments
 (0)