From 1b03f72e7edc609b326927dfebc9f3f0bd6228a1 Mon Sep 17 00:00:00 2001 From: Nathan Gass Date: Fri, 27 Nov 2020 12:31:32 +0100 Subject: pass array values instead of keys to functions with only one argument in it::map and it::filter --- it.class | 3 +++ 1 file changed, 3 insertions(+) (limited to 'it.class') diff --git a/it.class b/it.class index 0b48229..200829c 100644 --- a/it.class +++ b/it.class @@ -1034,6 +1034,9 @@ static function date($format = "", $stamp = null) # Internal: Convert expression or funcname or function literal to callable static function createfunc($code) { + if ($code instanceof Closure && (new ReflectionFunction($code))->getNumberOfRequiredParameters() == 1) + $code = function($dummy, $v) use ($code) {return $code($v);}; + if (is_string($code) && it::match('^[\w:]+$', $code) && is_callable($code)) $code .= '($v)'; -- cgit v1.2.3