From a48297dfc1144931e18073a87ed83ea337e3d37a Mon Sep 17 00:00:00 2001 From: jvoisin Date: Sat, 23 Feb 2019 00:03:14 +0000 Subject: Add php8 to travis and fix php7.4 - Use clang-format on the code - Improve portability wrt. php8 - Fix php7.4 compatibility. See https://dustri.org/b/fixing-snuffleupagus-sloppy-comparison-on-array_keys-for-php74.html for a detailed writeup--- src/sp_sloppy.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src/sp_sloppy.c') diff --git a/src/sp_sloppy.c b/src/sp_sloppy.c index d510181..8c36822 100644 --- a/src/sp_sloppy.c +++ b/src/sp_sloppy.c @@ -43,20 +43,21 @@ static void array_handler(INTERNAL_FUNCTION_PARAMETERS, const char* name, zval func_name; zval params[3]; zval *value, *array = NULL; - zend_bool strict = 1; + zend_bool strict = 0; + uint32_t nb_params = ZEND_NUM_ARGS(); - memset(¶ms, 0, sizeof(params)); - - zend_parse_parameters(ZEND_NUM_ARGS(), spec, &value, &array, &strict); + zend_parse_parameters(nb_params, spec, &value, &array, &strict); ZVAL_COPY(¶ms[0], value); + ZVAL_BOOL(¶ms[2], 1); // we want to always have strict mode enabled + if (array) { ZVAL_COPY(¶ms[1], array); - ZVAL_BOOL(¶ms[2], 1); + // Lie about the number of parameters, + // since we are always passing strict = 1 + nb_params = 3; } else { - // if there is no array as parameter, don't set strict mode. - // check php's implementation for details. - ZVAL_BOOL(¶ms[2], 0); + ZVAL_NULL(¶ms[1]); } ZVAL_STRING(&func_name, name); @@ -67,8 +68,8 @@ static void array_handler(INTERNAL_FUNCTION_PARAMETERS, const char* name, zend_hash_str_find_ptr(CG(function_table), name, size); func->handler = handler; - call_user_function(CG(function_table), NULL, &func_name, return_value, 3, - params); + call_user_function(CG(function_table), NULL, &func_name, return_value, + nb_params, params); func->handler = orig_handler; } -- cgit v1.3