Skip to content

Commit 40804a6

Browse files
authored
tree-wide: Add explicit braces around FOREACH body (#21651)
Places searched with: .*FOREACH.*\(.+\)\s*(?!\{)\n and then manually adjusted.
1 parent 19eabc6 commit 40804a6

File tree

4 files changed

+24
-24
lines changed

4 files changed

+24
-24
lines changed

Zend/zend_compile.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7472,15 +7472,15 @@ static void zend_are_intersection_types_redundant(const zend_type left_type, con
74727472

74737473
unsigned int sum = 0;
74747474
const zend_type *outer_type;
7475-
ZEND_TYPE_LIST_FOREACH(smaller_type_list, outer_type)
7475+
ZEND_TYPE_LIST_FOREACH(smaller_type_list, outer_type) {
74767476
const zend_type *inner_type;
7477-
ZEND_TYPE_LIST_FOREACH(larger_type_list, inner_type)
7477+
ZEND_TYPE_LIST_FOREACH(larger_type_list, inner_type) {
74787478
if (zend_string_equals_ci(ZEND_TYPE_NAME(*inner_type), ZEND_TYPE_NAME(*outer_type))) {
74797479
sum++;
74807480
break;
74817481
}
7482-
ZEND_TYPE_LIST_FOREACH_END();
7483-
ZEND_TYPE_LIST_FOREACH_END();
7482+
} ZEND_TYPE_LIST_FOREACH_END();
7483+
} ZEND_TYPE_LIST_FOREACH_END();
74847484

74857485
if (sum == smaller_type_list->num_types) {
74867486
zend_string *smaller_type_str;
@@ -7508,14 +7508,14 @@ static void zend_is_intersection_type_redundant_by_single_type(const zend_type i
75087508
ZEND_ASSERT(!ZEND_TYPE_IS_INTERSECTION(single_type));
75097509

75107510
const zend_type *single_intersection_type = NULL;
7511-
ZEND_TYPE_FOREACH(intersection_type, single_intersection_type)
7511+
ZEND_TYPE_FOREACH(intersection_type, single_intersection_type) {
75127512
if (zend_string_equals_ci(ZEND_TYPE_NAME(*single_intersection_type), ZEND_TYPE_NAME(single_type))) {
75137513
zend_string *single_type_str = zend_type_to_string(single_type);
75147514
zend_string *complete_type = zend_type_to_string(intersection_type);
75157515
zend_error_noreturn(E_COMPILE_ERROR, "Type %s is redundant as it is more restrictive than type %s",
75167516
ZSTR_VAL(complete_type), ZSTR_VAL(single_type_str));
75177517
}
7518-
ZEND_TYPE_FOREACH_END();
7518+
} ZEND_TYPE_FOREACH_END();
75197519
}
75207520

75217521
/* Used by both intersection and union types prior to transforming the type list to a full zend_type */
@@ -8465,7 +8465,7 @@ static void compile_implicit_lexical_binds(
84658465
op_array->static_variables = zend_new_array(8);
84668466
}
84678467

8468-
ZEND_HASH_MAP_FOREACH_STR_KEY(&info->uses, var_name)
8468+
ZEND_HASH_MAP_FOREACH_STR_KEY(&info->uses, var_name) {
84698469
zval *value = zend_hash_add(
84708470
op_array->static_variables, var_name, &EG(uninitialized_zval));
84718471
uint32_t offset = (uint32_t)((char*)value - (char*)op_array->static_variables->arData);
@@ -8474,7 +8474,7 @@ static void compile_implicit_lexical_binds(
84748474
opline->op2_type = IS_CV;
84758475
opline->op2.var = lookup_cv(var_name);
84768476
opline->extended_value = offset | ZEND_BIND_IMPLICIT;
8477-
ZEND_HASH_FOREACH_END();
8477+
} ZEND_HASH_FOREACH_END();
84788478
}
84798479

84808480
static void zend_compile_closure_uses(zend_ast *ast) /* {{{ */
@@ -8514,11 +8514,11 @@ static void zend_compile_closure_uses(zend_ast *ast) /* {{{ */
85148514
static void zend_compile_implicit_closure_uses(const closure_info *info)
85158515
{
85168516
zend_string *var_name;
8517-
ZEND_HASH_MAP_FOREACH_STR_KEY(&info->uses, var_name)
8517+
ZEND_HASH_MAP_FOREACH_STR_KEY(&info->uses, var_name) {
85188518
zval zv;
85198519
ZVAL_NULL(&zv);
85208520
zend_compile_static_var_common(var_name, &zv, ZEND_BIND_IMPLICIT);
8521-
ZEND_HASH_FOREACH_END();
8521+
} ZEND_HASH_FOREACH_END();
85228522
}
85238523

85248524
static void add_stringable_interface(zend_class_entry *ce) {

ext/standard/basic_functions.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,9 +1283,9 @@ static void add_config_entries(HashTable *hash, zval *return_value) /* {{{ */
12831283
zend_string *key;
12841284
zval *zv;
12851285

1286-
ZEND_HASH_FOREACH_KEY_VAL(hash, h, key, zv)
1286+
ZEND_HASH_FOREACH_KEY_VAL(hash, h, key, zv) {
12871287
add_config_entry(h, key, zv, return_value);
1288-
ZEND_HASH_FOREACH_END();
1288+
} ZEND_HASH_FOREACH_END();
12891289
}
12901290
/* }}} */
12911291

sapi/apache2handler/php_functions.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,10 @@ PHP_FUNCTION(apache_request_headers)
179179
ctx = SG(server_context);
180180
arr = apr_table_elts(ctx->r->headers_in);
181181

182-
APR_ARRAY_FOREACH_OPEN(arr, key, val)
182+
APR_ARRAY_FOREACH_OPEN(arr, key, val) {
183183
if (!val) val = "";
184184
add_assoc_string(return_value, key, val);
185-
APR_ARRAY_FOREACH_CLOSE()
185+
} APR_ARRAY_FOREACH_CLOSE();
186186
}
187187
/* }}} */
188188

@@ -200,10 +200,10 @@ PHP_FUNCTION(apache_response_headers)
200200
ctx = SG(server_context);
201201
arr = apr_table_elts(ctx->r->headers_out);
202202

203-
APR_ARRAY_FOREACH_OPEN(arr, key, val)
203+
APR_ARRAY_FOREACH_OPEN(arr, key, val) {
204204
if (!val) val = "";
205205
add_assoc_string(return_value, key, val);
206-
APR_ARRAY_FOREACH_CLOSE()
206+
} APR_ARRAY_FOREACH_CLOSE();
207207
}
208208
/* }}} */
209209

@@ -411,12 +411,12 @@ PHP_MINFO_FUNCTION(apache)
411411
SECTION("Apache Environment");
412412
php_info_print_table_start();
413413
php_info_print_table_header(2, "Variable", "Value");
414-
APR_ARRAY_FOREACH_OPEN(arr, key, val)
414+
APR_ARRAY_FOREACH_OPEN(arr, key, val) {
415415
if (!val) {
416416
val = "";
417417
}
418418
php_info_print_table_row(2, key, val);
419-
APR_ARRAY_FOREACH_CLOSE()
419+
} APR_ARRAY_FOREACH_CLOSE();
420420

421421
php_info_print_table_end();
422422

@@ -426,21 +426,21 @@ PHP_MINFO_FUNCTION(apache)
426426
php_info_print_table_row(2, "HTTP Request", ((php_struct *) SG(server_context))->r->the_request);
427427

428428
arr = apr_table_elts(((php_struct *) SG(server_context))->r->headers_in);
429-
APR_ARRAY_FOREACH_OPEN(arr, key, val)
429+
APR_ARRAY_FOREACH_OPEN(arr, key, val) {
430430
if (!val) {
431431
val = "";
432432
}
433433
php_info_print_table_row(2, key, val);
434-
APR_ARRAY_FOREACH_CLOSE()
434+
} APR_ARRAY_FOREACH_CLOSE();
435435

436436
php_info_print_table_colspan_header(2, "HTTP Response Headers");
437437
arr = apr_table_elts(((php_struct *) SG(server_context))->r->headers_out);
438-
APR_ARRAY_FOREACH_OPEN(arr, key, val)
438+
APR_ARRAY_FOREACH_OPEN(arr, key, val) {
439439
if (!val) {
440440
val = "";
441441
}
442442
php_info_print_table_row(2, key, val);
443-
APR_ARRAY_FOREACH_CLOSE()
443+
} APR_ARRAY_FOREACH_CLOSE();
444444

445445
php_info_print_table_end();
446446
}

sapi/apache2handler/sapi_apache2.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,14 +269,14 @@ php_apache_sapi_register_variables(zval *track_vars_array)
269269
char *key, *val;
270270
size_t new_val_len;
271271

272-
APR_ARRAY_FOREACH_OPEN(arr, key, val)
272+
APR_ARRAY_FOREACH_OPEN(arr, key, val) {
273273
if (!val) {
274274
val = "";
275275
}
276276
if (sapi_module.input_filter(PARSE_SERVER, key, &val, strlen(val), &new_val_len)) {
277277
php_register_variable_safe(key, val, new_val_len, track_vars_array);
278278
}
279-
APR_ARRAY_FOREACH_CLOSE()
279+
} APR_ARRAY_FOREACH_CLOSE();
280280

281281
if (sapi_module.input_filter(PARSE_SERVER, "PHP_SELF", &ctx->r->uri, strlen(ctx->r->uri), &new_val_len)) {
282282
php_register_variable_safe("PHP_SELF", ctx->r->uri, new_val_len, track_vars_array);

0 commit comments

Comments
 (0)