summaryrefslogtreecommitdiff
path: root/Zend/zend_compile.c
diff options
context:
space:
mode:
authorrjhdby <andrewgrom@rambler.ru>2019-03-13 13:51:31 +0300
committerNikita Popov <nikita.ppv@gmail.com>2019-07-19 10:06:10 +0200
commitd574df63dc375f5fc9202ce5afde23f866b6450a (patch)
tree5fd118cf3045f46cef4de60235a6bc9e980ac4a9 /Zend/zend_compile.c
parentd5943f5a11976ffbe89b9634b86d9a0b2adda30a (diff)
downloadphp-git-d574df63dc375f5fc9202ce5afde23f866b6450a.tar.gz
Deprecate alternative array access syntax
RFC: https://wiki.php.net/rfc/deprecate_curly_braces_array_access
Diffstat (limited to 'Zend/zend_compile.c')
-rw-r--r--Zend/zend_compile.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 59dea8664b..07a987aeef 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -2371,6 +2371,10 @@ static inline void zend_emit_assign_znode(zend_ast *var_ast, znode *value_node)
static zend_op *zend_delayed_compile_dim(znode *result, zend_ast *ast, uint32_t type) /* {{{ */
{
+ if (ast->attr == ZEND_DIM_ALTERNATIVE_SYNTAX) {
+ zend_error(E_DEPRECATED, "Array and string offset access syntax with curly braces is deprecated");
+ }
+
zend_ast *var_ast = ast->child[0];
zend_ast *dim_ast = ast->child[1];
zend_op *opline;
@@ -8745,7 +8749,7 @@ void zend_eval_const_expr(zend_ast **ast_ptr) /* {{{ */
case ZEND_AST_COALESCE:
/* Set isset fetch indicator here, opcache disallows runtime altering of the AST */
if (ast->child[0]->kind == ZEND_AST_DIM) {
- ast->child[0]->attr = ZEND_DIM_IS;
+ ast->child[0]->attr |= ZEND_DIM_IS;
}
zend_eval_const_expr(&ast->child[0]);
@@ -8799,9 +8803,14 @@ void zend_eval_const_expr(zend_ast **ast_ptr) /* {{{ */
zend_error_noreturn(E_COMPILE_ERROR, "Cannot use [] for reading");
}
+ if (ast->attr & ZEND_DIM_ALTERNATIVE_SYNTAX) {
+ ast->attr &= ~ZEND_DIM_ALTERNATIVE_SYNTAX; /* remove flag to avoid duplicate warning */
+ zend_error(E_DEPRECATED, "Array and string offset access syntax with curly braces is deprecated");
+ }
+
/* Set isset fetch indicator here, opcache disallows runtime altering of the AST */
- if (ast->attr == ZEND_DIM_IS && ast->child[0]->kind == ZEND_AST_DIM) {
- ast->child[0]->attr = ZEND_DIM_IS;
+ if (ast->attr & ZEND_DIM_IS && ast->child[0]->kind == ZEND_AST_DIM) {
+ ast->child[0]->attr |= ZEND_DIM_IS;
}
zend_eval_const_expr(&ast->child[0]);