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) 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