mirror of
https://github.com/php/php-src.git
synced 2025-08-15 13:38:49 +02:00
Deprecate terminating case statements with a semicolon (#19215)
Part of https://wiki.php.net/rfc/deprecations_php_8_5 Closes GH-15258
This commit is contained in:
parent
d01aa02ef5
commit
5f8d648af6
8 changed files with 22 additions and 11 deletions
2
NEWS
2
NEWS
|
@ -7,6 +7,8 @@ PHP NEWS
|
||||||
been deprecated. (Girgias)
|
been deprecated. (Girgias)
|
||||||
. The $exclude_disabled parameter of the get_defined_functions() function has
|
. The $exclude_disabled parameter of the get_defined_functions() function has
|
||||||
been deprecated, as it no longer has any effect since PHP 8.0. (Girgias)
|
been deprecated, as it no longer has any effect since PHP 8.0. (Girgias)
|
||||||
|
. Terminating case statements with a semicolon instead of a colon has
|
||||||
|
been deprecated. (theodorejb)
|
||||||
|
|
||||||
- DOM:
|
- DOM:
|
||||||
. Fixed bug GH-18877 (\Dom\HTMLDocument querySelectorAll selecting only the
|
. Fixed bug GH-18877 (\Dom\HTMLDocument querySelectorAll selecting only the
|
||||||
|
|
|
@ -322,6 +322,9 @@ PHP 8.5 UPGRADE NOTES
|
||||||
. The $exclude_disabled parameter of the get_defined_functions() function has
|
. The $exclude_disabled parameter of the get_defined_functions() function has
|
||||||
been deprecated, as it no longer has any effect since PHP 8.0.
|
been deprecated, as it no longer has any effect since PHP 8.0.
|
||||||
RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_the_exclude_disabled_parameter_of_get_defined_functions
|
RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_the_exclude_disabled_parameter_of_get_defined_functions
|
||||||
|
. Terminating case statements with a semicolon instead of a colon has
|
||||||
|
been deprecated.
|
||||||
|
RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_semicolon_after_case_in_switch_statement
|
||||||
|
|
||||||
- FileInfo:
|
- FileInfo:
|
||||||
. The finfo_close() function has been deprecated.
|
. The finfo_close() function has been deprecated.
|
||||||
|
|
|
@ -6313,6 +6313,11 @@ static void zend_compile_switch(zend_ast *ast) /* {{{ */
|
||||||
continue;
|
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);
|
zend_compile_expr(&cond_node, cond_ast);
|
||||||
|
|
||||||
if (expr_node.op_type == IS_CONST
|
if (expr_node.op_type == IS_CONST
|
||||||
|
|
|
@ -1127,6 +1127,7 @@ ZEND_API zend_string *zend_type_to_string(zend_type type);
|
||||||
((ZEND_TYPE_FULL_MASK((arg_info)->type) & _ZEND_IS_TENTATIVE_BIT) != 0)
|
((ZEND_TYPE_FULL_MASK((arg_info)->type) & _ZEND_IS_TENTATIVE_BIT) != 0)
|
||||||
|
|
||||||
#define ZEND_DIM_IS (1 << 0) /* isset fetch needed for null coalesce. Set in zend_compile.c for ZEND_AST_DIM nested within ZEND_AST_COALESCE. */
|
#define ZEND_DIM_IS (1 << 0) /* isset fetch needed for null coalesce. Set in zend_compile.c for ZEND_AST_DIM nested within ZEND_AST_COALESCE. */
|
||||||
|
#define ZEND_ALT_CASE_SYNTAX (1 << 1) /* deprecated switch case terminated by semicolon */
|
||||||
|
|
||||||
/* Attributes for ${} encaps var in strings (ZEND_AST_DIM or ZEND_AST_VAR node) */
|
/* Attributes for ${} encaps var in strings (ZEND_AST_DIM or ZEND_AST_VAR node) */
|
||||||
/* ZEND_AST_VAR nodes can have any of the ZEND_ENCAPS_VAR_* flags */
|
/* ZEND_AST_VAR nodes can have any of the ZEND_ENCAPS_VAR_* flags */
|
||||||
|
|
|
@ -713,15 +713,14 @@ switch_case_list:
|
||||||
|
|
||||||
case_list:
|
case_list:
|
||||||
%empty { $$ = zend_ast_create_list(0, ZEND_AST_SWITCH_LIST); }
|
%empty { $$ = zend_ast_create_list(0, ZEND_AST_SWITCH_LIST); }
|
||||||
| case_list T_CASE expr case_separator inner_statement_list
|
| case_list T_CASE expr ':' inner_statement_list
|
||||||
{ $$ = zend_ast_list_add($1, zend_ast_create(ZEND_AST_SWITCH_CASE, $3, $5)); }
|
{ $$ = zend_ast_list_add($1, zend_ast_create(ZEND_AST_SWITCH_CASE, $3, $5)); }
|
||||||
| case_list T_DEFAULT case_separator inner_statement_list
|
| case_list T_CASE expr ';' inner_statement_list
|
||||||
|
{ $$ = zend_ast_list_add($1, zend_ast_create_ex(ZEND_AST_SWITCH_CASE, ZEND_ALT_CASE_SYNTAX, $3, $5)); }
|
||||||
|
| case_list T_DEFAULT ':' inner_statement_list
|
||||||
{ $$ = zend_ast_list_add($1, zend_ast_create(ZEND_AST_SWITCH_CASE, NULL, $4)); }
|
{ $$ = zend_ast_list_add($1, zend_ast_create(ZEND_AST_SWITCH_CASE, NULL, $4)); }
|
||||||
;
|
| case_list T_DEFAULT ';' inner_statement_list
|
||||||
|
{ $$ = zend_ast_list_add($1, zend_ast_create_ex(ZEND_AST_SWITCH_CASE, ZEND_ALT_CASE_SYNTAX, NULL, $4)); }
|
||||||
case_separator:
|
|
||||||
':'
|
|
||||||
| ';'
|
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,9 +15,9 @@ class ZException extends Exception {
|
||||||
function dummy($query) {
|
function dummy($query) {
|
||||||
try {
|
try {
|
||||||
switch ($query) {
|
switch ($query) {
|
||||||
case 1;
|
case 1:
|
||||||
break;
|
break;
|
||||||
case 2;
|
case 2:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Exception('exception');
|
throw new Exception('exception');
|
||||||
|
|
|
@ -37,7 +37,8 @@ switch ($a):
|
||||||
break;
|
break;
|
||||||
endswitch;
|
endswitch;
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECTF--
|
||||||
|
Deprecated: Case statements followed by a semicolon (;) are deprecated, use a colon (:) instead in %s
|
||||||
If: 11
|
If: 11
|
||||||
While: 12346789
|
While: 12346789
|
||||||
For: 0123401234
|
For: 0123401234
|
||||||
|
|
|
@ -15,7 +15,7 @@ for ($i = 0; $i < $len; $i++) {
|
||||||
|
|
||||||
$str = '*';
|
$str = '*';
|
||||||
switch ($str[0]) {
|
switch ($str[0]) {
|
||||||
case '*';
|
case '*':
|
||||||
echo "OK\n";
|
echo "OK\n";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue