From c7efb186e47135acac829f5831615e3f6bd03b5d Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Thu, 8 Sep 2011 16:51:21 +0000 Subject: pass line in last arg to some functions --- it_pipe.class | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'it_pipe.class') 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; -- cgit v1.2.3