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