From a5ec2f00d5c153226f2851f9cfa8880fd53e1ddf Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Sun, 24 Aug 2025 13:49:43 +0200 Subject: [PATCH 1/2] Zend/zend_ast: zend_ast_evaluate_inner() can be static It is not exported in any header --- Zend/zend_ast.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Zend/zend_ast.c b/Zend/zend_ast.c index 1172cba2d4f16..6cb6fe076cacd 100644 --- a/Zend/zend_ast.c +++ b/Zend/zend_ast.c @@ -558,7 +558,7 @@ static zend_class_entry *zend_ast_fetch_class(zend_ast *ast, zend_class_entry *s return zend_fetch_class_with_scope(zend_ast_get_str(ast), (ast->attr >> ZEND_CONST_EXPR_NEW_FETCH_TYPE_SHIFT) | ZEND_FETCH_CLASS_EXCEPTION, scope); } -ZEND_API zend_result ZEND_FASTCALL zend_ast_evaluate_inner( +static zend_result ZEND_FASTCALL zend_ast_evaluate_inner( zval *result, zend_ast *ast, zend_class_entry *scope, @@ -589,7 +589,7 @@ ZEND_API zend_result ZEND_FASTCALL zend_ast_evaluate_ex( return r; } -ZEND_API zend_result ZEND_FASTCALL zend_ast_evaluate_inner( +static zend_result ZEND_FASTCALL zend_ast_evaluate_inner( zval *result, zend_ast *ast, zend_class_entry *scope, From a1beac37ec023ea1cb4bb78ae23667fc3c1d1082 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Sun, 24 Aug 2025 13:30:53 +0200 Subject: [PATCH 2/2] Zend: add const modifiers --- Zend/zend_API.c | 8 ++++---- Zend/zend_API.h | 22 +++++++++++----------- Zend/zend_attributes.c | 16 ++++++++-------- Zend/zend_attributes.h | 12 ++++++------ Zend/zend_constants.c | 10 +++++----- Zend/zend_constants.h | 6 +++--- Zend/zend_execute_API.c | 2 +- ext/reflection/php_reflection.c | 2 +- 8 files changed, 39 insertions(+), 39 deletions(-) diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 8ac140cdceffc..28c6efbab4810 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -1418,7 +1418,7 @@ ZEND_API void zend_merge_properties(zval *obj, HashTable *properties) /* {{{ */ } /* }}} */ -static zend_class_mutable_data *zend_allocate_mutable_data(zend_class_entry *class_type) /* {{{ */ +static zend_class_mutable_data *zend_allocate_mutable_data(const zend_class_entry *class_type) /* {{{ */ { zend_class_mutable_data *mutable_data; @@ -1434,7 +1434,7 @@ static zend_class_mutable_data *zend_allocate_mutable_data(zend_class_entry *cla } /* }}} */ -ZEND_API HashTable *zend_separate_class_constants_table(zend_class_entry *class_type) /* {{{ */ +ZEND_API HashTable *zend_separate_class_constants_table(const zend_class_entry *class_type) /* {{{ */ { zend_class_mutable_data *mutable_data; HashTable *constants_table; @@ -5208,7 +5208,7 @@ ZEND_API zend_result zend_update_static_property_stringl(zend_class_entry *scope } /* }}} */ -ZEND_API zval *zend_read_property_ex(zend_class_entry *scope, zend_object *object, zend_string *name, bool silent, zval *rv) /* {{{ */ +ZEND_API zval *zend_read_property_ex(const zend_class_entry *scope, zend_object *object, zend_string *name, bool silent, zval *rv) /* {{{ */ { zval *value; const zend_class_entry *old_scope = EG(fake_scope); @@ -5222,7 +5222,7 @@ ZEND_API zval *zend_read_property_ex(zend_class_entry *scope, zend_object *objec } /* }}} */ -ZEND_API zval *zend_read_property(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, bool silent, zval *rv) /* {{{ */ +ZEND_API zval *zend_read_property(const zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, bool silent, zval *rv) /* {{{ */ { zval *value; zend_string *str; diff --git a/Zend/zend_API.h b/Zend/zend_API.h index 78a30d630ae6e..3a51952e4b42f 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -448,12 +448,12 @@ ZEND_API void zend_declare_class_constant_string(zend_class_entry *ce, const cha ZEND_API zend_result zend_update_class_constant(zend_class_constant *c, const zend_string *name, zend_class_entry *scope); ZEND_API zend_result zend_update_class_constants(zend_class_entry *class_type); -ZEND_API HashTable *zend_separate_class_constants_table(zend_class_entry *class_type); +ZEND_API HashTable *zend_separate_class_constants_table(const zend_class_entry *class_type); -static zend_always_inline HashTable *zend_class_constants_table(zend_class_entry *ce) { +static zend_always_inline const HashTable *zend_class_constants_table(const zend_class_entry *ce) { if ((ce->ce_flags & ZEND_ACC_HAS_AST_CONSTANTS) && ZEND_MAP_PTR(ce->mutable_data)) { - zend_class_mutable_data *mutable_data = - (zend_class_mutable_data*)ZEND_MAP_PTR_GET_IMM(ce->mutable_data); + const zend_class_mutable_data *mutable_data = + (const zend_class_mutable_data*)ZEND_MAP_PTR_GET_IMM(ce->mutable_data); if (mutable_data && mutable_data->constants_table) { return mutable_data->constants_table; } else { @@ -464,10 +464,10 @@ static zend_always_inline HashTable *zend_class_constants_table(zend_class_entry } } -static zend_always_inline zval *zend_class_default_properties_table(zend_class_entry *ce) { +static zend_always_inline zval *zend_class_default_properties_table(const zend_class_entry *ce) { if ((ce->ce_flags & ZEND_ACC_HAS_AST_PROPERTIES) && ZEND_MAP_PTR(ce->mutable_data)) { - zend_class_mutable_data *mutable_data = - (zend_class_mutable_data*)ZEND_MAP_PTR_GET_IMM(ce->mutable_data); + const zend_class_mutable_data *mutable_data = + (const zend_class_mutable_data*)ZEND_MAP_PTR_GET_IMM(ce->mutable_data); return mutable_data->default_properties_table; } else { return ce->default_properties_table; @@ -484,10 +484,10 @@ static zend_always_inline void zend_class_set_backed_enum_table(zend_class_entry } } -static zend_always_inline HashTable *zend_class_backed_enum_table(zend_class_entry *ce) +static zend_always_inline HashTable *zend_class_backed_enum_table(const zend_class_entry *ce) { if (ZEND_MAP_PTR(ce->mutable_data) && ce->type == ZEND_USER_CLASS) { - zend_class_mutable_data *mutable_data = (zend_class_mutable_data*)ZEND_MAP_PTR_GET_IMM(ce->mutable_data); + const zend_class_mutable_data *mutable_data = (const zend_class_mutable_data*)ZEND_MAP_PTR_GET_IMM(ce->mutable_data); return mutable_data->backed_enum_table; } else { return ce->backed_enum_table; @@ -514,8 +514,8 @@ ZEND_API zend_result zend_update_static_property_double(zend_class_entry *scope, ZEND_API zend_result zend_update_static_property_string(zend_class_entry *scope, const char *name, size_t name_length, const char *value); ZEND_API zend_result zend_update_static_property_stringl(zend_class_entry *scope, const char *name, size_t name_length, const char *value, size_t value_length); -ZEND_API zval *zend_read_property_ex(zend_class_entry *scope, zend_object *object, zend_string *name, bool silent, zval *rv); -ZEND_API zval *zend_read_property(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, bool silent, zval *rv); +ZEND_API zval *zend_read_property_ex(const zend_class_entry *scope, zend_object *object, zend_string *name, bool silent, zval *rv); +ZEND_API zval *zend_read_property(const zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, bool silent, zval *rv); ZEND_API zval *zend_read_static_property_ex(zend_class_entry *scope, zend_string *name, bool silent); ZEND_API zval *zend_read_static_property(zend_class_entry *scope, const char *name, size_t name_length, bool silent); diff --git a/Zend/zend_attributes.c b/Zend/zend_attributes.c index 4777e5ca08ad1..430a26eee614e 100644 --- a/Zend/zend_attributes.c +++ b/Zend/zend_attributes.c @@ -246,7 +246,7 @@ ZEND_METHOD(NoDiscard, __construct) } } -static zend_attribute *get_attribute(HashTable *attributes, zend_string *lcname, uint32_t offset) +static zend_attribute *get_attribute(const HashTable *attributes, const zend_string *lcname, uint32_t offset) { if (attributes) { zend_attribute *attr; @@ -261,7 +261,7 @@ static zend_attribute *get_attribute(HashTable *attributes, zend_string *lcname, return NULL; } -static zend_attribute *get_attribute_str(HashTable *attributes, const char *str, size_t len, uint32_t offset) +static zend_attribute *get_attribute_str(const HashTable *attributes, const char *str, size_t len, uint32_t offset) { if (attributes) { zend_attribute *attr; @@ -276,27 +276,27 @@ static zend_attribute *get_attribute_str(HashTable *attributes, const char *str, return NULL; } -ZEND_API zend_attribute *zend_get_attribute(HashTable *attributes, zend_string *lcname) +ZEND_API zend_attribute *zend_get_attribute(const HashTable *attributes, const zend_string *lcname) { return get_attribute(attributes, lcname, 0); } -ZEND_API zend_attribute *zend_get_attribute_str(HashTable *attributes, const char *str, size_t len) +ZEND_API zend_attribute *zend_get_attribute_str(const HashTable *attributes, const char *str, size_t len) { return get_attribute_str(attributes, str, len, 0); } -ZEND_API zend_attribute *zend_get_parameter_attribute(HashTable *attributes, zend_string *lcname, uint32_t offset) +ZEND_API zend_attribute *zend_get_parameter_attribute(const HashTable *attributes, const zend_string *lcname, uint32_t offset) { return get_attribute(attributes, lcname, offset + 1); } -ZEND_API zend_attribute *zend_get_parameter_attribute_str(HashTable *attributes, const char *str, size_t len, uint32_t offset) +ZEND_API zend_attribute *zend_get_parameter_attribute_str(const HashTable *attributes, const char *str, size_t len, uint32_t offset) { return get_attribute_str(attributes, str, len, offset + 1); } -ZEND_API zend_result zend_get_attribute_value(zval *ret, zend_attribute *attr, uint32_t i, zend_class_entry *scope) +ZEND_API zend_result zend_get_attribute_value(zval *ret, const zend_attribute *attr, uint32_t i, zend_class_entry *scope) { if (i >= attr->argc) { return FAILURE; @@ -428,7 +428,7 @@ ZEND_API zend_string *zend_get_attribute_target_names(uint32_t flags) return smart_str_extract(&str); } -ZEND_API bool zend_is_attribute_repeated(HashTable *attributes, zend_attribute *attr) +ZEND_API bool zend_is_attribute_repeated(const HashTable *attributes, const zend_attribute *attr) { zend_attribute *other; diff --git a/Zend/zend_attributes.h b/Zend/zend_attributes.h index 10227c2d1e8ef..0bc7c1eb9e897 100644 --- a/Zend/zend_attributes.h +++ b/Zend/zend_attributes.h @@ -77,17 +77,17 @@ typedef struct _zend_internal_attribute { zend_string* (*validator)(zend_attribute *attr, uint32_t target, zend_class_entry *scope); } zend_internal_attribute; -ZEND_API zend_attribute *zend_get_attribute(HashTable *attributes, zend_string *lcname); -ZEND_API zend_attribute *zend_get_attribute_str(HashTable *attributes, const char *str, size_t len); +ZEND_API zend_attribute *zend_get_attribute(const HashTable *attributes, const zend_string *lcname); +ZEND_API zend_attribute *zend_get_attribute_str(const HashTable *attributes, const char *str, size_t len); -ZEND_API zend_attribute *zend_get_parameter_attribute(HashTable *attributes, zend_string *lcname, uint32_t offset); -ZEND_API zend_attribute *zend_get_parameter_attribute_str(HashTable *attributes, const char *str, size_t len, uint32_t offset); +ZEND_API zend_attribute *zend_get_parameter_attribute(const HashTable *attributes, const zend_string *lcname, uint32_t offset); +ZEND_API zend_attribute *zend_get_parameter_attribute_str(const HashTable *attributes, const char *str, size_t len, uint32_t offset); -ZEND_API zend_result zend_get_attribute_value(zval *ret, zend_attribute *attr, uint32_t i, zend_class_entry *scope); +ZEND_API zend_result zend_get_attribute_value(zval *ret, const zend_attribute *attr, uint32_t i, zend_class_entry *scope); ZEND_API zend_result zend_get_attribute_object(zval *out, zend_class_entry *attribute_ce, zend_attribute *attribute_data, zend_class_entry *scope, zend_string *filename); ZEND_API zend_string *zend_get_attribute_target_names(uint32_t targets); -ZEND_API bool zend_is_attribute_repeated(HashTable *attributes, zend_attribute *attr); +ZEND_API bool zend_is_attribute_repeated(const HashTable *attributes, const zend_attribute *attr); ZEND_API zend_internal_attribute *zend_mark_internal_attribute(zend_class_entry *ce); ZEND_API zend_internal_attribute *zend_internal_attribute_register(zend_class_entry *ce, uint32_t flags); diff --git a/Zend/zend_constants.c b/Zend/zend_constants.c index efdcb905fd773..0bb10489d7d19 100644 --- a/Zend/zend_constants.c +++ b/Zend/zend_constants.c @@ -251,7 +251,7 @@ ZEND_API zend_constant *_zend_get_special_const(const char *name, size_t len) /* } /* }}} */ -ZEND_API bool zend_verify_const_access(zend_class_constant *c, zend_class_entry *scope) /* {{{ */ +ZEND_API bool zend_verify_const_access(const zend_class_constant *c, const zend_class_entry *scope) /* {{{ */ { if (ZEND_CLASS_CONST_FLAGS(c) & ZEND_ACC_PUBLIC) { return 1; @@ -312,9 +312,9 @@ ZEND_API zval *zend_get_constant(zend_string *name) return NULL; } -ZEND_API zval *zend_get_class_constant_ex(zend_string *class_name, zend_string *constant_name, zend_class_entry *scope, uint32_t flags) +ZEND_API zval *zend_get_class_constant_ex(zend_string *class_name, zend_string *constant_name, const zend_class_entry *scope, uint32_t flags) { - zend_class_entry *ce = NULL; + const zend_class_entry *ce = NULL; zend_class_constant *c = NULL; zval *ret_constant = NULL; @@ -413,7 +413,7 @@ ZEND_API zval *zend_get_class_constant_ex(zend_string *class_name, zend_string * return ret_constant; } -ZEND_API zval *zend_get_constant_ex(zend_string *cname, zend_class_entry *scope, uint32_t flags) +ZEND_API zval *zend_get_constant_ex(zend_string *cname, const zend_class_entry *scope, uint32_t flags) { zend_constant *c; const char *colon; @@ -492,7 +492,7 @@ ZEND_API zval *zend_get_constant_ex(zend_string *cname, zend_class_entry *scope, return &c->value; } -static void* zend_hash_add_constant(HashTable *ht, zend_string *key, zend_constant *c) +static void* zend_hash_add_constant(HashTable *ht, zend_string *key, const zend_constant *c) { void *ret; zend_constant *copy = pemalloc(sizeof(zend_constant), ZEND_CONSTANT_FLAGS(c) & CONST_PERSISTENT); diff --git a/Zend/zend_constants.h b/Zend/zend_constants.h index 6bdb19c4d5afc..3d7f60920bc1a 100644 --- a/Zend/zend_constants.h +++ b/Zend/zend_constants.h @@ -85,12 +85,12 @@ void clean_module_constants(int module_number); void free_zend_constant(zval *zv); void zend_startup_constants(void); void zend_register_standard_constants(void); -ZEND_API bool zend_verify_const_access(zend_class_constant *c, zend_class_entry *ce); +ZEND_API bool zend_verify_const_access(const zend_class_constant *c, const zend_class_entry *ce); ZEND_API zval *zend_get_constant(zend_string *name); ZEND_API zend_constant *zend_get_constant_ptr(zend_string *name); ZEND_API zval *zend_get_constant_str(const char *name, size_t name_len); -ZEND_API zval *zend_get_constant_ex(zend_string *name, zend_class_entry *scope, uint32_t flags); -ZEND_API zval *zend_get_class_constant_ex(zend_string *class_name, zend_string *constant_name, zend_class_entry *scope, uint32_t flags); +ZEND_API zval *zend_get_constant_ex(zend_string *name, const zend_class_entry *scope, uint32_t flags); +ZEND_API zval *zend_get_class_constant_ex(zend_string *class_name, zend_string *constant_name, const zend_class_entry *scope, uint32_t flags); ZEND_API zend_constant *zend_register_bool_constant(const char *name, size_t name_len, bool bval, int flags, int module_number); ZEND_API zend_constant *zend_register_null_constant(const char *name, size_t name_len, int flags, int module_number); ZEND_API zend_constant *zend_register_long_constant(const char *name, size_t name_len, zend_long lval, int flags, int module_number); diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 06618b3a9ded2..0d8c74c838fe2 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -1685,7 +1685,7 @@ void zend_unset_timeout(void) /* {{{ */ } /* }}} */ -static ZEND_COLD void report_class_fetch_error(zend_string *class_name, uint32_t fetch_type) +static ZEND_COLD void report_class_fetch_error(const zend_string *class_name, uint32_t fetch_type) { if (fetch_type & ZEND_FETCH_CLASS_SILENT) { return; diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index ab89c47bbb21a..bd7a8dd45dff1 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -4839,7 +4839,7 @@ ZEND_METHOD(ReflectionClass, getConstant) { reflection_object *intern; zend_class_entry *ce; - HashTable *constants_table; + const HashTable *constants_table; zend_class_constant *c; zend_string *name, *key;