private function visitNode($path, $vistor, $exact_match = false, $all_req_paths = false)
{
assert(count($path));
$pos =& $this->arr;
$next =& $pos;
foreach ($path as $i) {
if (is_null($next)) {
return !$all_req_paths;
}
if (!array_key_exists($i, $next)) {
if ($exact_match) {
return false;
}
if ($i == self::$end) {
return false;
}
//不要求完全匹配, 尝试匹配通配符
if (!array_key_exists(self::$wildcard, $next)) {
return false;
}
$pos =& $next[self::$wildcard];
} else {
$pos =& $next[$i];
}
if (!$vistor($i, $pos)) {
return false;
}
if (array_key_exists('next', $pos)) {
$next =& $pos['next'];
} else {
$nul = null;
$next =& $nul;
//$next = null 会导致引用的对象被赋值,而不是next被赋值
}
}
return true;
}