1/*
2   +----------------------------------------------------------------------+
3   | Zend Engine                                                          |
4   +----------------------------------------------------------------------+
5   | Copyright (c) 1998-2016 Zend Technologies Ltd. (http://www.zend.com) |
6   +----------------------------------------------------------------------+
7   | This source file is subject to version 2.00 of the Zend 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.zend.com/license/2_00.txt.                                |
11   | If you did not receive a copy of the Zend license and are unable to  |
12   | obtain it through the world-wide-web, please send a note to          |
13   | license@zend.com so we can mail you a copy immediately.              |
14   +----------------------------------------------------------------------+
15   | Authors: Andi Gutmans <andi@zend.com>                                |
16   |          Zeev Suraski <zeev@zend.com>                                |
17   |          Andrei Zmievski <andrei@php.net>                            |
18   |          Dmitry Stogov <dmitry@zend.com>                             |
19   +----------------------------------------------------------------------+
20*/
21
22/* $Id$ */
23
24#ifndef ZEND_API_H
25#define ZEND_API_H
26
27#include "zend_modules.h"
28#include "zend_list.h"
29#include "zend_operators.h"
30#include "zend_variables.h"
31#include "zend_execute.h"
32
33
34BEGIN_EXTERN_C()
35
36typedef struct _zend_function_entry {
37	const char *fname;
38	void (*handler)(INTERNAL_FUNCTION_PARAMETERS);
39	const struct _zend_internal_arg_info *arg_info;
40	uint32_t num_args;
41	uint32_t flags;
42} zend_function_entry;
43
44typedef struct _zend_fcall_info {
45	size_t size;
46	zval function_name;
47	zval *retval;
48	zval *params;
49	zend_object *object;
50	zend_bool no_separation;
51	uint32_t param_count;
52} zend_fcall_info;
53
54typedef struct _zend_fcall_info_cache {
55	zend_bool initialized;
56	zend_function *function_handler;
57	zend_class_entry *calling_scope;
58	zend_class_entry *called_scope;
59	zend_object *object;
60} zend_fcall_info_cache;
61
62#define ZEND_NS_NAME(ns, name)			ns "\\" name
63
64#define ZEND_FN(name) zif_##name
65#define ZEND_MN(name) zim_##name
66#define ZEND_NAMED_FUNCTION(name)		void name(INTERNAL_FUNCTION_PARAMETERS)
67#define ZEND_FUNCTION(name)				ZEND_NAMED_FUNCTION(ZEND_FN(name))
68#define ZEND_METHOD(classname, name)	ZEND_NAMED_FUNCTION(ZEND_MN(classname##_##name))
69
70#define ZEND_FENTRY(zend_name, name, arg_info, flags)	{ #zend_name, name, arg_info, (uint32_t) (sizeof(arg_info)/sizeof(struct _zend_internal_arg_info)-1), flags },
71
72#define ZEND_RAW_FENTRY(zend_name, name, arg_info, flags)   { zend_name, name, arg_info, (uint32_t) (sizeof(arg_info)/sizeof(struct _zend_internal_arg_info)-1), flags },
73#define ZEND_RAW_NAMED_FE(zend_name, name, arg_info) ZEND_RAW_FENTRY(#zend_name, name, arg_info, 0)
74
75#define ZEND_NAMED_FE(zend_name, name, arg_info)	ZEND_FENTRY(zend_name, name, arg_info, 0)
76#define ZEND_FE(name, arg_info)						ZEND_FENTRY(name, ZEND_FN(name), arg_info, 0)
77#define ZEND_DEP_FE(name, arg_info)                 ZEND_FENTRY(name, ZEND_FN(name), arg_info, ZEND_ACC_DEPRECATED)
78#define ZEND_FALIAS(name, alias, arg_info)			ZEND_FENTRY(name, ZEND_FN(alias), arg_info, 0)
79#define ZEND_DEP_FALIAS(name, alias, arg_info)		ZEND_FENTRY(name, ZEND_FN(alias), arg_info, ZEND_ACC_DEPRECATED)
80#define ZEND_NAMED_ME(zend_name, name, arg_info, flags)	ZEND_FENTRY(zend_name, name, arg_info, flags)
81#define ZEND_ME(classname, name, arg_info, flags)	ZEND_FENTRY(name, ZEND_MN(classname##_##name), arg_info, flags)
82#define ZEND_ABSTRACT_ME(classname, name, arg_info)	ZEND_FENTRY(name, NULL, arg_info, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT)
83#define ZEND_MALIAS(classname, name, alias, arg_info, flags) \
84                                                    ZEND_FENTRY(name, ZEND_MN(classname##_##alias), arg_info, flags)
85#define ZEND_ME_MAPPING(name, func_name, arg_types, flags) ZEND_NAMED_ME(name, ZEND_FN(func_name), arg_types, flags)
86
87#define ZEND_NS_FENTRY(ns, zend_name, name, arg_info, flags)		ZEND_RAW_FENTRY(ZEND_NS_NAME(ns, #zend_name), name, arg_info, flags)
88
89#define ZEND_NS_RAW_FENTRY(ns, zend_name, name, arg_info, flags)	ZEND_RAW_FENTRY(ZEND_NS_NAME(ns, zend_name), name, arg_info, flags)
90#define ZEND_NS_RAW_NAMED_FE(ns, zend_name, name, arg_info)			ZEND_NS_RAW_FENTRY(ns, #zend_name, name, arg_info, 0)
91
92#define ZEND_NS_NAMED_FE(ns, zend_name, name, arg_info)	ZEND_NS_FENTRY(ns, zend_name, name, arg_info, 0)
93#define ZEND_NS_FE(ns, name, arg_info)					ZEND_NS_FENTRY(ns, name, ZEND_FN(name), arg_info, 0)
94#define ZEND_NS_DEP_FE(ns, name, arg_info)				ZEND_NS_FENTRY(ns, name, ZEND_FN(name), arg_info, ZEND_ACC_DEPRECATED)
95#define ZEND_NS_FALIAS(ns, name, alias, arg_info)		ZEND_NS_FENTRY(ns, name, ZEND_FN(alias), arg_info, 0)
96#define ZEND_NS_DEP_FALIAS(ns, name, alias, arg_info)	ZEND_NS_FENTRY(ns, name, ZEND_FN(alias), arg_info, ZEND_ACC_DEPRECATED)
97
98#define ZEND_FE_END            { NULL, NULL, NULL, 0, 0 }
99
100#define ZEND_ARG_INFO(pass_by_ref, name)                             { #name, NULL, 0, pass_by_ref, 0, 0 },
101#define ZEND_ARG_PASS_INFO(pass_by_ref)                              { NULL,  NULL, 0, pass_by_ref, 0, 0 },
102#define ZEND_ARG_OBJ_INFO(pass_by_ref, name, classname, allow_null)  { #name, #classname, IS_OBJECT, pass_by_ref, allow_null, 0 },
103#define ZEND_ARG_ARRAY_INFO(pass_by_ref, name, allow_null)           { #name, NULL, IS_ARRAY, pass_by_ref, allow_null, 0 },
104#define ZEND_ARG_CALLABLE_INFO(pass_by_ref, name, allow_null)        { #name, NULL, IS_CALLABLE, pass_by_ref, allow_null, 0 },
105#define ZEND_ARG_TYPE_INFO(pass_by_ref, name, type_hint, allow_null) { #name, NULL, type_hint, pass_by_ref, allow_null, 0 },
106#define ZEND_ARG_VARIADIC_INFO(pass_by_ref, name)                    { #name, NULL, 0, pass_by_ref, 0, 1 },
107
108
109#define ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, type, class_name, allow_null) \
110	static const zend_internal_arg_info name[] = { \
111	   	{ (const char*)(zend_uintptr_t)(required_num_args), class_name, type, return_reference, allow_null, 0 },
112#define ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO(name, type, class_name, allow_null) \
113	ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(name, 0, -1, type, class_name, allow_null)
114
115#define ZEND_BEGIN_ARG_INFO_EX(name, _unused, return_reference, required_num_args)	\
116	static const zend_internal_arg_info name[] = { \
117		{ (const char*)(zend_uintptr_t)(required_num_args), NULL, 0, return_reference, 0, 0 },
118#define ZEND_BEGIN_ARG_INFO(name, _unused)	\
119	ZEND_BEGIN_ARG_INFO_EX(name, 0, ZEND_RETURN_VALUE, -1)
120#define ZEND_END_ARG_INFO()		};
121
122/* Name macros */
123#define ZEND_MODULE_STARTUP_N(module)       zm_startup_##module
124#define ZEND_MODULE_SHUTDOWN_N(module)		zm_shutdown_##module
125#define ZEND_MODULE_ACTIVATE_N(module)		zm_activate_##module
126#define ZEND_MODULE_DEACTIVATE_N(module)	zm_deactivate_##module
127#define ZEND_MODULE_POST_ZEND_DEACTIVATE_N(module)	zm_post_zend_deactivate_##module
128#define ZEND_MODULE_INFO_N(module)			zm_info_##module
129#define ZEND_MODULE_GLOBALS_CTOR_N(module)  zm_globals_ctor_##module
130#define ZEND_MODULE_GLOBALS_DTOR_N(module)  zm_globals_dtor_##module
131
132/* Declaration macros */
133#define ZEND_MODULE_STARTUP_D(module)		int ZEND_MODULE_STARTUP_N(module)(INIT_FUNC_ARGS)
134#define ZEND_MODULE_SHUTDOWN_D(module)		int ZEND_MODULE_SHUTDOWN_N(module)(SHUTDOWN_FUNC_ARGS)
135#define ZEND_MODULE_ACTIVATE_D(module)		int ZEND_MODULE_ACTIVATE_N(module)(INIT_FUNC_ARGS)
136#define ZEND_MODULE_DEACTIVATE_D(module)	int ZEND_MODULE_DEACTIVATE_N(module)(SHUTDOWN_FUNC_ARGS)
137#define ZEND_MODULE_POST_ZEND_DEACTIVATE_D(module)	int ZEND_MODULE_POST_ZEND_DEACTIVATE_N(module)(void)
138#define ZEND_MODULE_INFO_D(module)			void ZEND_MODULE_INFO_N(module)(ZEND_MODULE_INFO_FUNC_ARGS)
139#define ZEND_MODULE_GLOBALS_CTOR_D(module)  void ZEND_MODULE_GLOBALS_CTOR_N(module)(zend_##module##_globals *module##_globals)
140#define ZEND_MODULE_GLOBALS_DTOR_D(module)  void ZEND_MODULE_GLOBALS_DTOR_N(module)(zend_##module##_globals *module##_globals)
141
142#define ZEND_GET_MODULE(name) \
143    BEGIN_EXTERN_C()\
144	ZEND_DLEXPORT zend_module_entry *get_module(void) { return &name##_module_entry; }\
145    END_EXTERN_C()
146
147#define ZEND_BEGIN_MODULE_GLOBALS(module_name)		\
148	typedef struct _zend_##module_name##_globals {
149#define ZEND_END_MODULE_GLOBALS(module_name)		\
150	} zend_##module_name##_globals;
151
152#ifdef ZTS
153
154#define ZEND_DECLARE_MODULE_GLOBALS(module_name)							\
155	ts_rsrc_id module_name##_globals_id;
156#define ZEND_EXTERN_MODULE_GLOBALS(module_name)								\
157	extern ts_rsrc_id module_name##_globals_id;
158#define ZEND_INIT_MODULE_GLOBALS(module_name, globals_ctor, globals_dtor)	\
159	ts_allocate_id(&module_name##_globals_id, sizeof(zend_##module_name##_globals), (ts_allocate_ctor) globals_ctor, (ts_allocate_dtor) globals_dtor);
160#define ZEND_MODULE_GLOBALS_ACCESSOR(module_name, v) ZEND_TSRMG(module_name##_globals_id, zend_##module_name##_globals *, v)
161#define ZEND_MODULE_GLOBALS_BULK(module_name) TSRMG_BULK(module_name##_globals_id, zend_##module_name##_globals *)
162
163#else
164
165#define ZEND_DECLARE_MODULE_GLOBALS(module_name)							\
166	zend_##module_name##_globals module_name##_globals;
167#define ZEND_EXTERN_MODULE_GLOBALS(module_name)								\
168	extern zend_##module_name##_globals module_name##_globals;
169#define ZEND_INIT_MODULE_GLOBALS(module_name, globals_ctor, globals_dtor)	\
170	globals_ctor(&module_name##_globals);
171#define ZEND_MODULE_GLOBALS_ACCESSOR(module_name, v) (module_name##_globals.v)
172#define ZEND_MODULE_GLOBALS_BULK(module_name) (&module_name##_globals)
173
174#endif
175
176#define INIT_CLASS_ENTRY(class_container, class_name, functions) \
177	INIT_OVERLOADED_CLASS_ENTRY(class_container, class_name, functions, NULL, NULL, NULL)
178
179#define INIT_CLASS_ENTRY_EX(class_container, class_name, class_name_len, functions) \
180	INIT_OVERLOADED_CLASS_ENTRY_EX(class_container, class_name, class_name_len, functions, NULL, NULL, NULL, NULL, NULL)
181
182#define INIT_OVERLOADED_CLASS_ENTRY_EX(class_container, class_name, class_name_len, functions, handle_fcall, handle_propget, handle_propset, handle_propunset, handle_propisset) \
183	{															\
184		zend_string *cl_name;									\
185		cl_name = zend_string_init(class_name, class_name_len, 1);		\
186		class_container.name = zend_new_interned_string(cl_name);	\
187		INIT_CLASS_ENTRY_INIT_METHODS(class_container, functions, handle_fcall, handle_propget, handle_propset, handle_propunset, handle_propisset) \
188	}
189
190#define INIT_CLASS_ENTRY_INIT_METHODS(class_container, functions, handle_fcall, handle_propget, handle_propset, handle_propunset, handle_propisset) \
191	{															\
192		class_container.constructor = NULL;						\
193		class_container.destructor = NULL;						\
194		class_container.clone = NULL;							\
195		class_container.serialize = NULL;						\
196		class_container.unserialize = NULL;						\
197		class_container.create_object = NULL;					\
198		class_container.interface_gets_implemented = NULL;		\
199		class_container.get_static_method = NULL;				\
200		class_container.__call = handle_fcall;					\
201		class_container.__callstatic = NULL;					\
202		class_container.__tostring = NULL;						\
203		class_container.__get = handle_propget;					\
204		class_container.__set = handle_propset;					\
205		class_container.__unset = handle_propunset;				\
206		class_container.__isset = handle_propisset;				\
207		class_container.__debugInfo = NULL;					\
208		class_container.serialize_func = NULL;					\
209		class_container.unserialize_func = NULL;				\
210		class_container.serialize = NULL;						\
211		class_container.unserialize = NULL;						\
212		class_container.parent = NULL;							\
213		class_container.num_interfaces = 0;						\
214		class_container.traits = NULL;							\
215		class_container.num_traits = 0;							\
216		class_container.trait_aliases = NULL;					\
217		class_container.trait_precedences = NULL;				\
218		class_container.interfaces = NULL;						\
219		class_container.get_iterator = NULL;					\
220		class_container.iterator_funcs.funcs = NULL;			\
221		class_container.info.internal.module = NULL;			\
222		class_container.info.internal.builtin_functions = functions;	\
223	}
224
225#define INIT_OVERLOADED_CLASS_ENTRY(class_container, class_name, functions, handle_fcall, handle_propget, handle_propset) \
226	INIT_OVERLOADED_CLASS_ENTRY_EX(class_container, class_name, sizeof(class_name)-1, functions, handle_fcall, handle_propget, handle_propset, NULL, NULL)
227
228#define INIT_NS_CLASS_ENTRY(class_container, ns, class_name, functions) \
229	INIT_CLASS_ENTRY(class_container, ZEND_NS_NAME(ns, class_name), functions)
230#define INIT_OVERLOADED_NS_CLASS_ENTRY_EX(class_container, ns, class_name, functions, handle_fcall, handle_propget, handle_propset, handle_propunset, handle_propisset) \
231	INIT_OVERLOADED_CLASS_ENTRY_EX(class_container, ZEND_NS_NAME(ns, class_name), sizeof(ZEND_NS_NAME(ns, class_name))-1, functions, handle_fcall, handle_propget, handle_propset, handle_propunset, handle_propisset)
232#define INIT_OVERLOADED_NS_CLASS_ENTRY(class_container, ns, class_name, functions, handle_fcall, handle_propget, handle_propset) \
233	INIT_OVERLOADED_CLASS_ENTRY(class_container, ZEND_NS_NAME(ns, class_name), functions, handle_fcall, handle_propget, handle_propset)
234
235#ifdef ZTS
236#	define CE_STATIC_MEMBERS(ce) (((ce)->type==ZEND_USER_CLASS)?(ce)->static_members_table:CG(static_members_table)[(zend_intptr_t)(ce)->static_members_table])
237#else
238#	define CE_STATIC_MEMBERS(ce) ((ce)->static_members_table)
239#endif
240
241#define ZEND_FCI_INITIALIZED(fci) ((fci).size != 0)
242
243ZEND_API int zend_next_free_module(void);
244
245BEGIN_EXTERN_C()
246ZEND_API int zend_get_parameters(int ht, int param_count, ...);
247ZEND_API ZEND_ATTRIBUTE_DEPRECATED int zend_get_parameters_ex(int param_count, ...);
248ZEND_API int _zend_get_parameters_array_ex(int param_count, zval *argument_array);
249
250/* internal function to efficiently copy parameters when executing __call() */
251ZEND_API int zend_copy_parameters_array(int param_count, zval *argument_array);
252
253#define zend_get_parameters_array(ht, param_count, argument_array) \
254	_zend_get_parameters_array_ex(param_count, argument_array)
255#define zend_get_parameters_array_ex(param_count, argument_array) \
256	_zend_get_parameters_array_ex(param_count, argument_array)
257#define zend_parse_parameters_none() \
258	(EXPECTED(ZEND_NUM_ARGS() == 0) ? SUCCESS : zend_parse_parameters(ZEND_NUM_ARGS(), ""))
259
260/* Parameter parsing API -- andrei */
261
262#define ZEND_PARSE_PARAMS_QUIET (1<<1)
263#define ZEND_PARSE_PARAMS_THROW (1<<2)
264ZEND_API int zend_parse_parameters(int num_args, const char *type_spec, ...);
265ZEND_API int zend_parse_parameters_ex(int flags, int num_args, const char *type_spec, ...);
266ZEND_API int zend_parse_parameters_throw(int num_args, const char *type_spec, ...);
267ZEND_API char *zend_zval_type_name(const zval *arg);
268
269ZEND_API int zend_parse_method_parameters(int num_args, zval *this_ptr, const char *type_spec, ...);
270ZEND_API int zend_parse_method_parameters_ex(int flags, int num_args, zval *this_ptr, const char *type_spec, ...);
271
272ZEND_API int zend_parse_parameter(int flags, int arg_num, zval *arg, const char *spec, ...);
273
274/* End of parameter parsing API -- andrei */
275
276ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_function_entry *functions, HashTable *function_table, int type);
277ZEND_API void zend_unregister_functions(const zend_function_entry *functions, int count, HashTable *function_table);
278ZEND_API int zend_startup_module(zend_module_entry *module_entry);
279ZEND_API zend_module_entry* zend_register_internal_module(zend_module_entry *module_entry);
280ZEND_API zend_module_entry* zend_register_module_ex(zend_module_entry *module);
281ZEND_API int zend_startup_module_ex(zend_module_entry *module);
282ZEND_API int zend_startup_modules(void);
283ZEND_API void zend_collect_module_handlers(void);
284ZEND_API void zend_destroy_modules(void);
285ZEND_API void zend_check_magic_method_implementation(const zend_class_entry *ce, const zend_function *fptr, int error_type);
286
287ZEND_API zend_class_entry *zend_register_internal_class(zend_class_entry *class_entry);
288ZEND_API zend_class_entry *zend_register_internal_class_ex(zend_class_entry *class_entry, zend_class_entry *parent_ce);
289ZEND_API zend_class_entry *zend_register_internal_interface(zend_class_entry *orig_class_entry);
290ZEND_API void zend_class_implements(zend_class_entry *class_entry, int num_interfaces, ...);
291
292ZEND_API int zend_register_class_alias_ex(const char *name, size_t name_len, zend_class_entry *ce);
293
294#define zend_register_class_alias(name, ce) \
295	zend_register_class_alias_ex(name, sizeof(name)-1, ce)
296#define zend_register_ns_class_alias(ns, name, ce) \
297	zend_register_class_alias_ex(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, ce)
298
299ZEND_API int zend_disable_function(char *function_name, size_t function_name_length);
300ZEND_API int zend_disable_class(char *class_name, size_t class_name_length);
301
302ZEND_API ZEND_COLD void zend_wrong_param_count(void);
303
304#define IS_CALLABLE_CHECK_SYNTAX_ONLY (1<<0)
305#define IS_CALLABLE_CHECK_NO_ACCESS   (1<<1)
306#define IS_CALLABLE_CHECK_IS_STATIC   (1<<2)
307#define IS_CALLABLE_CHECK_SILENT      (1<<3)
308
309#define IS_CALLABLE_STRICT  (IS_CALLABLE_CHECK_IS_STATIC)
310
311ZEND_API zend_bool zend_is_callable_ex(zval *callable, zend_object *object, uint check_flags, zend_string **callable_name, zend_fcall_info_cache *fcc, char **error);
312ZEND_API zend_bool zend_is_callable(zval *callable, uint check_flags, zend_string **callable_name);
313ZEND_API zend_bool zend_make_callable(zval *callable, zend_string **callable_name);
314ZEND_API const char *zend_get_module_version(const char *module_name);
315ZEND_API int zend_get_module_started(const char *module_name);
316ZEND_API int zend_declare_property_ex(zend_class_entry *ce, zend_string *name, zval *property, int access_type, zend_string *doc_comment);
317ZEND_API int zend_declare_property(zend_class_entry *ce, const char *name, size_t name_length, zval *property, int access_type);
318ZEND_API int zend_declare_property_null(zend_class_entry *ce, const char *name, size_t name_length, int access_type);
319ZEND_API int zend_declare_property_bool(zend_class_entry *ce, const char *name, size_t name_length, zend_long value, int access_type);
320ZEND_API int zend_declare_property_long(zend_class_entry *ce, const char *name, size_t name_length, zend_long value, int access_type);
321ZEND_API int zend_declare_property_double(zend_class_entry *ce, const char *name, size_t name_length, double value, int access_type);
322ZEND_API int zend_declare_property_string(zend_class_entry *ce, const char *name, size_t name_length, const char *value, int access_type);
323ZEND_API int zend_declare_property_stringl(zend_class_entry *ce, const char *name, size_t name_length, const char *value, size_t value_len, int access_type);
324
325ZEND_API int zend_declare_class_constant_ex(zend_class_entry *ce, zend_string *name, zval *value, int access_type, zend_string *doc_comment);
326ZEND_API int zend_declare_class_constant(zend_class_entry *ce, const char *name, size_t name_length, zval *value);
327ZEND_API int zend_declare_class_constant_null(zend_class_entry *ce, const char *name, size_t name_length);
328ZEND_API int zend_declare_class_constant_long(zend_class_entry *ce, const char *name, size_t name_length, zend_long value);
329ZEND_API int zend_declare_class_constant_bool(zend_class_entry *ce, const char *name, size_t name_length, zend_bool value);
330ZEND_API int zend_declare_class_constant_double(zend_class_entry *ce, const char *name, size_t name_length, double value);
331ZEND_API int zend_declare_class_constant_stringl(zend_class_entry *ce, const char *name, size_t name_length, const char *value, size_t value_length);
332ZEND_API int zend_declare_class_constant_string(zend_class_entry *ce, const char *name, size_t name_length, const char *value);
333
334ZEND_API int zend_update_class_constants(zend_class_entry *class_type);
335
336ZEND_API void zend_update_property_ex(zend_class_entry *scope, zval *object, zend_string *name, zval *value);
337ZEND_API void zend_update_property(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zval *value);
338ZEND_API void zend_update_property_null(zend_class_entry *scope, zval *object, const char *name, size_t name_length);
339ZEND_API void zend_update_property_bool(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_long value);
340ZEND_API void zend_update_property_long(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_long value);
341ZEND_API void zend_update_property_double(zend_class_entry *scope, zval *object, const char *name, size_t name_length, double value);
342ZEND_API void zend_update_property_str(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_string *value);
343ZEND_API void zend_update_property_string(zend_class_entry *scope, zval *object, const char *name, size_t name_length, const char *value);
344ZEND_API void zend_update_property_stringl(zend_class_entry *scope, zval *object, const char *name, size_t name_length, const char *value, size_t value_length);
345
346ZEND_API int zend_update_static_property(zend_class_entry *scope, const char *name, size_t name_length, zval *value);
347ZEND_API int zend_update_static_property_null(zend_class_entry *scope, const char *name, size_t name_length);
348ZEND_API int zend_update_static_property_bool(zend_class_entry *scope, const char *name, size_t name_length, zend_long value);
349ZEND_API int zend_update_static_property_long(zend_class_entry *scope, const char *name, size_t name_length, zend_long value);
350ZEND_API int zend_update_static_property_double(zend_class_entry *scope, const char *name, size_t name_length, double value);
351ZEND_API int zend_update_static_property_string(zend_class_entry *scope, const char *name, size_t name_length, const char *value);
352ZEND_API int zend_update_static_property_stringl(zend_class_entry *scope, const char *name, size_t name_length, const char *value, size_t value_length);
353
354ZEND_API zval *zend_read_property_ex(zend_class_entry *scope, zval *object, zend_string *name, zend_bool silent, zval *rv);
355ZEND_API zval *zend_read_property(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_bool silent, zval *rv);
356
357ZEND_API zval *zend_read_static_property(zend_class_entry *scope, const char *name, size_t name_length, zend_bool silent);
358
359ZEND_API char *zend_get_type_by_const(int type);
360
361#define getThis()							((Z_TYPE(EX(This)) == IS_OBJECT) ? &EX(This) : NULL)
362#define ZEND_IS_METHOD_CALL()				(EX(func)->common.scope != NULL)
363
364#define WRONG_PARAM_COUNT					ZEND_WRONG_PARAM_COUNT()
365#define WRONG_PARAM_COUNT_WITH_RETVAL(ret)	ZEND_WRONG_PARAM_COUNT_WITH_RETVAL(ret)
366#define ARG_COUNT(dummy)					EX_NUM_ARGS()
367#define ZEND_NUM_ARGS()						EX_NUM_ARGS()
368#define ZEND_WRONG_PARAM_COUNT()					{ zend_wrong_param_count(); return; }
369#define ZEND_WRONG_PARAM_COUNT_WITH_RETVAL(ret)		{ zend_wrong_param_count(); return ret; }
370
371#ifndef ZEND_WIN32
372#define DLEXPORT
373#endif
374
375#define array_init(arg)			_array_init((arg), 0 ZEND_FILE_LINE_CC)
376#define array_init_size(arg, size) _array_init((arg), (size) ZEND_FILE_LINE_CC)
377#define object_init(arg)		_object_init((arg) ZEND_FILE_LINE_CC)
378#define object_init_ex(arg, ce)	_object_init_ex((arg), (ce) ZEND_FILE_LINE_CC)
379#define object_and_properties_init(arg, ce, properties)	_object_and_properties_init((arg), (ce), (properties) ZEND_FILE_LINE_CC)
380ZEND_API int _array_init(zval *arg, uint32_t size ZEND_FILE_LINE_DC);
381ZEND_API int _object_init(zval *arg ZEND_FILE_LINE_DC);
382ZEND_API int _object_init_ex(zval *arg, zend_class_entry *ce ZEND_FILE_LINE_DC);
383ZEND_API int _object_and_properties_init(zval *arg, zend_class_entry *ce, HashTable *properties ZEND_FILE_LINE_DC);
384ZEND_API void object_properties_init(zend_object *object, zend_class_entry *class_type);
385ZEND_API void object_properties_init_ex(zend_object *object, HashTable *properties);
386ZEND_API void object_properties_load(zend_object *object, HashTable *properties);
387
388ZEND_API void zend_merge_properties(zval *obj, HashTable *properties);
389
390ZEND_API int add_assoc_long_ex(zval *arg, const char *key, size_t key_len, zend_long n);
391ZEND_API int add_assoc_null_ex(zval *arg, const char *key, size_t key_len);
392ZEND_API int add_assoc_bool_ex(zval *arg, const char *key, size_t key_len, int b);
393ZEND_API int add_assoc_resource_ex(zval *arg, const char *key, size_t key_len, zend_resource *r);
394ZEND_API int add_assoc_double_ex(zval *arg, const char *key, size_t key_len, double d);
395ZEND_API int add_assoc_str_ex(zval *arg, const char *key, size_t key_len, zend_string *str);
396ZEND_API int add_assoc_string_ex(zval *arg, const char *key, size_t key_len, char *str);
397ZEND_API int add_assoc_stringl_ex(zval *arg, const char *key, size_t key_len, char *str, size_t length);
398ZEND_API int add_assoc_zval_ex(zval *arg, const char *key, size_t key_len, zval *value);
399
400#define add_assoc_long(__arg, __key, __n) add_assoc_long_ex(__arg, __key, strlen(__key), __n)
401#define add_assoc_null(__arg, __key) add_assoc_null_ex(__arg, __key, strlen(__key))
402#define add_assoc_bool(__arg, __key, __b) add_assoc_bool_ex(__arg, __key, strlen(__key), __b)
403#define add_assoc_resource(__arg, __key, __r) add_assoc_resource_ex(__arg, __key, strlen(__key), __r)
404#define add_assoc_double(__arg, __key, __d) add_assoc_double_ex(__arg, __key, strlen(__key), __d)
405#define add_assoc_str(__arg, __key, __str) add_assoc_str_ex(__arg, __key, strlen(__key), __str)
406#define add_assoc_string(__arg, __key, __str) add_assoc_string_ex(__arg, __key, strlen(__key), __str)
407#define add_assoc_stringl(__arg, __key, __str, __length) add_assoc_stringl_ex(__arg, __key, strlen(__key), __str, __length)
408#define add_assoc_zval(__arg, __key, __value) add_assoc_zval_ex(__arg, __key, strlen(__key), __value)
409
410/* unset() functions are only suported for legacy modules and null() functions should be used */
411#define add_assoc_unset(__arg, __key) add_assoc_null_ex(__arg, __key, strlen(__key))
412#define add_index_unset(__arg, __key) add_index_null(__arg, __key)
413#define add_next_index_unset(__arg) add_next_index_null(__arg)
414#define add_property_unset(__arg, __key) add_property_null(__arg, __key)
415
416ZEND_API int add_index_long(zval *arg, zend_ulong idx, zend_long n);
417ZEND_API int add_index_null(zval *arg, zend_ulong idx);
418ZEND_API int add_index_bool(zval *arg, zend_ulong idx, int b);
419ZEND_API int add_index_resource(zval *arg, zend_ulong idx, zend_resource *r);
420ZEND_API int add_index_double(zval *arg, zend_ulong idx, double d);
421ZEND_API int add_index_str(zval *arg, zend_ulong idx, zend_string *str);
422ZEND_API int add_index_string(zval *arg, zend_ulong idx, const char *str);
423ZEND_API int add_index_stringl(zval *arg, zend_ulong idx, const char *str, size_t length);
424ZEND_API int add_index_zval(zval *arg, zend_ulong index, zval *value);
425
426ZEND_API int add_next_index_long(zval *arg, zend_long n);
427ZEND_API int add_next_index_null(zval *arg);
428ZEND_API int add_next_index_bool(zval *arg, int b);
429ZEND_API int add_next_index_resource(zval *arg, zend_resource *r);
430ZEND_API int add_next_index_double(zval *arg, double d);
431ZEND_API int add_next_index_str(zval *arg, zend_string *str);
432ZEND_API int add_next_index_string(zval *arg, const char *str);
433ZEND_API int add_next_index_stringl(zval *arg, const char *str, size_t length);
434ZEND_API int add_next_index_zval(zval *arg, zval *value);
435
436ZEND_API zval *add_get_assoc_string_ex(zval *arg, const char *key, uint key_len, const char *str);
437ZEND_API zval *add_get_assoc_stringl_ex(zval *arg, const char *key, uint key_len, const char *str, size_t length);
438
439#define add_get_assoc_string(__arg, __key, __str) add_get_assoc_string_ex(__arg, __key, strlen(__key), __str)
440#define add_get_assoc_stringl(__arg, __key, __str, __length) add_get_assoc_stringl_ex(__arg, __key, strlen(__key), __str, __length)
441
442ZEND_API zval *add_get_index_long(zval *arg, zend_ulong idx, zend_long l);
443ZEND_API zval *add_get_index_double(zval *arg, zend_ulong idx, double d);
444ZEND_API zval *add_get_index_str(zval *arg, zend_ulong index, zend_string *str);
445ZEND_API zval *add_get_index_string(zval *arg, zend_ulong idx, const char *str);
446ZEND_API zval *add_get_index_stringl(zval *arg, zend_ulong idx, const char *str, size_t length);
447
448ZEND_API int array_set_zval_key(HashTable *ht, zval *key, zval *value);
449
450ZEND_API int add_property_long_ex(zval *arg, const char *key, size_t key_len, zend_long l);
451ZEND_API int add_property_null_ex(zval *arg, const char *key, size_t key_len);
452ZEND_API int add_property_bool_ex(zval *arg, const char *key, size_t key_len, zend_long b);
453ZEND_API int add_property_resource_ex(zval *arg, const char *key, size_t key_len, zend_resource *r);
454ZEND_API int add_property_double_ex(zval *arg, const char *key, size_t key_len, double d);
455ZEND_API int add_property_str_ex(zval *arg, const char *key, size_t key_len, zend_string *str);
456ZEND_API int add_property_string_ex(zval *arg, const char *key, size_t key_len, const char *str);
457ZEND_API int add_property_stringl_ex(zval *arg, const char *key, size_t key_len,  const char *str, size_t length);
458ZEND_API int add_property_zval_ex(zval *arg, const char *key, size_t key_len, zval *value);
459
460#define add_property_long(__arg, __key, __n) add_property_long_ex(__arg, __key, strlen(__key), __n)
461#define add_property_null(__arg, __key) add_property_null_ex(__arg, __key, strlen(__key))
462#define add_property_bool(__arg, __key, __b) add_property_bool_ex(__arg, __key, strlen(__key), __b)
463#define add_property_resource(__arg, __key, __r) add_property_resource_ex(__arg, __key, strlen(__key), __r)
464#define add_property_double(__arg, __key, __d) add_property_double_ex(__arg, __key, strlen(__key), __d)
465#define add_property_str(__arg, __key, __str) add_property_str_ex(__arg, __key, strlen(__key), __str)
466#define add_property_string(__arg, __key, __str) add_property_string_ex(__arg, __key, strlen(__key), __str)
467#define add_property_stringl(__arg, __key, __str, __length) add_property_stringl_ex(__arg, __key, strlen(__key), __str, __length)
468#define add_property_zval(__arg, __key, __value) add_property_zval_ex(__arg, __key, strlen(__key), __value)
469
470
471ZEND_API int _call_user_function_ex(zval *object, zval *function_name, zval *retval_ptr, uint32_t param_count, zval params[], int no_separation);
472
473#define call_user_function(function_table, object, function_name, retval_ptr, param_count, params) \
474	_call_user_function_ex(object, function_name, retval_ptr, param_count, params, 1)
475#define call_user_function_ex(function_table, object, function_name, retval_ptr, param_count, params, no_separation, symbol_table) \
476	_call_user_function_ex(object, function_name, retval_ptr, param_count, params, no_separation)
477
478ZEND_API extern const zend_fcall_info empty_fcall_info;
479ZEND_API extern const zend_fcall_info_cache empty_fcall_info_cache;
480
481/** Build zend_call_info/cache from a zval*
482 *
483 * Caller is responsible to provide a return value (fci->retval), otherwise the we will crash.
484 * In order to pass parameters the following members need to be set:
485 * fci->param_count = 0;
486 * fci->params = NULL;
487 * The callable_name argument may be NULL.
488 * Set check_flags to IS_CALLABLE_STRICT for every new usage!
489 */
490ZEND_API int zend_fcall_info_init(zval *callable, uint check_flags, zend_fcall_info *fci, zend_fcall_info_cache *fcc, zend_string **callable_name, char **error);
491
492/** Clear arguments connected with zend_fcall_info *fci
493 * If free_mem is not zero then the params array gets free'd as well
494 */
495ZEND_API void zend_fcall_info_args_clear(zend_fcall_info *fci, int free_mem);
496
497/** Save current arguments from zend_fcall_info *fci
498 * params array will be set to NULL
499 */
500ZEND_API void zend_fcall_info_args_save(zend_fcall_info *fci, int *param_count, zval **params);
501
502/** Free arguments connected with zend_fcall_info *fci andset back saved ones.
503 */
504ZEND_API void zend_fcall_info_args_restore(zend_fcall_info *fci, int param_count, zval *params);
505
506/** Set or clear the arguments in the zend_call_info struct taking care of
507 * refcount. If args is NULL and arguments are set then those are cleared.
508 */
509ZEND_API int zend_fcall_info_args(zend_fcall_info *fci, zval *args);
510ZEND_API int zend_fcall_info_args_ex(zend_fcall_info *fci, zend_function *func, zval *args);
511
512/** Set arguments in the zend_fcall_info struct taking care of refcount.
513 * If argc is 0 the arguments which are set will be cleared, else pass
514 * a variable amount of zval** arguments.
515 */
516ZEND_API int zend_fcall_info_argp(zend_fcall_info *fci, int argc, zval *argv);
517
518/** Set arguments in the zend_fcall_info struct taking care of refcount.
519 * If argc is 0 the arguments which are set will be cleared, else pass
520 * a variable amount of zval** arguments.
521 */
522ZEND_API int zend_fcall_info_argv(zend_fcall_info *fci, int argc, va_list *argv);
523
524/** Set arguments in the zend_fcall_info struct taking care of refcount.
525 * If argc is 0 the arguments which are set will be cleared, else pass
526 * a variable amount of zval** arguments.
527 */
528ZEND_API int zend_fcall_info_argn(zend_fcall_info *fci, int argc, ...);
529
530/** Call a function using information created by zend_fcall_info_init()/args().
531 * If args is given then those replace the argument info in fci is temporarily.
532 */
533ZEND_API int zend_fcall_info_call(zend_fcall_info *fci, zend_fcall_info_cache *fcc, zval *retval, zval *args);
534
535ZEND_API int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache);
536
537ZEND_API int zend_set_hash_symbol(zval *symbol, const char *name, int name_length, zend_bool is_ref, int num_symbol_tables, ...);
538
539ZEND_API int zend_delete_global_variable(zend_string *name);
540
541ZEND_API zend_array *zend_rebuild_symbol_table(void);
542ZEND_API void zend_attach_symbol_table(zend_execute_data *execute_data);
543ZEND_API void zend_detach_symbol_table(zend_execute_data *execute_data);
544ZEND_API int zend_set_local_var(zend_string *name, zval *value, int force);
545ZEND_API int zend_set_local_var_str(const char *name, size_t len, zval *value, int force);
546
547ZEND_API zend_string *zend_find_alias_name(zend_class_entry *ce, zend_string *name);
548ZEND_API zend_string *zend_resolve_method_name(zend_class_entry *ce, zend_function *f);
549
550ZEND_API const char *zend_get_object_type(const zend_class_entry *ce);
551
552#define add_method(arg, key, method)	add_assoc_function((arg), (key), (method))
553
554ZEND_API ZEND_FUNCTION(display_disabled_function);
555ZEND_API ZEND_FUNCTION(display_disabled_class);
556END_EXTERN_C()
557
558#if ZEND_DEBUG
559#define CHECK_ZVAL_STRING(str) \
560	if (ZSTR_VAL(str)[ZSTR_LEN(str)] != '\0') { zend_error(E_WARNING, "String is not zero-terminated (%s)", ZSTR_VAL(str)); }
561#define CHECK_ZVAL_STRING_REL(str) \
562	if (ZSTR_VAL(str)[ZSTR_LEN(str)] != '\0') { zend_error(E_WARNING, "String is not zero-terminated (%s) (source: %s:%d)", ZSTR_VAL(str) ZEND_FILE_LINE_RELAY_CC); }
563#else
564#define CHECK_ZVAL_STRING(z)
565#define CHECK_ZVAL_STRING_REL(z)
566#endif
567
568#define CHECK_ZVAL_NULL_PATH(p) (Z_STRLEN_P(p) != strlen(Z_STRVAL_P(p)))
569#define CHECK_NULL_PATH(p, l) (strlen(p) != l)
570
571#define ZVAL_STRINGL(z, s, l) do {				\
572		ZVAL_NEW_STR(z, zend_string_init(s, l, 0));		\
573	} while (0)
574
575#define ZVAL_STRING(z, s) do {					\
576		const char *_s = (s);					\
577		ZVAL_STRINGL(z, _s, strlen(_s));		\
578	} while (0)
579
580#define ZVAL_EMPTY_STRING(z) do {				\
581		ZVAL_INTERNED_STR(z, ZSTR_EMPTY_ALLOC());		\
582	} while (0)
583
584#define ZVAL_PSTRINGL(z, s, l) do {				\
585		ZVAL_NEW_STR(z, zend_string_init(s, l, 1));		\
586	} while (0)
587
588#define ZVAL_PSTRING(z, s) do {					\
589		const char *_s = (s);					\
590		ZVAL_PSTRINGL(z, _s, strlen(_s));		\
591	} while (0)
592
593#define ZVAL_EMPTY_PSTRING(z) do {				\
594		ZVAL_PSTRINGL(z, "", 0);				\
595	} while (0)
596
597#define ZVAL_ZVAL(z, zv, copy, dtor) do {		\
598		zval *__z = (z);						\
599		zval *__zv = (zv);						\
600		if (EXPECTED(!Z_ISREF_P(__zv))) {		\
601			if (copy && !dtor) {				\
602				ZVAL_COPY(__z, __zv);			\
603			} else {							\
604				ZVAL_COPY_VALUE(__z, __zv);		\
605			}									\
606		} else {								\
607			ZVAL_COPY(__z, Z_REFVAL_P(__zv));	\
608			if (dtor || !copy) {				\
609				zval_ptr_dtor(__zv);			\
610			}									\
611		}										\
612	} while (0)
613
614#define RETVAL_BOOL(b)					ZVAL_BOOL(return_value, b)
615#define RETVAL_NULL() 					ZVAL_NULL(return_value)
616#define RETVAL_LONG(l) 					ZVAL_LONG(return_value, l)
617#define RETVAL_DOUBLE(d) 				ZVAL_DOUBLE(return_value, d)
618#define RETVAL_STR(s)			 		ZVAL_STR(return_value, s)
619#define RETVAL_INTERNED_STR(s)	 		ZVAL_INTERNED_STR(return_value, s)
620#define RETVAL_NEW_STR(s)		 		ZVAL_NEW_STR(return_value, s)
621#define RETVAL_STR_COPY(s)		 		ZVAL_STR_COPY(return_value, s)
622#define RETVAL_STRING(s)		 		ZVAL_STRING(return_value, s)
623#define RETVAL_STRINGL(s, l)		 	ZVAL_STRINGL(return_value, s, l)
624#define RETVAL_EMPTY_STRING() 			ZVAL_EMPTY_STRING(return_value)
625#define RETVAL_RES(r)			 		ZVAL_RES(return_value, r)
626#define RETVAL_ARR(r)			 		ZVAL_ARR(return_value, r)
627#define RETVAL_OBJ(r)			 		ZVAL_OBJ(return_value, r)
628#define RETVAL_ZVAL(zv, copy, dtor)		ZVAL_ZVAL(return_value, zv, copy, dtor)
629#define RETVAL_FALSE  					ZVAL_FALSE(return_value)
630#define RETVAL_TRUE   					ZVAL_TRUE(return_value)
631
632#define RETURN_BOOL(b) 					{ RETVAL_BOOL(b); return; }
633#define RETURN_NULL() 					{ RETVAL_NULL(); return;}
634#define RETURN_LONG(l) 					{ RETVAL_LONG(l); return; }
635#define RETURN_DOUBLE(d) 				{ RETVAL_DOUBLE(d); return; }
636#define RETURN_STR(s) 					{ RETVAL_STR(s); return; }
637#define RETURN_INTERNED_STR(s)			{ RETVAL_INTERNED_STR(s); return; }
638#define RETURN_NEW_STR(s)				{ RETVAL_NEW_STR(s); return; }
639#define RETURN_STR_COPY(s)				{ RETVAL_STR_COPY(s); return; }
640#define RETURN_STRING(s) 				{ RETVAL_STRING(s); return; }
641#define RETURN_STRINGL(s, l) 			{ RETVAL_STRINGL(s, l); return; }
642#define RETURN_EMPTY_STRING() 			{ RETVAL_EMPTY_STRING(); return; }
643#define RETURN_RES(r) 					{ RETVAL_RES(r); return; }
644#define RETURN_ARR(r) 					{ RETVAL_ARR(r); return; }
645#define RETURN_OBJ(r) 					{ RETVAL_OBJ(r); return; }
646#define RETURN_ZVAL(zv, copy, dtor)		{ RETVAL_ZVAL(zv, copy, dtor); return; }
647#define RETURN_FALSE  					{ RETVAL_FALSE; return; }
648#define RETURN_TRUE   					{ RETVAL_TRUE; return; }
649
650#define HASH_OF(p) (Z_TYPE_P(p)==IS_ARRAY ? Z_ARRVAL_P(p) : ((Z_TYPE_P(p)==IS_OBJECT ? Z_OBJ_HT_P(p)->get_properties((p)) : NULL)))
651#define ZVAL_IS_NULL(z) (Z_TYPE_P(z) == IS_NULL)
652
653/* For compatibility */
654#define ZEND_MINIT			ZEND_MODULE_STARTUP_N
655#define ZEND_MSHUTDOWN		ZEND_MODULE_SHUTDOWN_N
656#define ZEND_RINIT			ZEND_MODULE_ACTIVATE_N
657#define ZEND_RSHUTDOWN		ZEND_MODULE_DEACTIVATE_N
658#define ZEND_MINFO			ZEND_MODULE_INFO_N
659#define ZEND_GINIT(module)		((void (*)(void*))(ZEND_MODULE_GLOBALS_CTOR_N(module)))
660#define ZEND_GSHUTDOWN(module)	((void (*)(void*))(ZEND_MODULE_GLOBALS_DTOR_N(module)))
661
662#define ZEND_MINIT_FUNCTION			ZEND_MODULE_STARTUP_D
663#define ZEND_MSHUTDOWN_FUNCTION		ZEND_MODULE_SHUTDOWN_D
664#define ZEND_RINIT_FUNCTION			ZEND_MODULE_ACTIVATE_D
665#define ZEND_RSHUTDOWN_FUNCTION		ZEND_MODULE_DEACTIVATE_D
666#define ZEND_MINFO_FUNCTION			ZEND_MODULE_INFO_D
667#define ZEND_GINIT_FUNCTION			ZEND_MODULE_GLOBALS_CTOR_D
668#define ZEND_GSHUTDOWN_FUNCTION		ZEND_MODULE_GLOBALS_DTOR_D
669
670/* Fast parameter parsing API */
671
672/* This API should be used only for really often used functions.
673 * (Keep the original parsing code and wrap usage with #ifndef FAST_ZPP)
674 */
675#define FAST_ZPP 1
676
677#ifdef FAST_ZPP
678
679#define Z_EXPECTED_TYPES(_) \
680	_(Z_EXPECTED_LONG,		"integer") \
681	_(Z_EXPECTED_BOOL,		"boolean") \
682	_(Z_EXPECTED_STRING,	"string") \
683	_(Z_EXPECTED_ARRAY,		"array") \
684	_(Z_EXPECTED_FUNC,		"valid callback") \
685	_(Z_EXPECTED_RESOURCE,	"resource") \
686	_(Z_EXPECTED_PATH,		"a valid path") \
687	_(Z_EXPECTED_OBJECT,	"object") \
688	_(Z_EXPECTED_DOUBLE,	"float")
689
690#define Z_EXPECTED_TYPE_ENUM(id, str) id,
691#define Z_EXPECTED_TYPE_STR(id, str)  str,
692
693typedef enum _zend_expected_type {
694	Z_EXPECTED_TYPES(Z_EXPECTED_TYPE_ENUM)
695	Z_EXPECTED_LAST
696} zend_expected_type;
697
698ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameters_count_error(int num_args, int min_num_args, int max_num_args);
699ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_type_error(int num, zend_expected_type expected_type, zval *arg);
700ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_error(int num, char *name, zval *arg);
701ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(int severity, int num, char *error);
702
703#define ZPP_ERROR_OK             0
704#define ZPP_ERROR_FAILURE        1
705#define ZPP_ERROR_WRONG_CALLBACK 2
706#define ZPP_ERROR_WRONG_CLASS    3
707#define ZPP_ERROR_WRONG_ARG      4
708#define ZPP_ERROR_WRONG_COUNT    5
709
710#define ZEND_PARSE_PARAMETERS_START_EX(flags, min_num_args, max_num_args) do { \
711		const int _flags = (flags); \
712		int _min_num_args = (min_num_args); \
713		int _max_num_args = (max_num_args); \
714		int _num_args = EX_NUM_ARGS(); \
715		int _i; \
716		zval *_real_arg, *_arg = NULL; \
717		zend_expected_type _expected_type = IS_UNDEF; \
718		char *_error = NULL; \
719		zend_bool _dummy; \
720		zend_bool _optional = 0; \
721		int error_code = ZPP_ERROR_OK; \
722		((void)_i); \
723		((void)_real_arg); \
724		((void)_arg); \
725		((void)_expected_type); \
726		((void)_error); \
727		((void)_dummy); \
728		((void)_optional); \
729		\
730		do { \
731			if (UNEXPECTED(_num_args < _min_num_args) || \
732			    (UNEXPECTED(_num_args > _max_num_args) && \
733			     EXPECTED(_max_num_args >= 0))) { \
734				if (!(_flags & ZEND_PARSE_PARAMS_QUIET)) { \
735					zend_wrong_parameters_count_error(_num_args, _min_num_args, _max_num_args); \
736				} \
737				error_code = ZPP_ERROR_FAILURE; \
738				break; \
739			} \
740			_i = 0; \
741			_real_arg = ZEND_CALL_ARG(execute_data, 0);
742
743#define ZEND_PARSE_PARAMETERS_START(min_num_args, max_num_args) \
744	ZEND_PARSE_PARAMETERS_START_EX(0, min_num_args, max_num_args)
745
746#define ZEND_PARSE_PARAMETERS_END_EX(failure) \
747		} while (0); \
748		if (UNEXPECTED(error_code != ZPP_ERROR_OK)) { \
749			if (!(_flags & ZEND_PARSE_PARAMS_QUIET)) { \
750				if (error_code == ZPP_ERROR_WRONG_CALLBACK) { \
751					zend_wrong_callback_error(E_WARNING, _i, _error); \
752				} else if (error_code == ZPP_ERROR_WRONG_CLASS) { \
753					zend_wrong_parameter_class_error(_i, _error, _arg); \
754				} else if (error_code == ZPP_ERROR_WRONG_ARG) { \
755					zend_wrong_parameter_type_error(_i, _expected_type, _arg); \
756				} \
757			} \
758			failure; \
759		} \
760	} while (0)
761
762#define ZEND_PARSE_PARAMETERS_END() \
763	ZEND_PARSE_PARAMETERS_END_EX(return)
764
765#define Z_PARAM_PROLOGUE(separate) \
766	++_i; \
767	ZEND_ASSERT(_i <= _min_num_args || _optional==1); \
768	ZEND_ASSERT(_i >  _min_num_args || _optional==0); \
769	if (_optional) { \
770		if (UNEXPECTED(_i >_num_args)) break; \
771	} \
772	_real_arg++; \
773	_arg = _real_arg; \
774	ZVAL_DEREF(_arg); \
775	if (separate) { \
776		SEPARATE_ZVAL_NOREF(_arg); \
777	}
778
779/* old "|" */
780#define Z_PARAM_OPTIONAL \
781	_optional = 1;
782
783/* old "a" */
784#define Z_PARAM_ARRAY_EX(dest, check_null, separate) \
785		Z_PARAM_PROLOGUE(separate); \
786		if (UNEXPECTED(!zend_parse_arg_array(_arg, &dest, check_null, 0))) { \
787			_expected_type = Z_EXPECTED_ARRAY; \
788			error_code = ZPP_ERROR_WRONG_ARG; \
789			break; \
790		}
791
792#define Z_PARAM_ARRAY(dest) \
793	Z_PARAM_ARRAY_EX(dest, 0, 0)
794
795/* old "A" */
796#define Z_PARAM_ARRAY_OR_OBJECT_EX(dest, check_null, separate) \
797		Z_PARAM_PROLOGUE(separate); \
798		if (UNEXPECTED(!zend_parse_arg_array(_arg, &dest, check_null, 1))) { \
799			_expected_type = Z_EXPECTED_ARRAY; \
800			error_code = ZPP_ERROR_WRONG_ARG; \
801			break; \
802		}
803
804#define Z_PARAM_ARRAY_OR_OBJECT(dest, check_null, separate) \
805	Z_PARAM_ARRAY_OR_OBJECT_EX(dest, 0, 0)
806
807/* old "b" */
808#define Z_PARAM_BOOL_EX(dest, is_null, check_null, separate) \
809		Z_PARAM_PROLOGUE(separate); \
810		if (UNEXPECTED(!zend_parse_arg_bool(_arg, &dest, &is_null, check_null))) { \
811			_expected_type = Z_EXPECTED_BOOL; \
812			error_code = ZPP_ERROR_WRONG_ARG; \
813			break; \
814		}
815
816#define Z_PARAM_BOOL(dest) \
817	Z_PARAM_BOOL_EX(dest, _dummy, 0, 0)
818
819/* old "C" */
820#define Z_PARAM_CLASS_EX(dest, check_null, separate) \
821		Z_PARAM_PROLOGUE(separate); \
822		if (UNEXPECTED(!zend_parse_arg_class(_arg, &dest, _i, check_null))) { \
823			error_code = ZPP_ERROR_FAILURE; \
824			break; \
825		}
826
827#define Z_PARAM_CLASS(dest) \
828	Z_PARAM_CLASS_EX(dest, 0, 0)
829
830/* old "d" */
831#define Z_PARAM_DOUBLE_EX(dest, is_null, check_null, separate) \
832		Z_PARAM_PROLOGUE(separate); \
833		if (UNEXPECTED(!zend_parse_arg_double(_arg, &dest, &is_null, check_null))) { \
834			_expected_type = Z_EXPECTED_DOUBLE; \
835			error_code = ZPP_ERROR_WRONG_ARG; \
836			break; \
837		}
838
839#define Z_PARAM_DOUBLE(dest) \
840	Z_PARAM_DOUBLE_EX(dest, _dummy, 0, 0)
841
842/* old "f" */
843#define Z_PARAM_FUNC_EX(dest_fci, dest_fcc, check_null, separate) \
844		Z_PARAM_PROLOGUE(separate); \
845		if (UNEXPECTED(!zend_parse_arg_func(_arg, &dest_fci, &dest_fcc, check_null, &_error))) { \
846			if (!_error) { \
847				_expected_type = Z_EXPECTED_FUNC; \
848				error_code = ZPP_ERROR_WRONG_ARG; \
849				break; \
850			} else { \
851				error_code = ZPP_ERROR_WRONG_CALLBACK; \
852				break; \
853			} \
854		} else if (UNEXPECTED(_error != NULL)) { \
855			zend_wrong_callback_error(E_DEPRECATED, _i, _error); \
856		}
857
858#define Z_PARAM_FUNC(dest_fci, dest_fcc) \
859	Z_PARAM_FUNC_EX(dest_fci, dest_fcc, 0, 0)
860
861/* old "h" */
862#define Z_PARAM_ARRAY_HT_EX(dest, check_null, separate) \
863		Z_PARAM_PROLOGUE(separate); \
864		if (UNEXPECTED(!zend_parse_arg_array_ht(_arg, &dest, check_null, 0))) { \
865			_expected_type = Z_EXPECTED_ARRAY; \
866			error_code = ZPP_ERROR_WRONG_ARG; \
867			break; \
868		}
869
870#define Z_PARAM_ARRAY_HT(dest) \
871	Z_PARAM_ARRAY_HT_EX(dest, 0, 0)
872
873/* old "H" */
874#define Z_PARAM_ARRAY_OR_OBJECT_HT_EX(dest, check_null, separate) \
875		Z_PARAM_PROLOGUE(separate); \
876		if (UNEXPECTED(!zend_parse_arg_array_ht(_arg, &dest, check_null, 1))) { \
877			_expected_type = Z_EXPECTED_ARRAY; \
878			error_code = ZPP_ERROR_WRONG_ARG; \
879			break; \
880		}
881
882#define Z_PARAM_ARRAY_OR_OBJECT_HT(dest) \
883	Z_PARAM_ARRAY_OR_OBJECT_HT_EX(dest, 0, 0)
884
885/* old "l" */
886#define Z_PARAM_LONG_EX(dest, is_null, check_null, separate) \
887		Z_PARAM_PROLOGUE(separate); \
888		if (UNEXPECTED(!zend_parse_arg_long(_arg, &dest, &is_null, check_null, 0))) { \
889			_expected_type = Z_EXPECTED_LONG; \
890			error_code = ZPP_ERROR_WRONG_ARG; \
891			break; \
892		}
893
894#define Z_PARAM_LONG(dest) \
895	Z_PARAM_LONG_EX(dest, _dummy, 0, 0)
896
897/* old "L" */
898#define Z_PARAM_STRICT_LONG_EX(dest, is_null, check_null, separate) \
899		Z_PARAM_PROLOGUE(separate); \
900		if (UNEXPECTED(!zend_parse_arg_long(_arg, &dest, &is_null, check_null, 1))) { \
901			_expected_type = Z_EXPECTED_LONG; \
902			error_code = ZPP_ERROR_WRONG_ARG; \
903			break; \
904		}
905
906#define Z_PARAM_STRICT_LONG(dest) \
907	Z_PARAM_STRICT_LONG_EX(dest, _dummy, 0, 0)
908
909/* old "o" */
910#define Z_PARAM_OBJECT_EX(dest, check_null, separate) \
911		Z_PARAM_PROLOGUE(separate); \
912		if (UNEXPECTED(!zend_parse_arg_object(_arg, &dest, NULL, check_null))) { \
913			_expected_type = Z_EXPECTED_OBJECT; \
914			error_code = ZPP_ERROR_WRONG_ARG; \
915			break; \
916		}
917
918#define Z_PARAM_OBJECT(dest) \
919	Z_PARAM_OBJECT_EX(dest, 0, 0)
920
921/* old "O" */
922#define Z_PARAM_OBJECT_OF_CLASS_EX(dest, _ce, check_null, separate) \
923		Z_PARAM_PROLOGUE(separate); \
924		if (UNEXPECTED(!zend_parse_arg_object(_arg, &dest, _ce, check_null))) { \
925			if (_ce) { \
926				_error = ZSTR_VAL((_ce)->name); \
927				error_code = ZPP_ERROR_WRONG_CLASS; \
928				break; \
929			} else { \
930				_expected_type = Z_EXPECTED_OBJECT; \
931				error_code = ZPP_ERROR_WRONG_ARG; \
932				break; \
933			} \
934		}
935
936#define Z_PARAM_OBJECT_OF_CLASS(dest, _ce) \
937	Z_PARAM_OBJECT_OF_CLASS_EX(dest, _ce, 0, 0)
938
939/* old "p" */
940#define Z_PARAM_PATH_EX(dest, dest_len, check_null, separate) \
941		Z_PARAM_PROLOGUE(separate); \
942		if (UNEXPECTED(!zend_parse_arg_path(_arg, &dest, &dest_len, check_null))) { \
943			_expected_type = Z_EXPECTED_PATH; \
944			error_code = ZPP_ERROR_WRONG_ARG; \
945			break; \
946		}
947
948#define Z_PARAM_PATH(dest, dest_len) \
949	Z_PARAM_PATH_EX(dest, dest_len, 0, 0)
950
951/* old "P" */
952#define Z_PARAM_PATH_STR_EX(dest, check_null, separate) \
953		Z_PARAM_PROLOGUE(separate); \
954		if (UNEXPECTED(!zend_parse_arg_path_str(_arg, &dest, check_null))) { \
955			_expected_type = Z_EXPECTED_PATH; \
956			error_code = ZPP_ERROR_WRONG_ARG; \
957			break; \
958		}
959
960#define Z_PARAM_PATH_STR(dest) \
961	Z_PARAM_PATH_STR_EX(dest, 0, 0)
962
963/* old "r" */
964#define Z_PARAM_RESOURCE_EX(dest, check_null, separate) \
965		Z_PARAM_PROLOGUE(separate); \
966		if (UNEXPECTED(!zend_parse_arg_resource(_arg, &dest, check_null))) { \
967			_expected_type = Z_EXPECTED_RESOURCE; \
968			error_code = ZPP_ERROR_WRONG_ARG; \
969			break; \
970		}
971
972#define Z_PARAM_RESOURCE(dest) \
973	Z_PARAM_RESOURCE_EX(dest, 0, 0)
974
975/* old "s" */
976#define Z_PARAM_STRING_EX(dest, dest_len, check_null, separate) \
977		Z_PARAM_PROLOGUE(separate); \
978		if (UNEXPECTED(!zend_parse_arg_string(_arg, &dest, &dest_len, check_null))) { \
979			_expected_type = Z_EXPECTED_STRING; \
980			error_code = ZPP_ERROR_WRONG_ARG; \
981			break; \
982		}
983
984#define Z_PARAM_STRING(dest, dest_len) \
985	Z_PARAM_STRING_EX(dest, dest_len, 0, 0)
986
987/* old "S" */
988#define Z_PARAM_STR_EX(dest, check_null, separate) \
989		Z_PARAM_PROLOGUE(separate); \
990		if (UNEXPECTED(!zend_parse_arg_str(_arg, &dest, check_null))) { \
991			_expected_type = Z_EXPECTED_STRING; \
992			error_code = ZPP_ERROR_WRONG_ARG; \
993			break; \
994		}
995
996#define Z_PARAM_STR(dest) \
997	Z_PARAM_STR_EX(dest, 0, 0)
998
999/* old "z" */
1000#define Z_PARAM_ZVAL_EX(dest, check_null, separate) \
1001		if (separate) { \
1002			Z_PARAM_PROLOGUE(separate); \
1003			zend_parse_arg_zval_deref(_arg, &dest, check_null); \
1004		} else { \
1005			++_i; \
1006			ZEND_ASSERT(_i <= _min_num_args || _optional==1); \
1007			ZEND_ASSERT(_i >  _min_num_args || _optional==0); \
1008			if (_optional && UNEXPECTED(_i >_num_args)) break; \
1009			_real_arg++; \
1010			zend_parse_arg_zval(_real_arg, &dest, check_null); \
1011		}
1012
1013#define Z_PARAM_ZVAL(dest) \
1014	Z_PARAM_ZVAL_EX(dest, 0, 0)
1015
1016/* old "z" (with dereference) */
1017#define Z_PARAM_ZVAL_DEREF_EX(dest, check_null, separate) \
1018		Z_PARAM_PROLOGUE(separate); \
1019		zend_parse_arg_zval_deref(_arg, &dest, check_null);
1020
1021#define Z_PARAM_ZVAL_DEREF(dest) \
1022	Z_PARAM_ZVAL_DEREF_EX(dest, 0, 0)
1023
1024/* old "+" and "*" */
1025#define Z_PARAM_VARIADIC_EX(spec, dest, dest_num, post_varargs) do { \
1026		int _num_varargs = _num_args - _i - (post_varargs); \
1027		if (EXPECTED(_num_varargs > 0)) { \
1028			dest = _real_arg + 1; \
1029			dest_num = _num_varargs; \
1030			_i += _num_varargs; \
1031			_real_arg += _num_varargs; \
1032		} else { \
1033			dest = NULL; \
1034			dest_num = 0; \
1035		} \
1036	} while (0);
1037
1038#define Z_PARAM_VARIADIC(spec, dest, dest_num) \
1039	Z_PARAM_VARIADIC_EX(spec, dest, dest_num, 0)
1040
1041#endif /* FAST_ZPP */
1042
1043/* End of new parameter parsing API */
1044
1045/* Inlined implementations shared by new and old parameter parsing APIs */
1046
1047ZEND_API int ZEND_FASTCALL zend_parse_arg_class(zval *arg, zend_class_entry **pce, int num, int check_null);
1048ZEND_API int ZEND_FASTCALL zend_parse_arg_bool_slow(zval *arg, zend_bool *dest);
1049ZEND_API int ZEND_FASTCALL zend_parse_arg_bool_weak(zval *arg, zend_bool *dest);
1050ZEND_API int ZEND_FASTCALL zend_parse_arg_long_slow(zval *arg, zend_long *dest);
1051ZEND_API int ZEND_FASTCALL zend_parse_arg_long_weak(zval *arg, zend_long *dest);
1052ZEND_API int ZEND_FASTCALL zend_parse_arg_long_cap_slow(zval *arg, zend_long *dest);
1053ZEND_API int ZEND_FASTCALL zend_parse_arg_long_cap_weak(zval *arg, zend_long *dest);
1054ZEND_API int ZEND_FASTCALL zend_parse_arg_double_slow(zval *arg, double *dest);
1055ZEND_API int ZEND_FASTCALL zend_parse_arg_double_weak(zval *arg, double *dest);
1056ZEND_API int ZEND_FASTCALL zend_parse_arg_str_slow(zval *arg, zend_string **dest);
1057ZEND_API int ZEND_FASTCALL zend_parse_arg_str_weak(zval *arg, zend_string **dest);
1058
1059static zend_always_inline int zend_parse_arg_bool(zval *arg, zend_bool *dest, zend_bool *is_null, int check_null)
1060{
1061	if (check_null) {
1062		*is_null = 0;
1063	}
1064	if (EXPECTED(Z_TYPE_P(arg) == IS_TRUE)) {
1065		*dest = 1;
1066	} else if (EXPECTED(Z_TYPE_P(arg) == IS_FALSE)) {
1067		*dest = 0;
1068	} else if (check_null && Z_TYPE_P(arg) == IS_NULL) {
1069		*is_null = 1;
1070		*dest = 0;
1071	} else {
1072		return zend_parse_arg_bool_slow(arg, dest);
1073	}
1074	return 1;
1075}
1076
1077static zend_always_inline int zend_parse_arg_long(zval *arg, zend_long *dest, zend_bool *is_null, int check_null, int cap)
1078{
1079	if (check_null) {
1080		*is_null = 0;
1081	}
1082	if (EXPECTED(Z_TYPE_P(arg) == IS_LONG)) {
1083		*dest = Z_LVAL_P(arg);
1084	} else if (check_null && Z_TYPE_P(arg) == IS_NULL) {
1085		*is_null = 1;
1086		*dest = 0;
1087	} else if (cap) {
1088		return zend_parse_arg_long_cap_slow(arg, dest);
1089	} else {
1090		return zend_parse_arg_long_slow(arg, dest);
1091	}
1092	return 1;
1093}
1094
1095static zend_always_inline int zend_parse_arg_double(zval *arg, double *dest, zend_bool *is_null, int check_null)
1096{
1097	if (check_null) {
1098		*is_null = 0;
1099	}
1100	if (EXPECTED(Z_TYPE_P(arg) == IS_DOUBLE)) {
1101		*dest = Z_DVAL_P(arg);
1102	} else if (check_null && Z_TYPE_P(arg) == IS_NULL) {
1103		*is_null = 1;
1104		*dest = 0.0;
1105	} else {
1106		return zend_parse_arg_double_slow(arg, dest);
1107	}
1108	return 1;
1109}
1110
1111static zend_always_inline int zend_parse_arg_str(zval *arg, zend_string **dest, int check_null)
1112{
1113	if (EXPECTED(Z_TYPE_P(arg) == IS_STRING)) {
1114		*dest = Z_STR_P(arg);
1115	} else if (check_null && Z_TYPE_P(arg) == IS_NULL) {
1116		*dest = NULL;
1117	} else {
1118		return zend_parse_arg_str_slow(arg, dest);
1119	}
1120	return 1;
1121}
1122
1123static zend_always_inline int zend_parse_arg_string(zval *arg, char **dest, size_t *dest_len, int check_null)
1124{
1125	zend_string *str;
1126
1127	if (!zend_parse_arg_str(arg, &str, check_null)) {
1128		return 0;
1129	}
1130	if (check_null && UNEXPECTED(!str)) {
1131		*dest = NULL;
1132		*dest_len = 0;
1133	} else {
1134		*dest = ZSTR_VAL(str);
1135		*dest_len = ZSTR_LEN(str);
1136	}
1137	return 1;
1138}
1139
1140static zend_always_inline int zend_parse_arg_path_str(zval *arg, zend_string **dest, int check_null)
1141{
1142	if (!zend_parse_arg_str(arg, dest, check_null) ||
1143	    (*dest && UNEXPECTED(CHECK_NULL_PATH(ZSTR_VAL(*dest), ZSTR_LEN(*dest))))) {
1144		return 0;
1145	}
1146	return 1;
1147}
1148
1149static zend_always_inline int zend_parse_arg_path(zval *arg, char **dest, size_t *dest_len, int check_null)
1150{
1151	zend_string *str;
1152
1153	if (!zend_parse_arg_path_str(arg, &str, check_null)) {
1154		return 0;
1155	}
1156	if (check_null && UNEXPECTED(!str)) {
1157		*dest = NULL;
1158		*dest_len = 0;
1159	} else {
1160		*dest = ZSTR_VAL(str);
1161		*dest_len = ZSTR_LEN(str);
1162	}
1163	return 1;
1164}
1165
1166static zend_always_inline int zend_parse_arg_array(zval *arg, zval **dest, int check_null, int or_object)
1167{
1168	if (EXPECTED(Z_TYPE_P(arg) == IS_ARRAY) ||
1169		(or_object && EXPECTED(Z_TYPE_P(arg) == IS_OBJECT))) {
1170		*dest = arg;
1171	} else if (check_null && EXPECTED(Z_TYPE_P(arg) == IS_NULL)) {
1172		*dest = NULL;
1173	} else {
1174		return 0;
1175	}
1176	return 1;
1177}
1178
1179static zend_always_inline int zend_parse_arg_array_ht(zval *arg, HashTable **dest, int check_null, int or_object)
1180{
1181	if (EXPECTED(Z_TYPE_P(arg) == IS_ARRAY)) {
1182		*dest = Z_ARRVAL_P(arg);
1183	} else if (or_object && EXPECTED(Z_TYPE_P(arg) == IS_OBJECT)) {
1184		*dest = Z_OBJ_HT_P(arg)->get_properties(arg);
1185	} else if (check_null && EXPECTED(Z_TYPE_P(arg) == IS_NULL)) {
1186		*dest = NULL;
1187	} else {
1188		return 0;
1189	}
1190	return 1;
1191}
1192
1193static zend_always_inline int zend_parse_arg_object(zval *arg, zval **dest, zend_class_entry *ce, int check_null)
1194{
1195	if (EXPECTED(Z_TYPE_P(arg) == IS_OBJECT) &&
1196	    (!ce || EXPECTED(instanceof_function(Z_OBJCE_P(arg), ce) != 0))) {
1197		*dest = arg;
1198	} else if (check_null && EXPECTED(Z_TYPE_P(arg) == IS_NULL)) {
1199		*dest = NULL;
1200	} else {
1201		return 0;
1202	}
1203	return 1;
1204}
1205
1206static zend_always_inline int zend_parse_arg_resource(zval *arg, zval **dest, int check_null)
1207{
1208	if (EXPECTED(Z_TYPE_P(arg) == IS_RESOURCE)) {
1209		*dest = arg;
1210	} else if (check_null && EXPECTED(Z_TYPE_P(arg) == IS_NULL)) {
1211		*dest = NULL;
1212	} else {
1213		return 0;
1214	}
1215	return 1;
1216}
1217
1218static zend_always_inline int zend_parse_arg_func(zval *arg, zend_fcall_info *dest_fci, zend_fcall_info_cache *dest_fcc, int check_null, char **error)
1219{
1220	if (check_null && UNEXPECTED(Z_TYPE_P(arg) == IS_NULL)) {
1221		dest_fci->size = 0;
1222		dest_fcc->initialized = 0;
1223		*error = NULL;
1224	} else if (UNEXPECTED(zend_fcall_info_init(arg, 0, dest_fci, dest_fcc, NULL, error) != SUCCESS)) {
1225		return 0;
1226	}
1227	return 1;
1228}
1229
1230static zend_always_inline void zend_parse_arg_zval(zval *arg, zval **dest, int check_null)
1231{
1232	*dest = (check_null &&
1233	    (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL) ||
1234	     (UNEXPECTED(Z_ISREF_P(arg)) &&
1235	      UNEXPECTED(Z_TYPE_P(Z_REFVAL_P(arg)) == IS_NULL)))) ? NULL : arg;
1236}
1237
1238static zend_always_inline void zend_parse_arg_zval_deref(zval *arg, zval **dest, int check_null)
1239{
1240	*dest = (check_null && UNEXPECTED(Z_TYPE_P(arg) == IS_NULL)) ? NULL : arg;
1241}
1242
1243END_EXTERN_C()
1244
1245#endif /* ZEND_API_H */
1246
1247
1248/*
1249 * Local variables:
1250 * tab-width: 4
1251 * c-basic-offset: 4
1252 * indent-tabs-mode: t
1253 * End:
1254 */
1255