summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJulien Voisin2021-04-26 22:25:50 +0200
committerGitHub2021-04-26 20:25:50 +0000
commit7fc7743977905807b4c2fdcde183a219ace25ba9 (patch)
tree086f027784544b2d865e7f60a00fa61498405f90 /src
parent0aaa9e51bbf102c37a9f545309c07650b6ee527b (diff)
Make it easier to figure functions parameters' names
Diffstat (limited to 'src')
-rw-r--r--src/sp_var_value.c9
-rw-r--r--src/tests/broken_configuration/broken_conf_config_invalid_param.phpt6
2 files changed, 13 insertions, 2 deletions
diff --git a/src/sp_var_value.c b/src/sp_var_value.c
index b9ac357..e351446 100644
--- a/src/sp_var_value.c
+++ b/src/sp_var_value.c
@@ -1,6 +1,7 @@
1#include "php_snuffleupagus.h" 1#include "php_snuffleupagus.h"
2 2
3static zval *get_param_var(zend_execute_data *ed, const char *var_name) { 3static zval *get_param_var(zend_execute_data *ed, const char *var_name,
4 bool print) {
4 unsigned int nb_param = ed->func->common.num_args; 5 unsigned int nb_param = ed->func->common.num_args;
5 6
6 for (unsigned int i = 0; i < nb_param; i++) { 7 for (unsigned int i = 0; i < nb_param; i++) {
@@ -13,6 +14,9 @@ static zval *get_param_var(zend_execute_data *ed, const char *var_name) {
13 if (0 == strcmp(arg_name, var_name)) { 14 if (0 == strcmp(arg_name, var_name)) {
14 return ZEND_CALL_VAR_NUM(ed, i); 15 return ZEND_CALL_VAR_NUM(ed, i);
15 } 16 }
17 if (print == true) {
18 sp_log_warn("config", " - %d parameter's name: '%s'", i, arg_name);
19 }
16 } 20 }
17 return NULL; 21 return NULL;
18} 22}
@@ -68,7 +72,7 @@ static zval *get_var_value(zend_execute_data *ed, const char *var_name,
68 } 72 }
69 73
70 if (is_param) { 74 if (is_param) {
71 zval *zvalue = get_param_var(ed, var_name); 75 zval *zvalue = get_param_var(ed, var_name, false);
72 if (!zvalue) { 76 if (!zvalue) {
73 char *complete_function_path = get_complete_function_path(ed); 77 char *complete_function_path = get_complete_function_path(ed);
74 sp_log_warn("config", 78 sp_log_warn("config",
@@ -76,6 +80,7 @@ static zval *get_var_value(zend_execute_data *ed, const char *var_name,
76 "'%s' of the function '%s', but the parameter does " 80 "'%s' of the function '%s', but the parameter does "
77 "not exists.", 81 "not exists.",
78 var_name, complete_function_path); 82 var_name, complete_function_path);
83 get_param_var(ed, var_name, true);
79 efree(complete_function_path); 84 efree(complete_function_path);
80 return NULL; 85 return NULL;
81 } 86 }
diff --git a/src/tests/broken_configuration/broken_conf_config_invalid_param.phpt b/src/tests/broken_configuration/broken_conf_config_invalid_param.phpt
index ac85dea..45ccf24 100644
--- a/src/tests/broken_configuration/broken_conf_config_invalid_param.phpt
+++ b/src/tests/broken_configuration/broken_conf_config_invalid_param.phpt
@@ -13,4 +13,10 @@ function foo($blah, $x = null, $y = null) {
13foo("qwe"); 13foo("qwe");
14--EXPECTF-- 14--EXPECTF--
15Warning: [snuffleupagus][0.0.0.0][config][log] It seems that you are filtering on a parameter 'qwe' of the function 'foo', but the parameter does not exists. in %s/tests/broken_configuration/broken_conf_config_invalid_param.php on line %d 15Warning: [snuffleupagus][0.0.0.0][config][log] It seems that you are filtering on a parameter 'qwe' of the function 'foo', but the parameter does not exists. in %s/tests/broken_configuration/broken_conf_config_invalid_param.php on line %d
16
17Warning: [snuffleupagus][0.0.0.0][config][log] - 0 parameter's name: 'blah' in %s/tests/broken_configuration/broken_conf_config_invalid_param.php on line %d
18
19Warning: [snuffleupagus][0.0.0.0][config][log] - 1 parameter's name: 'x' in %s/tests/broken_configuration/broken_conf_config_invalid_param.php on line %d
20
21Warning: [snuffleupagus][0.0.0.0][config][log] - 2 parameter's name: 'y' in %s/tests/broken_configuration/broken_conf_config_invalid_param.php on line %d
16ok 22ok