1 /*
2    +----------------------------------------------------------------------+
3    | Zend Engine, Func Info                                               |
4    +----------------------------------------------------------------------+
5    | Copyright (c) The PHP Group                                          |
6    +----------------------------------------------------------------------+
7    | This source file is subject to version 3.01 of the PHP license,      |
8    | that is bundled with this package in the file LICENSE, and is        |
9    | available through the world-wide-web at the following url:           |
10    | http://www.php.net/license/3_01.txt                                  |
11    | If you did not receive a copy of the PHP license and are unable to   |
12    | obtain it through the world-wide-web, please send a note to          |
13    | license@php.net so we can mail you a copy immediately.               |
14    +----------------------------------------------------------------------+
15    | Authors: Dmitry Stogov <dmitry@php.net>                              |
16    |          Xinchen Hui <laruence@php.net>                              |
17    +----------------------------------------------------------------------+
18 */
19 
20 #include "php.h"
21 #include "zend_compile.h"
22 #include "zend_extensions.h"
23 #include "zend_ssa.h"
24 #include "zend_optimizer_internal.h"
25 #include "zend_inference.h"
26 #include "zend_call_graph.h"
27 #include "zend_func_info.h"
28 #include "zend_inference.h"
29 #ifdef _WIN32
30 #include "win32/ioutil.h"
31 #endif
32 
33 typedef uint32_t (*info_func_t)(const zend_call_info *call_info, const zend_ssa *ssa);
34 
35 typedef struct _func_info_t {
36 	const char *name;
37 	int         name_len;
38 	uint32_t    info;
39 	info_func_t info_func;
40 } func_info_t;
41 
42 #define F0(name, info) \
43 	{name, sizeof(name)-1, (info), NULL}
44 #define F1(name, info) \
45 	{name, sizeof(name)-1, (MAY_BE_RC1 | (info)), NULL}
46 #define FN(name, info) \
47 	{name, sizeof(name)-1, (MAY_BE_RC1 | MAY_BE_RCN | (info)), NULL}
48 #define FR(name, info) \
49 	{name, sizeof(name)-1, (MAY_BE_REF | (info)), NULL}
50 #define FX(name, info) \
51 	{name, sizeof(name)-1, (MAY_BE_RC1 | MAY_BE_RCN | MAY_BE_REF | (info)), NULL}
52 #define FC(name, callback) \
53 	{name, sizeof(name)-1, 0, callback}
54 
zend_range_info(const zend_call_info * call_info,const zend_ssa * ssa)55 static uint32_t zend_range_info(const zend_call_info *call_info, const zend_ssa *ssa)
56 {
57 	if (!call_info->send_unpack
58 	 && (call_info->num_args == 2 || call_info->num_args == 3)
59 	 && ssa
60 	 && !(ssa->cfg.flags & ZEND_SSA_TSSA)) {
61 		zend_op_array *op_array = call_info->caller_op_array;
62 		uint32_t t1 = _ssa_op1_info(op_array, ssa, call_info->arg_info[0].opline,
63 			&ssa->ops[call_info->arg_info[0].opline - op_array->opcodes]);
64 		uint32_t t2 = _ssa_op1_info(op_array, ssa, call_info->arg_info[1].opline,
65 			&ssa->ops[call_info->arg_info[1].opline - op_array->opcodes]);
66 		uint32_t t3 = 0;
67 		uint32_t tmp = MAY_BE_RC1 | MAY_BE_ARRAY | MAY_BE_ARRAY_PACKED;
68 
69 		if (call_info->num_args == 3) {
70 			t3 = _ssa_op1_info(op_array, ssa, call_info->arg_info[2].opline,
71 				&ssa->ops[call_info->arg_info[2].opline - op_array->opcodes]);
72 		}
73 		if ((t1 & MAY_BE_STRING) && (t2 & MAY_BE_STRING)) {
74 			tmp |= MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_DOUBLE | MAY_BE_ARRAY_OF_STRING;
75 		}
76 		if ((t1 & (MAY_BE_DOUBLE|MAY_BE_STRING))
77 				|| (t2 & (MAY_BE_DOUBLE|MAY_BE_STRING))
78 				|| (t3 & (MAY_BE_DOUBLE|MAY_BE_STRING))) {
79 			tmp |= MAY_BE_ARRAY_OF_DOUBLE;
80 		}
81 		if ((t1 & (MAY_BE_ANY-MAY_BE_DOUBLE)) && (t2 & (MAY_BE_ANY-MAY_BE_DOUBLE))) {
82 			if ((t3 & MAY_BE_ANY) != MAY_BE_DOUBLE) {
83 				tmp |= MAY_BE_ARRAY_OF_LONG;
84 			}
85 		}
86 		return tmp;
87 	} else {
88 		/* May throw */
89 		return MAY_BE_RC1 | MAY_BE_ARRAY | MAY_BE_ARRAY_PACKED | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_DOUBLE | MAY_BE_ARRAY_OF_STRING;
90 	}
91 }
92 
93 #define UNKNOWN_INFO (MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF)
94 
95 static const func_info_t func_infos[] = {
96 	/* zend */
97 	F1("zend_version",            MAY_BE_STRING),
98 	FN("func_get_arg",            UNKNOWN_INFO),
99 	FN("func_get_args",           MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_ANY),
100 	F1("get_class_vars",          MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF),
101 	F1("get_class_methods",       MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
102 	F1("get_included_files",      MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
103 	FN("set_error_handler",       MAY_BE_NULL | MAY_BE_STRING | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING | MAY_BE_ARRAY_OF_OBJECT | MAY_BE_OBJECT),
104 	F0("restore_error_handler",   MAY_BE_TRUE),
105 	F0("restore_exception_handler", MAY_BE_TRUE),
106 	F1("get_declared_traits",     MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
107 	F1("get_declared_classes",    MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
108 	F1("get_declared_interfaces", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
109 	F1("get_defined_functions",   MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_ARRAY),
110 	F1("get_defined_vars",        MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF),
111 	F1("get_resource_type",       MAY_BE_STRING),
112 	F1("get_defined_constants",   MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_NULL | MAY_BE_ARRAY_OF_FALSE | MAY_BE_ARRAY_OF_TRUE | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_DOUBLE | MAY_BE_ARRAY_OF_STRING | MAY_BE_ARRAY_OF_RESOURCE | MAY_BE_ARRAY_OF_ARRAY),
113 	F1("debug_backtrace",         MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_ARRAY),
114 	F1("get_loaded_extensions",   MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
115 	F1("get_extension_funcs",     MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
116 
117 	/* ext/standard */
118 	FN("constant",                     MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_TRUE | MAY_BE_LONG | MAY_BE_DOUBLE | MAY_BE_STRING | MAY_BE_RESOURCE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY),
119 	F1("bin2hex",                      MAY_BE_STRING),
120 	F1("hex2bin",                      MAY_BE_FALSE | MAY_BE_STRING),
121 #if HAVE_NANOSLEEP
122 	F1("time_nanosleep",               MAY_BE_FALSE | MAY_BE_TRUE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_LONG),
123 #endif
124 #if HAVE_STRPTIME
125 	F1("strptime",                     MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_STRING),
126 #endif
127 	F1("wordwrap",                     MAY_BE_STRING),
128 	F1("htmlspecialchars",             MAY_BE_STRING),
129 	F1("htmlentities",                 MAY_BE_STRING),
130 	F1("get_html_translation_table",   MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_STRING),
131 	F1("sha1",                         MAY_BE_STRING),
132 	F1("sha1_file",                    MAY_BE_FALSE | MAY_BE_STRING),
133 	F1("md5",                          MAY_BE_STRING),
134 	F1("md5_file",                     MAY_BE_FALSE | MAY_BE_STRING),
135 	F1("iptcparse",                    MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_ARRAY),
136 	F1("iptcembed",                    MAY_BE_FALSE | MAY_BE_TRUE | MAY_BE_STRING),
137 	F1("getimagesize",                 MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_STRING),
138 	F1("getimagesizefromstring",       MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_STRING),
139 	F1("image_type_to_mime_type",      MAY_BE_STRING),
140 	F1("image_type_to_extension",      MAY_BE_FALSE | MAY_BE_STRING),
141 	F0("phpinfo",                      MAY_BE_TRUE),
142 	F1("phpversion",                   MAY_BE_FALSE | MAY_BE_STRING),
143 	F0("phpcredits",                   MAY_BE_TRUE),
144 	F1("php_sapi_name",                MAY_BE_FALSE | MAY_BE_STRING),
145 	F1("php_uname",                    MAY_BE_STRING),
146 	F1("php_ini_scanned_files",        MAY_BE_FALSE | MAY_BE_STRING),
147 	F1("php_ini_loaded_file",          MAY_BE_FALSE | MAY_BE_STRING),
148 	F1("strtok",                       MAY_BE_FALSE | MAY_BE_STRING),
149 	F1("strrev",                       MAY_BE_STRING),
150 	F1("hebrev",                       MAY_BE_STRING),
151 	F1("basename",                     MAY_BE_STRING),
152 	F1("dirname",                      MAY_BE_STRING),
153 	F1("pathinfo",                     MAY_BE_STRING | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_STRING),
154 	F1("stripslashes",                 MAY_BE_STRING),
155 	F1("stripcslashes",                MAY_BE_STRING),
156 	F1("strstr",                       MAY_BE_FALSE | MAY_BE_STRING),
157 	F1("stristr",                      MAY_BE_FALSE | MAY_BE_STRING),
158 	F1("strrchr",                      MAY_BE_FALSE | MAY_BE_STRING),
159 	F1("str_shuffle",                  MAY_BE_STRING),
160 	F1("str_word_count",               MAY_BE_LONG | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
161 	F1("str_split",                    MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
162 	F1("strpbrk",                      MAY_BE_FALSE | MAY_BE_STRING),
163 	FN("substr_replace",               MAY_BE_STRING | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_STRING),
164 	F1("quotemeta",                    MAY_BE_STRING),
165 	F1("ucwords",                      MAY_BE_STRING),
166 	FN("str_replace",                  MAY_BE_STRING | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_STRING),
167 	FN("str_ireplace",                 MAY_BE_STRING | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_STRING),
168 	F1("str_repeat",                   MAY_BE_STRING),
169 	F1("count_chars",                  MAY_BE_STRING | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_LONG),
170 	F1("chunk_split",                  MAY_BE_STRING),
171 	F1("strip_tags",                   MAY_BE_STRING),
172 	F1("explode",                      MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
173 	F1("localeconv",                   MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_STRING | MAY_BE_ARRAY_OF_ARRAY),
174 #if HAVE_NL_LANGINFO
175 	F1("nl_langinfo",                  MAY_BE_FALSE | MAY_BE_STRING),
176 #endif
177 	F1("soundex",                      MAY_BE_STRING),
178 	F1("chr",                          MAY_BE_STRING),
179 	F1("str_getcsv",                   MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_NULL | MAY_BE_ARRAY_OF_STRING),
180 	F1("strchr",                       MAY_BE_FALSE | MAY_BE_STRING),
181 	F1("sprintf",                      MAY_BE_STRING),
182 	F1("vsprintf",                     MAY_BE_STRING),
183 	F1("sscanf",                       MAY_BE_NULL | MAY_BE_LONG | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_ANY),
184 	F1("fscanf",                       MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_LONG | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_ANY),
185 	F1("parse_url",                    MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_LONG | MAY_BE_STRING | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_STRING | MAY_BE_ARRAY_OF_LONG),
186 	F1("urlencode",                    MAY_BE_STRING),
187 	F1("urldecode",                    MAY_BE_STRING),
188 	F1("rawurlencode",                 MAY_BE_STRING),
189 	F1("rawurldecode",                 MAY_BE_STRING),
190 	F1("http_build_query",             MAY_BE_STRING),
191 #if defined(HAVE_SYMLINK) || defined(PHP_WIN32)
192 	F1("readlink",                     MAY_BE_FALSE | MAY_BE_STRING),
193 #endif
194 	F1("exec",                         MAY_BE_FALSE | MAY_BE_STRING),
195 	F1("system",                       MAY_BE_FALSE | MAY_BE_STRING),
196 	F1("escapeshellcmd",               MAY_BE_STRING),
197 	F1("escapeshellarg",               MAY_BE_STRING),
198 	F0("passthru",                     MAY_BE_NULL | MAY_BE_FALSE),
199 	F1("shell_exec",                   MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_STRING),
200 #ifdef PHP_CAN_SUPPORT_PROC_OPEN
201 	F1("proc_open",                    MAY_BE_FALSE | MAY_BE_RESOURCE),
202 	F1("proc_get_status",              MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_FALSE | MAY_BE_ARRAY_OF_TRUE | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_STRING),
203 #endif
204 	F1("random_bytes",                 MAY_BE_STRING),
205 #if HAVE_GETSERVBYPORT
206 	F1("getservbyport",                MAY_BE_FALSE | MAY_BE_STRING),
207 #endif
208 #if HAVE_GETPROTOBYNUMBER
209 	F1("getprotobynumber",             MAY_BE_FALSE | MAY_BE_STRING),
210 #endif
211 	F1("base64_decode",                MAY_BE_FALSE | MAY_BE_STRING),
212 	F1("base64_encode",                MAY_BE_STRING),
213 	F1("password_hash",                MAY_BE_STRING),
214 	F1("password_get_info",            MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_NULL | MAY_BE_ARRAY_OF_STRING | MAY_BE_ARRAY_OF_ARRAY),
215 	F1("convert_uuencode",             MAY_BE_STRING),
216 	F1("convert_uudecode",             MAY_BE_FALSE | MAY_BE_STRING),
217 	F1("decbin",                       MAY_BE_STRING),
218 	F1("decoct",                       MAY_BE_STRING),
219 	F1("dechex",                       MAY_BE_STRING),
220 	F1("base_convert",                 MAY_BE_STRING),
221 	F1("number_format",                MAY_BE_STRING),
222 #ifdef HAVE_INET_NTOP
223 	F1("inet_ntop",                    MAY_BE_FALSE | MAY_BE_STRING),
224 #endif
225 #ifdef HAVE_INET_PTON
226 	F1("inet_pton",                    MAY_BE_FALSE | MAY_BE_STRING),
227 #endif
228 	F1("long2ip",                      MAY_BE_FALSE | MAY_BE_STRING),
229 	F1("getenv",                       MAY_BE_FALSE | MAY_BE_STRING | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_STRING),
230 #ifdef HAVE_PUTENV
231 #endif
232 	F1("getopt",                       MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_FALSE | MAY_BE_ARRAY_OF_TRUE | MAY_BE_ARRAY_OF_STRING | MAY_BE_ARRAY_OF_ARRAY),
233 #ifdef HAVE_GETLOADAVG
234 	F1("sys_getloadavg",               MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_DOUBLE),
235 #endif
236 #ifdef HAVE_GETTIMEOFDAY
237 	F1("microtime",                    MAY_BE_DOUBLE | MAY_BE_STRING),
238 	F1("gettimeofday",                 MAY_BE_DOUBLE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_LONG),
239 #endif
240 #ifdef HAVE_GETRUSAGE
241 	F1("getrusage",                    MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_LONG),
242 #endif
243 #ifdef HAVE_GETTIMEOFDAY
244 	F1("uniqid",                       MAY_BE_STRING),
245 #endif
246 	F1("quoted_printable_decode",      MAY_BE_STRING),
247 	F1("quoted_printable_encode",      MAY_BE_STRING),
248 	F1("get_current_user",             MAY_BE_STRING),
249 	F1("get_cfg_var",                  MAY_BE_FALSE | MAY_BE_STRING | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_STRING | MAY_BE_ARRAY_OF_ARRAY),
250 	F1("error_get_last",               MAY_BE_NULL | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_STRING),
251 	FN("call_user_func",               UNKNOWN_INFO),
252 	FN("call_user_func_array",         UNKNOWN_INFO),
253 	FN("call_user_method",             UNKNOWN_INFO),
254 	FN("call_user_method_array",       UNKNOWN_INFO),
255 	FN("forward_static_call",          UNKNOWN_INFO),
256 	FN("forward_static_call_array",    UNKNOWN_INFO),
257 	F1("serialize",                    MAY_BE_STRING),
258 	FN("unserialize",                  UNKNOWN_INFO),
259 	F1("var_export",                   MAY_BE_NULL | MAY_BE_STRING),
260 	F1("print_r",                      MAY_BE_TRUE | MAY_BE_STRING),
261 	F0("register_shutdown_function",   MAY_BE_NULL | MAY_BE_FALSE),
262 	F1("highlight_file",               MAY_BE_FALSE | MAY_BE_TRUE | MAY_BE_STRING),
263 	F1("show_source",                  MAY_BE_FALSE | MAY_BE_TRUE | MAY_BE_STRING),
264 	F1("highlight_string",             MAY_BE_FALSE | MAY_BE_TRUE | MAY_BE_STRING),
265 	F1("php_strip_whitespace",         MAY_BE_STRING),
266 	F1("ini_get_all",                  MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_NULL | MAY_BE_ARRAY_OF_STRING | MAY_BE_ARRAY_OF_ARRAY),
267 	F1("get_include_path",             MAY_BE_FALSE | MAY_BE_STRING),
268 	F1("set_include_path",             MAY_BE_FALSE | MAY_BE_STRING),
269 	F1("headers_list",                 MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
270 	F1("parse_ini_file",               MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_NULL | MAY_BE_ARRAY_OF_FALSE | MAY_BE_ARRAY_OF_TRUE | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_DOUBLE | MAY_BE_ARRAY_OF_STRING | MAY_BE_ARRAY_OF_ARRAY),
271 	F1("parse_ini_string",             MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_NULL | MAY_BE_ARRAY_OF_FALSE | MAY_BE_ARRAY_OF_TRUE | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_DOUBLE | MAY_BE_ARRAY_OF_STRING | MAY_BE_ARRAY_OF_ARRAY),
272 #if ZEND_DEBUG
273 	F1("config_get_hash",              MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_STRING | MAY_BE_ARRAY_OF_ARRAY),
274 #endif
275 	F1("gethostbyaddr",                MAY_BE_FALSE | MAY_BE_STRING),
276 	F1("gethostbyname",                MAY_BE_STRING),
277 	F1("gethostbynamel",               MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
278 #ifdef HAVE_GETHOSTNAME
279 	F1("gethostname",                  MAY_BE_FALSE | MAY_BE_STRING),
280 #endif
281 #if defined(PHP_WIN32) || HAVE_DNS_SEARCH_FUNC
282 # if defined(PHP_WIN32) || HAVE_FULL_DNS_FUNCS
283 	F1("dns_get_record",               MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_ARRAY),
284 # endif
285 #endif
286 	F1("popen",                        MAY_BE_FALSE | MAY_BE_RESOURCE),
287 	F1("fgetc",                        MAY_BE_FALSE | MAY_BE_STRING),
288 	F1("fgets",                        MAY_BE_FALSE | MAY_BE_STRING),
289 	F1("fread",                        MAY_BE_FALSE | MAY_BE_STRING),
290 	F1("fopen",                        MAY_BE_FALSE | MAY_BE_RESOURCE),
291 	F1("fstat",                        MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_LONG),
292 	F1("tempnam",                      MAY_BE_FALSE | MAY_BE_STRING),
293 	F1("tmpfile",                      MAY_BE_FALSE | MAY_BE_RESOURCE),
294 	F1("file",                         MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
295 	F1("file_get_contents",            MAY_BE_FALSE | MAY_BE_STRING),
296 	F1("stream_context_create",        MAY_BE_RESOURCE),
297 	F1("stream_context_get_params",    MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_ANY),
298 	FN("stream_context_get_options",   MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_ANY),
299 	FN("stream_context_get_default",   MAY_BE_RESOURCE),
300 	FN("stream_context_set_default",   MAY_BE_RESOURCE),
301 	FN("stream_filter_prepend",        MAY_BE_FALSE | MAY_BE_RESOURCE),
302 	FN("stream_filter_append",         MAY_BE_FALSE | MAY_BE_RESOURCE),
303 	F1("stream_socket_client",         MAY_BE_FALSE | MAY_BE_RESOURCE),
304 	F1("stream_socket_server",         MAY_BE_FALSE | MAY_BE_RESOURCE),
305 	F1("stream_socket_accept",         MAY_BE_FALSE | MAY_BE_RESOURCE),
306 	F1("stream_socket_recvfrom",       MAY_BE_FALSE | MAY_BE_STRING),
307 #if HAVE_SOCKETPAIR
308 	F1("stream_socket_pair",           MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_RESOURCE),
309 #endif
310 	F1("stream_get_contents",          MAY_BE_FALSE | MAY_BE_STRING),
311 	F1("fgetcsv",                      MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_NULL | MAY_BE_ARRAY_OF_STRING),
312 	F1("get_meta_tags",                MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_STRING),
313 	F1("stream_get_meta_data",         MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_ANY),
314 	F1("stream_get_line",              MAY_BE_FALSE | MAY_BE_STRING),
315 	F1("stream_get_wrappers",          MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
316 	F1("stream_get_transports",        MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
317 	F1("stream_resolve_include_path",  MAY_BE_FALSE | MAY_BE_STRING),
318 	F1("get_headers",                  MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_STRING | MAY_BE_ARRAY_OF_ARRAY),
319 	F1("socket_get_status",            MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_ANY),
320 	F1("realpath",                     MAY_BE_FALSE | MAY_BE_STRING),
321 	F1("fsockopen",                    MAY_BE_FALSE | MAY_BE_RESOURCE),
322 	FN("pfsockopen",                   MAY_BE_FALSE | MAY_BE_RESOURCE),
323 	F1("pack",                         MAY_BE_STRING),
324 	F1("unpack",                       MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY),
325 	F1("get_browser",                  MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_OBJECT | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_ANY),
326 	F1("crypt",                        MAY_BE_STRING),
327 	FN("opendir",                      MAY_BE_FALSE | MAY_BE_RESOURCE),
328 	F1("getcwd",                       MAY_BE_FALSE | MAY_BE_STRING),
329 	F1("readdir",                      MAY_BE_FALSE | MAY_BE_STRING),
330 	F1("dir",                          MAY_BE_FALSE | MAY_BE_OBJECT),
331 	F1("scandir",                      MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
332 #ifdef HAVE_GLOB
333 	F1("glob",                         MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
334 #endif
335 	F1("filetype",                     MAY_BE_FALSE | MAY_BE_STRING),
336 	F1("stat",                         MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_FALSE | MAY_BE_ARRAY_OF_TRUE | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_STRING),
337 	F1("lstat",                        MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_FALSE | MAY_BE_ARRAY_OF_TRUE | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_STRING),
338 	F1("realpath_cache_get",           MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_ARRAY),
339 #ifdef HAVE_SYSLOG_H
340 	F0("syslog",                       MAY_BE_TRUE),
341 	F0("closelog",                     MAY_BE_TRUE),
342 #endif
343 	F1("metaphone",                    MAY_BE_STRING),
344 	F1("ob_get_flush",                 MAY_BE_FALSE | MAY_BE_STRING),
345 	F1("ob_get_clean",                 MAY_BE_FALSE | MAY_BE_STRING),
346 	F1("ob_get_status",                MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_STRING | MAY_BE_ARRAY_OF_ARRAY),
347 	F1("ob_list_handlers",             MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
348 	F0("array_walk",                   MAY_BE_TRUE),
349 	F0("array_walk_recursive",         MAY_BE_TRUE),
350 	F0("arsort",                       MAY_BE_TRUE),
351 	F0("asort",                        MAY_BE_TRUE),
352 	F0("krsort",                       MAY_BE_TRUE),
353 	F0("ksort",                        MAY_BE_TRUE),
354 	F0("shuffle",                      MAY_BE_TRUE),
355 	F0("sort",                         MAY_BE_TRUE),
356 	F0("usort",                        MAY_BE_TRUE),
357 	F0("uasort",                       MAY_BE_TRUE),
358 	F0("uksort",                       MAY_BE_TRUE),
359 	FN("end",                          UNKNOWN_INFO),
360 	FN("prev",                         UNKNOWN_INFO),
361 	FN("next",                         UNKNOWN_INFO),
362 	FN("reset",                        UNKNOWN_INFO),
363 	FN("current",                      UNKNOWN_INFO),
364 	FN("min",                          UNKNOWN_INFO),
365 	FN("max",                          UNKNOWN_INFO),
366 	F1("compact",                      MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
367 	FN("array_fill",                   MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_ANY),
368 	F1("array_fill_keys",              MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
369 	FC("range",                        zend_range_info),
370 	FN("array_pop",                    UNKNOWN_INFO),
371 	FN("array_shift",                  UNKNOWN_INFO),
372 	F1("array_replace",                MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
373 	F1("array_replace_recursive",      MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
374 	FN("array_keys",                   MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_STRING),
375 	FN("array_values",                 MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
376 	F1("array_count_values",           MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_LONG),
377 	F1("array_column",                 MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
378 	F1("array_reverse",                MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
379 	F1("array_flip",                   MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_STRING),
380 	F1("array_change_key_case",        MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
381 	FN("array_rand",                   MAY_BE_LONG | MAY_BE_STRING | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_STRING),
382 	F1("array_intersect",              MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
383 	F1("array_intersect_key",          MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
384 	F1("array_intersect_ukey",         MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
385 	F1("array_uintersect",             MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
386 	F1("array_intersect_assoc",        MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
387 	F1("array_uintersect_assoc",       MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
388 	F1("array_intersect_uassoc",       MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
389 	F1("array_uintersect_uassoc",      MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
390 	F1("array_diff_key",               MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
391 	F1("array_diff_ukey",              MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
392 	F1("array_udiff",                  MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
393 	F1("array_diff_assoc",             MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
394 	F1("array_udiff_assoc",            MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
395 	F1("array_diff_uassoc",            MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
396 	F1("array_udiff_uassoc",           MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
397 	F1("str_rot13",                    MAY_BE_STRING),
398 	F1("stream_get_filters",           MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
399 	F1("stream_bucket_make_writeable", MAY_BE_NULL | MAY_BE_OBJECT),
400 	F1("stream_bucket_new",            MAY_BE_OBJECT),
401 	F1("sys_get_temp_dir",             MAY_BE_STRING),
402 
403 	/* ext/date */
404 	F1("date",                                  MAY_BE_STRING),
405 	F1("gmdate",                                MAY_BE_STRING),
406 	F1("strftime",                              MAY_BE_FALSE | MAY_BE_STRING),
407 	F1("gmstrftime",                            MAY_BE_FALSE | MAY_BE_STRING),
408 	F1("localtime",                             MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_LONG),
409 	F1("getdate",                               MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_STRING),
410 	F1("date_create",                           MAY_BE_FALSE | MAY_BE_OBJECT),
411 	F1("date_create_immutable",                 MAY_BE_FALSE | MAY_BE_OBJECT),
412 	F1("date_create_from_format",               MAY_BE_FALSE | MAY_BE_OBJECT),
413 	F1("date_create_immutable_from_format",     MAY_BE_FALSE | MAY_BE_OBJECT),
414 	F1("date_parse",                            MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_ANY),
415 	F1("date_parse_from_format",                MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_ANY),
416 	F1("date_get_last_errors",                  MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_ARRAY),
417 	F1("date_format",                           MAY_BE_STRING),
418 	F1("date_timezone_get",                     MAY_BE_FALSE | MAY_BE_OBJECT),
419 	F1("date_diff",                             MAY_BE_OBJECT),
420 	F1("timezone_open",                         MAY_BE_FALSE | MAY_BE_OBJECT),
421 	F1("timezone_name_get",                     MAY_BE_STRING),
422 	F1("timezone_name_from_abbr",               MAY_BE_FALSE | MAY_BE_STRING),
423 	F1("timezone_transitions_get",              MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY),
424 	F1("timezone_location_get",                 MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_DOUBLE | MAY_BE_ARRAY_OF_STRING),
425 	F1("timezone_identifiers_list",             MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
426 	F1("timezone_abbreviations_list",           MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_ARRAY),
427 	F1("timezone_version_get",                  MAY_BE_STRING),
428 	F1("date_interval_create_from_date_string", MAY_BE_FALSE | MAY_BE_OBJECT),
429 	F1("date_interval_format",                  MAY_BE_STRING),
430 	F1("date_default_timezone_get",             MAY_BE_STRING),
431 	F1("date_sunrise",                          MAY_BE_FALSE | MAY_BE_LONG | MAY_BE_DOUBLE | MAY_BE_STRING),
432 	F1("date_sunset",                           MAY_BE_FALSE | MAY_BE_LONG | MAY_BE_DOUBLE | MAY_BE_STRING),
433 	F1("date_sun_info",                         MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_FALSE | MAY_BE_ARRAY_OF_TRUE | MAY_BE_ARRAY_OF_LONG),
434 
435 	/* ext/preg */
436 	FN("preg_replace",			                MAY_BE_NULL | MAY_BE_STRING | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_STRING),
437 	FN("preg_replace_callback",	                MAY_BE_NULL | MAY_BE_STRING | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_STRING),
438 	F1("preg_filter",				            MAY_BE_NULL | MAY_BE_STRING | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_STRING),
439 	F1("preg_split",				            MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING | MAY_BE_ARRAY_OF_ARRAY),
440 	F1("preg_grep",				                MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
441 
442 	/* ext/mysqli */
443 	F1("mysqli_connect",						MAY_BE_FALSE | MAY_BE_OBJECT),
444 	F0("mysqli_close",							MAY_BE_TRUE),
445 	F1("mysqli_connect_error",					MAY_BE_NULL | MAY_BE_STRING),
446 	F1("mysqli_get_client_stats",				MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_STRING),
447 	F1("mysqli_error_list",						MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_ARRAY),
448 	F1("mysqli_get_links_stats",				MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_LONG),
449 	F1("mysqli_query",							MAY_BE_FALSE | MAY_BE_TRUE | MAY_BE_OBJECT),
450 	F1("mysqli_get_charset", 					MAY_BE_NULL | MAY_BE_OBJECT),
451 	F1("mysqli_fetch_array",					MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY),
452 	F1("mysqli_fetch_assoc",					MAY_BE_NULL | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY),
453 	F1("mysqli_fetch_all",						MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY),
454 	F1("mysqli_fetch_object",					MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_OBJECT),
455 	F1("mysqli_affected_rows",					MAY_BE_LONG | MAY_BE_STRING),
456 	F1("mysqli_character_set_name",				MAY_BE_STRING),
457 	F0("mysqli_debug",							MAY_BE_TRUE),
458 	F1("mysqli_error",							MAY_BE_STRING),
459 	F1("mysqli_reap_async_query",				MAY_BE_FALSE | MAY_BE_TRUE | MAY_BE_OBJECT),
460 	F1("mysqli_stmt_get_result",				MAY_BE_FALSE | MAY_BE_OBJECT),
461 	F1("mysqli_get_warnings",					MAY_BE_FALSE | MAY_BE_OBJECT),
462 	F1("mysqli_stmt_error_list",				MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_ARRAY),
463 	F1("mysqli_stmt_get_warnings",				MAY_BE_FALSE | MAY_BE_OBJECT),
464 	F1("mysqli_fetch_field",					MAY_BE_FALSE | MAY_BE_OBJECT),
465 	F1("mysqli_fetch_fields",					MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_OBJECT),
466 	F1("mysqli_fetch_field_direct",				MAY_BE_FALSE | MAY_BE_OBJECT),
467 	F1("mysqli_fetch_lengths",					MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_LONG),
468 	F1("mysqli_fetch_row",						MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_ANY),
469 	F1("mysqli_get_client_info",				MAY_BE_STRING),
470 	F1("mysqli_get_host_info",					MAY_BE_STRING),
471 	F1("mysqli_get_server_info",				MAY_BE_STRING),
472 	F1("mysqli_info",							MAY_BE_NULL | MAY_BE_STRING),
473 	F1("mysqli_init",							MAY_BE_FALSE | MAY_BE_OBJECT),
474 	F1("mysqli_insert_id",						MAY_BE_LONG | MAY_BE_STRING),
475 	F1("mysqli_num_rows",						MAY_BE_LONG | MAY_BE_STRING),
476 	F1("mysqli_prepare",						MAY_BE_FALSE | MAY_BE_OBJECT),
477 	F1("mysqli_real_escape_string",				MAY_BE_STRING),
478 	F1("mysqli_stmt_affected_rows",				MAY_BE_LONG | MAY_BE_STRING),
479 	F1("mysqli_stmt_insert_id",					MAY_BE_LONG | MAY_BE_STRING),
480 	F1("mysqli_stmt_num_rows",					MAY_BE_LONG | MAY_BE_STRING),
481 	F1("mysqli_sqlstate",						MAY_BE_STRING),
482 	F0("mysqli_ssl_set",						MAY_BE_TRUE),
483 	F1("mysqli_stat",							MAY_BE_FALSE | MAY_BE_STRING),
484 	F1("mysqli_stmt_error",						MAY_BE_STRING),
485 	F1("mysqli_stmt_init",						MAY_BE_FALSE | MAY_BE_OBJECT),
486 	F1("mysqli_stmt_result_metadata",			MAY_BE_FALSE | MAY_BE_OBJECT),
487 	F1("mysqli_stmt_sqlstate",					MAY_BE_STRING),
488 	F1("mysqli_store_result",					MAY_BE_FALSE | MAY_BE_OBJECT),
489 	F1("mysqli_use_result",						MAY_BE_FALSE | MAY_BE_OBJECT),
490 
491 	/* ext/curl */
492 	F1("curl_init",                             MAY_BE_FALSE | MAY_BE_OBJECT),
493 	F1("curl_copy_handle",                      MAY_BE_FALSE | MAY_BE_OBJECT),
494 	F1("curl_version",                          MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_STRING | MAY_BE_ARRAY_OF_ARRAY),
495 	F1("curl_getinfo",                          MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_STRING | MAY_BE_LONG | MAY_BE_DOUBLE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY),
496 	F1("curl_error",                            MAY_BE_STRING),
497 	F1("curl_strerror",                         MAY_BE_NULL | MAY_BE_STRING),
498 	F1("curl_multi_strerror",                   MAY_BE_NULL | MAY_BE_STRING),
499 	F1("curl_escape",                           MAY_BE_FALSE | MAY_BE_STRING),
500 	F1("curl_unescape",                         MAY_BE_FALSE | MAY_BE_STRING),
501 	F1("curl_multi_init",                       MAY_BE_OBJECT),
502 	F1("curl_multi_info_read",                  MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_OBJECT),
503 	F1("curl_share_init",                       MAY_BE_OBJECT),
504 	F1("curl_file_create",                      MAY_BE_OBJECT),
505 
506 	/* ext/mbstring */
507 	F1("mb_convert_case",                       MAY_BE_STRING),
508 	F1("mb_strtoupper",                         MAY_BE_STRING),
509 	F1("mb_strtolower",                         MAY_BE_STRING),
510 	F1("mb_language",                           MAY_BE_FALSE | MAY_BE_TRUE | MAY_BE_STRING),
511 	F1("mb_internal_encoding",                  MAY_BE_FALSE | MAY_BE_TRUE | MAY_BE_STRING),
512 	F1("mb_http_input",                         MAY_BE_FALSE | MAY_BE_STRING| MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
513 	F1("mb_http_output",                        MAY_BE_FALSE | MAY_BE_TRUE | MAY_BE_STRING),
514 	F1("mb_detect_order",                       MAY_BE_TRUE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
515 	F1("mb_substitute_character",               MAY_BE_FALSE | MAY_BE_TRUE | MAY_BE_LONG | MAY_BE_STRING),
516 	F1("mb_output_handler",                     MAY_BE_STRING),
517 	F1("mb_preferred_mime_name",                MAY_BE_FALSE | MAY_BE_STRING),
518 	F1("mb_strstr",                             MAY_BE_FALSE | MAY_BE_STRING),
519 	F1("mb_strrchr",                            MAY_BE_FALSE | MAY_BE_STRING),
520 	F1("mb_stristr",                            MAY_BE_FALSE | MAY_BE_STRING),
521 	F1("mb_strrichr",                           MAY_BE_FALSE | MAY_BE_STRING),
522 	F1("mb_substr",                             MAY_BE_STRING),
523 	F1("mb_strcut",                             MAY_BE_STRING),
524 	F1("mb_strimwidth",                         MAY_BE_STRING),
525 	F1("mb_convert_encoding",                   MAY_BE_FALSE | MAY_BE_STRING | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY),
526 	F1("mb_detect_encoding",                    MAY_BE_FALSE | MAY_BE_STRING),
527 	F1("mb_list_encodings",                     MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
528 	F1("mb_encoding_aliases",                   MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
529 	F1("mb_convert_kana",                       MAY_BE_STRING),
530 	F1("mb_encode_mimeheader",                  MAY_BE_STRING),
531 	F1("mb_decode_mimeheader",                  MAY_BE_STRING),
532 	F1("mb_convert_variables",                  MAY_BE_FALSE | MAY_BE_STRING),
533 	F1("mb_encode_numericentity",               MAY_BE_STRING),
534 	F1("mb_decode_numericentity",               MAY_BE_STRING),
535 	F1("mb_get_info",                           MAY_BE_FALSE | MAY_BE_LONG | MAY_BE_STRING | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_STRING | MAY_BE_ARRAY_OF_ARRAY),
536 
537 	F1("mb_regex_encoding",                     MAY_BE_FALSE | MAY_BE_TRUE | MAY_BE_STRING),
538 	F1("mb_regex_set_options",                  MAY_BE_STRING),
539 	F1("mb_ereg_replace",                       MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_STRING),
540 	F1("mb_eregi_replace",                      MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_STRING),
541 	F1("mb_ereg_replace_callback",              MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_STRING),
542 	F1("mb_split",                              MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
543 	F1("mb_ereg_search_pos",                    MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_LONG),
544 	F1("mb_ereg_search_regs",                   MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_FALSE | MAY_BE_ARRAY_OF_STRING),
545 	F1("mb_ereg_search_getregs",                MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_FALSE | MAY_BE_ARRAY_OF_STRING),
546 
547 	/* ext/iconv */
548 	F1("iconv",                                 MAY_BE_FALSE | MAY_BE_STRING),
549 	F1("iconv_get_encoding",                    MAY_BE_FALSE | MAY_BE_STRING | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_STRING),
550 	F1("iconv_substr",                          MAY_BE_FALSE | MAY_BE_STRING),
551 	F1("iconv_mime_encode",                     MAY_BE_FALSE | MAY_BE_STRING),
552 	F1("iconv_mime_decode",                     MAY_BE_FALSE | MAY_BE_STRING),
553 	F1("iconv_mime_decode_headers",             MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_STRING | MAY_BE_ARRAY_OF_ARRAY),
554 
555 	/* ext/json */
556 	F1("json_encode",                           MAY_BE_FALSE | MAY_BE_STRING),
557 	FN("json_decode",                           MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY),
558 	F1("json_last_error_msg",                   MAY_BE_STRING),
559 
560 	/* ext/xml */
561 	F1("xml_error_string",                      MAY_BE_NULL | MAY_BE_STRING),
562 	F1("xml_parser_get_option",                 MAY_BE_LONG | MAY_BE_STRING),
563 	F1("utf8_encode",                           MAY_BE_STRING),
564 	F1("utf8_decode",                           MAY_BE_STRING),
565 
566 	/* ext/zlib */
567 	F1("gzgetc",                                MAY_BE_FALSE | MAY_BE_STRING),
568 	F1("gzgets",                                MAY_BE_FALSE | MAY_BE_STRING),
569 	F1("gzread",                                MAY_BE_FALSE | MAY_BE_STRING),
570 	F1("gzopen",                                MAY_BE_FALSE | MAY_BE_RESOURCE),
571 	F1("gzfile",                                MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
572 	F1("gzcompress",                            MAY_BE_FALSE | MAY_BE_STRING),
573 	F1("gzuncompress",                          MAY_BE_FALSE | MAY_BE_STRING),
574 	F1("gzdeflate",                             MAY_BE_FALSE | MAY_BE_STRING),
575 	F1("gzinflate",                             MAY_BE_FALSE | MAY_BE_STRING),
576 	F1("gzencode",                              MAY_BE_FALSE | MAY_BE_STRING),
577 	F1("gzdecode",                              MAY_BE_FALSE | MAY_BE_STRING),
578 	F1("zlib_encode",                           MAY_BE_FALSE | MAY_BE_STRING),
579 	F1("zlib_decode",                           MAY_BE_FALSE | MAY_BE_STRING),
580 	F1("zlib_get_coding_type",                  MAY_BE_FALSE | MAY_BE_STRING),
581 	F1("ob_gzhandler",                          MAY_BE_FALSE | MAY_BE_STRING),
582 
583 	/* ext/hash */
584 	F1("hash",                                  MAY_BE_STRING),
585 	F1("hash_file",                             MAY_BE_FALSE | MAY_BE_STRING),
586 	F1("hash_hmac",                             MAY_BE_STRING),
587 	F1("hash_hmac_algos",                       MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
588 	F1("hash_hmac_file",                        MAY_BE_FALSE | MAY_BE_STRING),
589 	F1("hash_hkdf",                             MAY_BE_STRING),
590 	F1("hash_init",                             MAY_BE_OBJECT),
591 	F1("hash_final",                            MAY_BE_STRING),
592 	F1("hash_copy",                             MAY_BE_OBJECT),
593 	F1("hash_algos",                            MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
594 	F1("hash_pbkdf2",                           MAY_BE_STRING),
595 	F1("mhash_keygen_s2k",                      MAY_BE_FALSE | MAY_BE_STRING),
596 	F1("mhash_get_hash_name",                   MAY_BE_FALSE | MAY_BE_STRING),
597 	F1("mhash",                                 MAY_BE_FALSE | MAY_BE_FALSE | MAY_BE_STRING),
598 
599 	/* ext/sodium */
600 	F1("sodium_crypto_shorthash",				MAY_BE_STRING),
601 	F1("sodium_crypto_secretbox",				MAY_BE_STRING),
602 	F1("sodium_crypto_secretbox_open",			MAY_BE_FALSE | MAY_BE_STRING),
603 	F1("sodium_crypto_generichash",				MAY_BE_STRING),
604 	F1("sodium_crypto_generichash_init",		MAY_BE_STRING),
605 	F0("sodium_crypto_generichash_update",		MAY_BE_TRUE),
606 	F1("sodium_crypto_generichash_final",		MAY_BE_STRING),
607 	F1("sodium_crypto_box_keypair",				MAY_BE_STRING),
608 	F1("sodium_crypto_box_seed_keypair",		MAY_BE_STRING),
609 	F1("sodium_crypto_box_secretkey",			MAY_BE_STRING),
610 	F1("sodium_crypto_box_publickey",			MAY_BE_STRING),
611 	F1("sodium_crypto_box",						MAY_BE_STRING),
612 	F1("sodium_crypto_box_open",				MAY_BE_FALSE | MAY_BE_STRING),
613 	F1("sodium_crypto_box_seal",				MAY_BE_STRING),
614 	F1("sodium_crypto_box_seal_open",			MAY_BE_FALSE | MAY_BE_STRING),
615 	F1("sodium_crypto_sign_keypair",			MAY_BE_STRING),
616 	F1("sodium_crypto_sign_seed_keypair",		MAY_BE_STRING),
617 	F1("sodium_crypto_sign_secretkey",			MAY_BE_STRING),
618 	F1("sodium_crypto_sign_publickey",			MAY_BE_STRING),
619 	F1("sodium_crypto_sign",					MAY_BE_STRING),
620 	F1("sodium_crypto_sign_open",				MAY_BE_FALSE | MAY_BE_STRING),
621 	F1("sodium_crypto_sign_detached",			MAY_BE_STRING),
622 	F1("sodium_crypto_stream",					MAY_BE_STRING),
623 	F1("sodium_crypto_stream_xor",				MAY_BE_STRING),
624 	F1("sodium_crypto_pwhash",					MAY_BE_STRING),
625 	F1("sodium_crypto_pwhash_str",				MAY_BE_STRING),
626 	F1("sodium_crypto_aead_aes256gcm_encrypt",	MAY_BE_STRING),
627 	F1("sodium_crypto_aead_aes256gcm_decrypt",	MAY_BE_FALSE | MAY_BE_STRING),
628 	F1("sodium_bin2hex",						MAY_BE_STRING),
629 	F1("sodium_hex2bin",						MAY_BE_STRING),
630 	F1("sodium_crypto_scalarmult",				MAY_BE_STRING),
631 	F1("sodium_crypto_kx_seed_keypair",			MAY_BE_STRING),
632 	F1("sodium_crypto_kx_keypair",				MAY_BE_STRING),
633 	F1("sodium_crypto_kx_secretkey",			MAY_BE_STRING),
634 	F1("sodium_crypto_kx_publickey",			MAY_BE_STRING),
635 	F1("sodium_crypto_kx_client_session_keys",	MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
636 	F1("sodium_crypto_kx_server_session_keys",	MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
637 	F1("sodium_crypto_auth",					MAY_BE_STRING),
638 	F1("sodium_crypto_aead_aes256gcm_keygen",	MAY_BE_STRING),
639 	F1("sodium_crypto_auth_keygen",				MAY_BE_STRING),
640 	F1("sodium_crypto_generichash_keygen",		MAY_BE_STRING),
641 	F1("sodium_crypto_kdf_keygen",				MAY_BE_STRING),
642 	F1("sodium_crypto_secretbox_keygen",		MAY_BE_STRING),
643 	F1("sodium_crypto_shorthash_keygen",		MAY_BE_STRING),
644 	F1("sodium_crypto_stream_keygen",			MAY_BE_STRING),
645 	F1("sodium_crypto_kdf_derive_from_key",		MAY_BE_STRING),
646 	F1("sodium_pad",							MAY_BE_STRING),
647 	F1("sodium_unpad",							MAY_BE_STRING),
648 
649 	F1("sodium_crypto_box_keypair_from_secretkey_and_publickey",	MAY_BE_STRING),
650 	F1("sodium_crypto_box_publickey_from_secretkey",				MAY_BE_STRING),
651 	F1("sodium_crypto_sign_keypair_from_secretkey_and_publickey",	MAY_BE_STRING),
652 	F1("sodium_crypto_sign_publickey_from_secretkey",				MAY_BE_STRING),
653 	F1("sodium_crypto_pwhash_scryptsalsa208sha256",					MAY_BE_STRING),
654 	F1("sodium_crypto_pwhash_scryptsalsa208sha256_str",				MAY_BE_STRING),
655 	F1("sodium_crypto_sign_ed25519_sk_to_curve25519",				MAY_BE_STRING),
656 	F1("sodium_crypto_sign_ed25519_pk_to_curve25519",				MAY_BE_STRING),
657 	F1("sodium_crypto_aead_chacha20poly1305_encrypt",				MAY_BE_STRING),
658 	F1("sodium_crypto_aead_chacha20poly1305_decrypt",				MAY_BE_FALSE | MAY_BE_STRING),
659 	F1("sodium_crypto_aead_chacha20poly1305_ietf_encrypt",			MAY_BE_STRING),
660 	F1("sodium_crypto_aead_chacha20poly1305_ietf_decrypt",			MAY_BE_FALSE | MAY_BE_STRING),
661 	F1("sodium_crypto_aead_xchacha20poly1305_ietf_encrypt",			MAY_BE_STRING),
662 	F1("sodium_crypto_aead_xchacha20poly1305_ietf_decrypt",			MAY_BE_FALSE | MAY_BE_STRING),
663 	F1("sodium_crypto_aead_chacha20poly1305_keygen",				MAY_BE_STRING),
664 	F1("sodium_crypto_aead_chacha20poly1305_ietf_keygen",			MAY_BE_STRING),
665 	F1("sodium_crypto_aead_xchacha20poly1305_ietf_keygen",			MAY_BE_STRING),
666 
667 	/* ext/session */
668 	F1("session_get_cookie_params",				MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_ANY),
669 	F1("session_name",							MAY_BE_FALSE | MAY_BE_STRING),
670 	F1("session_module_name",					MAY_BE_FALSE | MAY_BE_STRING),
671 	F1("session_save_path",						MAY_BE_FALSE | MAY_BE_STRING),
672 	F1("session_create_id",						MAY_BE_FALSE | MAY_BE_STRING),
673 	F1("session_cache_limiter",					MAY_BE_FALSE | MAY_BE_STRING),
674 	F1("session_encode",						MAY_BE_FALSE | MAY_BE_STRING),
675 
676 	/* ext/pgsql */
677 	FN("pg_connect",							MAY_BE_FALSE | MAY_BE_RESOURCE),
678 	FN("pg_pconnect",							MAY_BE_FALSE | MAY_BE_RESOURCE),
679 	F1("pg_dbname",								MAY_BE_STRING),
680 	F1("pg_last_error",							MAY_BE_STRING),
681 	F1("pg_options",							MAY_BE_STRING),
682 	F1("pg_port",								MAY_BE_STRING),
683 	F1("pg_tty",								MAY_BE_STRING),
684 	F1("pg_host",								MAY_BE_STRING),
685 	F1("pg_version",							MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_STRING | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_NULL),
686 	F1("pg_parameter_status",					MAY_BE_FALSE | MAY_BE_STRING),
687 	F1("pg_query",								MAY_BE_FALSE | MAY_BE_RESOURCE),
688 	F1("pg_query_params",						MAY_BE_FALSE | MAY_BE_RESOURCE),
689 	F1("pg_prepare",							MAY_BE_FALSE | MAY_BE_RESOURCE),
690 	F1("pg_execute",							MAY_BE_FALSE | MAY_BE_RESOURCE),
691 	FN("pg_last_notice",						MAY_BE_FALSE | MAY_BE_TRUE | MAY_BE_STRING | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY ),
692 	F1("pg_field_table",						MAY_BE_FALSE | MAY_BE_LONG | MAY_BE_STRING),
693 	F1("pg_field_name",							MAY_BE_STRING),
694 	F1("pg_field_type",							MAY_BE_STRING),
695 	F1("pg_field_type_oid",						MAY_BE_LONG | MAY_BE_STRING),
696 	F1("pg_fetch_result",						MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_STRING),
697 	F1("pg_fetch_row",							MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_NULL | MAY_BE_ARRAY_OF_STRING),
698 	F1("pg_fetch_assoc",						MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_NULL | MAY_BE_ARRAY_OF_STRING),
699 	F1("pg_fetch_array",						MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_NULL | MAY_BE_ARRAY_OF_STRING),
700 	F1("pg_fetch_object",						MAY_BE_FALSE | MAY_BE_OBJECT),
701 	F1("pg_fetch_all",							MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_ARRAY),
702 	F1("pg_fetch_all_columns",					MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_NULL | MAY_BE_ARRAY_OF_STRING),
703 	F1("pg_last_oid",							MAY_BE_FALSE | MAY_BE_LONG | MAY_BE_STRING),
704 	F1("pg_lo_create",							MAY_BE_FALSE | MAY_BE_LONG | MAY_BE_STRING),
705 	F1("pg_lo_open",							MAY_BE_FALSE | MAY_BE_RESOURCE),
706 	F1("pg_lo_read",							MAY_BE_FALSE | MAY_BE_STRING),
707 	F1("pg_lo_import",							MAY_BE_FALSE | MAY_BE_LONG | MAY_BE_STRING),
708 	F1("pg_copy_to",							MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
709 	F1("pg_escape_string",						MAY_BE_STRING),
710 	F1("pg_escape_bytea",						MAY_BE_STRING),
711 	F1("pg_unescape_bytea",						MAY_BE_STRING),
712 	F1("pg_escape_literal",						MAY_BE_FALSE | MAY_BE_STRING),
713 	F1("pg_escape_identifier",					MAY_BE_FALSE | MAY_BE_STRING),
714 	F1("pg_result_error",						MAY_BE_FALSE | MAY_BE_STRING),
715 	F1("pg_result_error_field",					MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_STRING),
716 	F1("pg_get_result",							MAY_BE_FALSE | MAY_BE_RESOURCE),
717 	F1("pg_result_status",						MAY_BE_LONG | MAY_BE_STRING),
718 	F1("pg_get_notify",							MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY),
719 	F1("pg_socket",								MAY_BE_FALSE | MAY_BE_RESOURCE),
720 	F1("pg_meta_data",							MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_ARRAY),
721 	F1("pg_convert",							MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_ANY),
722 	F1("pg_insert",								MAY_BE_FALSE | MAY_BE_TRUE | MAY_BE_RESOURCE | MAY_BE_STRING),
723 	F1("pg_update",								MAY_BE_FALSE | MAY_BE_TRUE | MAY_BE_STRING),
724 	F1("pg_delete",								MAY_BE_FALSE | MAY_BE_TRUE | MAY_BE_STRING),
725 	F1("pg_select",								MAY_BE_FALSE | MAY_BE_STRING | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_ARRAY),
726 
727 	/* ext/bcmath */
728 	F1("bcadd",									MAY_BE_STRING),
729 	F1("bcsub",									MAY_BE_STRING),
730 	F1("bcmul",									MAY_BE_STRING),
731 	F1("bcdiv",									MAY_BE_STRING),
732 	F1("bcmod",									MAY_BE_STRING),
733 	F1("bcpowmod",								MAY_BE_STRING),
734 	F1("bcpow",									MAY_BE_STRING),
735 	F1("bcsqrt",								MAY_BE_STRING),
736 
737 	/* ext/exif */
738 	F1("exif_tagname",							MAY_BE_FALSE | MAY_BE_STRING),
739 	F1("exif_read_data",						MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_ANY),
740 	F1("exif_thumbnail",						MAY_BE_FALSE | MAY_BE_STRING),
741 
742 	/* ext/filter */
743 	FN("filter_input",							UNKNOWN_INFO),
744 	FN("filter_var",							UNKNOWN_INFO),
745 	F1("filter_input_array",					MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY),
746 	F1("filter_var_array",						MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF),
747 	F1("filter_list",							MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
748 
749 	/* ext/gettext */
750 	F1("textdomain",							MAY_BE_STRING),
751 	F1("gettext",								MAY_BE_STRING),
752 	F1("_",										MAY_BE_STRING),
753 	F1("dgettext",								MAY_BE_STRING),
754 	F1("dcgettext",								MAY_BE_STRING),
755 	F1("bindtextdomain",						MAY_BE_FALSE | MAY_BE_STRING),
756 #if HAVE_NGETTEXT
757 	F1("ngettext",								MAY_BE_STRING),
758 #endif
759 #if HAVE_DNGETTEXT
760 	F1("dcngettext",							MAY_BE_STRING),
761 #endif
762 #if HAVE_BIND_TEXTDOMAIN_CODESET
763 	F1("bind_textdomain_codeset",				MAY_BE_FALSE | MAY_BE_STRING),
764 #endif
765 
766 	/* ext/fileinfo */
767 	F1("finfo_open",							MAY_BE_FALSE | MAY_BE_RESOURCE),
768 	F1("finfo_file",							MAY_BE_FALSE | MAY_BE_STRING),
769 	F1("finfo_buffer",							MAY_BE_FALSE | MAY_BE_STRING),
770 	F1("mime_content_type",						MAY_BE_FALSE | MAY_BE_STRING),
771 
772 	/* ext/gd */
773 	F1("gd_info",								MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_STRING | MAY_BE_ARRAY_OF_FALSE | MAY_BE_ARRAY_OF_TRUE),
774 	F1("imagecreatetruecolor",					MAY_BE_FALSE | MAY_BE_OBJECT),
775 #ifdef PHP_WIN32
776 	F1("imagegrabwindow",						MAY_BE_FALSE | MAY_BE_OBJECT),
777 	F1("imagegrabscreen",						MAY_BE_FALSE | MAY_BE_OBJECT),
778 #endif
779 	F1("imagerotate",							MAY_BE_FALSE | MAY_BE_OBJECT),
780 	F1("imagecreate",							MAY_BE_FALSE | MAY_BE_OBJECT),
781 	F1("imagecreatefromstring",					MAY_BE_FALSE | MAY_BE_OBJECT),
782 	F1("imagecreatefromgif",					MAY_BE_FALSE | MAY_BE_OBJECT),
783 #ifdef HAVE_GD_JPG
784 	F1("imagecreatefromjpeg",					MAY_BE_FALSE | MAY_BE_OBJECT),
785 #endif
786 #ifdef HAVE_GD_PNG
787 	F1("imagecreatefrompng",					MAY_BE_FALSE | MAY_BE_OBJECT),
788 #endif
789 #ifdef HAVE_GD_WEBP
790 	F1("imagecreatefromwebp",					MAY_BE_FALSE | MAY_BE_OBJECT),
791 #endif
792 	F1("imagecreatefromxbm",					MAY_BE_FALSE | MAY_BE_OBJECT),
793 #if defined(HAVE_GD_XPM)
794 	F1("imagecreatefromxpm",					MAY_BE_FALSE | MAY_BE_OBJECT),
795 #endif
796 	F1("imagecreatefromwbmp",					MAY_BE_FALSE | MAY_BE_OBJECT),
797 	F1("imagecreatefromgd",						MAY_BE_FALSE | MAY_BE_OBJECT),
798 	F1("imagecreatefromgd2",					MAY_BE_FALSE | MAY_BE_OBJECT),
799 	F1("imagecreatefromgd2part",				MAY_BE_FALSE | MAY_BE_OBJECT),
800 #if defined(HAVE_GD_BMP)
801 	F1("imagecreatefrombmp",					MAY_BE_FALSE | MAY_BE_OBJECT),
802 #endif
803 	F0("imagecolorset",							MAY_BE_NULL | MAY_BE_FALSE),
804 	F1("imagecolorsforindex",					MAY_BE_ARRAY |  MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_LONG),
805 	F1("imagegetclip",							MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_LONG),
806 	F1("imageftbbox",							MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_LONG),
807 	F1("imagefttext",							MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_LONG),
808 	F1("imagettfbbox",							MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_LONG),
809 	F1("imagettftext",							MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_LONG),
810 	F1("imagecrop",								MAY_BE_FALSE | MAY_BE_OBJECT),
811 	F1("imagecropauto",							MAY_BE_FALSE | MAY_BE_OBJECT),
812 	F1("imagescale",							MAY_BE_FALSE | MAY_BE_OBJECT),
813 	F1("imageaffine",							MAY_BE_FALSE | MAY_BE_OBJECT),
814 	F1("imageaffinematrixget",					MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_DOUBLE),
815 	F1("imageaffinematrixconcat",				MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_DOUBLE),
816 	F1("imageresolution",						MAY_BE_TRUE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_LONG),
817 
818 	/* ext/spl */
819 	F1("class_implements",						MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_STRING),
820 	F1("class_parents",							MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_STRING),
821 	F1("class_uses",							MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_STRING),
822 	F1("iterator_to_array",						MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
823 	F1("spl_classes",							MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_STRING),
824 	F1("spl_object_hash",						MAY_BE_STRING),
825 
826 };
827 
828 static HashTable func_info;
829 int zend_func_info_rid = -1;
830 
get_internal_func_info(const zend_call_info * call_info,const zend_ssa * ssa,zend_string * lcname)831 static uint32_t get_internal_func_info(
832 		const zend_call_info *call_info, const zend_ssa *ssa, zend_string *lcname) {
833 	if (call_info->callee_func->common.scope) {
834 		/* This is a method, not a function. */
835 		return 0;
836 	}
837 
838 	zval *zv = zend_hash_find_ex(&func_info, lcname, 1);
839 	if (!zv) {
840 		return 0;
841 	}
842 
843 	func_info_t *info = Z_PTR_P(zv);
844 	if (info->info_func) {
845 		return info->info_func(call_info, ssa);
846 	} else {
847 		return info->info;
848 	}
849 }
850 
zend_get_func_info(const zend_call_info * call_info,const zend_ssa * ssa,zend_class_entry ** ce,zend_bool * ce_is_instanceof)851 uint32_t zend_get_func_info(
852 		const zend_call_info *call_info, const zend_ssa *ssa,
853 		zend_class_entry **ce, zend_bool *ce_is_instanceof)
854 {
855 	uint32_t ret = 0;
856 	const zend_function *callee_func = call_info->callee_func;
857 	*ce = NULL;
858 	*ce_is_instanceof = 0;
859 
860 	if (callee_func->type == ZEND_INTERNAL_FUNCTION) {
861 		zend_string *lcname = Z_STR_P(CRT_CONSTANT_EX(call_info->caller_op_array, call_info->caller_init_opline, call_info->caller_init_opline->op2));
862 
863 		uint32_t internal_ret = get_internal_func_info(call_info, ssa, lcname);
864 #if !ZEND_DEBUG
865 		if (internal_ret) {
866 			return internal_ret;
867 		}
868 #endif
869 
870 		if (callee_func->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE) {
871 			ret = zend_fetch_arg_info_type(NULL, callee_func->common.arg_info - 1, ce);
872 			*ce_is_instanceof = 1;
873 		} else {
874 #if 0
875 			fprintf(stderr, "Unknown internal function '%s'\n", func->common.function_name);
876 #endif
877 			ret = MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF
878 				| MAY_BE_RC1 | MAY_BE_RCN;
879 		}
880 		if (callee_func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) {
881 			ret |= MAY_BE_REF;
882 		}
883 
884 #if ZEND_DEBUG
885 		if (internal_ret) {
886 			/* Check whether the func_info information is a subset of the information we can
887 			 * compute from the specified return type, otherwise it contains redundant types. */
888 			if (internal_ret & ~ret) {
889 				fprintf(stderr, "Inaccurate func info for %s()\n", ZSTR_VAL(lcname));
890 			}
891 			/* Check whether the func info is completely redundant with arginfo.
892 			 * Ignore UNKNOWN_INFO for now. */
893 			if (internal_ret == ret && (internal_ret & MAY_BE_ANY) != MAY_BE_ANY) {
894 				fprintf(stderr, "Useless func info for %s()\n", ZSTR_VAL(lcname));
895 			}
896 			/* If the return type is not mixed, check that the types match exactly if we exclude
897 			 * RC and array information. */
898 			uint32_t ret_any = ret & MAY_BE_ANY, internal_ret_any = internal_ret & MAY_BE_ANY;
899 			if (ret_any != MAY_BE_ANY) {
900 				uint32_t diff = internal_ret_any ^ ret_any;
901 				/* Func info may contain "true" types as well as isolated "null" and "false". */
902 				if (diff && !(diff == MAY_BE_FALSE && (ret & MAY_BE_FALSE))
903 						&& (internal_ret_any & ~(MAY_BE_NULL|MAY_BE_FALSE))) {
904 					fprintf(stderr, "Incorrect func info for %s()\n", ZSTR_VAL(lcname));
905 				}
906 			}
907 			return internal_ret;
908 		}
909 #endif
910 	} else {
911 		// FIXME: the order of functions matters!!!
912 		zend_func_info *info = ZEND_FUNC_INFO((zend_op_array*)callee_func);
913 		if (info) {
914 			ret = info->return_info.type;
915 			*ce = info->return_info.ce;
916 			*ce_is_instanceof = info->return_info.is_instanceof;
917 		}
918 		if (!ret) {
919 			ret = MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF
920 				| MAY_BE_RC1 | MAY_BE_RCN;
921 			/* For generators RETURN_REFERENCE refers to the yielded values. */
922 			if ((callee_func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE)
923 					&& !(callee_func->common.fn_flags & ZEND_ACC_GENERATOR)) {
924 				ret |= MAY_BE_REF;
925 			}
926 		}
927 	}
928 	return ret;
929 }
930 
zend_func_info_startup(void)931 int zend_func_info_startup(void)
932 {
933 	size_t i;
934 
935 	if (zend_func_info_rid == -1) {
936 		zend_func_info_rid = zend_get_resource_handle("Zend Optimizer");
937 		if (zend_func_info_rid < 0) {
938 			return FAILURE;
939 		}
940 
941 		zend_hash_init(&func_info, sizeof(func_infos)/sizeof(func_info_t), NULL, NULL, 1);
942 		for (i = 0; i < sizeof(func_infos)/sizeof(func_info_t); i++) {
943 			zend_string *key = zend_string_init_interned(func_infos[i].name, func_infos[i].name_len, 1);
944 
945 			if (zend_hash_add_ptr(&func_info, key, (void**)&func_infos[i]) == NULL) {
946 				fprintf(stderr, "ERROR: Duplicate function info for \"%s\"\n", func_infos[i].name);
947 			}
948 			zend_string_release_ex(key, 1);
949 		}
950 	}
951 
952 	return SUCCESS;
953 }
954 
zend_func_info_shutdown(void)955 int zend_func_info_shutdown(void)
956 {
957 	if (zend_func_info_rid != -1) {
958 		zend_hash_destroy(&func_info);
959 		zend_func_info_rid = -1;
960 	}
961 	return SUCCESS;
962 }
963