Skip to content

Commit c208f1a

Browse files
committed
Redirect add_property_TYPE() calls to zend_update_property_TYPE()
As those functions effectively did the same thing just with a slightly different signature
1 parent 6b8e195 commit c208f1a

File tree

3 files changed

+77
-126
lines changed

3 files changed

+77
-126
lines changed

UPGRADING.INTERNALS

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,16 @@ PHP 8.3 INTERNALS UPGRADE NOTES
6969
* Removed unused macros PHP_FNV1_32A_INIT and PHP_FNV1A_64_INIT. See GH-11114.
7070
* New zend_update_property_TYPE_ex() and zend_update_static_property_TYPE_ex()
7171
functions have been added that take the property name as a zend_string*.
72+
* The add_property_TYPE() and add_property_TYPE_ex() functions now redirect to
73+
the zend_update_property_TYPE() functions.
74+
Except the following functions:
75+
- add_property_resource_ex()
76+
- add_property_array_ex()
77+
- add_property_object_ex()
78+
- add_property_reference_ex()
79+
As there exists no equivalent.
80+
It is recommended to convert these usages to the zend_update_property_TYPE()
81+
functions.
7282

7383
========================
7484
2. Build system changes

Zend/zend_API.c

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -2115,33 +2115,6 @@ ZEND_API zend_result array_set_zval_key(HashTable *ht, zval *key, zval *value) /
21152115
}
21162116
/* }}} */
21172117

2118-
ZEND_API void add_property_long_ex(zval *arg, const char *key, size_t key_len, zend_long n) /* {{{ */
2119-
{
2120-
zval tmp;
2121-
2122-
ZVAL_LONG(&tmp, n);
2123-
add_property_zval_ex(arg, key, key_len, &tmp);
2124-
}
2125-
/* }}} */
2126-
2127-
ZEND_API void add_property_bool_ex(zval *arg, const char *key, size_t key_len, zend_long b) /* {{{ */
2128-
{
2129-
zval tmp;
2130-
2131-
ZVAL_BOOL(&tmp, b);
2132-
add_property_zval_ex(arg, key, key_len, &tmp);
2133-
}
2134-
/* }}} */
2135-
2136-
ZEND_API void add_property_null_ex(zval *arg, const char *key, size_t key_len) /* {{{ */
2137-
{
2138-
zval tmp;
2139-
2140-
ZVAL_NULL(&tmp);
2141-
add_property_zval_ex(arg, key, key_len, &tmp);
2142-
}
2143-
/* }}} */
2144-
21452118
ZEND_API void add_property_resource_ex(zval *arg, const char *key, size_t key_len, zend_resource *r) /* {{{ */
21462119
{
21472120
zval tmp;
@@ -2152,45 +2125,6 @@ ZEND_API void add_property_resource_ex(zval *arg, const char *key, size_t key_le
21522125
}
21532126
/* }}} */
21542127

2155-
ZEND_API void add_property_double_ex(zval *arg, const char *key, size_t key_len, double d) /* {{{ */
2156-
{
2157-
zval tmp;
2158-
2159-
ZVAL_DOUBLE(&tmp, d);
2160-
add_property_zval_ex(arg, key, key_len, &tmp);
2161-
}
2162-
/* }}} */
2163-
2164-
ZEND_API void add_property_str_ex(zval *arg, const char *key, size_t key_len, zend_string *str) /* {{{ */
2165-
{
2166-
zval tmp;
2167-
2168-
ZVAL_STR(&tmp, str);
2169-
add_property_zval_ex(arg, key, key_len, &tmp);
2170-
zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */
2171-
}
2172-
/* }}} */
2173-
2174-
ZEND_API void add_property_string_ex(zval *arg, const char *key, size_t key_len, const char *str) /* {{{ */
2175-
{
2176-
zval tmp;
2177-
2178-
ZVAL_STRING(&tmp, str);
2179-
add_property_zval_ex(arg, key, key_len, &tmp);
2180-
zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */
2181-
}
2182-
/* }}} */
2183-
2184-
ZEND_API void add_property_stringl_ex(zval *arg, const char *key, size_t key_len, const char *str, size_t length) /* {{{ */
2185-
{
2186-
zval tmp;
2187-
2188-
ZVAL_STRINGL(&tmp, str, length);
2189-
add_property_zval_ex(arg, key, key_len, &tmp);
2190-
zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */
2191-
}
2192-
/* }}} */
2193-
21942128
ZEND_API void add_property_array_ex(zval *arg, const char *key, size_t key_len, zend_array *arr) /* {{{ */
21952129
{
21962130
zval tmp;
@@ -2221,16 +2155,6 @@ ZEND_API void add_property_reference_ex(zval *arg, const char *key, size_t key_l
22212155
}
22222156
/* }}} */
22232157

2224-
ZEND_API void add_property_zval_ex(zval *arg, const char *key, size_t key_len, zval *value) /* {{{ */
2225-
{
2226-
zend_string *str;
2227-
2228-
str = zend_string_init(key, key_len, 0);
2229-
Z_OBJ_HANDLER_P(arg, write_property)(Z_OBJ_P(arg), str, value, NULL);
2230-
zend_string_release_ex(str, 0);
2231-
}
2232-
/* }}} */
2233-
22342158
ZEND_API zend_result zend_startup_module_ex(zend_module_entry *module) /* {{{ */
22352159
{
22362160
size_t name_len;

Zend/zend_API.h

Lines changed: 67 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,73 @@ ZEND_API void zend_update_property_stringl_ex(zend_class_entry *scope, zend_obje
506506
ZEND_API void zend_unset_property(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length);
507507
ZEND_API void zend_unset_property_ex(zend_class_entry *scope, zend_object *object, zend_string *name);
508508

509+
/* Legacy API */
510+
static zend_always_inline void add_property_zval(zval *z_object, const char *name, zval *value) {
511+
zend_update_property(Z_OBJCE_P(z_object), Z_OBJ_P(z_object), name, strlen(name), value);
512+
}
513+
static zend_always_inline void add_property_zval_ex(zval *z_object, const char *name, size_t name_length, zval *value) {
514+
zend_update_property(Z_OBJCE_P(z_object), Z_OBJ_P(z_object), name, name_length, value);
515+
}
516+
static zend_always_inline void add_property_null(zval *z_object, const char *name) {
517+
zend_update_property_null(Z_OBJCE_P(z_object), Z_OBJ_P(z_object), name, strlen(name));
518+
}
519+
static zend_always_inline void add_property_null_ex(zval *z_object, const char *name, size_t name_length) {
520+
zend_update_property_null(Z_OBJCE_P(z_object), Z_OBJ_P(z_object), name, name_length);
521+
}
522+
static zend_always_inline void add_property_bool(zval *z_object, const char *name, bool value) {
523+
zend_update_property_bool(Z_OBJCE_P(z_object), Z_OBJ_P(z_object), name, strlen(name), value);
524+
}
525+
static zend_always_inline void add_property_bool_ex(zval *z_object, const char *name, size_t name_length, bool value) {
526+
zend_update_property_bool(Z_OBJCE_P(z_object), Z_OBJ_P(z_object), name, name_length, value);
527+
}
528+
static zend_always_inline void add_property_long(zval *z_object, const char *name, zend_long value) {
529+
zend_update_property_long(Z_OBJCE_P(z_object), Z_OBJ_P(z_object), name, strlen(name), value);
530+
}
531+
static zend_always_inline void add_property_long_ex(zval *z_object, const char *name, size_t name_length, zend_long value) {
532+
zend_update_property_long(Z_OBJCE_P(z_object), Z_OBJ_P(z_object), name, name_length, value);
533+
}
534+
static zend_always_inline void add_property_double(zval *z_object, const char *name, double value) {
535+
zend_update_property_double(Z_OBJCE_P(z_object), Z_OBJ_P(z_object), name, strlen(name), value);
536+
}
537+
static zend_always_inline void add_property_double_ex(zval *z_object, const char *name, size_t name_length, double value) {
538+
zend_update_property_double(Z_OBJCE_P(z_object), Z_OBJ_P(z_object), name, name_length, value);
539+
}
540+
static zend_always_inline void add_property_str(zval *z_object, const char *name, zend_string *value) {
541+
zend_update_property_str(Z_OBJCE_P(z_object), Z_OBJ_P(z_object), name, strlen(name), value);
542+
}
543+
static zend_always_inline void add_property_str_ex(zval *z_object, const char *name, size_t name_length, zend_string *value) {
544+
zend_update_property_str(Z_OBJCE_P(z_object), Z_OBJ_P(z_object), name, name_length, value);
545+
}
546+
static zend_always_inline void add_property_string(zval *z_object, const char *name, const char *value) {
547+
zend_update_property_string(Z_OBJCE_P(z_object), Z_OBJ_P(z_object), name, strlen(name), value);
548+
}
549+
static zend_always_inline void add_property_string_ex(zval *z_object, const char *name, size_t name_length, const char *value) {
550+
zend_update_property_string(Z_OBJCE_P(z_object), Z_OBJ_P(z_object), name, name_length, value);
551+
}
552+
static zend_always_inline void add_property_stringl(zval *z_object, const char *name, const char *value, size_t value_len) {
553+
zend_update_property_stringl(Z_OBJCE_P(z_object), Z_OBJ_P(z_object), name, strlen(name), value, value_len);
554+
}
555+
static zend_always_inline void add_property_stringl_ex(zval *z_object, const char *name, size_t name_length, const char *value, size_t value_len) {
556+
zend_update_property_stringl(Z_OBJCE_P(z_object), Z_OBJ_P(z_object), name, name_length, value, value_len);
557+
}
558+
559+
ZEND_API void add_property_resource_ex(zval *arg, const char *key, size_t key_len, zend_resource *r);
560+
ZEND_API void add_property_array_ex(zval *arg, const char *key, size_t key_len, zend_array *arr);
561+
ZEND_API void add_property_object_ex(zval *arg, const char *key, size_t key_len, zend_object *obj);
562+
ZEND_API void add_property_reference_ex(zval *arg, const char *key, size_t key_len, zend_reference *ref);
563+
static zend_always_inline void add_property_resource(zval *arg, const char *key, zend_resource *r) {
564+
add_property_resource_ex(arg, key, strlen(key), r);
565+
}
566+
static zend_always_inline void add_property_array(zval *arg, const char *key, zend_array *arr) {
567+
add_property_array_ex(arg, key, strlen(key), arr);
568+
}
569+
static zend_always_inline void add_property_object(zval *arg, const char *key, zend_object *obj) {
570+
add_property_object_ex(arg, key, strlen(key), obj);
571+
}
572+
static zend_always_inline void add_property_reference(zval *arg, const char *key, zend_reference *ref) {
573+
add_property_reference_ex(arg, key, strlen(key), ref);
574+
}
575+
509576
ZEND_API zend_result zend_update_static_property_ex(zend_class_entry *scope, zend_string *name, zval *value);
510577
ZEND_API zend_result zend_update_static_property(zend_class_entry *scope, const char *name, size_t name_length, zval *value);
511578
ZEND_API zend_result zend_update_static_property_null(zend_class_entry *scope, const char *name, size_t name_length);
@@ -641,56 +708,6 @@ static zend_always_inline zend_result add_next_index_zval(zval *arg, zval *value
641708

642709
ZEND_API zend_result array_set_zval_key(HashTable *ht, zval *key, zval *value);
643710

644-
ZEND_API void add_property_long_ex(zval *arg, const char *key, size_t key_len, zend_long l);
645-
ZEND_API void add_property_null_ex(zval *arg, const char *key, size_t key_len);
646-
ZEND_API void add_property_bool_ex(zval *arg, const char *key, size_t key_len, zend_long b);
647-
ZEND_API void add_property_resource_ex(zval *arg, const char *key, size_t key_len, zend_resource *r);
648-
ZEND_API void add_property_double_ex(zval *arg, const char *key, size_t key_len, double d);
649-
ZEND_API void add_property_str_ex(zval *arg, const char *key, size_t key_len, zend_string *str);
650-
ZEND_API void add_property_string_ex(zval *arg, const char *key, size_t key_len, const char *str);
651-
ZEND_API void add_property_stringl_ex(zval *arg, const char *key, size_t key_len, const char *str, size_t length);
652-
ZEND_API void add_property_array_ex(zval *arg, const char *key, size_t key_len, zend_array *arr);
653-
ZEND_API void add_property_object_ex(zval *arg, const char *key, size_t key_len, zend_object *obj);
654-
ZEND_API void add_property_reference_ex(zval *arg, const char *key, size_t key_len, zend_reference *ref);
655-
ZEND_API void add_property_zval_ex(zval *arg, const char *key, size_t key_len, zval *value);
656-
657-
static zend_always_inline void add_property_long(zval *arg, const char *key, zend_long n) {
658-
add_property_long_ex(arg, key, strlen(key), n);
659-
}
660-
static zend_always_inline void add_property_null(zval *arg, const char *key) {
661-
add_property_null_ex(arg, key, strlen(key));
662-
}
663-
static zend_always_inline void add_property_bool(zval *arg, const char *key, bool b) {
664-
add_property_bool_ex(arg, key, strlen(key), b);
665-
}
666-
static zend_always_inline void add_property_resource(zval *arg, const char *key, zend_resource *r) {
667-
add_property_resource_ex(arg, key, strlen(key), r);
668-
}
669-
static zend_always_inline void add_property_double(zval *arg, const char *key, double d) {
670-
add_property_double_ex(arg, key, strlen(key), d);
671-
}
672-
static zend_always_inline void add_property_str(zval *arg, const char *key, zend_string *str) {
673-
add_property_str_ex(arg, key, strlen(key), str);
674-
}
675-
static zend_always_inline void add_property_string(zval *arg, const char *key, const char *str) {
676-
add_property_string_ex(arg, key, strlen(key), str);
677-
}
678-
static zend_always_inline void add_property_stringl(zval *arg, const char *key, const char *str, size_t length) {
679-
add_property_stringl_ex(arg, key, strlen(key), str, length);
680-
}
681-
static zend_always_inline void add_property_array(zval *arg, const char *key, zend_array *arr) {
682-
add_property_array_ex(arg, key, strlen(key), arr);
683-
}
684-
static zend_always_inline void add_property_object(zval *arg, const char *key, zend_object *obj) {
685-
add_property_object_ex(arg, key, strlen(key), obj);
686-
}
687-
static zend_always_inline void add_property_reference(zval *arg, const char *key, zend_reference *ref) {
688-
add_property_reference_ex(arg, key, strlen(key), ref);
689-
}
690-
static zend_always_inline void add_property_zval(zval *arg, const char *key, zval *value) {
691-
add_property_zval_ex(arg, key, strlen(key), value);
692-
}
693-
694711
ZEND_API zend_result _call_user_function_impl(zval *object, zval *function_name, zval *retval_ptr, uint32_t param_count, zval params[], HashTable *named_params);
695712

696713
#define call_user_function(function_table, object, function_name, retval_ptr, param_count, params) \

0 commit comments

Comments
 (0)