Skip to content

Commit c03215b

Browse files
authored
Fix missing deprecation message for default case statement followed by semicolon (php#20172)
Follow-up to phpGH-19215
1 parent 3472174 commit c03215b

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ PHP NEWS
66
. Fixed bug GH-20113 (Missing new Foo(...) error in constant expressions).
77
(ilutov)
88
. Fixed bug GH-19844 (Don't bail when closing resources on shutdown). (ilutov)
9+
. Fixed deprecation for default case statement followed by semicolon not
10+
being emitted. (theodorejb)
911

1012
- DOM:
1113
. Fix getNamedItemNS() incorrect namespace check. (nielsdos)

Zend/zend_compile.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6333,6 +6333,11 @@ static void zend_compile_switch(zend_ast *ast) /* {{{ */
63336333
zend_ast *cond_ast = case_ast->child[0];
63346334
znode cond_node;
63356335

6336+
if (case_ast->attr == ZEND_ALT_CASE_SYNTAX) {
6337+
CG(zend_lineno) = case_ast->lineno;
6338+
zend_error(E_DEPRECATED, "Case statements followed by a semicolon (;) are deprecated, use a colon (:) instead");
6339+
}
6340+
63366341
if (!cond_ast) {
63376342
if (has_default_case) {
63386343
CG(zend_lineno) = case_ast->lineno;
@@ -6343,11 +6348,6 @@ static void zend_compile_switch(zend_ast *ast) /* {{{ */
63436348
continue;
63446349
}
63456350

6346-
if (case_ast->attr == ZEND_ALT_CASE_SYNTAX) {
6347-
CG(zend_lineno) = case_ast->lineno;
6348-
zend_error(E_DEPRECATED, "Case statements followed by a semicolon (;) are deprecated, use a colon (:) instead");
6349-
}
6350-
63516351
zend_compile_expr(&cond_node, cond_ast);
63526352

63536353
if (expr_node.op_type == IS_CONST

tests/lang/033.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ switch ($a):
3838
endswitch;
3939
?>
4040
--EXPECTF--
41+
Deprecated: Case statements followed by a semicolon (;) are deprecated, use a colon (:) instead in %s
42+
4143
Deprecated: Case statements followed by a semicolon (;) are deprecated, use a colon (:) instead in %s
4244
If: 11
4345
While: 12346789

0 commit comments

Comments
 (0)