Skip to content

Commit

Permalink
Add support for null coalesce assign operator
Browse files Browse the repository at this point in the history
(cherry picked from commit af90320)
  • Loading branch information
thegallagher committed Jan 13, 2025
1 parent caa9079 commit 18e529e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/PHPCfg/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,7 @@ protected function parseExprNode($expr)
'Expr_AssignOp_BitwiseAnd' => Op\Expr\BinaryOp\BitwiseAnd::class,
'Expr_AssignOp_BitwiseOr' => Op\Expr\BinaryOp\BitwiseOr::class,
'Expr_AssignOp_BitwiseXor' => Op\Expr\BinaryOp\BitwiseXor::class,
'Expr_AssignOp_Coalesce' => Op\Expr\BinaryOp\Coalesce::class,
'Expr_AssignOp_Concat' => Op\Expr\BinaryOp\Concat::class,
'Expr_AssignOp_Div' => Op\Expr\BinaryOp\Div::class,
'Expr_AssignOp_Minus' => Op\Expr\BinaryOp\Minus::class,
Expand Down
17 changes: 17 additions & 0 deletions test/code/assign_coalesce.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

$x ??= a();
-----
Block#1
Expr_FuncCall
name: LITERAL('a')
result: Var#1
Expr_BinaryOp_Coalesce
left: Var#2<$x>
right: Var#1
result: Var#3
Expr_Assign
var: Var#4<$x>
expr: Var#3
result: Var#5
Terminal_Return

0 comments on commit 18e529e

Please sign in to comment.