示例#1
0
 public function removeCodeFrom($lines)
 {
     $keys = array_keys($lines);
     $first = array_shift($keys);
     $last = array_pop($keys);
     for ($i = $first; $i <= $last; $i++) {
         $line = $lines[$i];
         if (preg_match('%function\\s*\\([^)]*\\)\\s*{%', $line, $match, PREG_OFFSET_CAPTURE)) {
             $declaration = new DojoFunctionDeclare($this, $i, $match[0][1]);
             list($i, ) = $declaration->build();
             $lines = $declaration->removeCodeFrom($lines);
         } elseif (preg_match('%^.*(with|switch)\\s*\\([^(]*\\)\\s*{%', $line, $match)) {
             $with_lines = Text::chop($lines, $i, strlen($match[0]) - 1, null, null, true);
             list($end_line, $end_pos) = Text::findTermination($with_lines, '}', '{}()[]');
             for ($j = $i; $j <= $end_line; $j++) {
                 $line = $lines[$j];
                 if ($j == $i) {
                     $lines[$j] = Text::blankOutAt($line, strlen($match[0]) - 1);
                 } elseif ($j == $end_line) {
                     $lines[$j] = Text::blankOutAt($line, 0, $end_pos);
                 } else {
                     $lines[$j] = Text::blankOut($line, $line);
                 }
             }
         }
     }
     return $lines;
 }