@@ -706,7 +706,6 @@ ZEND_API inheritance_status zend_perform_covariant_type_check(
706706 }
707707 }
708708
709- zend_type * single_type ;
710709 inheritance_status early_exit_status ;
711710 bool have_unresolved = false;
712711
@@ -728,6 +727,7 @@ ZEND_API inheritance_status zend_perform_covariant_type_check(
728727 * We need to iterate over fe_type (U_i) first and the logic is independent of
729728 * whether proto_type is a union or intersection (only the inner check differs). */
730729 early_exit_status = INHERITANCE_ERROR ;
730+ zend_type * single_type ;
731731 ZEND_TYPE_FOREACH (fe_type , single_type ) {
732732 inheritance_status status ;
733733 /* Union has an intersection type as it's member */
@@ -790,7 +790,7 @@ static inheritance_status zend_do_perform_implementation_check(
790790 const zend_function * fe , zend_class_entry * fe_scope ,
791791 const zend_function * proto , zend_class_entry * proto_scope ) /* {{{ */
792792{
793- uint32_t i , num_args , proto_num_args , fe_num_args ;
793+ uint32_t num_args , proto_num_args , fe_num_args ;
794794 inheritance_status status , local_status ;
795795 bool proto_is_variadic , fe_is_variadic ;
796796
@@ -831,7 +831,7 @@ static inheritance_status zend_do_perform_implementation_check(
831831 num_args = MAX (proto_num_args , fe_num_args );
832832
833833 status = INHERITANCE_SUCCESS ;
834- for (i = 0 ; i < num_args ; i ++ ) {
834+ for (uint32_t i = 0 ; i < num_args ; i ++ ) {
835835 zend_arg_info * proto_arg_info =
836836 i < proto_num_args ? & proto -> common .arg_info [i ] :
837837 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(
933933 smart_str_appendc (& str , '(' );
934934
935935 if (fptr -> common .arg_info ) {
936- uint32_t i , num_args , required ;
936+ uint32_t num_args , required ;
937937 zend_arg_info * arg_info = fptr -> common .arg_info ;
938938
939939 required = fptr -> common .required_num_args ;
940940 num_args = fptr -> common .num_args ;
941941 if (fptr -> common .fn_flags & ZEND_ACC_VARIADIC ) {
942942 num_args ++ ;
943943 }
944- for (i = 0 ; i < num_args ;) {
944+ for (uint32_t i = 0 ; i < num_args ;) {
945945 zend_append_type_hint (& str , scope , arg_info , 0 );
946946
947947 if (ZEND_ARG_SEND_MODE (arg_info )) {
@@ -1451,10 +1451,9 @@ static prop_variance prop_get_variance(const zend_property_info *prop_info) {
14511451static void do_inherit_property (zend_property_info * parent_info , zend_string * key , zend_class_entry * ce ) /* {{{ */
14521452{
14531453 zval * child = zend_hash_find_known_hash (& ce -> properties_info , key );
1454- zend_property_info * child_info ;
14551454
14561455 if (UNEXPECTED (child )) {
1457- child_info = Z_PTR_P (child );
1456+ zend_property_info * child_info = Z_PTR_P (child );
14581457 if (parent_info -> flags & (ZEND_ACC_PRIVATE |ZEND_ACC_CHANGED )) {
14591458 child_info -> flags |= ZEND_ACC_CHANGED ;
14601459 }
@@ -1596,7 +1595,6 @@ static void zend_do_inherit_interfaces(zend_class_entry *ce, const zend_class_en
15961595{
15971596 /* expects interface to be contained in ce's interface list already */
15981597 uint32_t i , ce_num , if_num = iface -> num_interfaces ;
1599- zend_class_entry * entry ;
16001598
16011599 ce_num = ce -> num_interfaces ;
16021600
@@ -1608,7 +1606,7 @@ static void zend_do_inherit_interfaces(zend_class_entry *ce, const zend_class_en
16081606
16091607 /* Inherit the interfaces, only if they're not already inherited by the class */
16101608 while (if_num -- ) {
1611- entry = iface -> interfaces [if_num ];
1609+ zend_class_entry * entry = iface -> interfaces [if_num ];
16121610 for (i = 0 ; i < ce_num ; i ++ ) {
16131611 if (ce -> interfaces [i ] == entry ) {
16141612 break ;
@@ -1830,7 +1828,6 @@ static void zend_link_hooked_object_iter(zend_class_entry *ce) {
18301828ZEND_API void zend_do_inheritance_ex (zend_class_entry * ce , zend_class_entry * parent_ce , bool checked ) /* {{{ */
18311829{
18321830 zend_property_info * property_info ;
1833- zend_function * func ;
18341831 zend_string * key ;
18351832
18361833 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
20212018 if (!checked ) {
20222019 flags |= ZEND_INHERITANCE_CHECK_PROTO | ZEND_INHERITANCE_CHECK_VISIBILITY ;
20232020 }
2021+ zend_function * func ;
20242022 ZEND_HASH_MAP_FOREACH_STR_KEY_PTR (& parent_ce -> function_table , key , func ) {
20252023 do_inherit_method (key , func , ce , 0 , flags );
20262024 } ZEND_HASH_FOREACH_END ();
@@ -2196,15 +2194,13 @@ static void do_interface_implementation(zend_class_entry *ce, zend_class_entry *
21962194
21972195ZEND_API void zend_do_implement_interface (zend_class_entry * ce , zend_class_entry * iface ) /* {{{ */
21982196{
2199- uint32_t i , ignore = 0 ;
2197+ uint32_t ignore = 0 ;
22002198 uint32_t current_iface_num = ce -> num_interfaces ;
22012199 uint32_t parent_iface_num = ce -> parent ? ce -> parent -> num_interfaces : 0 ;
2202- zend_string * key ;
2203- zend_class_constant * c ;
22042200
22052201 ZEND_ASSERT (ce -> ce_flags & ZEND_ACC_LINKED );
22062202
2207- for (i = 0 ; i < ce -> num_interfaces ; i ++ ) {
2203+ for (uint32_t i = 0 ; i < ce -> num_interfaces ; i ++ ) {
22082204 if (ce -> interfaces [i ] == NULL ) {
22092205 memmove (ce -> interfaces + i , ce -> interfaces + i + 1 , sizeof (zend_class_entry * ) * (-- ce -> num_interfaces - i ));
22102206 i -- ;
@@ -2217,6 +2213,8 @@ ZEND_API void zend_do_implement_interface(zend_class_entry *ce, zend_class_entry
22172213 }
22182214 }
22192215 if (ignore ) {
2216+ zend_string * key ;
2217+ zend_class_constant * c ;
22202218 /* Check for attempt to redeclare interface constants */
22212219 ZEND_HASH_MAP_FOREACH_STR_KEY_PTR (& iface -> constants_table , key , c ) {
22222220 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
22382236
22392237static void zend_do_implement_interfaces (zend_class_entry * ce , zend_class_entry * * interfaces ) /* {{{ */
22402238{
2241- zend_class_entry * iface ;
22422239 uint32_t num_parent_interfaces = ce -> parent ? ce -> parent -> num_interfaces : 0 ;
22432240 uint32_t num_interfaces = num_parent_interfaces ;
22442241 zend_string * key ;
22452242 zend_class_constant * c ;
2246- uint32_t i , j ;
2243+ uint32_t i ;
22472244
22482245 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 ];
22502247 if (!(iface -> ce_flags & ZEND_ACC_LINKED )) {
22512248 add_dependency_obligation (ce , iface );
22522249 }
@@ -2255,7 +2252,7 @@ static void zend_do_implement_interfaces(zend_class_entry *ce, zend_class_entry
22552252 zend_error_noreturn (E_ERROR , "%s cannot implement %s - it is not an interface" , ZSTR_VAL (ce -> name ), ZSTR_VAL (iface -> name ));
22562253 return ;
22572254 }
2258- for (j = 0 ; j < num_interfaces ; j ++ ) {
2255+ for (uint32_t j = 0 ; j < num_interfaces ; j ++ ) {
22592256 if (interfaces [j ] == iface ) {
22602257 if (j >= num_parent_interfaces ) {
22612258 efree (interfaces );
@@ -2442,7 +2439,6 @@ static void zend_traits_check_private_final_inheritance(uint32_t original_fn_fla
24422439static void zend_traits_copy_functions (zend_string * fnname , zend_function * fn , zend_class_entry * ce , HashTable * exclude_table , zend_class_entry * * aliases ) /* {{{ */
24432440{
24442441 zend_trait_alias * alias , * * alias_ptr ;
2445- zend_string * lcname ;
24462442 zend_function fn_copy ;
24472443 int i ;
24482444
@@ -2466,7 +2462,7 @@ static void zend_traits_copy_functions(zend_string *fnname, zend_function *fn, z
24662462
24672463 zend_traits_check_private_final_inheritance (fn -> common .fn_flags , & fn_copy , alias -> alias );
24682464
2469- lcname = zend_string_tolower (alias -> alias );
2465+ zend_string * lcname = zend_string_tolower (alias -> alias );
24702466 zend_add_trait_method (ce , alias -> alias , lcname , & fn_copy );
24712467 zend_string_release_ex (lcname , 0 );
24722468 }
@@ -2512,14 +2508,12 @@ static void zend_traits_copy_functions(zend_string *fnname, zend_function *fn, z
25122508
25132509static uint32_t zend_check_trait_usage (zend_class_entry * ce , zend_class_entry * trait , zend_class_entry * * traits ) /* {{{ */
25142510{
2515- uint32_t i ;
2516-
25172511 if (UNEXPECTED ((trait -> ce_flags & ZEND_ACC_TRAIT ) != ZEND_ACC_TRAIT )) {
25182512 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 ));
25192513 return 0 ;
25202514 }
25212515
2522- for (i = 0 ; i < ce -> num_traits ; i ++ ) {
2516+ for (uint32_t i = 0 ; i < ce -> num_traits ; i ++ ) {
25232517 if (traits [i ] == trait ) {
25242518 return i ;
25252519 }
@@ -2532,7 +2526,6 @@ static uint32_t zend_check_trait_usage(zend_class_entry *ce, zend_class_entry *t
25322526static void zend_traits_init_trait_structures (zend_class_entry * ce , zend_class_entry * * traits , HashTable * * * exclude_tables_ptr , zend_class_entry * * * aliases_ptr ) /* {{{ */
25332527{
25342528 size_t i , j = 0 ;
2535- zend_trait_precedence * * precedences ;
25362529 zend_trait_precedence * cur_precedence ;
25372530 zend_trait_method_reference * cur_method_ref ;
25382531 zend_string * lc_trait_name ;
@@ -2545,7 +2538,7 @@ static void zend_traits_init_trait_structures(zend_class_entry *ce, zend_class_e
25452538 if (ce -> trait_precedences ) {
25462539 exclude_tables = ecalloc (ce -> num_traits , sizeof (HashTable * ));
25472540 i = 0 ;
2548- precedences = ce -> trait_precedences ;
2541+ zend_trait_precedence * * precedences = ce -> trait_precedences ;
25492542 ce -> trait_precedences = NULL ;
25502543 while ((cur_precedence = precedences [i ])) {
25512544 /** Resolve classes for all precedence operations. */
@@ -2736,10 +2729,8 @@ static const zend_class_entry* find_first_constant_definition(const zend_class_e
27362729 * process like this is needed to find the location of the first definition
27372730 * of the constant from traits.
27382731 */
2739- size_t i ;
2740-
27412732 if (colliding_ce == ce ) {
2742- for (i = 0 ; i < current_trait ; i ++ ) {
2733+ for (size_t i = 0 ; i < current_trait ; i ++ ) {
27432734 if (traits [i ]
27442735 && zend_hash_exists (& traits [i ]-> constants_table , constant_name )) {
27452736 return traits [i ];
@@ -2806,9 +2797,7 @@ static bool do_trait_constant_check(
28062797
28072798static void zend_do_traits_constant_binding (zend_class_entry * ce , zend_class_entry * * traits ) /* {{{ */
28082799{
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 ++ ) {
28122801 zend_string * constant_name ;
28132802 zend_class_constant * constant ;
28142803
@@ -2850,10 +2839,8 @@ static void zend_do_traits_constant_binding(zend_class_entry *ce, zend_class_ent
28502839
28512840static 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 ) /* {{{ */
28522841{
2853- size_t i ;
2854-
28552842 if (colliding_ce == ce ) {
2856- for (i = 0 ; i < current_trait ; i ++ ) {
2843+ for (size_t i = 0 ; i < current_trait ; i ++ ) {
28572844 if (traits [i ]
28582845 && zend_hash_exists (& traits [i ]-> properties_info , prop_name )) {
28592846 return traits [i ];
@@ -2867,20 +2854,17 @@ static const zend_class_entry* find_first_property_definition(const zend_class_e
28672854
28682855static void zend_do_traits_property_binding (zend_class_entry * ce , zend_class_entry * * traits ) /* {{{ */
28692856{
2870- size_t i ;
28712857 zend_property_info * property_info ;
28722858 const zend_property_info * colliding_prop ;
2873- zend_property_info * new_prop ;
28742859 zend_string * prop_name ;
28752860 zval * prop_value ;
2876- zend_string * doc_comment ;
28772861
28782862 /* In the following steps the properties are inserted into the property table
28792863 * for that, a very strict approach is applied:
28802864 * - check for compatibility, if not compatible with any property in class -> fatal
28812865 * - if compatible, then strict notice
28822866 */
2883- for (i = 0 ; i < ce -> num_traits ; i ++ ) {
2867+ for (uint32_t i = 0 ; i < ce -> num_traits ; i ++ ) {
28842868 if (!traits [i ]) {
28852869 continue ;
28862870 }
@@ -2960,12 +2944,13 @@ static void zend_do_traits_property_binding(zend_class_entry *ce, zend_class_ent
29602944 prop_value = & tmp_prop_value ;
29612945 ZVAL_UNDEF (& tmp_prop_value );
29622946 }
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 ;
29642949
29652950 zend_type type = property_info -> type ;
29662951 /* Assumption: only userland classes can use traits, as such the type must be arena allocated */
29672952 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 );
29692954
29702955 if (property_info -> attributes ) {
29712956 new_prop -> attributes = property_info -> attributes ;
0 commit comments