Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions Zend/zend_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions tests/lang/033.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down