Skip to content

Commit f85725f

Browse files
thegallaghernikic
authored andcommitted
Add support for null coalesce assign operator
(cherry picked from commit af90320)
1 parent b446ec9 commit f85725f

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

lib/PHPCfg/Parser.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,7 @@ protected function parseExprNode($expr)
836836
'Expr_AssignOp_BitwiseAnd' => Op\Expr\BinaryOp\BitwiseAnd::class,
837837
'Expr_AssignOp_BitwiseOr' => Op\Expr\BinaryOp\BitwiseOr::class,
838838
'Expr_AssignOp_BitwiseXor' => Op\Expr\BinaryOp\BitwiseXor::class,
839+
'Expr_AssignOp_Coalesce' => Op\Expr\BinaryOp\Coalesce::class,
839840
'Expr_AssignOp_Concat' => Op\Expr\BinaryOp\Concat::class,
840841
'Expr_AssignOp_Div' => Op\Expr\BinaryOp\Div::class,
841842
'Expr_AssignOp_Minus' => Op\Expr\BinaryOp\Minus::class,

test/code/assign_coalesce.test

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
$x ??= a();
4+
-----
5+
Block#1
6+
Expr_FuncCall
7+
name: LITERAL('a')
8+
result: Var#1
9+
Expr_BinaryOp_Coalesce
10+
left: Var#2<$x>
11+
right: Var#1
12+
result: Var#3
13+
Expr_Assign
14+
var: Var#4<$x>
15+
expr: Var#3
16+
result: Var#5
17+
Terminal_Return

0 commit comments

Comments
 (0)