Ejemplo n.º 1
0
 public function pass_6()
 {
     $tokens = token_get_all($this->source[$this->last_pass]);
     $token_count = count($tokens);
     $tp = 0;
     $tokens_to_patch = array('T_FUNCTION');
     $last_class = '';
     while ($tp < $token_count) {
         $token_name = $this->token_name($tokens[$tp]);
         if ($token_name == 'T_NAMESPACE') {
             $current_namespace = $this->token_content($tokens[$this->get_next_non_comment($tokens, $tp + 1)]);
         }
         if ($token_name == 'T_CLASS') {
             $last_class = $this->token_content($tokens[$this->get_next_non_comment($tokens, $tp + 1)]);
             if (isset($current_namespace)) {
                 $last_class = $current_namespace . "\\" . $last_class;
             }
         }
         if (in_array($token_name, $tokens_to_patch)) {
             if ($blockstart = $this->search_token($tokens, $tp, '{', array(';'))) {
                 $function_name_tp = $this->get_next_non_comment($tokens, $tp + 1);
                 if (!is_array($tokens[$function_name_tp])) {
                     $function_name_tp = $this->get_next_non_comment($tokens, $function_name_tp + 1);
                 }
                 $function_name = $tokens[$function_name_tp][1];
                 if (!Analyzer::shouldpatch($function_name, $last_class)) {
                     $tp++;
                     continue;
                 }
                 //Analyzer::$instancenumberfor[$function_name] = 0;
                 $this->add_tokens_to_be_inserted_after($blockstart + 1, "", 0);
                 $blockend = $this->get_pair($tokens, $blockstart);
                 $children = $this->get_children_from($tokens, $blockstart, $blockend, 0, $temp, true);
                 //Analyzer::$possiblebranches[$function_name] = $children->getPaths();
             }
         }
         $tp++;
     }
     $this->source[$this->current_pass] = $this->change_stuff();
 }