diff --git a/src/parser/ArcanistCommentRemover.php b/src/parser/ArcanistCommentRemover.php index dad113c3..17f19c69 100644 --- a/src/parser/ArcanistCommentRemover.php +++ b/src/parser/ArcanistCommentRemover.php @@ -1,28 +1,32 @@ $line) { - if (!strlen($line)) { - unset($lines[$key]); - continue; - } - if ($line[0] == '#') { + if (preg_match('/^#/', $line)) { unset($lines[$key]); continue; } + break; } + $lines = array_reverse($lines); - return implode("\n", $lines)."\n"; + $lines = implode('', $lines); + $lines = rtrim($lines)."\n"; + + return $lines; } } diff --git a/src/parser/__tests__/ArcanistCommentRemoverTestCase.php b/src/parser/__tests__/ArcanistCommentRemoverTestCase.php index d89a3d08..7de70934 100644 --- a/src/parser/__tests__/ArcanistCommentRemoverTestCase.php +++ b/src/parser/__tests__/ArcanistCommentRemoverTestCase.php @@ -1,32 +1,47 @@ assertEqual($expect, ArcanistCommentRemover::removeComments($test)); + + $test = <<assertEqual($expect, ArcanistCommentRemover::removeComments($test)); } }