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

This commit is contained in:
Ilija Tovilo 2022-06-26 01:00:19 +02:00 committed by GitHub
parent 30cc0c1742
commit 3b92a96610
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 46 additions and 41 deletions

View File

@ -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

View File

@ -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;

View File

@ -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: {
@ -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));

View File

@ -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) */
@ -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);
@ -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);

View File

@ -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);

View File

@ -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;
@ -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;

View File

@ -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;

View File

@ -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 */

View File

@ -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,

View File

@ -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;
@ -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);
@ -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;
@ -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);
@ -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:

View File

@ -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) {
@ -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:
@ -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;

View File

@ -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);

View File

@ -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)
@ -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));
@ -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);
@ -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
@ -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;
@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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 *);
@ -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;
@ -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;