xref: /php-ast/tests/decl_ids.phpt (revision 260678d4)
1--TEST--
2Closures should have unique identifiers within parsed code in version 50
3--FILE--
4<?php
5
6require __DIR__ . '/../util.php';
7
8$code = <<<'PHP'
9<?php
10function () {}; function () {};
11function test() {} function test() {}
12class Test {} class Test{}
13PHP;
14echo ast_dump(ast\parse_code($code, $version=50)) . "\n";
15echo ast_dump(ast\parse_code($code, $version=80)) . "\n";
16
17?>
18--EXPECTF--
19Deprecated: ast\parse_code(): Version 50 is deprecated in %s.php on line 11
20AST_STMT_LIST
21    0: AST_CLOSURE
22        name: "{closure}"
23        docComment: null
24        params: AST_PARAM_LIST
25        uses: null
26        stmts: AST_STMT_LIST
27        returnType: null
28        __declId: 0
29    1: AST_CLOSURE
30        name: "{closure}"
31        docComment: null
32        params: AST_PARAM_LIST
33        uses: null
34        stmts: AST_STMT_LIST
35        returnType: null
36        __declId: 1
37    2: AST_FUNC_DECL
38        name: "test"
39        docComment: null
40        params: AST_PARAM_LIST
41        uses: null
42        stmts: AST_STMT_LIST
43        returnType: null
44        __declId: 2
45    3: AST_FUNC_DECL
46        name: "test"
47        docComment: null
48        params: AST_PARAM_LIST
49        uses: null
50        stmts: AST_STMT_LIST
51        returnType: null
52        __declId: 3
53    4: AST_CLASS
54        name: "Test"
55        docComment: null
56        extends: null
57        implements: null
58        stmts: AST_STMT_LIST
59        __declId: 4
60    5: AST_CLASS
61        name: "Test"
62        docComment: null
63        extends: null
64        implements: null
65        stmts: AST_STMT_LIST
66        __declId: 5
67AST_STMT_LIST
68    0: AST_CLOSURE
69        name: "{closure}"
70        docComment: null
71        params: AST_PARAM_LIST
72        uses: null
73        stmts: AST_STMT_LIST
74        returnType: null
75        attributes: null
76        __declId: 0
77    1: AST_CLOSURE
78        name: "{closure}"
79        docComment: null
80        params: AST_PARAM_LIST
81        uses: null
82        stmts: AST_STMT_LIST
83        returnType: null
84        attributes: null
85        __declId: 1
86    2: AST_FUNC_DECL
87        name: "test"
88        docComment: null
89        params: AST_PARAM_LIST
90        stmts: AST_STMT_LIST
91        returnType: null
92        attributes: null
93        __declId: 2
94    3: AST_FUNC_DECL
95        name: "test"
96        docComment: null
97        params: AST_PARAM_LIST
98        stmts: AST_STMT_LIST
99        returnType: null
100        attributes: null
101        __declId: 3
102    4: AST_CLASS
103        name: "Test"
104        docComment: null
105        extends: null
106        implements: null
107        stmts: AST_STMT_LIST
108        attributes: null
109        __declId: 4
110    5: AST_CLASS
111        name: "Test"
112        docComment: null
113        extends: null
114        implements: null
115        stmts: AST_STMT_LIST
116        attributes: null
117        __declId: 5
118