summaryrefslogtreecommitdiff
path: root/src/sp_sloppy.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/sp_sloppy.c')
-rw-r--r--src/sp_sloppy.c21
1 files changed, 11 insertions, 10 deletions
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,
43 zval func_name; 43 zval func_name;
44 zval params[3]; 44 zval params[3];
45 zval *value, *array = NULL; 45 zval *value, *array = NULL;
46 zend_bool strict = 1; 46 zend_bool strict = 0;
47 uint32_t nb_params = ZEND_NUM_ARGS();
47 48
48 memset(&params, 0, sizeof(params)); 49 zend_parse_parameters(nb_params, spec, &value, &array, &strict);
49
50 zend_parse_parameters(ZEND_NUM_ARGS(), spec, &value, &array, &strict);
51 50
52 ZVAL_COPY(&params[0], value); 51 ZVAL_COPY(&params[0], value);
52 ZVAL_BOOL(&params[2], 1); // we want to always have strict mode enabled
53
53 if (array) { 54 if (array) {
54 ZVAL_COPY(&params[1], array); 55 ZVAL_COPY(&params[1], array);
55 ZVAL_BOOL(&params[2], 1); 56 // Lie about the number of parameters,
57 // since we are always passing strict = 1
58 nb_params = 3;
56 } else { 59 } else {
57 // if there is no array as parameter, don't set strict mode. 60 ZVAL_NULL(&params[1]);
58 // check php's implementation for details.
59 ZVAL_BOOL(&params[2], 0);
60 } 61 }
61 62
62 ZVAL_STRING(&func_name, name); 63 ZVAL_STRING(&func_name, name);
@@ -67,8 +68,8 @@ static void array_handler(INTERNAL_FUNCTION_PARAMETERS, const char* name,
67 zend_hash_str_find_ptr(CG(function_table), name, size); 68 zend_hash_str_find_ptr(CG(function_table), name, size);
68 func->handler = handler; 69 func->handler = handler;
69 70
70 call_user_function(CG(function_table), NULL, &func_name, return_value, 3, 71 call_user_function(CG(function_table), NULL, &func_name, return_value,
71 params); 72 nb_params, params);
72 73
73 func->handler = orig_handler; 74 func->handler = orig_handler;
74} 75}