當前位置: 首頁>>代碼示例>>PHP>>正文


PHP tree::addChildren方法代碼示例

本文整理匯總了PHP中tree::addChildren方法的典型用法代碼示例。如果您正苦於以下問題:PHP tree::addChildren方法的具體用法?PHP tree::addChildren怎麽用?PHP tree::addChildren使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tree的用法示例。


在下文中一共展示了tree::addChildren方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: get_children_from

 private function get_children_from($tokens, $start, $end, $parent_node, &$last_node = null, $foroutput = false)
 {
     $branch_points = array('T_IF', 'T_FOR', 'T_FOREACH', 'T_WHILE', 'T_SWITCH', 'T_DO', 'T_BOOLEAN_OR', 'T_BOOLEAN_AND');
     $tp = $start;
     $tree = new tree();
     $current_node_id = $parent_node;
     $this->break_nodes = $this->return_nodes = $this->continue_nodes = array();
     while ($tp < $end) {
         $token_name = $this->token_name($tokens[$tp]);
         if ($token_name == 'T_FUNCTION') {
             if ($blockstart = $this->search_token($tokens, $tp, '{', array(';'))) {
                 if ($tp = $this->get_pair($tokens, $blockstart)) {
                     $tp++;
                     continue;
                 }
             }
         } elseif ($token_name == 'T_BREAK') {
             $level = $this->get_break_level($tokens, $tp);
             $break_target = $this->break_levels[count($this->break_levels) - $level];
             $this->jumps[$break_target][] = $current_node_id;
             $this->break_nodes[] = $current_node_id;
         } elseif ($token_name == 'T_CONTINUE') {
             $this->continue_nodes[] = $current_node_id;
         } elseif ($token_name == 'T_RETURN' || $token_name == 'T_THROW') {
             $this->return_nodes[] = $current_node_id;
         } elseif (in_array($token_name, $branch_points)) {
             if ($token_name == 'T_SWITCH') {
                 /*
                 $trace = debug_backtrace(false);
                 foreach ($trace as $t) var_dump($t['function']);
                 */
                 $node_children = $this->get_children_from_switch($tokens, $tp, $current_node_id, $current_node_id, $foroutput);
                 $tree->addChildren($node_children);
             } elseif (in_array($token_name, array('T_IF'))) {
                 $temp = $current_node_id;
                 $node_children = $this->get_children_from_if($tokens, $tp, $current_node_id, $current_node_id, $foroutput);
                 $tree->addChildren($node_children);
             } elseif ($token_name == 'T_DO') {
                 if ($node_children = $this->get_children_from_do($tokens, $tp, $current_node_id, $current_node_id, $foroutput)) {
                     $tree->addChildren($node_children);
                 }
             } elseif (in_array($token_name, array('T_BOOLEAN_AND', 'T_BOOLEAN_OR'))) {
                 $boolright = $this->get_right_of_boolean($tokens, $tp);
                 if ($node_children = $this->get_children_from_boolean($tokens, $tp, $boolright, $current_node_id, $current_node_id, $current_node_id, $foroutput)) {
                     $tree->addChildren($node_children);
                 }
             } else {
                 if ($node_children = $this->get_children_from_loop($tokens, $tp, $current_node_id, $current_node_id, $foroutput)) {
                     $tree->addChildren($node_children);
                 }
             }
         }
         $tp++;
     }
     $last_node = $current_node_id;
     return $tree;
 }
開發者ID:nicolask,項目名稱:Enhance-PHP,代碼行數:57,代碼來源:codespy.php


注:本文中的tree::addChildren方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。