This is not a real free interface. I have an object that creates a method stack. Which is executed by one function call. But now I can add another virtual method that takes this method stack.
Use case: I wrap my superglobal objects in objects. This allows me to "force" filter the input. $ _GET and co provide simple disinfection methods. And my new version now allows you to bind atomic filters. As an example:
$_GET->ascii->nocontrol->text["field"]
This is a method call. It uses angle brackets. But this is just a nice trick that makes it easy to rewrite any situation $_GET["field"]. Anyway.
Now there are also forms with enumerable fields, as in field [0], field [1], field [2]. This is why I added a filter method of virtual → arrays. It grabs the assembled method stack and repeats the remaining filters, for example. the value of the $ _POST array. For example $_POST->array->int["list"].
A slightly reduced implementation:
function exec_chain ($data) {
...
while ($filtername = array_pop($this->__filter)) {
...
$data = $this->{"_$filtername"} ($data);
...
}
function _array($data) {
list($multiplex, $this->__filter) = array($this->__filter, array());
$data = (array) $data;
foreach (array_keys($data) as $i) {
$this->__filter = $multiplex;
$data[$i] = $this->exec_chain($data[$i]);
}
return $data;
}
The method stack is collected in a list $this->__filter. Above exec_chain () simply iterates over it, each time deleting the name of the first method. The _array virtual handler is usually the first method. And he just steals this method stack and returns the remainder on each element of the array. Not quite the same as in the above code example, but it just repeats the original method stack.
. . ->xor. (YAGNI?), , , . $_REQUEST->array->xor->email->url["fields"]. , . ($ this → __ filter) swapping . , → xor / → .
, $this → __ array_pop() . . , - ?