private function removeEmptyLinesAfterLineWithTokenAt($index)
{
// find the line break
$tokenCount = count($this->tokens);
for ($end = $index; $end < $tokenCount; ++$end) {
if ($this->tokens[$end]->equals('}') || false !== strpos($this->tokens[$end]->getContent(), "\n")) {
break;
}
}
if ($end === $tokenCount) {
return;
// not found, early return
}
for ($i = $end; $i < $tokenCount && $this->tokens[$i]->isWhitespace(); ++$i) {
$content = $this->tokens[$i]->getContent();
if (substr_count($content, "\n") < 1) {
continue;
}
$ending = $this->whitespacesConfig->getLineEnding();
$pos = strrpos($content, "\n");
if ($pos + 2 < strlen($content)) {
// preserve indenting where possible
$this->tokens[$i]->setContent($ending . substr($content, $pos + 1));
} else {
$this->tokens[$i]->setContent($ending);
}
}
}