Skip to content

Instantly share code, notes, and snippets.

@dstogov
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dstogov/843a3df3149761a59f21 to your computer and use it in GitHub Desktop.
Save dstogov/843a3df3149761a59f21 to your computer and use it in GitHub Desktop.
diff --git a/Zend/zend.h b/Zend/zend.h
index c346c02..a90165c 100644
--- a/Zend/zend.h
+++ b/Zend/zend.h
@@ -179,6 +179,14 @@ char *alloca ();
# define ZEND_ATTRIBUTE_DEPRECATED
#endif
+#if defined(__GNUC__) && ZEND_GCC_VERSION >= 4003
+# define ZEND_ATTRIBUTE_UNUSED __attribute__((unused))
+# define ZEND_ATTRIBUTE_UNUSED_LABEL __attribute__((cold, unused));
+#else
+# define ZEND_ATTRIBUTE_UNUSED
+# define ZEND_ATTRIBUTE_UNUSED_LABEL
+#endif
+
#if defined(__GNUC__) && ZEND_GCC_VERSION >= 3004 && defined(__i386__)
# define ZEND_FASTCALL __attribute__((fastcall))
#elif defined(_MSC_VER) && defined(_M_IX86)
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index 33f1fc6..8fce663 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -302,7 +302,7 @@ static int parse_arg_object_to_string(zval *arg, char **p, int *pl, int type TSR
}
/* }}} */
-static int parse_arg_object_to_str(zval *arg, zend_string **str, int type TSRMLS_DC) /* {{{ */
+ZEND_API int parse_arg_object_to_str(zval *arg, zend_string **str, int type TSRMLS_DC) /* {{{ */
{
if (Z_OBJ_HANDLER_P(arg, cast_object)) {
zval obj;
@@ -342,6 +342,94 @@ static int parse_arg_object_to_str(zval *arg, zend_string **str, int type TSRMLS
}
/* }}} */
+#ifdef FAST_ZPP
+ZEND_API void zend_wrong_paramers_count_error(int num_args, int min_num_args, int max_num_args TSRMLS_DC) /* {{{ */
+{
+ zend_function *active_function = EG(current_execute_data)->function_state.function;
+ const char *class_name = active_function->common.scope ? active_function->common.scope->name->val : "";
+
+ zend_error(E_WARNING, "%s%s%s() expects %s %d parameter%s, %d given",
+ class_name, \
+ class_name[0] ? "::" : "", \
+ active_function->common.function_name->val,
+ min_num_args == max_num_args ? "exactly" : num_args < min_num_args ? "at least" : "at most",
+ num_args < min_num_args ? min_num_args : max_num_args,
+ (num_args < min_num_args ? min_num_args : max_num_args) == 1 ? "" : "s",
+ num_args);
+}
+/* }}} */
+
+ZEND_API void zend_wrong_paramer_type_error(int num, zend_expected_type expected_type, zval *arg TSRMLS_DC) /* {{{ */
+{
+ const char *space;
+ const char *class_name = get_active_class_name(&space TSRMLS_CC);
+ static const char * const expected_error[] = {
+ Z_EXPECTED_TYPES(Z_EXPECTED_TYPE_STR)
+ NULL
+ };
+
+ zend_error(E_WARNING, "%s%s%s() expects parameter %d to be %s, %s given",
+ class_name, space, get_active_function_name(TSRMLS_C), num, expected_error[expected_type], zend_zval_type_name(arg));
+}
+/* }}} */
+
+ZEND_API void zend_wrong_paramer_class_error(int num, char *name, zval *arg TSRMLS_DC) /* {{{ */
+{
+ const char *space;
+ const char *class_name = get_active_class_name(&space TSRMLS_CC);
+
+ zend_error(E_WARNING, "%s%s%s() expects parameter %d to be %s, %s given",
+ class_name, space, get_active_function_name(TSRMLS_C), num, name, zend_zval_type_name(arg));
+}
+/* }}} */
+
+ZEND_API void zend_wrong_callback_error(int severity, int num, char *error TSRMLS_DC) /* {{{ */
+{
+ const char *space;
+ const char *class_name = get_active_class_name(&space TSRMLS_CC);
+
+ zend_error(severity, "%s%s%s() expects parameter %d to be a valid callback, %s",
+ class_name, space, get_active_function_name(TSRMLS_C), num, error);
+ efree(error);
+}
+/* }}} */
+
+ZEND_API int _z_param_class(zval *arg, zend_class_entry **pce, int num, int check_null TSRMLS_CC) /* {{{ */
+{
+ zend_class_entry *ce_base = *pce;
+
+ if (check_null && Z_TYPE_P(arg) == IS_NULL) {
+ *pce = NULL;
+ return 1;
+ }
+ convert_to_string_ex(arg);
+ *pce = zend_lookup_class(Z_STR_P(arg) TSRMLS_CC);
+ if (ce_base) {
+ if ((!*pce || !instanceof_function(*pce, ce_base TSRMLS_CC))) {
+ const char *space;
+ const char *class_name = get_active_class_name(&space TSRMLS_CC);
+
+ zend_error(E_WARNING, "%s%s%s() expects parameter %d to be a class name derived from %s, '%s' given",
+ class_name, space, get_active_function_name(TSRMLS_C), num,
+ ce_base->name->val, Z_STRVAL_P(arg));
+ *pce = NULL;
+ return 0;
+ }
+ }
+ if (!*pce) {
+ const char *space;
+ const char *class_name = get_active_class_name(&space TSRMLS_CC);
+
+ zend_error(E_WARNING, "%s%s%s() expects parameter %d to be a valid class name, '%s' given",
+ class_name, space, get_active_function_name(TSRMLS_C), num,
+ Z_STRVAL_P(arg));
+ return 0;
+ }
+ return 1;
+}
+/* }}} */
+#endif
+
static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, const char **spec, char **error, int *severity TSRMLS_DC) /* {{{ */
{
const char *spec_walk = *spec;
diff --git a/Zend/zend_API.h b/Zend/zend_API.h
index 0b96db8..ec6dbed 100644
--- a/Zend/zend_API.h
+++ b/Zend/zend_API.h
@@ -660,6 +660,620 @@ END_EXTERN_C()
#define ZEND_GINIT_FUNCTION ZEND_MODULE_GLOBALS_CTOR_D
#define ZEND_GSHUTDOWN_FUNCTION ZEND_MODULE_GLOBALS_DTOR_D
+/* New parameter parsing API */
+#define FAST_ZPP 1
+
+#ifdef FAST_ZPP
+
+#define Z_EXPECTED_TYPES(_) \
+ _(Z_EXPECTED_LONG, "long") \
+ _(Z_EXPECTED_BOOL, "boolean") \
+ _(Z_EXPECTED_STRING, "string") \
+ _(Z_EXPECTED_ARRAY, "array") \
+ _(Z_EXPECTED_FUNC, "valid callback") \
+ _(Z_EXPECTED_RESOURCE, "resource") \
+ _(Z_EXPECTED_PATH, "a valid path") \
+ _(Z_EXPECTED_OBJECT, "object") \
+ _(Z_EXPECTED_DOUBLE, "double")
+
+#define Z_EXPECTED_TYPE_ENUM(id, str) id,
+#define Z_EXPECTED_TYPE_STR(id, str) str,
+
+typedef enum _zend_expected_type {
+ Z_EXPECTED_TYPES(Z_EXPECTED_TYPE_ENUM)
+ Z_EXPECTED_LAST
+} zend_expected_type;
+
+ZEND_API int parse_arg_object_to_str(zval *arg, zend_string **str, int type TSRMLS_DC);
+ZEND_API void zend_wrong_paramers_count_error(int num_args, int min_num_args, int max_num_args TSRMLS_DC);
+ZEND_API void zend_wrong_paramer_type_error(int num, zend_expected_type expected_type, zval *arg TSRMLS_DC);
+ZEND_API void zend_wrong_paramer_class_error(int num, char *name, zval *arg TSRMLS_DC);
+ZEND_API void zend_wrong_callback_error(int severity, int num, char *error TSRMLS_DC);
+ZEND_API int _z_param_class(zval *arg, zend_class_entry **pce, int num, int check_null TSRMLS_CC);
+
+#define ZEND_PARSE_PARAMETERS_START_EX(flags) do { \
+ const int _flags = (flags); \
+ int _min_num_args = -1; \
+ int _max_num_args = -1; \
+ zval *_top = zend_vm_stack_top(TSRMLS_C) - 1; \
+ int _num_args = Z_LVAL_P(_top); \
+ int _i; \
+ zval *_real_arg, *_arg; \
+ zend_expected_type _expected_type; \
+ char *_error; \
+ zend_bool _dummy; \
+ ((void)_i); \
+ ((void)_real_arg); \
+ ((void)_arg); \
+ ((void)_expected_type); \
+ ((void)_error); \
+ ((void)_dummy); \
+ _i = 0; \
+ _real_arg = _top - _num_args - 1;
+
+#define ZEND_PARSE_PARAMETERS_START() \
+ ZEND_PARSE_PARAMETERS_START_EX(0)
+
+#define ZEND_PARSE_PARAMETERS_END_EX(failure) \
+ if ((_min_num_args == -1 && _i > _num_args) || \
+ _num_args < _min_num_args || _i < _num_args) { \
+zend_parse_params_arg_count: \
+ if (!(_flags & ZEND_PARSE_PARAMS_QUIET)) { \
+ if (_min_num_args == -1) { \
+ _min_num_args = _i; \
+ } \
+ if (_max_num_args == -1) { \
+ _max_num_args = _i; \
+ } \
+ zend_wrong_paramers_count_error(_num_args, _min_num_args, _max_num_args); \
+ goto zend_parse_params_failure; \
+ } \
+ } \
+ if (0) { \
+zend_parse_params_wrong_callback: ZEND_ATTRIBUTE_UNUSED_LABEL \
+ if (!(_flags & ZEND_PARSE_PARAMS_QUIET)) { \
+ zend_wrong_callback_error(E_WARNING, _i, _error TSRMLS_DC); \
+ } \
+ goto zend_parse_params_failure; \
+zend_parse_params_wrong_class: ZEND_ATTRIBUTE_UNUSED_LABEL \
+ if (!(_flags & ZEND_PARSE_PARAMS_QUIET)) { \
+ zend_wrong_paramer_class_error(_i, _error, _arg TSRMLS_DC); \
+ } \
+ goto zend_parse_params_failure; \
+zend_parse_params_wrong_arg: ZEND_ATTRIBUTE_UNUSED_LABEL \
+ if (!(_flags & ZEND_PARSE_PARAMS_QUIET)) { \
+ zend_wrong_paramer_type_error(_i, _expected_type, _arg TSRMLS_DC); \
+ } \
+zend_parse_params_failure: ZEND_ATTRIBUTE_UNUSED_LABEL \
+ failure; \
+ } \
+ } while (0)
+
+#define ZEND_PARSE_PARAMETERS_END() \
+ ZEND_PARSE_PARAMETERS_END_EX(return)
+
+#define Z_PARAM_PROLOGUE(separate) \
+ if (UNEXPECTED(++_i >_num_args)) break; \
+ _real_arg++; \
+ _arg = _real_arg; \
+ ZVAL_DEREF(_arg); \
+ if (separate) { \
+ SEPARATE_ZVAL_NOREF(_arg); \
+ }
+
+/* old "|" */
+#define Z_PARAM_OPTIONAL do { \
+ _min_num_args = _i; \
+ } while (0);
+
+/* old "a" */
+#define Z_PARAM_ARRAY_EX(dest, check_null, separate) do { \
+ Z_PARAM_PROLOGUE(separate); \
+ if (!_z_param_array(_arg, &dest, check_null, 0)) { \
+ _expected_type = Z_EXPECTED_ARRAY; \
+ goto zend_parse_params_wrong_arg; \
+ } \
+ } while (0);
+
+#define Z_PARAM_ARRAY(dest) \
+ Z_PARAM_ARRAY_EX(dest, 0, 0)
+
+/* old "A" */
+#define Z_PARAM_ARRAY_OR_OBJECT_EX(dest, check_null, separate) do { \
+ Z_PARAM_PROLOGUE(separate); \
+ if (!_z_param_array(_arg, &dest, check_null, 1)) { \
+ _expected_type = Z_EXPECTED_ARRAY; \
+ goto zend_parse_params_wrong_arg; \
+ } \
+ } while (0);
+
+#define Z_PARAM_ARRAY_OR_OBJECT(dest, check_null, separate) \
+ Z_PARAM_ARRAY_OR_OBJECT_EX(dest, 0, 0)
+
+/* old "b" */
+#define Z_PARAM_BOOL_EX(dest, is_null, check_null, separate) do { \
+ Z_PARAM_PROLOGUE(separate); \
+ if (!_z_param_bool(_arg, &dest, &is_null, check_null)) { \
+ _expected_type = Z_EXPECTED_BOOL; \
+ goto zend_parse_params_wrong_arg; \
+ } \
+ } while (0);
+
+#define Z_PARAM_BOOL(dest) \
+ Z_PARAM_BOOL_EX(dest, _dummy, 0, 0)
+
+/* old "C" */
+#define Z_PARAM_CLASS_EX(dest, check_null, separate) do { \
+ Z_PARAM_PROLOGUE(separate); \
+ if (!_z_param_class(_arg, &dest, _i, check_null TSRMLS_CC)) { \
+ goto zend_parse_params_failure; \
+ } \
+ } while (0);
+
+#define Z_PARAM_CLASS(dest) \
+ Z_PARAM_CLASS_EX(dest, 0, 0)
+
+/* old "d" */
+#define Z_PARAM_DOUBLE_EX(dest, is_null, check_null, separate) do { \
+ Z_PARAM_PROLOGUE(separate); \
+ if (!_z_param_double(_arg, &dest, &is_null, check_null)) { \
+ _expected_type = Z_EXPECTED_DOUBLE; \
+ goto zend_parse_params_wrong_arg; \
+ } \
+ } while (0);
+
+#define Z_PARAM_DOUBLE(dest) \
+ Z_PARAM_DOUBLE_EX(dest, _dummy, 0, 0)
+
+/* old "f" */
+#define Z_PARAM_FUNC_EX(dest_fci, dest_fcc, check_null, separate) do { \
+ Z_PARAM_PROLOGUE(separate); \
+ if (!_z_param_func(_arg, &dest_fci, &dest_fcc, check_null, &_error)) { \
+ if (!_error) { \
+ _expected_type = Z_EXPECTED_FUNC; \
+ goto zend_parse_params_wrong_arg; \
+ } else { \
+ goto zend_parse_params_wrong_callback; \
+ } \
+ } else if (_error) { \
+ zend_wrong_callback_error(E_STRICT, _i, _error TSRMLS_DC); \
+ } \
+ } while (0);
+
+#define Z_PARAM_FUNC(dest_fci, dest_fcc) \
+ Z_PARAM_FUNC_EX(dest_fci, dest_fcc, 0, 0)
+
+/* old "h" */
+#define Z_PARAM_ARRAY_HT_EX(dest, check_null, separate) do { \
+ Z_PARAM_PROLOGUE(separate); \
+ if (!_z_param_array_ht(_arg, &dest, check_null, 0)) { \
+ _expected_type = Z_EXPECTED_ARRAY; \
+ goto zend_parse_params_wrong_arg; \
+ } \
+ } while (0);
+
+#define Z_PARAM_ARRAY_HT(dest) \
+ Z_PARAM_ARRAY_HT_EX(dest, 0, 0)
+
+/* old "H" */
+#define Z_PARAM_ARRAY_OR_OBJECT_HT_EX(dest, check_null, separate) do { \
+ Z_PARAM_PROLOGUE(separate); \
+ if (!_z_param_array_ht(_arg, &dest, check_null, 1)) { \
+ _expected_type = Z_EXPECTED_ARRAY; \
+ goto zend_parse_params_wrong_arg; \
+ } \
+ } while (0);
+
+#define Z_PARAM_ARRAY_OR_OBJECT_HT(dest) \
+ Z_PARAM_ARRAY_OR_OBJECT_HT_EX(dest, 0, 0)
+
+/* old "l" */
+#define Z_PARAM_LONG_EX(dest, is_null, check_null, separate) do { \
+ Z_PARAM_PROLOGUE(separate); \
+ if (!_z_param_long(_arg, &dest, &is_null, check_null, 0)) { \
+ _expected_type = Z_EXPECTED_LONG; \
+ goto zend_parse_params_wrong_arg; \
+ } \
+ } while (0);
+
+#define Z_PARAM_LONG(dest) \
+ Z_PARAM_LONG_EX(dest, _dummy, 0, 0)
+
+/* old "L" */
+#define Z_PARAM_STRICT_LONG_EX(dest, is_null, check_null, separate) do { \
+ Z_PARAM_PROLOGUE(separate); \
+ if (!_z_param_long(_arg, &dest, &is_null, check_null, 1)) { \
+ _expected_type = Z_EXPECTED_LONG; \
+ goto zend_parse_params_wrong_arg; \
+ } \
+ } while (0);
+
+#define Z_PARAM_STRICT_LONG(dest) \
+ Z_PARAM_STRICT_LONG_EX(dest, _dummy, 0, 0)
+
+/* old "o" */
+#define Z_PARAM_OBJECT_EX(dest, check_null, separate) do { \
+ Z_PARAM_PROLOGUE(separate); \
+ if (!_z_param_object(_arg, &dest, NULL, check_null)) { \
+ _expected_type = Z_EXPECTED_OBJECT; \
+ goto zend_parse_params_wrong_arg; \
+ } \
+ } while (0);
+
+#define Z_PARAM_OBJECT(dest) \
+ Z_PARAM_OBJECT_EX(dest, 0, 0)
+
+/* old "O" */
+#define Z_PARAM_OBJECT_OF_CLASS_EX(dest, _ce, check_null, separate) do { \
+ Z_PARAM_PROLOGUE(separate); \
+ if (!_z_param_object(_arg, &dest, _ce, check_null)) { \
+ if (_ce) { \
+ _error = (_ce)->name->val; \
+ goto zend_parse_params_wrong_class; \
+ } else { \
+ _expected_type = Z_EXPECTED_OBJECT; \
+ goto zend_parse_params_wrong_arg; \
+ } \
+ } \
+ } while (0);
+
+#define Z_PARAM_OBJECT_OF_CLASS(dest, _ce) \
+ Z_PARAM_OBJECT_OF_CLASS_EX(dest, _ce, 0, 0)
+
+/* old "p" */
+#define Z_PARAM_PATH_EX(dest, dest_len, check_null, separate) do { \
+ Z_PARAM_PROLOGUE(separate); \
+ if (!_z_param_path(_arg, &dest, &dest_len, check_null)) { \
+ _expected_type = Z_EXPECTED_PATH; \
+ goto zend_parse_params_wrong_arg; \
+ } \
+ } while (0);
+
+#define Z_PARAM_PATH(dest, dest_len) \
+ Z_PARAM_PATH_EX(dest, dest_len, 0, 0)
+
+/* old "P" */
+#define Z_PARAM_PATH_STR_EX(dest, check_null, separate) do { \
+ Z_PARAM_PROLOGUE(separate); \
+ if (!_z_param_path_str(_arg, &dest, check_null)) { \
+ _expected_type = Z_EXPECTED_PATH; \
+ goto zend_parse_params_wrong_arg; \
+ } \
+ } while (0);
+
+#define Z_PARAM_PATH_STR(dest) \
+ Z_PARAM_PATH_STR_EX(dest, 0, 0)
+
+/* old "r" */
+#define Z_PARAM_RESOURCE_EX(dest, check_null, separate) do { \
+ Z_PARAM_PROLOGUE(separate); \
+ if (!_z_param_resource(_arg, &dest, check_null)) { \
+ _expected_type = Z_EXPECTED_RESOURCE; \
+ goto zend_parse_params_wrong_arg; \
+ } \
+ } while (0);
+
+#define Z_PARAM_RESOURCE(dest) \
+ Z_PARAM_RESOURCE_EX(dest, 0, 0)
+
+/* old "s" */
+#define Z_PARAM_STRING_EX(dest, dest_len, check_null, separate) do { \
+ Z_PARAM_PROLOGUE(separate); \
+ if (!_z_param_string(_arg, &dest, &dest_len, check_null)) { \
+ _expected_type = Z_EXPECTED_STRING; \
+ goto zend_parse_params_wrong_arg; \
+ } \
+ } while (0);
+
+#define Z_PARAM_STRING(dest, dest_len) \
+ Z_PARAM_STRING_EX(dest, dest_len, 0, 0)
+
+/* old "S" */
+#define Z_PARAM_STR_EX(dest, check_null, separate) do { \
+ Z_PARAM_PROLOGUE(separate); \
+ if (!_z_param_str(_arg, &dest, check_null)) { \
+ _expected_type = Z_EXPECTED_STRING; \
+ goto zend_parse_params_wrong_arg; \
+ } \
+ } while (0);
+
+#define Z_PARAM_STR(dest) \
+ Z_PARAM_STR_EX(dest, 0, 0)
+
+/* old "z" */
+#define Z_PARAM_ZVAL_EX(dest, check_null, separate) do { \
+ if (separate) { \
+ Z_PARAM_PROLOGUE(separate); \
+ _z_param_zval_deref(_arg, &dest, check_null); \
+ } else { \
+ if (UNEXPECTED(++_i >_num_args)) break; \
+ _real_arg++; \
+ _z_param_zval(_real_arg, &dest, check_null); \
+ } \
+ } while (0);
+
+#define Z_PARAM_ZVAL(dest) \
+ Z_PARAM_ZVAL_EX(dest, 0, 0)
+
+/* old "z" (with dereference) */
+#define Z_PARAM_ZVAL_DEREF_EX(dest, check_null, separate) do { \
+ Z_PARAM_PROLOGUE(separate); \
+ _z_param_zval_deref(_arg, &dest, check_null); \
+ } while (0);
+
+#define Z_PARAM_ZVAL_DEREF(dest) \
+ Z_PARAM_ZVAL_DEREF_EX(dest, 0, 0)
+
+/* old "+" and "*" */
+#define Z_PARAM_VARIADIC_EX(spec, dest, dest_num, post_varargs) do { \
+ int _num_varargs = _num_args - _i - (post_varargs); \
+ if (spec == '+') { \
+ if (_i + 1 > _num_args) { \
+ _min_num_args = _i + 1; \
+ goto zend_parse_params_arg_count; \
+ } \
+ } \
+ if (_num_varargs > 0) { \
+ dest = _real_arg + 1; \
+ dest_num = _num_varargs; \
+ _i += _num_varargs; \
+ _real_arg += _num_varargs; \
+ } else { \
+ dest = NULL; \
+ dest_num = 0; \
+ } \
+ } while (0);
+
+#define Z_PARAM_VARIADIC(spec, dest, dest_num) \
+ Z_PARAM_VARIADIC_EX(spec, dest, dest_num, 0)
+
+/* Private part of new parameter parsing API */
+
+static zend_always_inline int _z_param_bool(zval *arg, zend_bool *dest, zend_bool *is_null, int check_null)
+{
+ if (check_null) {
+ *is_null = 0;
+ }
+ if (EXPECTED(Z_TYPE_P(arg) == IS_TRUE)) {
+ *dest = 1;
+ } else if (EXPECTED(Z_TYPE_P(arg) < IS_TRUE)) {
+ if (check_null) {
+ *is_null = (Z_TYPE_P(arg) == IS_NULL);
+ }
+ *dest = 0;
+ } else if (EXPECTED(Z_TYPE_P(arg) <= IS_STRING)) {
+ *dest = zend_is_true(arg);
+ } else {
+ return 0;
+ }
+ return 1;
+}
+
+static zend_always_inline int _z_param_long(zval *arg, long *dest, zend_bool *is_null, int check_null, int strict)
+{
+ if (check_null) {
+ *is_null = 0;
+ }
+ if (EXPECTED(Z_TYPE_P(arg) == IS_LONG)) {
+ if (strict && UNEXPECTED(Z_DVAL_P(arg) > LONG_MAX)) {
+ *dest = LONG_MAX;
+ } else if (strict && UNEXPECTED(Z_DVAL_P(arg) < LONG_MIN)) {
+ *dest = LONG_MIN;
+ } else {
+ *dest = Z_LVAL_P(arg);
+ }
+ } else if (EXPECTED(Z_TYPE_P(arg) == IS_DOUBLE)) {
+ *dest = zend_dval_to_lval(Z_DVAL_P(arg));
+ } else if (EXPECTED(Z_TYPE_P(arg) == IS_STRING)) {
+ double d;
+ int type;
+
+ if (UNEXPECTED((type = is_numeric_str_function(Z_STR_P(arg), dest, &d)) != IS_LONG)) {
+ if (EXPECTED(type != 0)) {
+ if (strict && UNEXPECTED(d > LONG_MAX)) {
+ *dest = LONG_MAX;
+ } else if (strict && UNEXPECTED(d < LONG_MIN)) {
+ *dest = LONG_MIN;
+ } else {
+ *dest = zend_dval_to_lval(d);
+ }
+ } else {
+ return 0;
+ }
+ }
+ } else if (EXPECTED(Z_TYPE_P(arg) < IS_TRUE)) {
+ if (check_null) {
+ *is_null = (Z_TYPE_P(arg) == IS_NULL);
+ }
+ *dest = 0;
+ } else if (EXPECTED(Z_TYPE_P(arg) == IS_TRUE)) {
+ *dest = 1;
+ } else {
+ return 0;
+ }
+ return 1;
+}
+
+static zend_always_inline int _z_param_double(zval *arg, double *dest, zend_bool *is_null, int check_null)
+{
+ if (check_null) {
+ *is_null = 0;
+ }
+ if (EXPECTED(Z_TYPE_P(arg) == IS_DOUBLE)) {
+ *dest = Z_DVAL_P(arg);
+ } else if (EXPECTED(Z_TYPE_P(arg) == IS_LONG)) {
+ *dest = (double)Z_LVAL_P(arg);
+ } else if (EXPECTED(Z_TYPE_P(arg) == IS_STRING)) {
+ long l;
+ int type;
+
+ if (UNEXPECTED((type = is_numeric_str_function(Z_STR_P(arg), &l, dest)) != IS_DOUBLE)) {
+ if (EXPECTED(type != 0)) {
+ *dest = (double)(l);
+ } else {
+ return 0;
+ }
+ }
+ } else if (EXPECTED(Z_TYPE_P(arg) < IS_TRUE)) {
+ if (check_null) {
+ *is_null = (Z_TYPE_P(arg) == IS_NULL);
+ }
+ *dest = 0.0;
+ } else if (EXPECTED(Z_TYPE_P(arg) == IS_TRUE)) {
+ *dest = 1.0;
+ } else {
+ return 0;
+ }
+ return 1;
+}
+
+static zend_always_inline int _z_param_str(zval *arg, zend_string **dest, int check_null)
+{
+ if (EXPECTED(Z_TYPE_P(arg) == IS_STRING)) {
+ *dest = Z_STR_P(arg);
+ } else if (EXPECTED(Z_TYPE_P(arg) < IS_STRING)) {
+ if (check_null && UNEXPECTED(Z_TYPE_P(arg) == IS_NULL)) {
+ *dest = NULL;
+ } else {
+ if (Z_COPYABLE_P(arg) && Z_REFCOUNT_P(arg) > 1) {
+ Z_DELREF_P(arg);
+ zval_copy_ctor_func(arg);
+ }
+ convert_to_string(arg);
+ *dest = Z_STR_P(arg);
+ }
+ } else if (UNEXPECTED(Z_TYPE_P(arg) != IS_OBJECT) ||
+ UNEXPECTED(parse_arg_object_to_str(arg, dest, IS_STRING TSRMLS_CC) != SUCCESS)) {
+ return 0;
+ }
+ return 1;
+}
+
+static zend_always_inline int _z_param_string(zval *arg, char **dest, int *dest_len, int check_null)
+{
+ zend_string *str;
+
+ if (!_z_param_str(arg, &str, check_null)) {
+ return 0;
+ }
+ if (check_null && UNEXPECTED(!str)) {
+ *dest = NULL;
+ *dest_len = 0;
+ } else {
+ *dest = str->val;
+ *dest_len = str->len;
+ }
+ return 1;
+}
+
+static zend_always_inline int _z_param_path_str(zval *arg, zend_string **dest, int check_null)
+{
+ if (!_z_param_str(arg, dest, check_null) ||
+ (check_null && UNEXPECTED(!(*dest)->val)) ||
+ UNEXPECTED(CHECK_NULL_PATH((*dest)->val, (*dest)->len))) {
+ return 0;
+ }
+ return 1;
+}
+
+static zend_always_inline int _z_param_path(zval *arg, char **dest, int *dest_len, int check_null)
+{
+ zend_string *str;
+
+ if (!_z_param_path_str(arg, &str, check_null)) {
+ return 0;
+ }
+ if (check_null && UNEXPECTED(!str)) {
+ *dest = NULL;
+ *dest_len = 0;
+ } else {
+ *dest = str->val;
+ *dest_len = str->len;
+ }
+ return 1;
+}
+
+static zend_always_inline int _z_param_array(zval *arg, zval **dest, int check_null, int or_object)
+{
+ if (EXPECTED(Z_TYPE_P(arg) == IS_ARRAY) ||
+ (or_object && EXPECTED(Z_TYPE_P(arg) == IS_OBJECT))) {
+ *dest = arg;
+ } else if (check_null && EXPECTED(Z_TYPE_P(arg) == IS_NULL)) {
+ *dest = NULL;
+ } else {
+ return 0;
+ }
+ return 1;
+}
+
+static zend_always_inline int _z_param_array_ht(zval *arg, HashTable **dest, int check_null, int or_object)
+{
+ if (EXPECTED(Z_TYPE_P(arg) == IS_ARRAY)) {
+ *dest = Z_ARRVAL_P(arg);
+ } else if (or_object && EXPECTED(Z_TYPE_P(arg) == IS_OBJECT)) {
+ *dest = Z_OBJ_HT_P(arg)->get_properties(arg TSRMLS_CC);
+ } else if (check_null && EXPECTED(Z_TYPE_P(arg) == IS_NULL)) {
+ *dest = NULL;
+ } else {
+ return 0;
+ }
+ return 1;
+}
+
+static zend_always_inline int _z_param_object(zval *arg, zval **dest, zend_class_entry *ce, int check_null)
+{
+ if (EXPECTED(Z_TYPE_P(arg) == IS_OBJECT) &&
+ (!ce || EXPECTED(instanceof_function(Z_OBJCE_P(arg), ce TSRMLS_CC) != 0))) {
+ *dest = arg;
+ } else if (check_null && EXPECTED(Z_TYPE_P(arg) == IS_NULL)) {
+ *dest = NULL;
+ } else {
+ return 0;
+ }
+ return 1;
+}
+
+static zend_always_inline int _z_param_resource(zval *arg, zval **dest, int check_null)
+{
+ if (EXPECTED(Z_TYPE_P(arg) == IS_RESOURCE)) {
+ *dest = arg;
+ } else if (check_null && EXPECTED(Z_TYPE_P(arg) == IS_NULL)) {
+ *dest = NULL;
+ } else {
+ return 0;
+ }
+ return 1;
+}
+
+static zend_always_inline int _z_param_func(zval *arg, zend_fcall_info *dest_fci, zend_fcall_info_cache *dest_fcc, int check_null, char **error)
+{
+ if (check_null && UNEXPECTED(Z_TYPE_P(arg) == IS_NULL)) {
+ dest_fci->size = 0;
+ dest_fcc->initialized = 0;
+ *error = NULL;
+ } else if (UNEXPECTED(zend_fcall_info_init(arg, 0, dest_fci, dest_fcc, NULL, error TSRMLS_CC) != SUCCESS)) {
+ return 0;
+ }
+ return 1;
+}
+
+static zend_always_inline void _z_param_zval(zval *arg, zval **dest, int check_null)
+{
+ *dest = (check_null &&
+ (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL) ||
+ (UNEXPECTED(Z_ISREF_P(arg)) &&
+ UNEXPECTED(Z_TYPE_P(Z_REFVAL_P(arg)) == IS_NULL)))) ? NULL : arg;
+}
+
+static zend_always_inline void _z_param_zval_deref(zval *arg, zval **dest, int check_null)
+{
+ *dest = (check_null && UNEXPECTED(Z_TYPE_P(arg) == IS_NULL)) ? NULL : arg;
+}
+
+#endif /* FAST_ZPP */
+
+/* End of new parameter parsing API */
+
END_EXTERN_C()
#endif /* ZEND_API_H */
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index f8f6a43..4d5d42a 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -491,9 +491,15 @@ ZEND_FUNCTION(strlen)
{
zend_string *s;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &s) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_STR(s)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
RETVAL_LONG(s->len);
}
@@ -670,9 +676,18 @@ ZEND_FUNCTION(define)
int case_sensitive = CONST_CS;
zend_constant c;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Sz|b", &name, &val, &non_cs) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_STR(name)
+ Z_PARAM_ZVAL(val)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_BOOL(non_cs)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
if(non_cs) {
case_sensitive = 0;
@@ -737,9 +752,15 @@ ZEND_FUNCTION(defined)
{
zend_string *name;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &name) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_STR(name)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
if (zend_get_constant_ex(name, NULL, ZEND_FETCH_CLASS_SILENT TSRMLS_CC)) {
RETURN_TRUE;
@@ -842,9 +863,18 @@ static void is_a_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool only_subclass)
zend_bool allow_string = only_subclass;
zend_bool retval;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zS|b", &obj, &class_name, &allow_string) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_ZVAL(obj)
+ Z_PARAM_STR(class_name)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_BOOL(allow_string)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
/*
* allow_string - is_a default is no, is_subclass_of is yes.
* if it's allowed, then the autoloader will be called if the class does not exist.
@@ -980,9 +1010,15 @@ ZEND_FUNCTION(get_object_vars)
uint prop_len;
zend_object *zobj;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &obj) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_OBJECT(obj)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
if (Z_OBJ_HT_P(obj)->get_properties == NULL) {
RETURN_FALSE;
@@ -1202,9 +1238,17 @@ ZEND_FUNCTION(class_exists)
zend_class_entry *ce;
zend_bool autoload = 1;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|b", &class_name, &autoload) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_STR(class_name)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_BOOL(autoload)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
if (!autoload) {
if (class_name->val[0] == '\\') {
@@ -1237,9 +1281,17 @@ ZEND_FUNCTION(interface_exists)
zend_class_entry *ce;
zend_bool autoload = 1;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|b", &iface_name, &autoload) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_STR(iface_name)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_BOOL(autoload)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
if (!autoload) {
if (iface_name->val[0] == '\\') {
@@ -1272,9 +1324,17 @@ ZEND_FUNCTION(trait_exists)
zend_class_entry *ce;
zend_bool autoload = 1;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|b", &trait_name, &autoload) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_STR(trait_name)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_BOOL(autoload)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
if (!autoload) {
if (trait_name->val[0] == '\\') {
@@ -1309,9 +1369,15 @@ ZEND_FUNCTION(function_exists)
zend_function *func;
zend_string *lcname;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_STRING(name, name_len)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
if (name[0] == '\\') {
/* Ignore leading "\" */
diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c
index caf5e78..dbd757c 100644
--- a/Zend/zend_operators.c
+++ b/Zend/zend_operators.c
@@ -2526,6 +2526,10 @@ ZEND_API zend_string *zend_long_to_str(long num) /* {{{ */
}
/* }}} */
+ZEND_API zend_uchar is_numeric_str_function(const zend_string *str, long *lval, double *dval) {
+ return is_numeric_string_ex(str->val, str->len, lval, dval, -1, NULL);
+}
+
/*
* Local variables:
* tab-width: 4
diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h
index b952b98..1ab9518 100644
--- a/Zend/zend_operators.h
+++ b/Zend/zend_operators.h
@@ -270,6 +270,8 @@ static inline zend_uchar is_numeric_string(const char *str, int length, long *lv
return is_numeric_string_ex(str, length, lval, dval, allow_errors, NULL);
}
+ZEND_API zend_uchar is_numeric_str_function(const zend_string *str, long *lval, double *dval);
+
static inline const char *
zend_memnstr(const char *haystack, const char *needle, int needle_len, char *end)
{
diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c
index 0ce3600..a291e30 100644
--- a/ext/pcre/php_pcre.c
+++ b/ext/pcre/php_pcre.c
@@ -542,10 +542,21 @@ static void php_do_pcre_match(INTERNAL_FUNCTION_PARAMETERS, int global) /* {{{ *
long flags = 0; /* Match control flags */
long start_offset = 0; /* Where the new search starts */
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Ss|z/ll", &regex,
&subject, &subject_len, &subpats, &flags, &start_offset) == FAILURE) {
RETURN_FALSE;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_STR(regex)
+ Z_PARAM_STRING(subject, subject_len)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_ZVAL_EX(subpats, 0, 1)
+ Z_PARAM_LONG(flags)
+ Z_PARAM_LONG(start_offset)
+ ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
+#endif
/* Compile regex or get it from cache. */
if ((pce = pcre_get_compiled_regex_cache(regex TSRMLS_CC)) == NULL) {
@@ -1351,10 +1362,21 @@ static void preg_replace_impl(INTERNAL_FUNCTION_PARAMETERS, int is_callable_repl
zend_string *callback_name;
int replace_count=0, old_replace_count;
+#ifndef FAST_ZPP
/* Get function parameters and do error-checking. */
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zzz|lz/", &regex, &replace, &subject, &limit, &zcount) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_ZVAL(regex)
+ Z_PARAM_ZVAL(replace)
+ Z_PARAM_ZVAL(subject)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_LONG(limit)
+ Z_PARAM_ZVAL_EX(zcount, 0, 1)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
if (!is_callable_replace && Z_TYPE_P(replace) == IS_ARRAY && Z_TYPE_P(regex) != IS_ARRAY) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Parameter mismatch, pattern is a string while replacement is an array");
@@ -1459,10 +1481,20 @@ static PHP_FUNCTION(preg_split)
pcre_cache_entry *pce; /* Compiled regular expression */
/* Get function parameters and do error checking */
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Ss|ll", &regex,
&subject, &subject_len, &limit_val, &flags) == FAILURE) {
RETURN_FALSE;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_STR(regex)
+ Z_PARAM_STRING(subject, subject_len)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_LONG(limit_val)
+ Z_PARAM_LONG(flags)
+ ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
+#endif
/* Compile regex or get it from cache. */
if ((pce = pcre_get_compiled_regex_cache(regex TSRMLS_CC)) == NULL) {
@@ -1664,10 +1696,18 @@ static PHP_FUNCTION(preg_quote)
zend_bool quote_delim = 0; /* Whether to quote additional delim char */
/* Get the arguments and check for errors */
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &in_str, &in_str_len,
&delim, &delim_len) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_STRING(in_str, in_str_len)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_STRING(delim, delim_len)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
in_str_end = in_str + in_str_len;
@@ -1745,10 +1785,19 @@ static PHP_FUNCTION(preg_grep)
pcre_cache_entry *pce; /* Compiled regular expression */
/* Get arguments and do error checking */
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Sa|l", &regex,
&input, &flags) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_STR(regex)
+ Z_PARAM_ARRAY(input)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_LONG(flags)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
/* Compile regex or get it from cache. */
if ((pce = pcre_get_compiled_regex_cache(regex TSRMLS_CC)) == NULL) {
@@ -1844,9 +1893,14 @@ PHPAPI void php_pcre_grep_impl(pcre_cache_entry *pce, zval *input, zval *return
Returns the error code of the last regexp execution. */
static PHP_FUNCTION(preg_last_error)
{
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ ZEND_PARSE_PARAMETERS_END();
+#endif
RETURN_LONG(PCRE_G(error_code));
}
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index 8611c9c..fe925d8 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -1494,9 +1494,17 @@ ZEND_METHOD(reflection, export)
int result;
zend_bool return_output = 0;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|b", &object, reflector_ptr, &return_output) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_OBJECT_OF_CLASS(object, reflector_ptr)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_BOOL(return_output)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
/* Invoke the __toString() method */
ZVAL_STRINGL(&fname, "__tostring", sizeof("__tostring") - 1);
diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c
index 2fa7a53..2c7915d 100644
--- a/ext/spl/spl_array.c
+++ b/ext/spl/spl_array.c
@@ -1261,9 +1261,15 @@ SPL_METHOD(Array, setIteratorClass)
spl_array_object *intern = Z_SPLARRAY_P(object);
zend_class_entry * ce_get_iterator = spl_ce_Iterator;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "C", &ce_get_iterator) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_CLASS(ce_get_iterator)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
intern->ce_get_iterator = ce_get_iterator;
}
diff --git a/ext/standard/array.c b/ext/standard/array.c
index 5446bb5..1358f30 100644
--- a/ext/standard/array.c
+++ b/ext/standard/array.c
@@ -291,9 +291,17 @@ PHP_FUNCTION(count)
long cnt;
zval *element;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|l", &array, &mode) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_ZVAL(array)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_LONG(mode)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
switch (Z_TYPE_P(array)) {
case IS_NULL:
@@ -771,9 +779,15 @@ PHP_FUNCTION(end)
HashTable *array;
zval *entry;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "H/", &array) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_ARRAY_OR_OBJECT_HT_EX(array, 0, 1)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
zend_hash_internal_pointer_end(array);
@@ -798,9 +812,15 @@ PHP_FUNCTION(prev)
HashTable *array;
zval *entry;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "H/", &array) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_ARRAY_OR_OBJECT_HT_EX(array, 0, 1)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
zend_hash_move_backwards(array);
@@ -825,9 +845,15 @@ PHP_FUNCTION(next)
HashTable *array;
zval *entry;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "H/", &array) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_ARRAY_OR_OBJECT_HT_EX(array, 0, 1)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
zend_hash_move_forward(array);
@@ -852,9 +878,15 @@ PHP_FUNCTION(reset)
HashTable *array;
zval *entry;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "H/", &array) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_ARRAY_OR_OBJECT_HT_EX(array, 0, 1)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
zend_hash_internal_pointer_reset(array);
@@ -879,9 +911,15 @@ PHP_FUNCTION(current)
HashTable *array;
zval *entry;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "H/", &array) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_ARRAY_OR_OBJECT_HT_EX(array, 0, 1)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
if ((entry = zend_hash_get_current_data(array)) == NULL) {
RETURN_FALSE;
@@ -901,9 +939,15 @@ PHP_FUNCTION(key)
{
HashTable *array;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "H/", &array) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_ARRAY_OR_OBJECT_HT_EX(array, 0, 1)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
zend_hash_get_current_key_zval(array, return_value);
}
@@ -1120,11 +1164,24 @@ PHP_FUNCTION(array_walk)
orig_array_walk_fci = BG(array_walk_fci);
orig_array_walk_fci_cache = BG(array_walk_fci_cache);
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "H/f|z/", &array, &BG(array_walk_fci), &BG(array_walk_fci_cache), &userdata) == FAILURE) {
BG(array_walk_fci) = orig_array_walk_fci;
BG(array_walk_fci_cache) = orig_array_walk_fci_cache;
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_ARRAY_OR_OBJECT_HT_EX(array, 0, 1)
+ Z_PARAM_FUNC(BG(array_walk_fci), BG(array_walk_fci_cache))
+ Z_PARAM_OPTIONAL
+ Z_PARAM_ZVAL_EX(userdata, 0, 1)
+ ZEND_PARSE_PARAMETERS_END_EX(
+ BG(array_walk_fci) = orig_array_walk_fci;
+ BG(array_walk_fci_cache) = orig_array_walk_fci_cache;
+ return
+ );
+#endif
php_array_walk(array, userdata, 0 TSRMLS_CC);
BG(array_walk_fci) = orig_array_walk_fci;
@@ -1172,9 +1229,18 @@ static void php_search_array(INTERNAL_FUNCTION_PARAMETERS, int behavior) /* {{{
zend_string *str_idx;
zend_bool strict = 0; /* strict comparison or not */
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "za|b", &value, &array, &strict) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_ZVAL(value)
+ Z_PARAM_ARRAY(array)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_BOOL(strict)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
if (strict) {
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(array), num_idx, str_idx, entry) {
@@ -1928,9 +1994,15 @@ static void _phpi_pop(INTERNAL_FUNCTION_PARAMETERS, int off_the_end)
zend_string *key = NULL;
ulong index;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/", &stack) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_ARRAY_EX(stack, 0, 1)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
if (zend_hash_num_elements(Z_ARRVAL_P(stack)) == 0) {
return;
@@ -2155,9 +2227,19 @@ PHP_FUNCTION(array_slice)
zend_string *string_key;
ulong num_key;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "al|zb", &input, &offset, &z_length, &preserve_keys) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_ARRAY(input)
+ Z_PARAM_LONG(offset)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_ZVAL(z_length)
+ Z_PARAM_BOOL(preserve_keys)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
/* Get number of entries in the input hash */
num_in = zend_hash_num_elements(Z_ARRVAL_P(input));
@@ -2393,9 +2475,15 @@ static void php_array_merge_or_replace_wrapper(INTERNAL_FUNCTION_PARAMETERS, int
zval *args = NULL;
int argc, i, init_size = 0;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "+", &args, &argc) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_VARIADIC('+', args, argc)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
for (i = 0; i < argc; i++) {
zval *arg = args + i;
@@ -4322,9 +4410,16 @@ PHP_FUNCTION(array_map)
int i, k, maxlen = 0;
int *array_len;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "f!+", &fci, &fci_cache, &arrays, &n_arrays) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_FUNC_EX(fci, fci_cache, 1, 0)
+ Z_PARAM_VARIADIC('+', arrays, n_arrays)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
RETVAL_NULL();
@@ -4446,9 +4541,16 @@ PHP_FUNCTION(array_key_exists)
zval *key; /* key to check for */
HashTable *array; /* array to check in */
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zH", &key, &array) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_ZVAL(key)
+ Z_PARAM_ARRAY_OR_OBJECT_HT(array)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
switch (Z_TYPE_P(key)) {
case IS_STRING:
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index 0242f8a..7e87786 100644
--- a/ext/standard/basic_functions.c
+++ b/ext/standard/basic_functions.c
@@ -4714,9 +4714,16 @@ PHP_FUNCTION(call_user_func)
zend_fcall_info fci;
zend_fcall_info_cache fci_cache;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "f*", &fci, &fci_cache, &fci.params, &fci.param_count) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_FUNC(fci, fci_cache)
+ Z_PARAM_VARIADIC('*', fci.params, fci.param_count)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
fci.retval = &retval;
@@ -4734,9 +4741,16 @@ PHP_FUNCTION(call_user_func_array)
zend_fcall_info fci;
zend_fcall_info_cache fci_cache;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "fa/", &fci, &fci_cache, &params) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_FUNC(fci, fci_cache)
+ Z_PARAM_ARRAY_EX(params, 0, 1)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
zend_fcall_info_args(&fci, params TSRMLS_CC);
fci.retval = &retval;
diff --git a/ext/standard/file.c b/ext/standard/file.c
index 897eaa7..753ea4c 100644
--- a/ext/standard/file.c
+++ b/ext/standard/file.c
@@ -885,9 +885,15 @@ PHPAPI PHP_FUNCTION(fclose)
zval *arg1;
php_stream *stream;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &arg1) == FAILURE) {
RETURN_FALSE;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_RESOURCE(arg1)
+ ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
+#endif
PHP_STREAM_TO_ZVAL(stream, arg1);
@@ -2301,9 +2307,15 @@ PHP_FUNCTION(realpath)
int filename_len;
char resolved_path_buff[MAXPATHLEN];
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &filename, &filename_len) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_PATH(filename, filename_len)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
if (VCWD_REALPATH(filename, resolved_path_buff)) {
if (php_check_open_basedir(resolved_path_buff TSRMLS_CC)) {
diff --git a/ext/standard/math.c b/ext/standard/math.c
index 9e98fd3..9676df5 100644
--- a/ext/standard/math.c
+++ b/ext/standard/math.c
@@ -382,9 +382,15 @@ PHP_FUNCTION(sin)
{
double num;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &num) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_DOUBLE(num)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
RETURN_DOUBLE(sin(num));
}
/* }}} */
@@ -395,9 +401,15 @@ PHP_FUNCTION(cos)
{
double num;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &num) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_DOUBLE(num)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
RETURN_DOUBLE(cos(num));
}
/* }}} */
@@ -408,9 +420,15 @@ PHP_FUNCTION(tan)
{
double num;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &num) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_DOUBLE(num)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
RETURN_DOUBLE(tan(num));
}
/* }}} */
@@ -421,9 +439,15 @@ PHP_FUNCTION(asin)
{
double num;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &num) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_DOUBLE(num)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
RETURN_DOUBLE(asin(num));
}
/* }}} */
@@ -434,9 +458,15 @@ PHP_FUNCTION(acos)
{
double num;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &num) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_DOUBLE(num)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
RETURN_DOUBLE(acos(num));
}
/* }}} */
@@ -447,9 +477,15 @@ PHP_FUNCTION(atan)
{
double num;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &num) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_DOUBLE(num)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
RETURN_DOUBLE(atan(num));
}
/* }}} */
@@ -460,9 +496,16 @@ PHP_FUNCTION(atan2)
{
double num1, num2;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &num1, &num2) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_DOUBLE(num1)
+ Z_PARAM_DOUBLE(num2)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
RETURN_DOUBLE(atan2(num1, num2));
}
/* }}} */
@@ -473,9 +516,15 @@ PHP_FUNCTION(sinh)
{
double num;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &num) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_DOUBLE(num)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
RETURN_DOUBLE(sinh(num));
}
/* }}} */
@@ -486,9 +535,15 @@ PHP_FUNCTION(cosh)
{
double num;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &num) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_DOUBLE(num)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
RETURN_DOUBLE(cosh(num));
}
/* }}} */
@@ -499,9 +554,15 @@ PHP_FUNCTION(tanh)
{
double num;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &num) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_DOUBLE(num)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
RETURN_DOUBLE(tanh(num));
}
/* }}} */
@@ -512,9 +573,15 @@ PHP_FUNCTION(asinh)
{
double num;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &num) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_DOUBLE(num)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
RETURN_DOUBLE(php_asinh(num));
}
/* }}} */
@@ -525,9 +592,15 @@ PHP_FUNCTION(acosh)
{
double num;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &num) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_DOUBLE(num)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
RETURN_DOUBLE(php_acosh(num));
}
/* }}} */
@@ -538,9 +611,15 @@ PHP_FUNCTION(atanh)
{
double num;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &num) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_DOUBLE(num)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
RETURN_DOUBLE(php_atanh(num));
}
/* }}} */
@@ -559,9 +638,15 @@ PHP_FUNCTION(is_finite)
{
double dval;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &dval) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_DOUBLE(dval)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
RETURN_BOOL(zend_finite(dval));
}
/* }}} */
@@ -572,9 +657,15 @@ PHP_FUNCTION(is_infinite)
{
double dval;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &dval) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_DOUBLE(dval)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
RETURN_BOOL(zend_isinf(dval));
}
/* }}} */
@@ -585,9 +676,15 @@ PHP_FUNCTION(is_nan)
{
double dval;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &dval) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_DOUBLE(dval)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
RETURN_BOOL(zend_isnan(dval));
}
/* }}} */
@@ -612,9 +709,15 @@ PHP_FUNCTION(exp)
{
double num;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &num) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_DOUBLE(num)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
RETURN_DOUBLE(exp(num));
}
@@ -630,9 +733,16 @@ PHP_FUNCTION(expm1)
{
double num;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &num) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_DOUBLE(num)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
+
RETURN_DOUBLE(php_expm1(num));
}
/* }}} */
@@ -647,9 +757,16 @@ PHP_FUNCTION(log1p)
{
double num;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &num) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_DOUBLE(num)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
+
RETURN_DOUBLE(php_log1p(num));
}
/* }}} */
@@ -660,9 +777,18 @@ PHP_FUNCTION(log)
{
double num, base = 0;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d|d", &num, &base) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_DOUBLE(num)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_DOUBLE(base)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
+
if (ZEND_NUM_ARGS() == 1) {
RETURN_DOUBLE(log(num));
}
@@ -684,9 +810,16 @@ PHP_FUNCTION(log10)
{
double num;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &num) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_DOUBLE(num)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
+
RETURN_DOUBLE(log10(num));
}
/* }}} */
@@ -697,9 +830,16 @@ PHP_FUNCTION(sqrt)
{
double num;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &num) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_DOUBLE(num)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
+
RETURN_DOUBLE(sqrt(num));
}
/* }}} */
@@ -710,9 +850,17 @@ PHP_FUNCTION(hypot)
{
double num1, num2;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &num1, &num2) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_DOUBLE(num1)
+ Z_PARAM_DOUBLE(num2)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
+
#if HAVE_HYPOT
RETURN_DOUBLE(hypot(num1, num2));
#elif defined(_MSC_VER)
@@ -729,9 +877,15 @@ PHP_FUNCTION(deg2rad)
{
double deg;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &deg) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_DOUBLE(deg)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
RETURN_DOUBLE((deg / 180.0) * M_PI);
}
/* }}} */
@@ -742,9 +896,16 @@ PHP_FUNCTION(rad2deg)
{
double rad;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &rad) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_DOUBLE(rad)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
+
RETURN_DOUBLE((rad / M_PI) * 180);
}
/* }}} */
@@ -1182,9 +1343,19 @@ PHP_FUNCTION(number_format)
char thousand_sep_chr = ',', dec_point_chr = '.';
int thousand_sep_len = 0, dec_point_len = 0;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d|ls!s!", &num, &dec, &dec_point, &dec_point_len, &thousand_sep, &thousand_sep_len) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_DOUBLE(num)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_LONG(dec)
+ Z_PARAM_STRING_EX(dec_point, dec_point_len, 1, 0)
+ Z_PARAM_STRING_EX(thousand_sep, thousand_sep_len, 1, 0)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
switch(ZEND_NUM_ARGS()) {
case 1:
@@ -1220,9 +1391,17 @@ PHP_FUNCTION(fmod)
{
double num1, num2;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &num1, &num2) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_DOUBLE(num1)
+ Z_PARAM_DOUBLE(num2)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
+
RETURN_DOUBLE(fmod(num1, num2));
}
/* }}} */
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 3250241..adbc015 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -834,9 +834,17 @@ static void php_do_trim(INTERNAL_FUNCTION_PARAMETERS, int mode)
char *what = NULL;
int str_len, what_len = 0;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &str, &str_len, &what, &what_len) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_STRING(str, str_len)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_STRING(what, what_len)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
php_trim(str, str_len, what, what_len, return_value, mode TSRMLS_CC);
}
@@ -1192,9 +1200,17 @@ PHP_FUNCTION(implode)
{
zval *arg1 = NULL, *arg2 = NULL, *delim, *arr, tmp;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|z", &arg1, &arg2) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_ZVAL(arg1)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_ZVAL(arg2)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
if (arg2 == NULL) {
if (Z_TYPE_P(arg1) != IS_ARRAY) {
@@ -1365,9 +1381,15 @@ PHP_FUNCTION(strtolower)
int arglen;
zend_string *result;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &arglen) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_STRING(str, arglen)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
result = STR_INIT(str, arglen, 0);
php_strtolower(result->val, result->len);
@@ -1777,9 +1799,18 @@ PHP_FUNCTION(strpos)
long offset = 0;
int haystack_len;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz|l", &haystack, &haystack_len, &needle, &offset) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_STRING(haystack, haystack_len)
+ Z_PARAM_ZVAL(needle)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_LONG(offset)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
if (offset < 0 || offset > haystack_len) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset not contained in string");
@@ -2192,9 +2223,18 @@ PHP_FUNCTION(substr)
int str_len;
int argc = ZEND_NUM_ARGS();
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl|l", &str, &str_len, &f, &l) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_STRING(str, str_len)
+ Z_PARAM_LONG(f)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_LONG(l)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
if (argc > 2) {
if ((l < 0 && -l > str_len)) {
@@ -2584,9 +2624,15 @@ PHP_FUNCTION(ord)
char *str;
int str_len;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_STRING(str, str_len)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
RETURN_LONG((unsigned char) str[0]);
}
@@ -3109,9 +3155,15 @@ PHP_FUNCTION(addslashes)
char *str;
int str_len;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_STRING(str, str_len)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
if (str_len == 0) {
RETURN_EMPTY_STRING();
@@ -3722,9 +3774,19 @@ static void php_str_replace_common(INTERNAL_FUNCTION_PARAMETERS, int case_sensit
int count = 0;
int argc = ZEND_NUM_ARGS();
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zzz|z/", &search, &replace, &subject, &zcount) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_ZVAL(search)
+ Z_PARAM_ZVAL(replace)
+ Z_PARAM_ZVAL(subject)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_ZVAL_EX(zcount, 0, 1)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
/* Make sure we're dealing with strings and do the replacement. */
if (Z_TYPE_P(search) != IS_ARRAY) {
diff --git a/ext/standard/type.c b/ext/standard/type.c
index a42dd0b..8f8ffb3 100644
--- a/ext/standard/type.c
+++ b/ext/standard/type.c
@@ -137,27 +137,22 @@ PHP_FUNCTION(settype)
PHP_FUNCTION(intval)
{
zval *num;
- long arg_base;
- int base;
+ long base = 10;
- switch (ZEND_NUM_ARGS()) {
- case 1:
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &num) == FAILURE) {
- return;
- }
- base = 10;
- break;
-
- case 2:
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zl", &num, &arg_base) == FAILURE) {
- return;
- }
- base = arg_base;
- break;
-
- default:
- WRONG_PARAM_COUNT;
+ if (ZEND_NUM_ARGS() != 1 && ZEND_NUM_ARGS() != 2) {
+ WRONG_PARAM_COUNT;
+ }
+#ifndef FAST_ZPP
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|l", &num, &base) == FAILURE) {
+ return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_ZVAL(num)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_LONG(base)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
RETVAL_ZVAL(num, 1, 0);
convert_to_long_base(return_value, base);
@@ -206,15 +201,21 @@ PHP_FUNCTION(strval)
}
/* }}} */
-static void php_is_type(INTERNAL_FUNCTION_PARAMETERS, int type)
+static inline void php_is_type(INTERNAL_FUNCTION_PARAMETERS, int type)
{
zval *arg;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &arg) == FAILURE) {
RETURN_FALSE;
}
-
ZVAL_DEREF(arg);
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_ZVAL_DEREF(arg)
+ ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
+#endif
+
if (Z_TYPE_P(arg) == type) {
if (type == IS_OBJECT) {
zend_class_entry *ce;
@@ -226,8 +227,7 @@ static void php_is_type(INTERNAL_FUNCTION_PARAMETERS, int type)
if (!strcmp(ce->name->val, INCOMPLETE_CLASS)) {
RETURN_FALSE;
}
- }
- if (type == IS_RESOURCE) {
+ } else if (type == IS_RESOURCE) {
const char *type_name = zend_rsrc_list_get_rsrc_type(Z_RES_P(arg) TSRMLS_CC);
if (!type_name) {
RETURN_FALSE;
@@ -348,9 +348,15 @@ PHP_FUNCTION(is_scalar)
{
zval *arg;
+#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &arg) == FAILURE) {
return;
}
+#else
+ ZEND_PARSE_PARAMETERS_START()
+ Z_PARAM_ZVAL(arg)
+ ZEND_PARSE_PARAMETERS_END();
+#endif
switch (Z_TYPE_P(arg)) {
case IS_FALSE:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment