@@ -706,7 +706,6 @@ ZEND_API inheritance_status zend_perform_covariant_type_check(
706
706
}
707
707
}
708
708
709
- zend_type * single_type ;
710
709
inheritance_status early_exit_status ;
711
710
bool have_unresolved = false;
712
711
@@ -728,6 +727,7 @@ ZEND_API inheritance_status zend_perform_covariant_type_check(
728
727
* We need to iterate over fe_type (U_i) first and the logic is independent of
729
728
* whether proto_type is a union or intersection (only the inner check differs). */
730
729
early_exit_status = INHERITANCE_ERROR ;
730
+ zend_type * single_type ;
731
731
ZEND_TYPE_FOREACH (fe_type , single_type ) {
732
732
inheritance_status status ;
733
733
/* Union has an intersection type as it's member */
@@ -790,7 +790,7 @@ static inheritance_status zend_do_perform_implementation_check(
790
790
const zend_function * fe , zend_class_entry * fe_scope ,
791
791
const zend_function * proto , zend_class_entry * proto_scope ) /* {{{ */
792
792
{
793
- uint32_t i , num_args , proto_num_args , fe_num_args ;
793
+ uint32_t num_args , proto_num_args , fe_num_args ;
794
794
inheritance_status status , local_status ;
795
795
bool proto_is_variadic , fe_is_variadic ;
796
796
@@ -831,7 +831,7 @@ static inheritance_status zend_do_perform_implementation_check(
831
831
num_args = MAX (proto_num_args , fe_num_args );
832
832
833
833
status = INHERITANCE_SUCCESS ;
834
- for (i = 0 ; i < num_args ; i ++ ) {
834
+ for (uint32_t i = 0 ; i < num_args ; i ++ ) {
835
835
zend_arg_info * proto_arg_info =
836
836
i < proto_num_args ? & proto -> common .arg_info [i ] :
837
837
proto_is_variadic ? & proto -> common .arg_info [proto_num_args - 1 ] : NULL ;
@@ -933,15 +933,15 @@ static ZEND_COLD zend_string *zend_get_function_declaration(
933
933
smart_str_appendc (& str , '(' );
934
934
935
935
if (fptr -> common .arg_info ) {
936
- uint32_t i , num_args , required ;
936
+ uint32_t num_args , required ;
937
937
zend_arg_info * arg_info = fptr -> common .arg_info ;
938
938
939
939
required = fptr -> common .required_num_args ;
940
940
num_args = fptr -> common .num_args ;
941
941
if (fptr -> common .fn_flags & ZEND_ACC_VARIADIC ) {
942
942
num_args ++ ;
943
943
}
944
- for (i = 0 ; i < num_args ;) {
944
+ for (uint32_t i = 0 ; i < num_args ;) {
945
945
zend_append_type_hint (& str , scope , arg_info , 0 );
946
946
947
947
if (ZEND_ARG_SEND_MODE (arg_info )) {
@@ -1451,10 +1451,9 @@ static prop_variance prop_get_variance(const zend_property_info *prop_info) {
1451
1451
static void do_inherit_property (zend_property_info * parent_info , zend_string * key , zend_class_entry * ce ) /* {{{ */
1452
1452
{
1453
1453
zval * child = zend_hash_find_known_hash (& ce -> properties_info , key );
1454
- zend_property_info * child_info ;
1455
1454
1456
1455
if (UNEXPECTED (child )) {
1457
- child_info = Z_PTR_P (child );
1456
+ zend_property_info * child_info = Z_PTR_P (child );
1458
1457
if (parent_info -> flags & (ZEND_ACC_PRIVATE |ZEND_ACC_CHANGED )) {
1459
1458
child_info -> flags |= ZEND_ACC_CHANGED ;
1460
1459
}
@@ -1596,7 +1595,6 @@ static void zend_do_inherit_interfaces(zend_class_entry *ce, const zend_class_en
1596
1595
{
1597
1596
/* expects interface to be contained in ce's interface list already */
1598
1597
uint32_t i , ce_num , if_num = iface -> num_interfaces ;
1599
- zend_class_entry * entry ;
1600
1598
1601
1599
ce_num = ce -> num_interfaces ;
1602
1600
@@ -1608,7 +1606,7 @@ static void zend_do_inherit_interfaces(zend_class_entry *ce, const zend_class_en
1608
1606
1609
1607
/* Inherit the interfaces, only if they're not already inherited by the class */
1610
1608
while (if_num -- ) {
1611
- entry = iface -> interfaces [if_num ];
1609
+ zend_class_entry * entry = iface -> interfaces [if_num ];
1612
1610
for (i = 0 ; i < ce_num ; i ++ ) {
1613
1611
if (ce -> interfaces [i ] == entry ) {
1614
1612
break ;
@@ -1830,7 +1828,6 @@ static void zend_link_hooked_object_iter(zend_class_entry *ce) {
1830
1828
ZEND_API void zend_do_inheritance_ex (zend_class_entry * ce , zend_class_entry * parent_ce , bool checked ) /* {{{ */
1831
1829
{
1832
1830
zend_property_info * property_info ;
1833
- zend_function * func ;
1834
1831
zend_string * key ;
1835
1832
1836
1833
if (UNEXPECTED (ce -> ce_flags & ZEND_ACC_INTERFACE )) {
@@ -2021,6 +2018,7 @@ ZEND_API void zend_do_inheritance_ex(zend_class_entry *ce, zend_class_entry *par
2021
2018
if (!checked ) {
2022
2019
flags |= ZEND_INHERITANCE_CHECK_PROTO | ZEND_INHERITANCE_CHECK_VISIBILITY ;
2023
2020
}
2021
+ zend_function * func ;
2024
2022
ZEND_HASH_MAP_FOREACH_STR_KEY_PTR (& parent_ce -> function_table , key , func ) {
2025
2023
do_inherit_method (key , func , ce , 0 , flags );
2026
2024
} ZEND_HASH_FOREACH_END ();
@@ -2196,15 +2194,13 @@ static void do_interface_implementation(zend_class_entry *ce, zend_class_entry *
2196
2194
2197
2195
ZEND_API void zend_do_implement_interface (zend_class_entry * ce , zend_class_entry * iface ) /* {{{ */
2198
2196
{
2199
- uint32_t i , ignore = 0 ;
2197
+ uint32_t ignore = 0 ;
2200
2198
uint32_t current_iface_num = ce -> num_interfaces ;
2201
2199
uint32_t parent_iface_num = ce -> parent ? ce -> parent -> num_interfaces : 0 ;
2202
- zend_string * key ;
2203
- zend_class_constant * c ;
2204
2200
2205
2201
ZEND_ASSERT (ce -> ce_flags & ZEND_ACC_LINKED );
2206
2202
2207
- for (i = 0 ; i < ce -> num_interfaces ; i ++ ) {
2203
+ for (uint32_t i = 0 ; i < ce -> num_interfaces ; i ++ ) {
2208
2204
if (ce -> interfaces [i ] == NULL ) {
2209
2205
memmove (ce -> interfaces + i , ce -> interfaces + i + 1 , sizeof (zend_class_entry * ) * (-- ce -> num_interfaces - i ));
2210
2206
i -- ;
@@ -2217,6 +2213,8 @@ ZEND_API void zend_do_implement_interface(zend_class_entry *ce, zend_class_entry
2217
2213
}
2218
2214
}
2219
2215
if (ignore ) {
2216
+ zend_string * key ;
2217
+ zend_class_constant * c ;
2220
2218
/* Check for attempt to redeclare interface constants */
2221
2219
ZEND_HASH_MAP_FOREACH_STR_KEY_PTR (& iface -> constants_table , key , c ) {
2222
2220
do_inherit_constant_check (ce , c , key );
@@ -2238,15 +2236,14 @@ ZEND_API void zend_do_implement_interface(zend_class_entry *ce, zend_class_entry
2238
2236
2239
2237
static void zend_do_implement_interfaces (zend_class_entry * ce , zend_class_entry * * interfaces ) /* {{{ */
2240
2238
{
2241
- zend_class_entry * iface ;
2242
2239
uint32_t num_parent_interfaces = ce -> parent ? ce -> parent -> num_interfaces : 0 ;
2243
2240
uint32_t num_interfaces = num_parent_interfaces ;
2244
2241
zend_string * key ;
2245
2242
zend_class_constant * c ;
2246
- uint32_t i , j ;
2243
+ uint32_t i ;
2247
2244
2248
2245
for (i = 0 ; i < ce -> num_interfaces ; i ++ ) {
2249
- iface = interfaces [num_parent_interfaces + i ];
2246
+ zend_class_entry * iface = interfaces [num_parent_interfaces + i ];
2250
2247
if (!(iface -> ce_flags & ZEND_ACC_LINKED )) {
2251
2248
add_dependency_obligation (ce , iface );
2252
2249
}
@@ -2255,7 +2252,7 @@ static void zend_do_implement_interfaces(zend_class_entry *ce, zend_class_entry
2255
2252
zend_error_noreturn (E_ERROR , "%s cannot implement %s - it is not an interface" , ZSTR_VAL (ce -> name ), ZSTR_VAL (iface -> name ));
2256
2253
return ;
2257
2254
}
2258
- for (j = 0 ; j < num_interfaces ; j ++ ) {
2255
+ for (uint32_t j = 0 ; j < num_interfaces ; j ++ ) {
2259
2256
if (interfaces [j ] == iface ) {
2260
2257
if (j >= num_parent_interfaces ) {
2261
2258
efree (interfaces );
@@ -2442,7 +2439,6 @@ static void zend_traits_check_private_final_inheritance(uint32_t original_fn_fla
2442
2439
static void zend_traits_copy_functions (zend_string * fnname , zend_function * fn , zend_class_entry * ce , HashTable * exclude_table , zend_class_entry * * aliases ) /* {{{ */
2443
2440
{
2444
2441
zend_trait_alias * alias , * * alias_ptr ;
2445
- zend_string * lcname ;
2446
2442
zend_function fn_copy ;
2447
2443
int i ;
2448
2444
@@ -2466,7 +2462,7 @@ static void zend_traits_copy_functions(zend_string *fnname, zend_function *fn, z
2466
2462
2467
2463
zend_traits_check_private_final_inheritance (fn -> common .fn_flags , & fn_copy , alias -> alias );
2468
2464
2469
- lcname = zend_string_tolower (alias -> alias );
2465
+ zend_string * lcname = zend_string_tolower (alias -> alias );
2470
2466
zend_add_trait_method (ce , alias -> alias , lcname , & fn_copy );
2471
2467
zend_string_release_ex (lcname , 0 );
2472
2468
}
@@ -2512,14 +2508,12 @@ static void zend_traits_copy_functions(zend_string *fnname, zend_function *fn, z
2512
2508
2513
2509
static uint32_t zend_check_trait_usage (zend_class_entry * ce , zend_class_entry * trait , zend_class_entry * * traits ) /* {{{ */
2514
2510
{
2515
- uint32_t i ;
2516
-
2517
2511
if (UNEXPECTED ((trait -> ce_flags & ZEND_ACC_TRAIT ) != ZEND_ACC_TRAIT )) {
2518
2512
zend_error_noreturn (E_COMPILE_ERROR , "Class %s is not a trait, Only traits may be used in 'as' and 'insteadof' statements" , ZSTR_VAL (trait -> name ));
2519
2513
return 0 ;
2520
2514
}
2521
2515
2522
- for (i = 0 ; i < ce -> num_traits ; i ++ ) {
2516
+ for (uint32_t i = 0 ; i < ce -> num_traits ; i ++ ) {
2523
2517
if (traits [i ] == trait ) {
2524
2518
return i ;
2525
2519
}
@@ -2532,7 +2526,6 @@ static uint32_t zend_check_trait_usage(zend_class_entry *ce, zend_class_entry *t
2532
2526
static void zend_traits_init_trait_structures (zend_class_entry * ce , zend_class_entry * * traits , HashTable * * * exclude_tables_ptr , zend_class_entry * * * aliases_ptr ) /* {{{ */
2533
2527
{
2534
2528
size_t i , j = 0 ;
2535
- zend_trait_precedence * * precedences ;
2536
2529
zend_trait_precedence * cur_precedence ;
2537
2530
zend_trait_method_reference * cur_method_ref ;
2538
2531
zend_string * lc_trait_name ;
@@ -2545,7 +2538,7 @@ static void zend_traits_init_trait_structures(zend_class_entry *ce, zend_class_e
2545
2538
if (ce -> trait_precedences ) {
2546
2539
exclude_tables = ecalloc (ce -> num_traits , sizeof (HashTable * ));
2547
2540
i = 0 ;
2548
- precedences = ce -> trait_precedences ;
2541
+ zend_trait_precedence * * precedences = ce -> trait_precedences ;
2549
2542
ce -> trait_precedences = NULL ;
2550
2543
while ((cur_precedence = precedences [i ])) {
2551
2544
/** Resolve classes for all precedence operations. */
@@ -2736,10 +2729,8 @@ static const zend_class_entry* find_first_constant_definition(const zend_class_e
2736
2729
* process like this is needed to find the location of the first definition
2737
2730
* of the constant from traits.
2738
2731
*/
2739
- size_t i ;
2740
-
2741
2732
if (colliding_ce == ce ) {
2742
- for (i = 0 ; i < current_trait ; i ++ ) {
2733
+ for (size_t i = 0 ; i < current_trait ; i ++ ) {
2743
2734
if (traits [i ]
2744
2735
&& zend_hash_exists (& traits [i ]-> constants_table , constant_name )) {
2745
2736
return traits [i ];
@@ -2806,9 +2797,7 @@ static bool do_trait_constant_check(
2806
2797
2807
2798
static void zend_do_traits_constant_binding (zend_class_entry * ce , zend_class_entry * * traits ) /* {{{ */
2808
2799
{
2809
- size_t i ;
2810
-
2811
- for (i = 0 ; i < ce -> num_traits ; i ++ ) {
2800
+ for (uint32_t i = 0 ; i < ce -> num_traits ; i ++ ) {
2812
2801
zend_string * constant_name ;
2813
2802
zend_class_constant * constant ;
2814
2803
@@ -2850,10 +2839,8 @@ static void zend_do_traits_constant_binding(zend_class_entry *ce, zend_class_ent
2850
2839
2851
2840
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 ) /* {{{ */
2852
2841
{
2853
- size_t i ;
2854
-
2855
2842
if (colliding_ce == ce ) {
2856
- for (i = 0 ; i < current_trait ; i ++ ) {
2843
+ for (size_t i = 0 ; i < current_trait ; i ++ ) {
2857
2844
if (traits [i ]
2858
2845
&& zend_hash_exists (& traits [i ]-> properties_info , prop_name )) {
2859
2846
return traits [i ];
@@ -2867,20 +2854,17 @@ static const zend_class_entry* find_first_property_definition(const zend_class_e
2867
2854
2868
2855
static void zend_do_traits_property_binding (zend_class_entry * ce , zend_class_entry * * traits ) /* {{{ */
2869
2856
{
2870
- size_t i ;
2871
2857
zend_property_info * property_info ;
2872
2858
const zend_property_info * colliding_prop ;
2873
- zend_property_info * new_prop ;
2874
2859
zend_string * prop_name ;
2875
2860
zval * prop_value ;
2876
- zend_string * doc_comment ;
2877
2861
2878
2862
/* In the following steps the properties are inserted into the property table
2879
2863
* for that, a very strict approach is applied:
2880
2864
* - check for compatibility, if not compatible with any property in class -> fatal
2881
2865
* - if compatible, then strict notice
2882
2866
*/
2883
- for (i = 0 ; i < ce -> num_traits ; i ++ ) {
2867
+ for (uint32_t i = 0 ; i < ce -> num_traits ; i ++ ) {
2884
2868
if (!traits [i ]) {
2885
2869
continue ;
2886
2870
}
@@ -2960,12 +2944,13 @@ static void zend_do_traits_property_binding(zend_class_entry *ce, zend_class_ent
2960
2944
prop_value = & tmp_prop_value ;
2961
2945
ZVAL_UNDEF (& tmp_prop_value );
2962
2946
}
2963
- doc_comment = property_info -> doc_comment ? zend_string_copy (property_info -> doc_comment ) : NULL ;
2947
+
2948
+ zend_string * doc_comment = property_info -> doc_comment ? zend_string_copy (property_info -> doc_comment ) : NULL ;
2964
2949
2965
2950
zend_type type = property_info -> type ;
2966
2951
/* Assumption: only userland classes can use traits, as such the type must be arena allocated */
2967
2952
zend_type_copy_ctor (& type , /* use arena */ true, /* persistent */ false);
2968
- new_prop = zend_declare_typed_property (ce , prop_name , prop_value , flags , doc_comment , type );
2953
+ zend_property_info * new_prop = zend_declare_typed_property (ce , prop_name , prop_value , flags , doc_comment , type );
2969
2954
2970
2955
if (property_info -> attributes ) {
2971
2956
new_prop -> attributes = property_info -> attributes ;
0 commit comments