From 70e31e5eaf807475e66f4319d98a351471ad8edb Mon Sep 17 00:00:00 2001 From: Theodore Brown Date: Tue, 14 Oct 2025 22:42:15 -0500 Subject: [PATCH 1/2] Fix missing deprecation message for default case statement followed by semicolon Follow-up to GH-19215 --- Zend/zend_compile.c | 10 +++++----- tests/lang/033.phpt | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 8d6ca5a64346d..35228722aa986 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -6333,6 +6333,11 @@ static void zend_compile_switch(zend_ast *ast) /* {{{ */ zend_ast *cond_ast = case_ast->child[0]; znode cond_node; + if (case_ast->attr == ZEND_ALT_CASE_SYNTAX) { + CG(zend_lineno) = case_ast->lineno; + zend_error(E_DEPRECATED, "Case statements followed by a semicolon (;) are deprecated, use a colon (:) instead"); + } + if (!cond_ast) { if (has_default_case) { CG(zend_lineno) = case_ast->lineno; @@ -6343,11 +6348,6 @@ static void zend_compile_switch(zend_ast *ast) /* {{{ */ continue; } - if (case_ast->attr == ZEND_ALT_CASE_SYNTAX) { - CG(zend_lineno) = case_ast->lineno; - zend_error(E_DEPRECATED, "Case statements followed by a semicolon (;) are deprecated, use a colon (:) instead"); - } - zend_compile_expr(&cond_node, cond_ast); if (expr_node.op_type == IS_CONST diff --git a/tests/lang/033.phpt b/tests/lang/033.phpt index 41424e40489d6..a8a5837a5501e 100644 --- a/tests/lang/033.phpt +++ b/tests/lang/033.phpt @@ -38,6 +38,8 @@ switch ($a): endswitch; ?> --EXPECTF-- +Deprecated: Case statements followed by a semicolon (;) are deprecated, use a colon (:) instead in %s + Deprecated: Case statements followed by a semicolon (;) are deprecated, use a colon (:) instead in %s If: 11 While: 12346789 From 532e6d1e8a6722c306ac8c9c886387194e64b499 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Mon, 20 Oct 2025 08:40:27 +0200 Subject: [PATCH 2/2] NEWS --- NEWS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS b/NEWS index ac12a8098b71b..08daf17d21993 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,8 @@ PHP NEWS . Fixed bug GH-20113 (Missing new Foo(...) error in constant expressions). (ilutov) . Fixed bug GH-19844 (Don't bail when closing resources on shutdown). (ilutov) + . Fixed deprecation for default case statement followed by semicolon not + being emitted. (theodorejb) - DOM: . Fix getNamedItemNS() incorrect namespace check. (nielsdos)