1There (mostly) can't be statements outside of namespaces
2-----
3<?php
4echo 1;
5echo 2;
6namespace A;
7-----
8Namespace declaration statement has to be the very first statement in the script from 4:1 to 4:9
9array(
10    0: Stmt_Echo(
11        exprs: array(
12            0: Scalar_Int(
13                value: 1
14            )
15        )
16    )
17    1: Stmt_Echo(
18        exprs: array(
19            0: Scalar_Int(
20                value: 2
21            )
22        )
23    )
24    2: Stmt_Namespace(
25        name: Name(
26            name: A
27        )
28        stmts: array(
29        )
30    )
31)
32-----
33<?php
34namespace A {}
35echo 1;
36-----
37No code may exist outside of namespace {} from 3:1 to 3:7
38array(
39    0: Stmt_Namespace(
40        name: Name(
41            name: A
42        )
43        stmts: array(
44        )
45    )
46    1: Stmt_Echo(
47        exprs: array(
48            0: Scalar_Int(
49                value: 1
50            )
51        )
52    )
53)
54-----
55<?php
56namespace A {}
57declare(ticks=1);
58foo();
59namespace B {}
60-----
61No code may exist outside of namespace {} from 3:1 to 3:17
62array(
63    0: Stmt_Namespace(
64        name: Name(
65            name: A
66        )
67        stmts: array(
68        )
69    )
70    1: Stmt_Declare(
71        declares: array(
72            0: DeclareItem(
73                key: Identifier(
74                    name: ticks
75                )
76                value: Scalar_Int(
77                    value: 1
78                )
79            )
80        )
81        stmts: null
82    )
83    2: Stmt_Expression(
84        expr: Expr_FuncCall(
85            name: Name(
86                name: foo
87            )
88            args: array(
89            )
90        )
91    )
92    3: Stmt_Namespace(
93        name: Name(
94            name: B
95        )
96        stmts: array(
97        )
98    )
99)
100