Ejemplo n.º 1
0
 private function clearIncludies(Tokens $tokens, array $includies)
 {
     foreach (array_reverse($includies) as $includy) {
         if ($includy['end']) {
             $tokens->removeLeadingWhitespace($includy['end']);
         }
         $braces = $includy['braces'];
         if ($braces) {
             $nextToken = $tokens->getNextNonWhitespace($includy['braces']['close']);
             if (!$nextToken->isArray() && ';' === $nextToken->content) {
                 $tokens->removeLeadingWhitespace($braces['open']);
                 $tokens->removeTrailingWhitespace($braces['open']);
                 $tokens->removeLeadingWhitespace($braces['close']);
                 $tokens->removeTrailingWhitespace($braces['close']);
                 $tokens[$braces['open']] = new Token(array(T_WHITESPACE, ' '));
                 $tokens[$braces['close']]->clear();
             }
         }
         $nextIndex = $includy['begin'] + 1;
         $nextToken = $tokens[$nextIndex];
         while ($nextToken->isEmpty()) {
             $nextToken = $tokens[++$nextIndex];
         }
         if ($nextToken->isWhitespace()) {
             $nextToken->content = ' ';
         } elseif ($braces) {
             $tokens->insertAt($includy['begin'] + 1, new Token(array(T_WHITESPACE, ' ')));
         }
     }
 }