Skip to content

Convert return type of various object handlers from int to zend_result #8755

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions UPGRADING.INTERNALS
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ PHP 8.2 INTERNALS UPGRADE NOTES
* Deprecated zend_atoi() and zend_atol(). Use ZEND_STRTOL() for general purpose
string to long conversion, or a variant of zend_ini_parse_quantity() for
parsing ini quantities.
* The return types of the following object handlers has changed from int to zend_result
- zend_object_cast_t
- zend_object_count_elements_t
- zend_object_get_closure_t
- zend_object_do_operation_t

========================
2. Build system changes
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_closures.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ static zend_object *zend_closure_clone(zend_object *zobject) /* {{{ */
}
/* }}} */

int zend_closure_get_closure(zend_object *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr, bool check_only) /* {{{ */
static zend_result zend_closure_get_closure(zend_object *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr, bool check_only) /* {{{ */
{
zend_closure *closure = (zend_closure*)obj;

Expand Down
4 changes: 2 additions & 2 deletions Zend/zend_object_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -1841,7 +1841,7 @@ ZEND_API zend_string *zend_std_get_class_name(const zend_object *zobj) /* {{{ */
}
/* }}} */

ZEND_API int zend_std_cast_object_tostring(zend_object *readobj, zval *writeobj, int type) /* {{{ */
ZEND_API zend_result zend_std_cast_object_tostring(zend_object *readobj, zval *writeobj, int type) /* {{{ */
{
switch (type) {
case IS_STRING: {
Expand Down Expand Up @@ -1871,7 +1871,7 @@ ZEND_API int zend_std_cast_object_tostring(zend_object *readobj, zval *writeobj,
}
/* }}} */

ZEND_API int zend_std_get_closure(zend_object *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr, bool check_only) /* {{{ */
ZEND_API zend_result zend_std_get_closure(zend_object *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr, bool check_only) /* {{{ */
{
zend_class_entry *ce = obj->ce;
zval *func = zend_hash_find_known_hash(&ce->function_table, ZSTR_KNOWN(ZEND_STR_MAGIC_INVOKE));
Expand Down
12 changes: 6 additions & 6 deletions Zend/zend_object_handlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,17 @@ typedef int (*zend_object_compare_t)(zval *object1, zval *object2);
/* Cast an object to some other type.
* readobj and retval must point to distinct zvals.
*/
typedef int (*zend_object_cast_t)(zend_object *readobj, zval *retval, int type);
typedef zend_result (*zend_object_cast_t)(zend_object *readobj, zval *retval, int type);

/* updates *count to hold the number of elements present and returns SUCCESS.
* Returns FAILURE if the object does not have any sense of overloaded dimensions */
typedef int (*zend_object_count_elements_t)(zend_object *object, zend_long *count);
typedef zend_result (*zend_object_count_elements_t)(zend_object *object, zend_long *count);

typedef int (*zend_object_get_closure_t)(zend_object *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr, bool check_only);
typedef zend_result (*zend_object_get_closure_t)(zend_object *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr, bool check_only);

typedef HashTable *(*zend_object_get_gc_t)(zend_object *object, zval **table, int *n);

typedef int (*zend_object_do_operation_t)(zend_uchar opcode, zval *result, zval *op1, zval *op2);
typedef zend_result (*zend_object_do_operation_t)(zend_uchar opcode, zval *result, zval *op1, zval *op2);

struct _zend_object_handlers {
/* offset of real object header (usually zero) */
Expand Down Expand Up @@ -209,7 +209,7 @@ ZEND_API struct _zend_property_info *zend_get_property_info(zend_class_entry *ce
ZEND_API HashTable *zend_std_get_properties(zend_object *object);
ZEND_API HashTable *zend_std_get_gc(zend_object *object, zval **table, int *n);
ZEND_API HashTable *zend_std_get_debug_info(zend_object *object, int *is_temp);
ZEND_API int zend_std_cast_object_tostring(zend_object *object, zval *writeobj, int type);
ZEND_API zend_result zend_std_cast_object_tostring(zend_object *object, zval *writeobj, int type);
ZEND_API zval *zend_std_get_property_ptr_ptr(zend_object *object, zend_string *member, int type, void **cache_slot);
ZEND_API zval *zend_std_read_property(zend_object *object, zend_string *member, int type, void **cache_slot, zval *rv);
ZEND_API zval *zend_std_write_property(zend_object *object, zend_string *member, zval *value, void **cache_slot);
Expand All @@ -222,7 +222,7 @@ ZEND_API void zend_std_unset_dimension(zend_object *object, zval *offset);
ZEND_API zend_function *zend_std_get_method(zend_object **obj_ptr, zend_string *method_name, const zval *key);
ZEND_API zend_string *zend_std_get_class_name(const zend_object *zobj);
ZEND_API int zend_std_compare_objects(zval *o1, zval *o2);
ZEND_API int zend_std_get_closure(zend_object *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr, bool check_only);
ZEND_API zend_result zend_std_get_closure(zend_object *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr, bool check_only);
ZEND_API void rebuild_object_properties(zend_object *zobj);

ZEND_API HashTable *zend_std_build_object_properties_array(zend_object *zobj);
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_weakrefs.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ static void zend_weakmap_unset_dimension(zend_object *object, zval *offset)
zend_weakref_unregister(obj_addr, ZEND_WEAKREF_ENCODE(&wm->ht, ZEND_WEAKREF_TAG_MAP), 1);
}

static int zend_weakmap_count_elements(zend_object *object, zend_long *count)
static zend_result zend_weakmap_count_elements(zend_object *object, zend_long *count)
{
zend_weakmap *wm = zend_weakmap_from(object);
*count = zend_hash_num_elements(&wm->ht);
Expand Down
4 changes: 2 additions & 2 deletions ext/com_dotnet/com_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ static int com_objects_compare(zval *object1, zval *object2)
return ret;
}

static int com_object_cast(zend_object *readobj, zval *writeobj, int type)
static zend_result com_object_cast(zend_object *readobj, zval *writeobj, int type)
{
php_com_dotnet_object *obj;
VARIANT v;
Expand Down Expand Up @@ -490,7 +490,7 @@ static int com_object_cast(zend_object *readobj, zval *writeobj, int type)
return zend_std_cast_object_tostring(readobj, writeobj, type);
}

static int com_object_count(zend_object *object, zend_long *count)
static zend_result com_object_count(zend_object *object, zend_long *count)
{
php_com_dotnet_object *obj;
LONG ubound = 0, lbound = 0;
Expand Down
4 changes: 2 additions & 2 deletions ext/com_dotnet/com_saproxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,12 +332,12 @@ static int saproxy_objects_compare(zval *object1, zval *object2)
return -1;
}

static int saproxy_object_cast(zend_object *readobj, zval *writeobj, int type)
static zend_result saproxy_object_cast(zend_object *readobj, zval *writeobj, int type)
{
return FAILURE;
}

static int saproxy_count_elements(zend_object *object, zend_long *count)
static zend_result saproxy_count_elements(zend_object *object, zend_long *count)
{
php_com_saproxy *proxy = (php_com_saproxy*) object;
LONG ubound, lbound;
Expand Down
2 changes: 1 addition & 1 deletion ext/curl/curl_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,6 @@ static inline php_curlsh *curl_share_from_obj(zend_object *obj) {
void curl_multi_register_handlers(void);
void curl_share_register_handlers(void);
void curlfile_register_class(void);
int curl_cast_object(zend_object *obj, zval *result, int type);
zend_result curl_cast_object(zend_object *obj, zval *result, int type);

#endif /* _PHP_CURL_PRIVATE_H */
2 changes: 1 addition & 1 deletion ext/curl/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -1443,7 +1443,7 @@ static HashTable *curl_get_gc(zend_object *object, zval **table, int *n)
return zend_std_get_properties(object);
}

int curl_cast_object(zend_object *obj, zval *result, int type)
zend_result curl_cast_object(zend_object *obj, zval *result, int type)
{
if (type == IS_LONG) {
/* For better backward compatibility, make (int) $curl_handle return the object ID,
Expand Down
10 changes: 5 additions & 5 deletions ext/ffi/ffi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,7 @@ static zval *zend_ffi_cdata_set(zend_object *obj, zend_string *member, zval *val
}
/* }}} */

static int zend_ffi_cdata_cast_object(zend_object *readobj, zval *writeobj, int type) /* {{{ */
static zend_result zend_ffi_cdata_cast_object(zend_object *readobj, zval *writeobj, int type) /* {{{ */
{
if (type == IS_STRING) {
zend_ffi_cdata *cdata = (zend_ffi_cdata*)readobj;
Expand Down Expand Up @@ -1703,7 +1703,7 @@ static int zend_ffi_cdata_compare_objects(zval *o1, zval *o2) /* {{{ */
}
/* }}} */

static int zend_ffi_cdata_count_elements(zend_object *obj, zend_long *count) /* {{{ */
static zend_result zend_ffi_cdata_count_elements(zend_object *obj, zend_long *count) /* {{{ */
{
zend_ffi_cdata *cdata = (zend_ffi_cdata*)obj;
zend_ffi_type *type = ZEND_FFI_TYPE(cdata->type);
Expand Down Expand Up @@ -1774,7 +1774,7 @@ static zend_object* zend_ffi_add(zend_ffi_cdata *base_cdata, zend_ffi_type *base
}
/* }}} */

static int zend_ffi_cdata_do_operation(zend_uchar opcode, zval *result, zval *op1, zval *op2) /* {{{ */
static zend_result zend_ffi_cdata_do_operation(zend_uchar opcode, zval *result, zval *op1, zval *op2) /* {{{ */
{
zend_long offset;

Expand Down Expand Up @@ -2056,7 +2056,7 @@ static HashTable *zend_ffi_cdata_get_debug_info(zend_object *obj, int *is_temp)
}
/* }}} */

static int zend_ffi_cdata_get_closure(zend_object *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr, bool check_only) /* {{{ */
static zend_result zend_ffi_cdata_get_closure(zend_object *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr, bool check_only) /* {{{ */
{
zend_ffi_cdata *cdata = (zend_ffi_cdata*)obj;
zend_ffi_type *type = ZEND_FFI_TYPE(cdata->type);
Expand Down Expand Up @@ -5021,7 +5021,7 @@ static HashTable *zend_fake_get_gc(zend_object *ob, zval **table, int *n) /* {{{
}
/* }}} */

static int zend_fake_cast_object(zend_object *obj, zval *result, int type)
static zend_result zend_fake_cast_object(zend_object *obj, zval *result, int type)
{
switch (type) {
case _IS_BOOL:
Expand Down
6 changes: 3 additions & 3 deletions ext/gmp/gmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ static inline void gmp_create(zval *target, mpz_ptr *gmpnum_target) /* {{{ */
}
/* }}} */

static int gmp_cast_object(zend_object *readobj, zval *writeobj, int type) /* {{{ */
static zend_result gmp_cast_object(zend_object *readobj, zval *writeobj, int type) /* {{{ */
{
mpz_ptr gmpnum;
switch (type) {
Expand Down Expand Up @@ -372,7 +372,7 @@ static void shift_operator_helper(gmp_binary_ui_op_t op, zval *return_value, zva
} \
return SUCCESS;

static int gmp_do_operation_ex(zend_uchar opcode, zval *result, zval *op1, zval *op2) /* {{{ */
static zend_result gmp_do_operation_ex(zend_uchar opcode, zval *result, zval *op1, zval *op2) /* {{{ */
{
switch (opcode) {
case ZEND_ADD:
Expand Down Expand Up @@ -409,7 +409,7 @@ static int gmp_do_operation_ex(zend_uchar opcode, zval *result, zval *op1, zval
}
/* }}} */

static int gmp_do_operation(zend_uchar opcode, zval *result, zval *op1, zval *op2) /* {{{ */
static zend_result gmp_do_operation(zend_uchar opcode, zval *result, zval *op1, zval *op2) /* {{{ */
{
zval op1_copy;
int retval;
Expand Down
2 changes: 1 addition & 1 deletion ext/intl/resourcebundle/resourcebundle_class.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ PHP_FUNCTION( resourcebundle_get )
/* }}} */

/* {{{ resourcebundle_array_count */
int resourcebundle_array_count(zend_object *object, zend_long *count)
static zend_result resourcebundle_array_count(zend_object *object, zend_long *count)
{
ResourceBundle_object *rb = php_intl_resourcebundle_fetch_object(object);

Expand Down
14 changes: 7 additions & 7 deletions ext/simplexml/simplexml.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static zval *php_sxe_iterator_current_data(zend_object_iterator *iter);
static void php_sxe_iterator_current_key(zend_object_iterator *iter, zval *key);
static void php_sxe_iterator_move_forward(zend_object_iterator *iter);
static void php_sxe_iterator_rewind(zend_object_iterator *iter);
static int sxe_object_cast_ex(zend_object *readobj, zval *writeobj, int type);
static zend_result sxe_object_cast_ex(zend_object *readobj, zval *writeobj, int type);

/* {{{ _node_as_zval() */
static void _node_as_zval(php_sxe_object *sxe, xmlNodePtr node, zval *value, SXE_ITER itertype, char *name, const xmlChar *nsprefix, int isprefix)
Expand Down Expand Up @@ -1801,7 +1801,7 @@ PHP_METHOD(SimpleXMLElement, addAttribute)
/* }}} */

/* {{{ cast_object() */
static int cast_object(zval *object, int type, char *contents)
static zend_result cast_object(zval *object, int type, char *contents)
{
if (contents) {
ZVAL_STRINGL(object, contents, strlen(contents));
Expand Down Expand Up @@ -1833,12 +1833,12 @@ static int cast_object(zval *object, int type, char *contents)
/* }}} */

/* {{{ sxe_object_cast() */
static int sxe_object_cast_ex(zend_object *readobj, zval *writeobj, int type)
static zend_result sxe_object_cast_ex(zend_object *readobj, zval *writeobj, int type)
{
php_sxe_object *sxe;
xmlChar *contents = NULL;
xmlNodePtr node;
int rv;
zend_result rv;

sxe = php_sxe_fetch_object(readobj);

Expand Down Expand Up @@ -1882,7 +1882,7 @@ static int sxe_object_cast_ex(zend_object *readobj, zval *writeobj, int type)
/* }}} */

/* {{{ Variant of sxe_object_cast_ex that handles overwritten __toString() method */
static int sxe_object_cast(zend_object *readobj, zval *writeobj, int type)
static zend_result sxe_object_cast(zend_object *readobj, zval *writeobj, int type)
{
if (type == IS_STRING
&& zend_std_cast_object_tostring(readobj, writeobj, IS_STRING) == SUCCESS
Expand All @@ -1908,7 +1908,7 @@ PHP_METHOD(SimpleXMLElement, __toString)
}
/* }}} */

static int php_sxe_count_elements_helper(php_sxe_object *sxe, zend_long *count) /* {{{ */
static zend_result php_sxe_count_elements_helper(php_sxe_object *sxe, zend_long *count) /* {{{ */
{
xmlNodePtr node;
zval data;
Expand All @@ -1935,7 +1935,7 @@ static int php_sxe_count_elements_helper(php_sxe_object *sxe, zend_long *count)
}
/* }}} */

static int sxe_count_elements(zend_object *object, zend_long *count) /* {{{ */
static zend_result sxe_count_elements(zend_object *object, zend_long *count) /* {{{ */
{
php_sxe_object *intern;
intern = php_sxe_fetch_object(object);
Expand Down
2 changes: 1 addition & 1 deletion ext/spl/spl_array.c
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,7 @@ static zend_long spl_array_object_count_elements_helper(spl_array_object *intern
}
} /* }}} */

int spl_array_object_count_elements(zend_object *object, zend_long *count) /* {{{ */
static zend_result spl_array_object_count_elements(zend_object *object, zend_long *count) /* {{{ */
{
spl_array_object *intern = spl_array_from_obj(object);

Expand Down
2 changes: 1 addition & 1 deletion ext/spl/spl_directory.c
Original file line number Diff line number Diff line change
Expand Up @@ -1854,7 +1854,7 @@ zend_object_iterator *spl_filesystem_tree_get_iterator(zend_class_entry *ce, zva
/* }}} */

/* {{{ spl_filesystem_object_cast */
static int spl_filesystem_object_cast(zend_object *readobj, zval *writeobj, int type)
static zend_result spl_filesystem_object_cast(zend_object *readobj, zval *writeobj, int type)
{
spl_filesystem_object *intern = spl_filesystem_from_obj(readobj);

Expand Down
2 changes: 1 addition & 1 deletion ext/spl/spl_dllist.c
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ static zend_object *spl_dllist_object_clone(zend_object *old_object) /* {{{ */
}
/* }}} */

static int spl_dllist_object_count_elements(zend_object *object, zend_long *count) /* {{{ */
static zend_result spl_dllist_object_count_elements(zend_object *object, zend_long *count) /* {{{ */
{
spl_dllist_object *intern = spl_dllist_from_obj(object);

Expand Down
2 changes: 1 addition & 1 deletion ext/spl/spl_fixedarray.c
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ static int spl_fixedarray_object_has_dimension(zend_object *object, zval *offset
return spl_fixedarray_object_has_dimension_helper(intern, offset, check_empty);
}

static int spl_fixedarray_object_count_elements(zend_object *object, zend_long *count)
static zend_result spl_fixedarray_object_count_elements(zend_object *object, zend_long *count)
{
spl_fixedarray_object *intern;

Expand Down
2 changes: 1 addition & 1 deletion ext/spl/spl_heap.c
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ static zend_object *spl_heap_object_clone(zend_object *old_object) /* {{{ */
}
/* }}} */

static int spl_heap_object_count_elements(zend_object *object, zend_long *count) /* {{{ */
static zend_result spl_heap_object_count_elements(zend_object *object, zend_long *count) /* {{{ */
{
spl_heap_object *intern = spl_heap_from_obj(object);

Expand Down
8 changes: 4 additions & 4 deletions ext/tidy/tidy.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ static void tidy_object_free_storage(zend_object *);
static zend_object *tidy_object_new_node(zend_class_entry *);
static zend_object *tidy_object_new_doc(zend_class_entry *);
static zval *tidy_instantiate(zend_class_entry *, zval *);
static int tidy_doc_cast_handler(zend_object *, zval *, int);
static int tidy_node_cast_handler(zend_object *, zval *, int);
static zend_result tidy_doc_cast_handler(zend_object *, zval *, int);
static zend_result tidy_node_cast_handler(zend_object *, zval *, int);
static void tidy_doc_update_properties(PHPTidyObj *);
static void tidy_add_node_default_properties(PHPTidyObj *);
static void *php_tidy_get_opt_val(PHPTidyDoc *, TidyOption, TidyOptionType *);
Expand Down Expand Up @@ -462,7 +462,7 @@ static zval *tidy_instantiate(zend_class_entry *pce, zval *object)
return object;
}

static int tidy_doc_cast_handler(zend_object *in, zval *out, int type)
static zend_result tidy_doc_cast_handler(zend_object *in, zval *out, int type)
{
TidyBuffer output;
PHPTidyObj *obj;
Expand Down Expand Up @@ -500,7 +500,7 @@ static int tidy_doc_cast_handler(zend_object *in, zval *out, int type)
return SUCCESS;
}

static int tidy_node_cast_handler(zend_object *in, zval *out, int type)
static zend_result tidy_node_cast_handler(zend_object *in, zval *out, int type)
{
TidyBuffer buf;
PHPTidyObj *obj;
Expand Down