xref: /php-ast/tests/use_declarations.phpt (revision 260678d4)
1--TEST--
2Test parse and dump of use declarations
3--FILE--
4<?php
5
6require __DIR__ . '/../util.php';
7
8$code = <<<'PHP'
9<?php
10use Foo\Bar as Baz;
11use function foo\bar as baz;
12use Foo\{Bar, function bar};
13use function foo\{bar, baz};
14PHP;
15
16echo ast_dump(ast\parse_code($code, $version=70));
17
18?>
19--EXPECTF--
20AST_STMT_LIST
21    0: AST_USE
22        flags: USE_NORMAL (%d)
23        0: AST_USE_ELEM
24            flags: 0
25            name: "Foo\Bar"
26            alias: "Baz"
27    1: AST_USE
28        flags: USE_FUNCTION (%d)
29        0: AST_USE_ELEM
30            flags: 0
31            name: "foo\bar"
32            alias: "baz"
33    2: AST_GROUP_USE
34        flags: 0
35        prefix: "Foo"
36        uses: AST_USE
37            flags: 0
38            0: AST_USE_ELEM
39                flags: USE_NORMAL (%d)
40                name: "Bar"
41                alias: null
42            1: AST_USE_ELEM
43                flags: USE_FUNCTION (%d)
44                name: "bar"
45                alias: null
46    3: AST_GROUP_USE
47        flags: USE_FUNCTION (%d)
48        prefix: "foo"
49        uses: AST_USE
50            flags: 0
51            0: AST_USE_ELEM
52                flags: 0
53                name: "bar"
54                alias: null
55            1: AST_USE_ELEM
56                flags: 0
57                name: "baz"
58                alias: null