summaryrefslogtreecommitdiff
path: root/it.class
diff options
context:
space:
mode:
authorNathan Gass2020-11-27 12:31:32 +0100
committerNathan Gass2020-11-27 12:42:38 +0100
commit1b03f72e7edc609b326927dfebc9f3f0bd6228a1 (patch)
treed717c958199d417ccb4940057fd693d75d5e4bb8 /it.class
parent39dbd947f59394fab9238f7faaab74390aa0b783 (diff)
downloaditools-1b03f72e7edc609b326927dfebc9f3f0bd6228a1.tar.gz
itools-1b03f72e7edc609b326927dfebc9f3f0bd6228a1.tar.bz2
itools-1b03f72e7edc609b326927dfebc9f3f0bd6228a1.zip
pass array values instead of keys to functions with only one argument in it::map and it::filter
Diffstat (limited to 'it.class')
-rw-r--r--it.class3
1 files changed, 3 insertions, 0 deletions
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)';