Skip to content

Commit 5ef74f0

Browse files
committed
Add AST-printing support for (void)
1 parent 26cd585 commit 5ef74f0

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
(void) is included in AST printing
3+
--FILE--
4+
<?php
5+
6+
try {
7+
assert(false && function () {
8+
(void) somefunc();
9+
});
10+
} catch (Error $e) {
11+
echo $e->getMessage(), "\n";
12+
}
13+
14+
?>
15+
--EXPECT--
16+
assert(false && function () {
17+
(void)somefunc();
18+
})

Zend/zend_ast.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2261,6 +2261,9 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
22612261
EMPTY_SWITCH_DEFAULT_CASE();
22622262
}
22632263
break;
2264+
case ZEND_AST_CAST_VOID:
2265+
PREFIX_OP("(void)", 240, 241);
2266+
break;
22642267
case ZEND_AST_EMPTY:
22652268
FUNC_OP("empty");
22662269
case ZEND_AST_ISSET:

0 commit comments

Comments
 (0)