File tree Expand file tree Collapse file tree 4 files changed +1114
-0
lines changed Expand file tree Collapse file tree 4 files changed +1114
-0
lines changed Original file line number Diff line number Diff line change 1+ --TEST--
2+ Tests empty closure with "use"
3+ --SKIPIF--
4+ <?php include (__DIR__ . '/../../skipif.inc ' ); ?>
5+ --FILE--
6+ <?php
7+
8+ $ code =<<<ZEP
9+ namespace Example;
10+
11+ class Closure
12+ {
13+ public function callback()
14+ {
15+ var abc = 42;
16+
17+ return function () use (abc) { };
18+ }
19+ }
20+ ZEP ;
21+
22+ $ ir = zephir_parse_file ($ code , '(eval code) ' );
23+
24+ var_dump ($ ir );
25+ ?>
26+ --EXPECT--
27+ array(2) {
28+ [0]=>
29+ array(5) {
30+ ["type"]=>
31+ string(9) "namespace"
32+ ["name"]=>
33+ string(7) "Example"
34+ ["file"]=>
35+ string(11) "(eval code)"
36+ ["line"]=>
37+ int(3)
38+ ["char"]=>
39+ int(5)
40+ }
41+ [1]=>
42+ array(8) {
43+ ["type"]=>
44+ string(5) "class"
45+ ["name"]=>
46+ string(7) "Closure"
47+ ["abstract"]=>
48+ int(0)
49+ ["final"]=>
50+ int(0)
51+ ["definition"]=>
52+ array(4) {
53+ ["methods"]=>
54+ array(1) {
55+ [0]=>
56+ array(8) {
57+ ["visibility"]=>
58+ array(1) {
59+ [0]=>
60+ string(6) "public"
61+ }
62+ ["type"]=>
63+ string(6) "method"
64+ ["name"]=>
65+ string(8) "callback"
66+ ["statements"]=>
67+ array(2) {
68+ [0]=>
69+ array(6) {
70+ ["type"]=>
71+ string(7) "declare"
72+ ["data-type"]=>
73+ string(8) "variable"
74+ ["variables"]=>
75+ array(1) {
76+ [0]=>
77+ array(5) {
78+ ["variable"]=>
79+ string(3) "abc"
80+ ["expr"]=>
81+ array(5) {
82+ ["type"]=>
83+ string(3) "int"
84+ ["value"]=>
85+ string(2) "42"
86+ ["file"]=>
87+ string(11) "(eval code)"
88+ ["line"]=>
89+ int(7)
90+ ["char"]=>
91+ int(21)
92+ }
93+ ["file"]=>
94+ string(11) "(eval code)"
95+ ["line"]=>
96+ int(7)
97+ ["char"]=>
98+ int(21)
99+ }
100+ }
101+ ["file"]=>
102+ string(11) "(eval code)"
103+ ["line"]=>
104+ int(9)
105+ ["char"]=>
106+ int(14)
107+ }
108+ [1]=>
109+ array(5) {
110+ ["type"]=>
111+ string(6) "return"
112+ ["expr"]=>
113+ array(5) {
114+ ["type"]=>
115+ string(7) "closure"
116+ ["use"]=>
117+ array(1) {
118+ [0]=>
119+ array(9) {
120+ ["type"]=>
121+ string(9) "parameter"
122+ ["name"]=>
123+ string(3) "abc"
124+ ["const"]=>
125+ int(0)
126+ ["data-type"]=>
127+ string(8) "variable"
128+ ["mandatory"]=>
129+ int(0)
130+ ["reference"]=>
131+ int(0)
132+ ["file"]=>
133+ string(11) "(eval code)"
134+ ["line"]=>
135+ int(9)
136+ ["char"]=>
137+ int(36)
138+ }
139+ }
140+ ["file"]=>
141+ string(11) "(eval code)"
142+ ["line"]=>
143+ int(9)
144+ ["char"]=>
145+ int(41)
146+ }
147+ ["file"]=>
148+ string(11) "(eval code)"
149+ ["line"]=>
150+ int(10)
151+ ["char"]=>
152+ int(5)
153+ }
154+ }
155+ ["file"]=>
156+ string(11) "(eval code)"
157+ ["line"]=>
158+ int(9)
159+ ["last-line"]=>
160+ int(11)
161+ ["char"]=>
162+ int(23)
163+ }
164+ }
165+ ["file"]=>
166+ string(11) "(eval code)"
167+ ["line"]=>
168+ int(3)
169+ ["char"]=>
170+ int(5)
171+ }
172+ ["file"]=>
173+ string(11) "(eval code)"
174+ ["line"]=>
175+ int(3)
176+ ["char"]=>
177+ int(5)
178+ }
179+ }
You can’t perform that action at this time.
0 commit comments