summaryrefslogtreecommitdiff
path: root/it.class
diff options
context:
space:
mode:
authorChristian Schneider2017-02-07 16:14:44 +0100
committerChristian Schneider2017-02-07 16:14:44 +0100
commitf82923f96c15e957f4265f21597cd2cdc994482f (patch)
tree58a134c583bb7fbc235e748acb1fd2824ece44b2 /it.class
parentfca09880bc39d2814492cee6197a76f12e715d91 (diff)
downloaditools-f82923f96c15e957f4265f21597cd2cdc994482f.tar.gz
itools-f82923f96c15e957f4265f21597cd2cdc994482f.tar.bz2
itools-f82923f96c15e957f4265f21597cd2cdc994482f.zip
Replace create_function which will be deprecated in PHP 7.2
Diffstat (limited to 'it.class')
-rw-r--r--it.class6
1 files changed, 2 insertions, 4 deletions
diff --git a/it.class b/it.class
index c0d26d7..34f0bf6 100644
--- a/it.class
+++ b/it.class
@@ -954,13 +954,11 @@ static function date($format = "", $stamp = null)
*/
static function map($code, $array, $p = null)
{
- static $cache = array();
-
if (is_string($code) && it::match('^[\w:]+$', $code) && is_callable($code))
$code .= '($v)';
- if (!is_callable($func = $code) && !($func = $cache[$code]))
- $func = $cache[$code] = create_function('$k,$v', "return $code;");
+ if (!is_callable($func = $code) && !function_exists($func = "_it_map_" . md5($code)))
+ eval("function $func(\$k, \$v) { return $code; }"); # Anonymous functions/closures are slower than this (PHP 7.1)
$result = is_array($array) ? $array : iterator_to_array($array);
foreach (isset($p['keys']) ? it::filter_keys($array, $p['keys']) : $array as $k => $v)