Skip to content

Commit 8b69093

Browse files
committed
Implement directly in parser to avoid compiler complications
1 parent 292c23c commit 8b69093

File tree

4 files changed

+13
-17
lines changed

4 files changed

+13
-17
lines changed

Zend/zend_ast.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ ZEND_API int ZEND_FASTCALL zend_ast_evaluate(zval *result, zend_ast *ast, zend_c
714714
zval_ptr_dtor_nogc(&op1);
715715
ret = FAILURE;
716716
} else {
717-
zend_fetch_dimension_const(result, &op1, &op2, (ast->attr & ZEND_DIM_IS) ? BP_VAR_IS : BP_VAR_R);
717+
zend_fetch_dimension_const(result, &op1, &op2, (ast->attr == ZEND_DIM_IS) ? BP_VAR_IS : BP_VAR_R);
718718

719719
zval_ptr_dtor_nogc(&op1);
720720
zval_ptr_dtor_nogc(&op2);

Zend/zend_compile.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2371,10 +2371,6 @@ static inline void zend_emit_assign_znode(zend_ast *var_ast, znode *value_node)
23712371

23722372
static zend_op *zend_delayed_compile_dim(znode *result, zend_ast *ast, uint32_t type) /* {{{ */
23732373
{
2374-
if (ast->attr == ZEND_ALTERNATIVE_ARRAY_SYNTAX) {
2375-
zend_error(E_DEPRECATED, "Array and string offset access syntax with curly braces is deprecated");
2376-
}
2377-
23782374
zend_ast *var_ast = ast->child[0];
23792375
zend_ast *dim_ast = ast->child[1];
23802376
zend_op *opline;
@@ -8748,7 +8744,7 @@ void zend_eval_const_expr(zend_ast **ast_ptr) /* {{{ */
87488744
case ZEND_AST_COALESCE:
87498745
/* Set isset fetch indicator here, opcache disallows runtime altering of the AST */
87508746
if (ast->child[0]->kind == ZEND_AST_DIM) {
8751-
ast->child[0]->attr |= ZEND_DIM_IS;
8747+
ast->child[0]->attr = ZEND_DIM_IS;
87528748
}
87538749
zend_eval_const_expr(&ast->child[0]);
87548750

@@ -8802,13 +8798,9 @@ void zend_eval_const_expr(zend_ast **ast_ptr) /* {{{ */
88028798
zend_error_noreturn(E_COMPILE_ERROR, "Cannot use [] for reading");
88038799
}
88048800

8805-
if (ast->attr & ZEND_ALTERNATIVE_ARRAY_SYNTAX) {
8806-
zend_error(E_DEPRECATED, "Array and string offset access syntax with curly braces is deprecated");
8807-
}
8808-
88098801
/* Set isset fetch indicator here, opcache disallows runtime altering of the AST */
8810-
if (ast->attr & ZEND_DIM_IS && ast->child[0]->kind == ZEND_AST_DIM) {
8811-
ast->child[0]->attr |= ZEND_DIM_IS;
8802+
if (ast->attr == ZEND_DIM_IS && ast->child[0]->kind == ZEND_AST_DIM) {
8803+
ast->child[0]->attr = ZEND_DIM_IS;
88128804
}
88138805

88148806
zend_eval_const_expr(&ast->child[0]);

Zend/zend_compile.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -991,9 +991,6 @@ static zend_always_inline int zend_check_arg_send_type(const zend_function *zf,
991991
#define ZEND_ARRAY_NOT_PACKED (1<<1)
992992
#define ZEND_ARRAY_SIZE_SHIFT 2
993993

994-
/* Array/string access syntax with curly braces is used */
995-
#define ZEND_ALTERNATIVE_ARRAY_SYNTAX 2
996-
997994
/* Attribute for ternary inside parentheses */
998995
#define ZEND_PARENTHESIZED_CONDITIONAL 1
999996

Zend/zend_language_parser.y

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,7 +1155,10 @@ callable_variable:
11551155
| constant '[' optional_expr ']'
11561156
{ $$ = zend_ast_create(ZEND_AST_DIM, $1, $3); }
11571157
| dereferencable '{' expr '}'
1158-
{ $$ = zend_ast_create_ex(ZEND_AST_DIM, ZEND_ALTERNATIVE_ARRAY_SYNTAX, $1, $3); }
1158+
{
1159+
$$ = zend_ast_create(ZEND_AST_DIM, $1, $3);
1160+
zend_error(E_DEPRECATED, "Array and string offset access syntax with curly braces is deprecated");
1161+
}
11591162
| dereferencable T_OBJECT_OPERATOR property_name argument_list
11601163
{ $$ = zend_ast_create(ZEND_AST_METHOD_CALL, $1, $3, $4); }
11611164
| function_call { $$ = $1; }
@@ -1273,7 +1276,11 @@ encaps_var:
12731276
| T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '[' expr ']' '}'
12741277
{ $$ = zend_ast_create(ZEND_AST_DIM,
12751278
zend_ast_create(ZEND_AST_VAR, $2), $4); }
1276-
| T_CURLY_OPEN variable '}' { $$ = $2; }
1279+
| T_CURLY_OPEN variable '}'
1280+
{
1281+
$$ = $2;
1282+
zend_error(E_DEPRECATED, "Array and string offset access syntax with curly braces is deprecated");
1283+
}
12771284
;
12781285

12791286
encaps_var_offset:

0 commit comments

Comments
 (0)