xref: /php-ast/tests/closure_use_vars.phpt (revision 260678d4)
1--TEST--
2Closure uses should parse to CLOSURE_USE_VAR nodes
3--FILE--
4<?php
5
6require __DIR__ . '/../util.php';
7
8$code = <<<'PHP'
9<?php
10$fn = static function &($a, &$b) use ($c, &$d) {
11};
12PHP;
13echo ast_dump(ast\parse_code($code, $version=70));
14
15?>
16--EXPECTF--
17AST_STMT_LIST
18    0: AST_ASSIGN
19        var: AST_VAR
20            name: "fn"
21        expr: AST_CLOSURE
22            flags: MODIFIER_STATIC | FUNC_RETURNS_REF (%d)
23            name: "{closure}"
24            docComment: null
25            params: AST_PARAM_LIST
26                0: AST_PARAM
27                    type: null
28                    name: "a"
29                    default: null
30                1: AST_PARAM
31                    flags: PARAM_REF (%d)
32                    type: null
33                    name: "b"
34                    default: null
35            uses: AST_CLOSURE_USES
36                0: AST_CLOSURE_VAR
37                    flags: 0
38                    name: "c"
39                1: AST_CLOSURE_VAR
40                    flags: CLOSURE_USE_REF (%d)
41                    name: "d"
42            stmts: AST_STMT_LIST
43            returnType: null
44            __declId: 0