comparison vendor/nikic/php-parser/test/code/parser/stmt/namespace/outsideStmtInvalid.test @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children 5fb285c0d0e3
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
1 There (mostly) can't be statements outside of namespaces
2 -----
3 <?php
4 echo 1;
5 echo 2;
6 namespace A;
7 -----
8 Namespace declaration statement has to be the very first statement in the script on line 4
9 array(
10 0: Stmt_Echo(
11 exprs: array(
12 0: Scalar_LNumber(
13 value: 1
14 )
15 )
16 )
17 1: Stmt_Echo(
18 exprs: array(
19 0: Scalar_LNumber(
20 value: 2
21 )
22 )
23 )
24 2: Stmt_Namespace(
25 name: Name(
26 parts: array(
27 0: A
28 )
29 )
30 stmts: array(
31 )
32 )
33 )
34 -----
35 <?php
36 namespace A {}
37 echo 1;
38 -----
39 No code may exist outside of namespace {} from 3:1 to 3:7
40 array(
41 0: Stmt_Namespace(
42 name: Name(
43 parts: array(
44 0: A
45 )
46 )
47 stmts: array(
48 )
49 )
50 1: Stmt_Echo(
51 exprs: array(
52 0: Scalar_LNumber(
53 value: 1
54 )
55 )
56 )
57 )
58 -----
59 <?php
60 namespace A {}
61 declare(ticks=1);
62 foo();
63 namespace B {}
64 -----
65 No code may exist outside of namespace {} from 3:1 to 3:17
66 array(
67 0: Stmt_Namespace(
68 name: Name(
69 parts: array(
70 0: A
71 )
72 )
73 stmts: array(
74 )
75 )
76 1: Stmt_Declare(
77 declares: array(
78 0: Stmt_DeclareDeclare(
79 key: ticks
80 value: Scalar_LNumber(
81 value: 1
82 )
83 )
84 )
85 stmts: null
86 )
87 2: Expr_FuncCall(
88 name: Name(
89 parts: array(
90 0: foo
91 )
92 )
93 args: array(
94 )
95 )
96 3: Stmt_Namespace(
97 name: Name(
98 parts: array(
99 0: B
100 )
101 )
102 stmts: array(
103 )
104 )
105 )