From 21196ca9f6279ad860dd63ca703df3087347a8cb Mon Sep 17 00:00:00 2001 From: DanielEScherzer Date: Tue, 17 Sep 2024 03:57:01 -0700 Subject: [PATCH] zend_enum.c: make a bunch of pointers `const` (#15932) * zend_enum.c: make a bunch of pointers `const` * interface_gets_implemented needs non-constant * zend_enum.h: update zend_verify_enum() signature --- Zend/zend_enum.c | 18 +++++++++--------- Zend/zend_enum.h | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Zend/zend_enum.c b/Zend/zend_enum.c index eb12ece50b4..8259441fd42 100644 --- a/Zend/zend_enum.c +++ b/Zend/zend_enum.c @@ -57,9 +57,9 @@ zend_object *zend_enum_new(zval *result, zend_class_entry *ce, zend_string *case return zobj; } -static void zend_verify_enum_properties(zend_class_entry *ce) +static void zend_verify_enum_properties(const zend_class_entry *ce) { - zend_property_info *property_info; + const zend_property_info *property_info; ZEND_HASH_MAP_FOREACH_PTR(&ce->properties_info, property_info) { if (zend_string_equals(property_info->name, ZSTR_KNOWN(ZEND_STR_NAME))) { @@ -77,7 +77,7 @@ static void zend_verify_enum_properties(zend_class_entry *ce) } ZEND_HASH_FOREACH_END(); } -static void zend_verify_enum_magic_methods(zend_class_entry *ce) +static void zend_verify_enum_magic_methods(const zend_class_entry *ce) { // Only __get, __call and __invoke are allowed @@ -109,7 +109,7 @@ static void zend_verify_enum_magic_methods(zend_class_entry *ce) } } -static void zend_verify_enum_interfaces(zend_class_entry *ce) +static void zend_verify_enum_interfaces(const zend_class_entry *ce) { if (zend_class_implements_interface(ce, zend_ce_serializable)) { zend_error_noreturn(E_COMPILE_ERROR, @@ -117,7 +117,7 @@ static void zend_verify_enum_interfaces(zend_class_entry *ce) } } -void zend_verify_enum(zend_class_entry *ce) +void zend_verify_enum(const zend_class_entry *ce) { zend_verify_enum_properties(ce); zend_verify_enum_magic_methods(ce); @@ -205,7 +205,7 @@ zend_result zend_enum_build_backed_enum_table(zend_class_entry *ce) zend_hash_init(backed_enum_table, 0, NULL, ZVAL_PTR_DTOR, 0); zend_class_set_backed_enum_table(ce, backed_enum_table); - zend_string *enum_class_name = ce->name; + const zend_string *enum_class_name = ce->name; zend_string *name; zval *val; @@ -228,7 +228,7 @@ zend_result zend_enum_build_backed_enum_table(zend_class_entry *ce) if (ce->enum_backing_type == IS_LONG) { zend_long long_key = Z_LVAL_P(case_value); - zval *existing_case_name = zend_hash_index_find(backed_enum_table, long_key); + const zval *existing_case_name = zend_hash_index_find(backed_enum_table, long_key); if (existing_case_name) { zend_throw_error(NULL, "Duplicate value in enum %s for cases %s and %s", ZSTR_VAL(enum_class_name), @@ -241,7 +241,7 @@ zend_result zend_enum_build_backed_enum_table(zend_class_entry *ce) } else { ZEND_ASSERT(ce->enum_backing_type == IS_STRING); zend_string *string_key = Z_STR_P(case_value); - zval *existing_case_name = zend_hash_find(backed_enum_table, string_key); + const zval *existing_case_name = zend_hash_find(backed_enum_table, string_key); if (existing_case_name != NULL) { zend_throw_error(NULL, "Duplicate value in enum %s for cases %s and %s", ZSTR_VAL(enum_class_name), @@ -294,7 +294,7 @@ ZEND_API zend_result zend_enum_get_case_by_value(zend_object **result, zend_clas } } - HashTable *backed_enum_table = CE_BACKED_ENUM_TABLE(ce); + const HashTable *backed_enum_table = CE_BACKED_ENUM_TABLE(ce); if (!backed_enum_table) { goto not_found; } diff --git a/Zend/zend_enum.h b/Zend/zend_enum.h index c3519ee35f3..7b3b0184b4e 100644 --- a/Zend/zend_enum.h +++ b/Zend/zend_enum.h @@ -34,7 +34,7 @@ void zend_register_enum_ce(void); void zend_enum_add_interfaces(zend_class_entry *ce); zend_result zend_enum_build_backed_enum_table(zend_class_entry *ce); zend_object *zend_enum_new(zval *result, zend_class_entry *ce, zend_string *case_name, zval *backing_value_zv); -void zend_verify_enum(zend_class_entry *ce); +void zend_verify_enum(const zend_class_entry *ce); void zend_enum_register_funcs(zend_class_entry *ce); void zend_enum_register_props(zend_class_entry *ce);