Skip to content

Commit 1d59f6e

Browse files
committed
Add support for void cast
1 parent 61c8866 commit 1d59f6e

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

ast.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,6 +1074,12 @@ static void ast_to_zval(zval *zv, zend_ast *ast, ast_state_info_t *state) {
10741074
}
10751075
}
10761076
break;
1077+
#endif
1078+
#if PHP_VERSION_ID >= 80500
1079+
case ZEND_AST_CAST_VOID:
1080+
ast->kind = ZEND_AST_CAST;
1081+
ast->attr = IS_VOID;
1082+
break;
10771083
#endif
10781084
}
10791085

tests/php85_pipe_operator.phpt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
Pipe operator
3+
--SKIPIF--
4+
<?php if (PHP_VERSION_ID < 80500) die('skip PHP >=8.5 only'); ?>
5+
--FILE--
6+
<?php
7+
8+
require __DIR__ . '/../util.php';
9+
10+
$code = <<<'PHP'
11+
<?php
12+
$a |> $b;
13+
PHP;
14+
15+
$node = ast\parse_code($code, $version=110);
16+
echo ast_dump($node), "\n";
17+
--EXPECTF--
18+
AST_STMT_LIST
19+
0: AST_BINARY_OP
20+
flags: BINARY_PIPE (%d)
21+
left: AST_VAR
22+
name: "a"
23+
right: AST_VAR
24+
name: "b"

tests/php85_void_cast.phpt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--TEST--
2+
Void cast
3+
--SKIPIF--
4+
<?php if (PHP_VERSION_ID < 80500) die('skip PHP >=8.5 only'); ?>
5+
--FILE--
6+
<?php
7+
8+
require __DIR__ . '/../util.php';
9+
10+
$code = <<<'PHP'
11+
<?php
12+
(void) foo();
13+
PHP;
14+
15+
$node = ast\parse_code($code, $version=110);
16+
echo ast_dump($node), "\n";
17+
--EXPECTF--
18+
AST_STMT_LIST
19+
0: AST_CAST
20+
flags: TYPE_VOID (%d)
21+
expr: AST_CALL
22+
expr: AST_NAME
23+
flags: NAME_NOT_FQ (%d)
24+
name: "foo"
25+
args: AST_ARG_LIST

0 commit comments

Comments
 (0)