xref: /php-ast/tests/named_children.phpt (revision 260678d4)
1--TEST--
2Named child nodes
3--FILE--
4<?php
5
6require __DIR__ . '/../util.php';
7
8$code = <<<'PHP'
9<?php
10
11$fn = function() use(&$var) {
12    $var += func();
13};
14PHP;
15
16echo ast_dump(ast\parse_code($code, $version=70));
17
18?>
19--EXPECT--
20AST_STMT_LIST
21    0: AST_ASSIGN
22        var: AST_VAR
23            name: "fn"
24        expr: AST_CLOSURE
25            name: "{closure}"
26            docComment: null
27            params: AST_PARAM_LIST
28            uses: AST_CLOSURE_USES
29                0: AST_CLOSURE_VAR
30                    flags: CLOSURE_USE_REF (1)
31                    name: "var"
32            stmts: AST_STMT_LIST
33                0: AST_ASSIGN_OP
34                    flags: BINARY_ADD (1)
35                    var: AST_VAR
36                        name: "var"
37                    expr: AST_CALL
38                        expr: AST_NAME
39                            flags: NAME_NOT_FQ (1)
40                            name: "func"
41                        args: AST_ARG_LIST
42            returnType: null
43            __declId: 0