本文整理汇总了PHP中tree::addChildToAllDecendants方法的典型用法代码示例。如果您正苦于以下问题:PHP tree::addChildToAllDecendants方法的具体用法?PHP tree::addChildToAllDecendants怎么用?PHP tree::addChildToAllDecendants使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tree
的用法示例。
在下文中一共展示了tree::addChildToAllDecendants方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_children_from_if
private function get_children_from_if($tokens, &$start, $parent_node, &$last_node, $foroutput = false)
{
$tree = new tree();
$current_node_id = $parent_node;
$tp = $start;
$tree = new tree();
while (1) {
$token_name = $this->token_name($tokens[$this->get_next_non_comment($tokens, $tp)]);
if (in_array($token_name, array('T_IF', 'T_ELSE', 'T_ELSEIF'))) {
if ($token_name == 'T_ELSE') {
$elsefound = true;
$start = $this->search_token($tokens, $tp, '{', array(';'));
} else {
if ($token_name == 'T_IF') {
if (isset($found_if)) {
break;
}
$found_if = true;
}
$boolleft = $start = $this->search_token($tokens, $tp, '(', array(';'));
$boolright = $start = $this->get_pair($tokens, $start);
$temp_current_node = $current_node_id;
$parent_node_old = $parent_node;
if ($node_children = $this->get_children_from_boolean($tokens, $boolleft, $boolright, $current_node_id, $current_node_id, $current_node_id, $foroutput)) {
if ($temp_current_node != $current_node_id) {
$parent_node = $current_node_id;
$tree->addChildToAllDecendants($temp_current_node + 1, $current_node_id + 1);
}
$tree->addChildren($node_children);
}
$start = $this->search_token($tokens, $start, '{', array(';'));
}
$end = $this->get_pair($tokens, $start);
$new_node = $current_node_id = $current_node_id + 1;
if (!in_array($parent_node, array_merge($this->break_nodes, $this->continue_nodes, $this->return_nodes))) {
$tree->addChild($parent_node, $new_node);
}
$this->add_tokens_to_be_inserted_after($start + 1, "/*{$new_node}*/" . "\\codespy\\Analyzer::\$executionbranches[__FILE__][__CLASS__][__FUNCTION__][\\codespy\\Analyzer::\$instancenumberfor[__FILE__][__CLASS__][__FUNCTION__]][{$new_node}] = 1;", $foroutput ? $new_node : false);
if ($children = $this->get_children_from($tokens, $start, $end, $current_node_id, $current_node_id, $foroutput)) {
$tree->addChildren($children);
}
$tp = $end + 1;
} else {
break;
}
}
$new_node = $current_node_id + 1;
if (!isset($elsefound)) {
if (!in_array($parent_node_old, array_merge($this->break_nodes, $this->continue_nodes, $this->return_nodes))) {
$tree->addChild($parent_node_old, $new_node);
}
}
echo "Pn = {$parent_node_old}";
$tree->addChildToAllLeavesOfParent($parent_node, $new_node, array_merge($this->break_nodes, $this->continue_nodes, $this->return_nodes));
$this->add_tokens_to_be_inserted_after($end + 1, "/*{$new_node}*/" . "\\codespy\\Analyzer::\$executionbranches[__FILE__][__CLASS__][__FUNCTION__][\\codespy\\Analyzer::\$instancenumberfor[__FILE__][__CLASS__][__FUNCTION__]][{$new_node}] = 1;", $foroutput ? $new_node : false);
$last_node = $new_node;
$start = $end;
array_pop($this->break_levels);
return $tree;
}