Skip to content

Commit 61ee869

Browse files
committed
Change the precedence of concatenation
This implements RFC https://wiki.php.net/rfc/concatenation_precedence
1 parent a3b2425 commit 61ee869

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Zend/zend_ast.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -871,8 +871,9 @@ ZEND_API void zend_ast_apply(zend_ast *ast, zend_ast_apply_func fn) {
871871
* 160 left &
872872
* 170 non-associative == != === !==
873873
* 180 non-associative < <= > >= <=>
874+
* 185 left .
874875
* 190 left << >>
875-
* 200 left + - .
876+
* 200 left + -
876877
* 210 left * / %
877878
* 220 right !
878879
* 230 non-associative instanceof
@@ -1682,7 +1683,7 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
16821683
case ZEND_MOD: BINARY_OP(" % ", 210, 210, 211);
16831684
case ZEND_SL: BINARY_OP(" << ", 190, 190, 191);
16841685
case ZEND_SR: BINARY_OP(" >> ", 190, 190, 191);
1685-
case ZEND_CONCAT: BINARY_OP(" . ", 200, 200, 201);
1686+
case ZEND_CONCAT: BINARY_OP(" . ", 185, 185, 186);
16861687
case ZEND_BW_OR: BINARY_OP(" | ", 140, 140, 141);
16871688
case ZEND_BW_AND: BINARY_OP(" & ", 160, 160, 161);
16881689
case ZEND_BW_XOR: BINARY_OP(" ^ ", 150, 150, 151);

Zend/zend_language_parser.y

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ static YYSIZE_T zend_yytnamerr(char*, const char*);
6969
%left '&'
7070
%nonassoc T_IS_EQUAL T_IS_NOT_EQUAL T_IS_IDENTICAL T_IS_NOT_IDENTICAL T_SPACESHIP
7171
%nonassoc '<' T_IS_SMALLER_OR_EQUAL '>' T_IS_GREATER_OR_EQUAL
72+
%left '.'
7273
%left T_SL T_SR
73-
%left '+' '-' '.'
74+
%left '+' '-'
7475
%left '*' '/' '%'
7576
%precedence '!'
7677
%precedence T_INSTANCEOF

0 commit comments

Comments
 (0)