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