-
-
Notifications
You must be signed in to change notification settings - Fork 467
/
fcall.zep
180 lines (150 loc) · 3.03 KB
/
fcall.zep
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
/**
* Function calls
*
* Test global functions declaration.
*/
function zephir_global_method_test(var str)
{
/**
* Simple comment
*/
return new Fcall()->testStrtokVarBySlash(str);
}
function zephir_global_method_with_type_casting(<\stdClass> variable)
{
return variable;
}
namespace Stub;
use Stub\Oo\PropertyAccess;
/**
* Test function declaration in namespace
*/
function zephir_namespaced_method_test(var str)
{
return new Fcall()->testCall5(str, 5);
}
function test_call_relative_object_hint(<PropertyAccess> a) -> boolean
{
return true;
}
function zephir_namespaced_method_with_type_casting(<\stdClass> variable)
{
return variable;
}
function test_call_object_hint(<\Stub\Oo\PropertyAccess> a) -> boolean
{
return true;
}
class Fcall
{
public function testCall1() -> int
{
return strpos("hello", "h");
}
public function testCall2() -> int
{
loop {
return mt_rand(0, 100);
}
}
public function testCall3()
{
var handle, handle2, buffer;
let handle = fopen("inputfile.txt", "r"), handle2 = fopen("outputfile.txt", "w");
if handle {
loop {
let buffer = fgets(handle, 4096);
if buffer === false {
break;
}
fwrite(handle2, buffer);
}
fclose(handle);
fclose(handle2);
}
}
public function testCall4()
{
var handle, handle2, buffer;
let handle = fopen(mode: "r", filename: "inputfile.txt"),
handle2 = fopen(filename: "outputfile.txt", mode: "w");
if handle {
loop {
let buffer = fgets(handle, 4096);
if buffer === false {
break;
}
fwrite(handle2, buffer);
}
fclose(handle);
fclose(handle2);
}
}
public function testCall5(var a, var b)
{
return str_repeat(a, b);
}
public function testCall6()
{
return rand();
}
public function testCall7()
{
memory_get_usage();
}
public function zvalFcallWith1Parameter(var callback, var param1 = null)
{
{callback}(param1);
}
public function testCall8(var a, var b)
{
var x;
let x = str_repeat(a, b);
return x;
}
public function testCall1FromVar() -> int
{
var funcName;
let funcName = "strpos";
return {funcName}("hello", "l");
}
public function testStrtokFalse() -> bool
{
return strtok("/");
}
public function testStrtokVarBySlash(var value) -> string
{
return strtok(value, "/");
}
public function testFunctionGetArgs(var param1, var param2) -> array
{
return func_get_args();
}
public function testFunctionGetArgsAllExtra() -> array
{
return func_get_args();
}
public static function testStaticFunctionGetArgsAllExtra() -> array
{
return func_get_args();
}
public function testFunctionGetArg(var param1, var param2) -> array
{
return [func_get_arg(0), func_get_arg(1)];
}
public function testFunctionGetArgAllExtra() -> array
{
return [func_get_arg(0), func_get_arg(1)];
}
public static function testStaticFunctionGetArgAllExtra() -> array
{
return [func_get_arg(0), func_get_arg(1)];
}
public function testArrayFill() -> array
{
var v1, v2;
let v1 = array_fill(0, 5, "?");
let v2 = array_fill(0, 6, "?");
return [v1, v2];
}
}