// filter_input_array() cannot be used with examples because changing predefined variables, eg "$_POST" has not effect on it public $method_to_exec = 'filter_var_array';
public $source_code = ' CHANGEABLE_VAR_predefined_var = $data; // array $data
inject_function_call
// note that filter_input_array() only uses the data passed to the script // subsequent changes, as in this example, would actually be ignored // filter_input_array() is emulated with filter_var_array() in this example
// see filter_var_array() for more examples including callbacks ';
function _get_options_list() { $constant_names = array_keys(get_defined_constants()); $var_names = [];
foreach ($constant_names as $constant_name) { if (preg_match('~^INPUT_~', $constant_name)) { $var_name = str_replace('INPUT', '$', $constant_name); $var_names[] = $var_name; } }
$options_list = ['predefined_var' => $var_names];
return $options_list; }
function pre_exec_function() { // creates the corresponding input type, eg "INPUT_POST", from the variable name, eg "$_POST", $predefined_var = $this->_filter->filter_var_name('predefined_var'); $type = str_replace('$', 'INPUT', $predefined_var);
if (! defined($type) or constant($type) !== $this->_filter->filter_arg_value('type')) { // the variable and type mismatch, resets the data $this->returned_params['data'] = []; }