xref: /php-ast/tests/class_consts.phpt (revision 260678d4)
1--TEST--
2Class constants
3--FILE--
4<?php
5
6require __DIR__ . '/../util.php';
7
8$code = <<<'PHP'
9<?php
10class Test {
11    /** Doc A */
12    const A = 1;
13    public const B = 2;
14    protected const C = 3;
15    private const D = 4;
16    const
17        /** Doc E */
18        E = 5,
19        /** Doc F */
20        F = 6;
21}
22PHP;
23
24echo ast_dump(ast\parse_code($code, $version=70));
25
26?>
27--EXPECTF--
28AST_STMT_LIST
29    0: AST_CLASS
30        name: "Test"
31        docComment: null
32        extends: null
33        implements: null
34        stmts: AST_STMT_LIST
35            0: AST_CLASS_CONST_DECL
36                flags: MODIFIER_PUBLIC (%d)
37                0: AST_CONST_ELEM
38                    name: "A"
39                    value: 1
40                    docComment: "/** Doc A */"
41            1: AST_CLASS_CONST_DECL
42                flags: MODIFIER_PUBLIC (%d)
43                0: AST_CONST_ELEM
44                    name: "B"
45                    value: 2
46                    docComment: null
47            2: AST_CLASS_CONST_DECL
48                flags: MODIFIER_PROTECTED (%d)
49                0: AST_CONST_ELEM
50                    name: "C"
51                    value: 3
52                    docComment: null
53            3: AST_CLASS_CONST_DECL
54                flags: MODIFIER_PRIVATE (%d)
55                0: AST_CONST_ELEM
56                    name: "D"
57                    value: 4
58                    docComment: null
59            4: AST_CLASS_CONST_DECL
60                flags: MODIFIER_PUBLIC (%d)
61                0: AST_CONST_ELEM
62                    name: "E"
63                    value: 5
64                    docComment: "/** Doc E */"
65                1: AST_CONST_ELEM
66                    name: "F"
67                    value: 6
68                    docComment: "/** Doc F */"
69        __declId: 0
70