summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUrban Müller2011-09-08 16:51:21 +0000
committerUrban Müller2011-09-08 16:51:21 +0000
commitc7efb186e47135acac829f5831615e3f6bd03b5d (patch)
tree31b17c7f9df6e2a8f921223e4fa6089314e2936c
parent086b8bd74b89931143340929cc349308411499a3 (diff)
downloaditools-c7efb186e47135acac829f5831615e3f6bd03b5d.tar.gz
itools-c7efb186e47135acac829f5831615e3f6bd03b5d.tar.bz2
itools-c7efb186e47135acac829f5831615e3f6bd03b5d.zip
pass line in last arg to some functions
-rw-r--r--it_pipe.class5
1 files changed, 3 insertions, 2 deletions
diff --git a/it_pipe.class b/it_pipe.class
index c7ef023..3dbf313 100644
--- a/it_pipe.class
+++ b/it_pipe.class
@@ -2,6 +2,7 @@
class it_pipe implements Iterator
{
+ static $lastargfunc = array('explode' => 1, 'preg_match' => 1, 'preg_split' => 1, 'it__match' => 1);
/**
* Creates a pipe object from input. Named arguments:
@@ -25,10 +26,10 @@ function __construct($p = array())
#
function __call($name, $params)
{
- array_unshift($params, "");
+ list($parampos) = self::$lastargfunc[$name] ? array(count($params)) : array(0, array_unshift($params, ""));
$func = ($t = it::match('(\w+)__(\w+)', $name)) ? array($t[0], $t[1]) : (method_exists($this, $name) ? array($this, $name) : $name);
- foreach($this->lines as $i => $params[0])
+ foreach($this->lines as $i => $params[$parampos])
$this->lines[$i] = call_user_func_array($func, $params);
return $this;