xref: /PHP-Parser/test/code/parser/expr/closure.test (revision 03caf4cc)
1Closures
2-----
3<?php
4function($a) { $a; };
5function($a) use($b) {};
6function() use($a, &$b) {};
7function &($a) {};
8static function() {};
9function($a) : array {};
10function() use($a) : \Foo\Bar {};
11-----
12array(
13    0: Stmt_Expression(
14        expr: Expr_Closure(
15            attrGroups: array(
16            )
17            static: false
18            byRef: false
19            params: array(
20                0: Param(
21                    attrGroups: array(
22                    )
23                    flags: 0
24                    type: null
25                    byRef: false
26                    variadic: false
27                    var: Expr_Variable(
28                        name: a
29                    )
30                    default: null
31                    hooks: array(
32                    )
33                )
34            )
35            uses: array(
36            )
37            returnType: null
38            stmts: array(
39                0: Stmt_Expression(
40                    expr: Expr_Variable(
41                        name: a
42                    )
43                )
44            )
45        )
46    )
47    1: Stmt_Expression(
48        expr: Expr_Closure(
49            attrGroups: array(
50            )
51            static: false
52            byRef: false
53            params: array(
54                0: Param(
55                    attrGroups: array(
56                    )
57                    flags: 0
58                    type: null
59                    byRef: false
60                    variadic: false
61                    var: Expr_Variable(
62                        name: a
63                    )
64                    default: null
65                    hooks: array(
66                    )
67                )
68            )
69            uses: array(
70                0: ClosureUse(
71                    var: Expr_Variable(
72                        name: b
73                    )
74                    byRef: false
75                )
76            )
77            returnType: null
78            stmts: array(
79            )
80        )
81    )
82    2: Stmt_Expression(
83        expr: Expr_Closure(
84            attrGroups: array(
85            )
86            static: false
87            byRef: false
88            params: array(
89            )
90            uses: array(
91                0: ClosureUse(
92                    var: Expr_Variable(
93                        name: a
94                    )
95                    byRef: false
96                )
97                1: ClosureUse(
98                    var: Expr_Variable(
99                        name: b
100                    )
101                    byRef: true
102                )
103            )
104            returnType: null
105            stmts: array(
106            )
107        )
108    )
109    3: Stmt_Expression(
110        expr: Expr_Closure(
111            attrGroups: array(
112            )
113            static: false
114            byRef: true
115            params: array(
116                0: Param(
117                    attrGroups: array(
118                    )
119                    flags: 0
120                    type: null
121                    byRef: false
122                    variadic: false
123                    var: Expr_Variable(
124                        name: a
125                    )
126                    default: null
127                    hooks: array(
128                    )
129                )
130            )
131            uses: array(
132            )
133            returnType: null
134            stmts: array(
135            )
136        )
137    )
138    4: Stmt_Expression(
139        expr: Expr_Closure(
140            attrGroups: array(
141            )
142            static: true
143            byRef: false
144            params: array(
145            )
146            uses: array(
147            )
148            returnType: null
149            stmts: array(
150            )
151        )
152    )
153    5: Stmt_Expression(
154        expr: Expr_Closure(
155            attrGroups: array(
156            )
157            static: false
158            byRef: false
159            params: array(
160                0: Param(
161                    attrGroups: array(
162                    )
163                    flags: 0
164                    type: null
165                    byRef: false
166                    variadic: false
167                    var: Expr_Variable(
168                        name: a
169                    )
170                    default: null
171                    hooks: array(
172                    )
173                )
174            )
175            uses: array(
176            )
177            returnType: Identifier(
178                name: array
179            )
180            stmts: array(
181            )
182        )
183    )
184    6: Stmt_Expression(
185        expr: Expr_Closure(
186            attrGroups: array(
187            )
188            static: false
189            byRef: false
190            params: array(
191            )
192            uses: array(
193                0: ClosureUse(
194                    var: Expr_Variable(
195                        name: a
196                    )
197                    byRef: false
198                )
199            )
200            returnType: Name_FullyQualified(
201                name: Foo\Bar
202            )
203            stmts: array(
204            )
205        )
206    )
207)
208