Skip to content

Commit 5b7346c

Browse files
committed
wip - add another type
1 parent 98e5212 commit 5b7346c

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/ASTConverter/ASTConverter.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,18 @@ private static function _init_handle_map() : array {
387387
$startLine
388388
);
389389
},
390+
'PhpParser\Node\Expr\Ternary' => function(PhpParser\Node\Expr\Ternary $n, int $startLine) : \ast\Node {
391+
return astnode(
392+
\ast\AST_CONDITIONAL,
393+
0,
394+
[
395+
'cond' => self::_phpparser_node_to_ast_node($n->cond),
396+
'true' => $n->if !== null ? self::_phpparser_node_to_ast_node($n->if) : null,
397+
'false' => self::_phpparser_node_to_ast_node($n->else),
398+
],
399+
$startLine
400+
);
401+
},
390402
'PhpParser\Node\Expr\UnaryMinus' => function(PhpParser\Node\Expr\UnaryMinus $n, int $startLine) : \ast\Node {
391403
return self::_ast_node_unary_op(\ast\flags\UNARY_MINUS, self::_phpparser_node_to_ast_node($n->expr), $startLine);
392404
},

test_files/src/ternary.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?php
2+
$a ? $b : $c;
3+
$a ?: $c;
4+
$a ?? $d;

0 commit comments

Comments
 (0)