@@ -95,7 +95,7 @@ static void zend_type_copy_ctor(zend_type *const type, bool use_arena, bool pers
95
95
}
96
96
}
97
97
98
- static zend_function * zend_duplicate_internal_function (zend_function * func , zend_class_entry * ce ) /* {{{ */
98
+ static zend_function * zend_duplicate_internal_function (zend_function * func , const zend_class_entry * ce ) /* {{{ */
99
99
{
100
100
zend_function * new_function ;
101
101
@@ -114,7 +114,7 @@ static zend_function *zend_duplicate_internal_function(zend_function *func, zend
114
114
}
115
115
/* }}} */
116
116
117
- static zend_always_inline zend_function * zend_duplicate_function (zend_function * func , zend_class_entry * ce ) /* {{{ */
117
+ static zend_always_inline zend_function * zend_duplicate_function (zend_function * func , const zend_class_entry * ce ) /* {{{ */
118
118
{
119
119
if (UNEXPECTED (func -> type == ZEND_INTERNAL_FUNCTION )) {
120
120
return zend_duplicate_internal_function (func , ce );
@@ -239,7 +239,7 @@ static zend_string *resolve_class_name(zend_class_entry *scope, zend_string *nam
239
239
}
240
240
}
241
241
242
- static bool class_visible (zend_class_entry * ce ) {
242
+ static bool class_visible (const zend_class_entry * ce ) {
243
243
if (ce -> type == ZEND_INTERNAL_CLASS ) {
244
244
return !(CG (compiler_options ) & ZEND_COMPILE_IGNORE_INTERNAL_CLASSES );
245
245
} else {
@@ -309,7 +309,7 @@ static zend_class_entry *lookup_class(zend_class_entry *scope, zend_string *name
309
309
}
310
310
311
311
/* Instanceof that's safe to use on unlinked classes. */
312
- static bool unlinked_instanceof (zend_class_entry * ce1 , zend_class_entry * ce2 ) {
312
+ static bool unlinked_instanceof (zend_class_entry * ce1 , const zend_class_entry * ce2 ) {
313
313
if (ce1 == ce2 ) {
314
314
return 1 ;
315
315
}
@@ -874,7 +874,7 @@ static inheritance_status zend_do_perform_implementation_check(
874
874
/* }}} */
875
875
876
876
static ZEND_COLD void zend_append_type_hint (
877
- smart_str * str , zend_class_entry * scope , zend_arg_info * arg_info , bool return_hint ) /* {{{ */
877
+ smart_str * str , zend_class_entry * scope , const zend_arg_info * arg_info , bool return_hint ) /* {{{ */
878
878
{
879
879
if (ZEND_TYPE_IS_SET (arg_info -> type )) {
880
880
zend_string * type_str = zend_type_to_string_resolved (arg_info -> type , scope );
@@ -1041,7 +1041,7 @@ static void ZEND_COLD emit_incompatible_method_error(
1041
1041
if (status == INHERITANCE_UNRESOLVED ) {
1042
1042
// TODO Improve error message if first unresolved class is present in child and parent?
1043
1043
/* Fetch the first unresolved class from registered autoloads */
1044
- zend_string * unresolved_class = NULL ;
1044
+ const zend_string * unresolved_class = NULL ;
1045
1045
ZEND_HASH_MAP_FOREACH_STR_KEY (CG (delayed_autoloads ), unresolved_class ) {
1046
1046
break ;
1047
1047
} ZEND_HASH_FOREACH_END ();
@@ -1051,7 +1051,7 @@ static void ZEND_COLD emit_incompatible_method_error(
1051
1051
"Could not check compatibility between %s and %s, because class %s is not available" ,
1052
1052
ZSTR_VAL (child_prototype ), ZSTR_VAL (parent_prototype ), ZSTR_VAL (unresolved_class ));
1053
1053
} else if (status == INHERITANCE_WARNING ) {
1054
- zend_attribute * return_type_will_change_attribute = zend_get_attribute_str (
1054
+ const zend_attribute * return_type_will_change_attribute = zend_get_attribute_str (
1055
1055
child -> common .attributes ,
1056
1056
"returntypewillchange" ,
1057
1057
sizeof ("returntypewillchange" )- 1
@@ -1407,7 +1407,7 @@ static void inherit_property_hook(
1407
1407
* compiler (variadic and by-ref args, etc). */
1408
1408
}
1409
1409
1410
- static prop_variance prop_get_variance (zend_property_info * prop_info ) {
1410
+ static prop_variance prop_get_variance (const zend_property_info * prop_info ) {
1411
1411
bool unbacked = prop_info -> flags & ZEND_ACC_VIRTUAL ;
1412
1412
if (unbacked && prop_info -> hooks ) {
1413
1413
if (!prop_info -> hooks [ZEND_PROPERTY_HOOK_SET ]) {
@@ -2649,7 +2649,7 @@ static void zend_do_traits_method_binding(zend_class_entry *ce, zend_class_entry
2649
2649
}
2650
2650
/* }}} */
2651
2651
2652
- static zend_class_entry * find_first_constant_definition (zend_class_entry * ce , zend_class_entry * * traits , size_t current_trait , zend_string * constant_name , zend_class_entry * colliding_ce ) /* {{{ */
2652
+ static const zend_class_entry * find_first_constant_definition (const zend_class_entry * ce , zend_class_entry * * traits , size_t current_trait , zend_string * constant_name , const zend_class_entry * colliding_ce ) /* {{{ */
2653
2653
{
2654
2654
/* This function is used to show the place of the existing conflicting
2655
2655
* definition in error messages when conflicts occur. Since trait constants
@@ -2674,7 +2674,7 @@ static zend_class_entry* find_first_constant_definition(zend_class_entry *ce, ze
2674
2674
/* }}} */
2675
2675
2676
2676
static void emit_incompatible_trait_constant_error (
2677
- zend_class_entry * ce , zend_class_constant * existing_constant , zend_class_constant * trait_constant , zend_string * name ,
2677
+ const zend_class_entry * ce , const zend_class_constant * existing_constant , const zend_class_constant * trait_constant , zend_string * name ,
2678
2678
zend_class_entry * * traits , size_t current_trait
2679
2679
) {
2680
2680
zend_error_noreturn (E_COMPILE_ERROR ,
@@ -2770,7 +2770,7 @@ static void zend_do_traits_constant_binding(zend_class_entry *ce, zend_class_ent
2770
2770
}
2771
2771
/* }}} */
2772
2772
2773
- static zend_class_entry * find_first_property_definition (zend_class_entry * ce , zend_class_entry * * traits , size_t current_trait , zend_string * prop_name , zend_class_entry * colliding_ce ) /* {{{ */
2773
+ static const zend_class_entry * find_first_property_definition (const zend_class_entry * ce , zend_class_entry * * traits , size_t current_trait , zend_string * prop_name , const zend_class_entry * colliding_ce ) /* {{{ */
2774
2774
{
2775
2775
size_t i ;
2776
2776
@@ -2791,7 +2791,7 @@ static void zend_do_traits_property_binding(zend_class_entry *ce, zend_class_ent
2791
2791
{
2792
2792
size_t i ;
2793
2793
zend_property_info * property_info ;
2794
- zend_property_info * colliding_prop ;
2794
+ const zend_property_info * colliding_prop ;
2795
2795
zend_property_info * new_prop ;
2796
2796
zend_string * prop_name ;
2797
2797
zval * prop_value ;
@@ -2963,11 +2963,11 @@ static void zend_do_bind_traits(zend_class_entry *ce, zend_class_entry **traits)
2963
2963
ai.afn[idx] && ai.afn[idx + 1] ? ", " : (ai.afn[idx] && ai.cnt > MAX_ABSTRACT_INFO_CNT ? ", ..." : "")
2964
2964
2965
2965
typedef struct _zend_abstract_info {
2966
- zend_function * afn [MAX_ABSTRACT_INFO_CNT + 1 ];
2966
+ const zend_function * afn [MAX_ABSTRACT_INFO_CNT + 1 ];
2967
2967
int cnt ;
2968
2968
} zend_abstract_info ;
2969
2969
2970
- static void zend_verify_abstract_class_function (zend_function * fn , zend_abstract_info * ai ) /* {{{ */
2970
+ static void zend_verify_abstract_class_function (const zend_function * fn , zend_abstract_info * ai ) /* {{{ */
2971
2971
{
2972
2972
if (ai -> cnt < MAX_ABSTRACT_INFO_CNT ) {
2973
2973
ai -> afn [ai -> cnt ] = fn ;
@@ -2978,7 +2978,7 @@ static void zend_verify_abstract_class_function(zend_function *fn, zend_abstract
2978
2978
2979
2979
void zend_verify_abstract_class (zend_class_entry * ce ) /* {{{ */
2980
2980
{
2981
- zend_function * func ;
2981
+ const zend_function * func ;
2982
2982
zend_abstract_info ai ;
2983
2983
bool is_explicit_abstract = (ce -> ce_flags & ZEND_ACC_EXPLICIT_ABSTRACT_CLASS ) != 0 ;
2984
2984
bool can_be_abstract = (ce -> ce_flags & ZEND_ACC_ENUM ) == 0 ;
@@ -2995,11 +2995,11 @@ void zend_verify_abstract_class(zend_class_entry *ce) /* {{{ */
2995
2995
} ZEND_HASH_FOREACH_END ();
2996
2996
2997
2997
if (!is_explicit_abstract ) {
2998
- zend_property_info * prop_info ;
2998
+ const zend_property_info * prop_info ;
2999
2999
ZEND_HASH_FOREACH_PTR (& ce -> properties_info , prop_info ) {
3000
3000
if (prop_info -> hooks ) {
3001
3001
for (uint32_t i = 0 ; i < ZEND_PROPERTY_HOOK_COUNT ; i ++ ) {
3002
- zend_function * fn = prop_info -> hooks [i ];
3002
+ const zend_function * fn = prop_info -> hooks [i ];
3003
3003
if (fn && (fn -> common .fn_flags & ZEND_ACC_ABSTRACT )) {
3004
3004
zend_verify_abstract_class_function (fn , & ai );
3005
3005
}
@@ -3245,7 +3245,7 @@ static void resolve_delayed_variance_obligations(zend_class_entry *ce) {
3245
3245
zend_hash_index_del (all_obligations , num_key );
3246
3246
}
3247
3247
3248
- static void check_unrecoverable_load_failure (zend_class_entry * ce ) {
3248
+ static void check_unrecoverable_load_failure (const zend_class_entry * ce ) {
3249
3249
/* If this class has been used while unlinked through a variance obligation, it is not legal
3250
3250
* to remove the class from the class table and throw an exception, because there is already
3251
3251
* a dependence on the inheritance hierarchy of this specific class. Instead we fall back to
@@ -3264,7 +3264,7 @@ static void check_unrecoverable_load_failure(zend_class_entry *ce) {
3264
3264
} while (0)
3265
3265
3266
3266
static zend_op_array * zend_lazy_method_load (
3267
- zend_op_array * op_array , zend_class_entry * ce , zend_class_entry * pce ) {
3267
+ zend_op_array * op_array , zend_class_entry * ce , const zend_class_entry * pce ) {
3268
3268
ZEND_ASSERT (op_array -> type == ZEND_USER_FUNCTION );
3269
3269
ZEND_ASSERT (op_array -> scope == pce );
3270
3270
ZEND_ASSERT (op_array -> prototype == NULL );
@@ -3585,7 +3585,7 @@ ZEND_API zend_class_entry *zend_do_link_class(zend_class_entry *ce, zend_string
3585
3585
zend_verify_enum (ce );
3586
3586
}
3587
3587
if (ce -> num_hooked_prop_variance_checks ) {
3588
- zend_property_info * prop_info ;
3588
+ const zend_property_info * prop_info ;
3589
3589
ZEND_HASH_MAP_FOREACH_PTR (& ce -> properties_info , prop_info ) {
3590
3590
if (prop_info -> ce == ce && prop_info -> hooks && prop_info -> hooks [ZEND_PROPERTY_HOOK_SET ]) {
3591
3591
switch (zend_verify_property_hook_variance (prop_info , prop_info -> hooks [ZEND_PROPERTY_HOOK_SET ])) {
@@ -3690,8 +3690,8 @@ static inheritance_status zend_can_early_bind(zend_class_entry *ce, zend_class_e
3690
3690
{
3691
3691
zend_string * key ;
3692
3692
zend_function * parent_func ;
3693
- zend_property_info * parent_info ;
3694
- zend_class_constant * parent_const ;
3693
+ const zend_property_info * parent_info ;
3694
+ const zend_class_constant * parent_const ;
3695
3695
inheritance_status overall_status = INHERITANCE_SUCCESS ;
3696
3696
3697
3697
ZEND_HASH_MAP_FOREACH_STR_KEY_PTR (& parent_ce -> function_table , key , parent_func ) {
@@ -3713,14 +3713,14 @@ static inheritance_status zend_can_early_bind(zend_class_entry *ce, zend_class_e
3713
3713
} ZEND_HASH_FOREACH_END ();
3714
3714
3715
3715
ZEND_HASH_MAP_FOREACH_STR_KEY_PTR (& parent_ce -> properties_info , key , parent_info ) {
3716
- zval * zv ;
3716
+ const zval * zv ;
3717
3717
if ((parent_info -> flags & ZEND_ACC_PRIVATE ) || !ZEND_TYPE_IS_SET (parent_info -> type )) {
3718
3718
continue ;
3719
3719
}
3720
3720
3721
3721
zv = zend_hash_find_known_hash (& ce -> properties_info , key );
3722
3722
if (zv ) {
3723
- zend_property_info * child_info = Z_PTR_P (zv );
3723
+ const zend_property_info * child_info = Z_PTR_P (zv );
3724
3724
if (ZEND_TYPE_IS_SET (child_info -> type )) {
3725
3725
inheritance_status status = verify_property_type_compatibility (parent_info , child_info , prop_get_variance (parent_info ), false, false);
3726
3726
if (UNEXPECTED (status != INHERITANCE_SUCCESS )) {
@@ -3731,14 +3731,14 @@ static inheritance_status zend_can_early_bind(zend_class_entry *ce, zend_class_e
3731
3731
} ZEND_HASH_FOREACH_END ();
3732
3732
3733
3733
ZEND_HASH_MAP_FOREACH_STR_KEY_PTR (& parent_ce -> constants_table , key , parent_const ) {
3734
- zval * zv ;
3734
+ const zval * zv ;
3735
3735
if ((ZEND_CLASS_CONST_FLAGS (parent_const ) & ZEND_ACC_PRIVATE ) || !ZEND_TYPE_IS_SET (parent_const -> type )) {
3736
3736
continue ;
3737
3737
}
3738
3738
3739
3739
zv = zend_hash_find_known_hash (& ce -> constants_table , key );
3740
3740
if (zv ) {
3741
- zend_class_constant * child_const = Z_PTR_P (zv );
3741
+ const zend_class_constant * child_const = Z_PTR_P (zv );
3742
3742
if (ZEND_TYPE_IS_SET (child_const -> type )) {
3743
3743
inheritance_status status = class_constant_types_compatible (parent_const , child_const );
3744
3744
ZEND_ASSERT (status != INHERITANCE_WARNING );
0 commit comments