xref: /PHP-Parser/test/code/parser/comments.test (revision 4e27a17c)
1Comments
2-----
3<?php
4
5/** doc 1 */
6/* foobar 1 */
7// foo 1
8// bar 1
9$var;
10
11if ($cond) {
12    /** doc 2 */
13    /* foobar 2 */
14    // foo 2
15    // bar 2
16}
17
18/** doc 3 */
19/* foobar 3 */
20// foo 3
21// bar 3
22-----
23array(
24    0: Stmt_Expression(
25        expr: Expr_Variable(
26            name: var
27        )
28        comments: array(
29            0: /** doc 1 */
30            1: /* foobar 1 */
31            2: // foo 1
32            3: // bar 1
33        )
34    )
35    1: Stmt_If(
36        cond: Expr_Variable(
37            name: cond
38        )
39        stmts: array(
40            0: Stmt_Nop(
41                comments: array(
42                    0: /** doc 2 */
43                    1: /* foobar 2 */
44                    2: // foo 2
45                    3: // bar 2
46                )
47            )
48        )
49        elseifs: array(
50        )
51        else: null
52    )
53    2: Stmt_Nop(
54        comments: array(
55            0: /** doc 3 */
56            1: /* foobar 3 */
57            2: // foo 3
58            3: // bar 3
59        )
60    )
61)
62-----
63<?php
64
65/** doc */
66/* foobar */
67// foo
68// bar
69
70?>
71-----
72array(
73    0: Stmt_Nop(
74        comments: array(
75            0: /** doc */
76            1: /* foobar */
77            2: // foo
78            3: // bar
79        )
80    )
81)
82-----
83<?php
84
85// comment
86if (42) {}
87-----
88array(
89    0: Stmt_If(
90        cond: Scalar_Int(
91            value: 42
92        )
93        stmts: array(
94        )
95        elseifs: array(
96        )
97        else: null
98        comments: array(
99            0: // comment
100        )
101    )
102)
103