summaryrefslogtreecommitdiff
path: root/Zend/zend_compile.c
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2021-01-25 16:18:11 +0100
committerNikita Popov <nikita.ppv@gmail.com>2021-01-25 16:18:11 +0100
commit6bc97b5921a7c76a6cc6b1e56cc1c0b5bc6b1e47 (patch)
tree3dfe46693fcc35b8bd3fcdec7da35fb222948ee2 /Zend/zend_compile.c
parentc8f809fcffc179614c10c149826b34a677a18689 (diff)
parent18507853cb727361ea09fca8a7e4458b9262b145 (diff)
downloadphp-git-6bc97b5921a7c76a6cc6b1e56cc1c0b5bc6b1e47.tar.gz
Merge branch 'PHP-8.0'
* PHP-8.0: Improve switch continue warning
Diffstat (limited to 'Zend/zend_compile.c')
-rw-r--r--Zend/zend_compile.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 90ab92251a..c671628479 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -4967,15 +4967,26 @@ void zend_compile_break_continue(zend_ast *ast) /* {{{ */
if (CG(context).brk_cont_array[cur].is_switch) {
if (depth == 1) {
- zend_error(E_WARNING,
- "\"continue\" targeting switch is equivalent to \"break\". " \
- "Did you mean to use \"continue " ZEND_LONG_FMT "\"?",
- depth + 1);
+ if (CG(context).brk_cont_array[cur].parent == -1) {
+ zend_error(E_WARNING,
+ "\"continue\" targeting switch is equivalent to \"break\"");
+ } else {
+ zend_error(E_WARNING,
+ "\"continue\" targeting switch is equivalent to \"break\". " \
+ "Did you mean to use \"continue " ZEND_LONG_FMT "\"?",
+ depth + 1);
+ }
} else {
- zend_error(E_WARNING,
- "\"continue " ZEND_LONG_FMT "\" targeting switch is equivalent to \"break " ZEND_LONG_FMT "\". " \
- "Did you mean to use \"continue " ZEND_LONG_FMT "\"?",
- depth, depth, depth + 1);
+ if (CG(context).brk_cont_array[cur].parent == -1) {
+ zend_error(E_WARNING,
+ "\"continue " ZEND_LONG_FMT "\" targeting switch is equivalent to \"break " ZEND_LONG_FMT "\"",
+ depth, depth);
+ } else {
+ zend_error(E_WARNING,
+ "\"continue " ZEND_LONG_FMT "\" targeting switch is equivalent to \"break " ZEND_LONG_FMT "\". " \
+ "Did you mean to use \"continue " ZEND_LONG_FMT "\"?",
+ depth, depth, depth + 1);
+ }
}
}
}