public static function v($cx, $in, $base, $path, $args = null)
{
$count = count($cx['scopes']);
while ($base) {
$v = $base;
foreach ($path as $name) {
if (is_array($v) && isset($v[$name])) {
$v = $v[$name];
continue;
}
if (is_object($v)) {
if ($cx['flags']['prop'] && !$v instanceof \Closure && isset($v->{$name})) {
$v = $v->{$name};
continue;
}
if ($cx['flags']['method'] && is_callable(array($v, $name))) {
$v = $v->{$name}();
continue;
}
}
if ($cx['flags']['mustlok']) {
unset($v);
break;
}
return null;
}
if (isset($v)) {
if ($v instanceof \Closure) {
if ($cx['flags']['mustlam'] || $cx['flags']['lambda']) {
if (!$cx['flags']['knohlp'] && ($args || $args === 0)) {
$A = $args ? $args[0] : array();
$A[] = array('hash' => $args[1], '_this' => $in);
} else {
$A = array($in);
}
$v = call_user_func_array($v, $A);
}
}
return $v;
}
$count--;
switch ($count) {
case -1:
$base = $cx['sp_vars']['root'];
break;
case -2:
return null;
default:
$base = $cx['scopes'][$count];
}
}
if ($args) {
static::err($cx, 'Can not find helper or lambda: "' . implode('.', $path) . '" !');
}
}