Skip to content

Commit bcf9d1e

Browse files
committed
new_variable '{' expr '}' is deprecated as well
Curly brace syntax for accessing array elements and string offsets is deprecated [1]; this should also be the case for respective `new` expressions. This issue has been reported by [email protected]. [1] <https://wiki.php.net/rfc/deprecate_curly_braces_array_access>
1 parent 51fd8bd commit bcf9d1e

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

Zend/tests/varSyntax/newVariable.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ var_dump(new $weird[0]->foo::$className);
2323

2424
?>
2525
--EXPECTF--
26+
Deprecated: Array and string offset access syntax with curly braces is deprecated in %s on line %d
2627
object(stdClass)#%d (0) {
2728
}
2829
object(stdClass)#%d (0) {

Zend/zend_language_parser.y

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1189,7 +1189,7 @@ new_variable:
11891189
| new_variable '[' optional_expr ']'
11901190
{ $$ = zend_ast_create(ZEND_AST_DIM, $1, $3); }
11911191
| new_variable '{' expr '}'
1192-
{ $$ = zend_ast_create(ZEND_AST_DIM, $1, $3); }
1192+
{ $$ = zend_ast_create_ex(ZEND_AST_DIM, ZEND_DIM_ALTERNATIVE_SYNTAX, $1, $3); }
11931193
| new_variable T_OBJECT_OPERATOR property_name
11941194
{ $$ = zend_ast_create(ZEND_AST_PROP, $1, $3); }
11951195
| class_name T_PAAMAYIM_NEKUDOTAYIM simple_variable

0 commit comments

Comments
 (0)