@@ -756,7 +756,7 @@ static bool zend_verify_weak_scalar_type_hint(uint32_t type_mask, zval *arg)
756
756
}
757
757
758
758
#if ZEND_DEBUG
759
- static bool can_convert_to_string (zval * zv ) {
759
+ static bool can_convert_to_string (const zval * zv ) {
760
760
/* We don't call cast_object here, because this check must be side-effect free. As this
761
761
* is only used for a sanity check of arginfo/zpp consistency, it's okay if we accept
762
762
* more than actually allowed here. */
@@ -768,7 +768,7 @@ static bool can_convert_to_string(zval *zv) {
768
768
}
769
769
770
770
/* Used to sanity-check internal arginfo types without performing any actual type conversions. */
771
- static bool zend_verify_weak_scalar_type_hint_no_sideeffect (uint32_t type_mask , zval * arg )
771
+ static bool zend_verify_weak_scalar_type_hint_no_sideeffect (uint32_t type_mask , const zval * arg )
772
772
{
773
773
zend_long lval ;
774
774
double dval ;
@@ -813,7 +813,7 @@ ZEND_API bool zend_verify_scalar_type_hint(uint32_t type_mask, zval *arg, bool s
813
813
return zend_verify_weak_scalar_type_hint (type_mask , arg );
814
814
}
815
815
816
- ZEND_COLD zend_never_inline void zend_verify_property_type_error (zend_property_info * info , zval * property )
816
+ ZEND_COLD zend_never_inline void zend_verify_property_type_error (const zend_property_info * info , const zval * property )
817
817
{
818
818
zend_string * type_str ;
819
819
@@ -831,7 +831,7 @@ ZEND_COLD zend_never_inline void zend_verify_property_type_error(zend_property_i
831
831
zend_string_release (type_str );
832
832
}
833
833
834
- ZEND_COLD zend_never_inline void zend_magic_get_property_type_inconsistency_error (zend_property_info * info , zval * property )
834
+ ZEND_COLD zend_never_inline void zend_magic_get_property_type_inconsistency_error (const zend_property_info * info , const zval * property )
835
835
{
836
836
/* we _may_ land here in case reading already errored and runtime cache thus has not been updated (i.e. it contains a valid but unrelated info) */
837
837
if (EG (exception )) {
@@ -848,7 +848,7 @@ ZEND_COLD zend_never_inline void zend_magic_get_property_type_inconsistency_erro
848
848
zend_string_release (type_str );
849
849
}
850
850
851
- ZEND_COLD void zend_match_unhandled_error (zval * value )
851
+ ZEND_COLD void zend_match_unhandled_error (const zval * value )
852
852
{
853
853
smart_str msg = {0 };
854
854
@@ -868,18 +868,18 @@ ZEND_COLD void zend_match_unhandled_error(zval *value)
868
868
}
869
869
870
870
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_readonly_property_modification_error (
871
- zend_property_info * info ) {
871
+ const zend_property_info * info ) {
872
872
zend_throw_error (NULL , "Cannot modify readonly property %s::$%s" ,
873
873
ZSTR_VAL (info -> ce -> name ), zend_get_unmangled_property_name (info -> name ));
874
874
}
875
875
876
- ZEND_API ZEND_COLD void ZEND_FASTCALL zend_readonly_property_indirect_modification_error (zend_property_info * info )
876
+ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_readonly_property_indirect_modification_error (const zend_property_info * info )
877
877
{
878
878
zend_throw_error (NULL , "Cannot indirectly modify readonly property %s::$%s" ,
879
879
ZSTR_VAL (info -> ce -> name ), zend_get_unmangled_property_name (info -> name ));
880
880
}
881
881
882
- static zend_class_entry * resolve_single_class_type (zend_string * name , zend_class_entry * self_ce ) {
882
+ static const zend_class_entry * resolve_single_class_type (zend_string * name , const zend_class_entry * self_ce ) {
883
883
if (zend_string_equals_literal_ci (name , "self" )) {
884
884
return self_ce ;
885
885
} else if (zend_string_equals_literal_ci (name , "parent" )) {
@@ -889,8 +889,8 @@ static zend_class_entry *resolve_single_class_type(zend_string *name, zend_class
889
889
}
890
890
}
891
891
892
- static zend_always_inline zend_class_entry * zend_ce_from_type (
893
- zend_property_info * info , zend_type * type ) {
892
+ static zend_always_inline const zend_class_entry * zend_ce_from_type (
893
+ const zend_property_info * info , const zend_type * type ) {
894
894
ZEND_ASSERT (ZEND_TYPE_HAS_NAME (* type ));
895
895
zend_string * name = ZEND_TYPE_NAME (* type );
896
896
if (ZSTR_HAS_CE_CACHE (name )) {
@@ -904,13 +904,13 @@ static zend_always_inline zend_class_entry *zend_ce_from_type(
904
904
}
905
905
906
906
static bool zend_check_intersection_for_property_class_type (zend_type_list * intersection_type_list ,
907
- zend_property_info * info , zend_class_entry * object_ce )
907
+ const zend_property_info * info , const zend_class_entry * object_ce )
908
908
{
909
909
zend_type * list_type ;
910
910
911
911
ZEND_TYPE_LIST_FOREACH (intersection_type_list , list_type ) {
912
912
ZEND_ASSERT (!ZEND_TYPE_HAS_LIST (* list_type ));
913
- zend_class_entry * ce = zend_ce_from_type (info , list_type );
913
+ const zend_class_entry * ce = zend_ce_from_type (info , list_type );
914
914
if (!ce || !instanceof_function (object_ce , ce )) {
915
915
return false;
916
916
}
@@ -919,7 +919,7 @@ static bool zend_check_intersection_for_property_class_type(zend_type_list *inte
919
919
}
920
920
921
921
static bool zend_check_and_resolve_property_class_type (
922
- zend_property_info * info , zend_class_entry * object_ce ) {
922
+ const zend_property_info * info , const zend_class_entry * object_ce ) {
923
923
if (ZEND_TYPE_HAS_LIST (info -> type )) {
924
924
zend_type * list_type ;
925
925
if (ZEND_TYPE_IS_INTERSECTION (info -> type )) {
@@ -935,20 +935,20 @@ static bool zend_check_and_resolve_property_class_type(
935
935
continue ;
936
936
}
937
937
ZEND_ASSERT (!ZEND_TYPE_HAS_LIST (* list_type ));
938
- zend_class_entry * ce = zend_ce_from_type (info , list_type );
938
+ const zend_class_entry * ce = zend_ce_from_type (info , list_type );
939
939
if (ce && instanceof_function (object_ce , ce )) {
940
940
return true;
941
941
}
942
942
} ZEND_TYPE_LIST_FOREACH_END ();
943
943
return false;
944
944
}
945
945
} else {
946
- zend_class_entry * ce = zend_ce_from_type (info , & info -> type );
946
+ const zend_class_entry * ce = zend_ce_from_type (info , & info -> type );
947
947
return ce && instanceof_function (object_ce , ce );
948
948
}
949
949
}
950
950
951
- static zend_always_inline bool i_zend_check_property_type (zend_property_info * info , zval * property , bool strict )
951
+ static zend_always_inline bool i_zend_check_property_type (const zend_property_info * info , zval * property , bool strict )
952
952
{
953
953
ZEND_ASSERT (!Z_ISREF_P (property ));
954
954
if (EXPECTED (ZEND_TYPE_CONTAINS_CODE (info -> type , Z_TYPE_P (property )))) {
@@ -965,7 +965,7 @@ static zend_always_inline bool i_zend_check_property_type(zend_property_info *in
965
965
return zend_verify_scalar_type_hint (type_mask , property , strict , 0 );
966
966
}
967
967
968
- static zend_always_inline bool i_zend_verify_property_type (zend_property_info * info , zval * property , bool strict )
968
+ static zend_always_inline bool i_zend_verify_property_type (const zend_property_info * info , zval * property , bool strict )
969
969
{
970
970
if (i_zend_check_property_type (info , property , strict )) {
971
971
return 1 ;
@@ -975,7 +975,7 @@ static zend_always_inline bool i_zend_verify_property_type(zend_property_info *i
975
975
return 0 ;
976
976
}
977
977
978
- ZEND_API bool zend_never_inline zend_verify_property_type (zend_property_info * info , zval * property , bool strict ) {
978
+ ZEND_API bool zend_never_inline zend_verify_property_type (const zend_property_info * info , zval * property , bool strict ) {
979
979
return i_zend_verify_property_type (info , property , strict );
980
980
}
981
981
@@ -3387,7 +3387,7 @@ static zend_always_inline zend_result zend_fetch_static_property_address(zval **
3387
3387
return SUCCESS ;
3388
3388
}
3389
3389
3390
- ZEND_API ZEND_COLD void zend_throw_ref_type_error_type (zend_property_info * prop1 , zend_property_info * prop2 , zval * zv ) {
3390
+ ZEND_API ZEND_COLD void zend_throw_ref_type_error_type (const zend_property_info * prop1 , const zend_property_info * prop2 , const zval * zv ) {
3391
3391
zend_string * type1_str = zend_type_to_string (prop1 -> type );
3392
3392
zend_string * type2_str = zend_type_to_string (prop2 -> type );
3393
3393
zend_type_error ("Reference with value of type %s held by property %s::$%s of type %s is not compatible with property %s::$%s of type %s" ,
@@ -3403,7 +3403,7 @@ ZEND_API ZEND_COLD void zend_throw_ref_type_error_type(zend_property_info *prop1
3403
3403
zend_string_release (type2_str );
3404
3404
}
3405
3405
3406
- ZEND_API ZEND_COLD void zend_throw_ref_type_error_zval (zend_property_info * prop , zval * zv ) {
3406
+ ZEND_API ZEND_COLD void zend_throw_ref_type_error_zval (const zend_property_info * prop , const zval * zv ) {
3407
3407
zend_string * type_str = zend_type_to_string (prop -> type );
3408
3408
zend_type_error ("Cannot assign %s to reference held by property %s::$%s of type %s" ,
3409
3409
zend_zval_type_name (zv ),
@@ -3414,7 +3414,7 @@ ZEND_API ZEND_COLD void zend_throw_ref_type_error_zval(zend_property_info *prop,
3414
3414
zend_string_release (type_str );
3415
3415
}
3416
3416
3417
- ZEND_API ZEND_COLD void zend_throw_conflicting_coercion_error (zend_property_info * prop1 , zend_property_info * prop2 , zval * zv ) {
3417
+ ZEND_API ZEND_COLD void zend_throw_conflicting_coercion_error (const zend_property_info * prop1 , const zend_property_info * prop2 , const zval * zv ) {
3418
3418
zend_string * type1_str = zend_type_to_string (prop1 -> type );
3419
3419
zend_string * type2_str = zend_type_to_string (prop2 -> type );
3420
3420
zend_type_error ("Cannot assign %s to reference held by property %s::$%s of type %s and property %s::$%s of type %s, as this would result in an inconsistent type conversion" ,
@@ -3432,7 +3432,7 @@ ZEND_API ZEND_COLD void zend_throw_conflicting_coercion_error(zend_property_info
3432
3432
3433
3433
/* 1: valid, 0: invalid, -1: may be valid after type coercion */
3434
3434
static zend_always_inline int i_zend_verify_type_assignable_zval (
3435
- zend_property_info * info , zval * zv , bool strict ) {
3435
+ const zend_property_info * info , const zval * zv , bool strict ) {
3436
3436
zend_type type = info -> type ;
3437
3437
uint32_t type_mask ;
3438
3438
zend_uchar zv_type = Z_TYPE_P (zv );
@@ -3474,11 +3474,11 @@ static zend_always_inline int i_zend_verify_type_assignable_zval(
3474
3474
3475
3475
ZEND_API bool ZEND_FASTCALL zend_verify_ref_assignable_zval (zend_reference * ref , zval * zv , bool strict )
3476
3476
{
3477
- zend_property_info * prop ;
3477
+ const zend_property_info * prop ;
3478
3478
3479
3479
/* The value must satisfy each property type, and coerce to the same value for each property
3480
3480
* type. Remember the first coerced type and value we've seen for this purpose. */
3481
- zend_property_info * first_prop = NULL ;
3481
+ const zend_property_info * first_prop = NULL ;
3482
3482
zval coerced_value ;
3483
3483
ZVAL_UNDEF (& coerced_value );
3484
3484
@@ -3584,7 +3584,7 @@ ZEND_API zval* zend_assign_to_typed_ref(zval *variable_ptr, zval *orig_value, ze
3584
3584
return variable_ptr ;
3585
3585
}
3586
3586
3587
- ZEND_API bool ZEND_FASTCALL zend_verify_prop_assignable_by_ref_ex (zend_property_info * prop_info , zval * orig_val , bool strict , zend_verify_prop_assignable_by_ref_context context ) {
3587
+ ZEND_API bool ZEND_FASTCALL zend_verify_prop_assignable_by_ref_ex (const zend_property_info * prop_info , zval * orig_val , bool strict , zend_verify_prop_assignable_by_ref_context context ) {
3588
3588
zval * val = orig_val ;
3589
3589
if (Z_ISREF_P (val ) && ZEND_REF_HAS_TYPE_SOURCES (Z_REF_P (val ))) {
3590
3590
int result ;
@@ -3601,7 +3601,7 @@ ZEND_API bool ZEND_FASTCALL zend_verify_prop_assignable_by_ref_ex(zend_property_
3601
3601
zval tmp ;
3602
3602
ZVAL_COPY (& tmp , val );
3603
3603
if (zend_verify_weak_scalar_type_hint (ZEND_TYPE_FULL_MASK (prop_info -> type ), & tmp )) {
3604
- zend_property_info * ref_prop = ZEND_REF_FIRST_SOURCE (Z_REF_P (orig_val ));
3604
+ const zend_property_info * ref_prop = ZEND_REF_FIRST_SOURCE (Z_REF_P (orig_val ));
3605
3605
zend_throw_ref_type_error_type (ref_prop , prop_info , val );
3606
3606
zval_ptr_dtor (& tmp );
3607
3607
return 0 ;
@@ -3625,7 +3625,7 @@ ZEND_API bool ZEND_FASTCALL zend_verify_prop_assignable_by_ref_ex(zend_property_
3625
3625
return 0 ;
3626
3626
}
3627
3627
3628
- ZEND_API bool ZEND_FASTCALL zend_verify_prop_assignable_by_ref (zend_property_info * prop_info , zval * orig_val , bool strict ) {
3628
+ ZEND_API bool ZEND_FASTCALL zend_verify_prop_assignable_by_ref (const zend_property_info * prop_info , zval * orig_val , bool strict ) {
3629
3629
return zend_verify_prop_assignable_by_ref_ex (prop_info , orig_val , strict , ZEND_VERIFY_PROP_ASSIGNABLE_BY_REF_CONTEXT_ASSIGNMENT );
3630
3630
}
3631
3631
@@ -3652,7 +3652,7 @@ ZEND_API void ZEND_FASTCALL zend_ref_add_type_source(zend_property_info_source_l
3652
3652
source_list -> list = ZEND_PROPERTY_INFO_SOURCE_FROM_LIST (list );
3653
3653
}
3654
3654
3655
- ZEND_API void ZEND_FASTCALL zend_ref_del_type_source (zend_property_info_source_list * source_list , zend_property_info * prop )
3655
+ ZEND_API void ZEND_FASTCALL zend_ref_del_type_source (zend_property_info_source_list * source_list , const zend_property_info * prop )
3656
3656
{
3657
3657
zend_property_info_list * list = ZEND_PROPERTY_INFO_SOURCE_TO_LIST (source_list -> list );
3658
3658
zend_property_info * * ptr , * * end ;
0 commit comments