Skip to content

Commit c9b1759

Browse files
committed
Zend: Use true / false instead of 1 / 0 for bool parameters
Changes done with Coccinelle: @r1@ identifier F; identifier p; typedef bool; parameter list [n1] PL1; parameter list [n2] PL2; @@ F(PL1, bool p, PL2) { ... } @r2@ identifier r1.F; expression list [r1.n1] EL1; expression list [r1.n2] EL2; @@ F(EL1, ( - 1 + true | - 0 + false ) , EL2)
1 parent fb2f7fe commit c9b1759

19 files changed

+133
-132
lines changed

Zend/zend.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ static void zend_print_zval_r_to_buf(smart_str *buf, zval *expr, int indent) /*
553553
}
554554
GC_PROTECT_RECURSION(Z_ARRVAL_P(expr));
555555
}
556-
print_hash(buf, Z_ARRVAL_P(expr), indent, 0);
556+
print_hash(buf, Z_ARRVAL_P(expr), indent, false);
557557
GC_TRY_UNPROTECT_RECURSION(Z_ARRVAL_P(expr));
558558
break;
559559
case IS_OBJECT:
@@ -583,12 +583,12 @@ static void zend_print_zval_r_to_buf(smart_str *buf, zval *expr, int indent) /*
583583
}
584584

585585
if ((properties = zend_get_properties_for(expr, ZEND_PROP_PURPOSE_DEBUG)) == NULL) {
586-
print_hash(buf, (HashTable*) &zend_empty_array, indent, 1);
586+
print_hash(buf, (HashTable*) &zend_empty_array, indent, true);
587587
break;
588588
}
589589

590590
ZEND_GUARD_OR_GC_PROTECT_RECURSION(guard, DEBUG, zobj);
591-
print_hash(buf, properties, indent, 1);
591+
print_hash(buf, properties, indent, true);
592592
ZEND_GUARD_OR_GC_UNPROTECT_RECURSION(guard, DEBUG, zobj);
593593

594594
zend_release_properties(properties);

Zend/zend_API.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4320,7 +4320,7 @@ ZEND_API void zend_fcall_info_args_save(zend_fcall_info *fci, uint32_t *param_co
43204320

43214321
ZEND_API void zend_fcall_info_args_restore(zend_fcall_info *fci, uint32_t param_count, zval *params) /* {{{ */
43224322
{
4323-
zend_fcall_info_args_clear(fci, 1);
4323+
zend_fcall_info_args_clear(fci, true);
43244324
fci->param_count = param_count;
43254325
fci->params = params;
43264326
}

Zend/zend_ast.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2139,7 +2139,7 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
21392139
case ZEND_AST_CLASS:
21402140
decl = (const zend_ast_decl *) ast;
21412141
if (decl->child[3]) {
2142-
zend_ast_export_attributes(str, decl->child[3], indent, 1);
2142+
zend_ast_export_attributes(str, decl->child[3], indent, true);
21432143
}
21442144
if (decl->flags & ZEND_ACC_INTERFACE) {
21452145
smart_str_appends(str, "interface ");
@@ -2173,11 +2173,11 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
21732173
case ZEND_AST_EXPR_LIST:
21742174
case ZEND_AST_PARAM_LIST:
21752175
simple_list:
2176-
zend_ast_export_list(str, zend_ast_get_list(ast), 1, 20, indent);
2176+
zend_ast_export_list(str, zend_ast_get_list(ast), true, 20, indent);
21772177
break;
21782178
case ZEND_AST_ARRAY:
21792179
smart_str_appendc(str, '[');
2180-
zend_ast_export_list(str, zend_ast_get_list(ast), 1, 20, indent);
2180+
zend_ast_export_list(str, zend_ast_get_list(ast), true, 20, indent);
21812181
smart_str_appendc(str, ']');
21822182
break;
21832183
case ZEND_AST_ENCAPS_LIST:
@@ -2195,7 +2195,7 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
21952195
case ZEND_AST_SWITCH_LIST:
21962196
case ZEND_AST_CATCH_LIST:
21972197
case ZEND_AST_MATCH_ARM_LIST:
2198-
zend_ast_export_list(str, zend_ast_get_list(ast), 0, 0, indent);
2198+
zend_ast_export_list(str, zend_ast_get_list(ast), false, 0, indent);
21992199
break;
22002200
case ZEND_AST_CLOSURE_USES:
22012201
smart_str_appends(str, " use(");
@@ -2207,7 +2207,7 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
22072207
zend_ast *prop_ast = ast->child[1];
22082208

22092209
if (ast->child[2]) {
2210-
zend_ast_export_attributes(str, ast->child[2], indent, 1);
2210+
zend_ast_export_attributes(str, ast->child[2], indent, true);
22112211
}
22122212

22132213
zend_ast_export_visibility(str, ast->attr, ZEND_MODIFIER_TARGET_PROPERTY);
@@ -2236,21 +2236,21 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
22362236
str,
22372237
ast_list->child[ast_list->children - 1],
22382238
indent,
2239-
1
2239+
true
22402240
);
22412241
/* So that the list printing doesn't try to print the attributes,
22422242
* use zend_ast_export_list_ex() to override the number of children
22432243
* to print. */
22442244
smart_str_appends(str, "const ");
2245-
zend_ast_export_list_ex(str, ast_list, 1, 20, indent, ast_list->children - 1);
2245+
zend_ast_export_list_ex(str, ast_list, true, 20, indent, ast_list->children - 1);
22462246
break;
22472247
}
22482248
smart_str_appends(str, "const ");
22492249
goto simple_list;
22502250
}
22512251
case ZEND_AST_CLASS_CONST_GROUP:
22522252
if (ast->child[1]) {
2253-
zend_ast_export_attributes(str, ast->child[1], indent, 1);
2253+
zend_ast_export_attributes(str, ast->child[1], indent, true);
22542254
}
22552255

22562256
zend_ast_export_visibility(str, ast->attr, ZEND_MODIFIER_TARGET_CONSTANT);
@@ -2534,7 +2534,7 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
25342534
if (ast->child[0]->kind == ZEND_AST_CLASS) {
25352535
const zend_ast_decl *decl = (const zend_ast_decl *) ast->child[0];
25362536
if (decl->child[3]) {
2537-
zend_ast_export_attributes(str, decl->child[3], indent, 0);
2537+
zend_ast_export_attributes(str, decl->child[3], indent, false);
25382538
}
25392539
smart_str_appends(str, "class");
25402540
if (!zend_ast_is_list(ast->child[1])
@@ -2635,7 +2635,7 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
26352635
case ZEND_AST_MATCH_ARM:
26362636
zend_ast_export_indent(str, indent);
26372637
if (ast->child[0]) {
2638-
zend_ast_export_list(str, zend_ast_get_list(ast->child[0]), 1, 0, indent);
2638+
zend_ast_export_list(str, zend_ast_get_list(ast->child[0]), true, 0, indent);
26392639
smart_str_appends(str, " => ");
26402640
} else {
26412641
smart_str_appends(str, "default => ");
@@ -2646,7 +2646,7 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
26462646
case ZEND_AST_DECLARE:
26472647
smart_str_appends(str, "declare(");
26482648
ZEND_ASSERT(ast->child[0]->kind == ZEND_AST_CONST_DECL);
2649-
zend_ast_export_list(str, zend_ast_get_list(ast->child[0]), 1, 0, indent);
2649+
zend_ast_export_list(str, zend_ast_get_list(ast->child[0]), true, 0, indent);
26502650
smart_str_appendc(str, ')');
26512651
if (ast->child[1]) {
26522652
smart_str_appends(str, " {\n");
@@ -2793,7 +2793,7 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
27932793
break;
27942794
case ZEND_AST_PARAM:
27952795
if (ast->child[3]) {
2796-
zend_ast_export_attributes(str, ast->child[3], indent, 0);
2796+
zend_ast_export_attributes(str, ast->child[3], indent, false);
27972797
}
27982798
zend_ast_export_visibility(str, ast->attr, ZEND_MODIFIER_TARGET_CPP);
27992799
if (ast->attr & ZEND_ACC_FINAL) {
@@ -2821,7 +2821,7 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
28212821
break;
28222822
case ZEND_AST_ENUM_CASE:
28232823
if (ast->child[3]) {
2824-
zend_ast_export_attributes(str, ast->child[3], indent, 1);
2824+
zend_ast_export_attributes(str, ast->child[3], indent, true);
28252825
}
28262826
smart_str_appends(str, "case ");
28272827
zend_ast_export_name(str, ast->child[0], 0, indent);

Zend/zend_builtin_functions.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -824,8 +824,8 @@ ZEND_FUNCTION(get_class_vars)
824824
}
825825

826826
scope = zend_get_executed_scope();
827-
add_class_vars(scope, ce, 0, return_value);
828-
add_class_vars(scope, ce, 1, return_value);
827+
add_class_vars(scope, ce, false, return_value);
828+
add_class_vars(scope, ce, true, return_value);
829829
}
830830
/* }}} */
831831

0 commit comments

Comments
 (0)