Skip to content
Permalink
Browse files

Add switch for newline swallowing

  • Loading branch information...
muglug committed Apr 17, 2019
1 parent cf36d50 commit f51b073c40bfc0ae2f32229d40de39574efedc3f
Showing with 17 additions and 15 deletions.
  1. +17 −15 src/Psalm/Internal/FileManipulation/FileManipulationBuffer.php
@@ -34,26 +34,28 @@ public static function addForCodeLocation(
) {
$bounds = $code_location->getSnippetBounds();
$project_analyzer = \Psalm\Internal\Analyzer\ProjectAnalyzer::getInstance();
if ($swallow_newlines) {
$project_analyzer = \Psalm\Internal\Analyzer\ProjectAnalyzer::getInstance();
$codebase = $project_analyzer->getCodebase();
$codebase = $project_analyzer->getCodebase();
$file_contents = $codebase->getFileContents($code_location->file_path);
$file_contents = $codebase->getFileContents($code_location->file_path);
$removed_lines = false;
$removed_lines = false;
if (($file_contents[$bounds[0] - 1] ?? null) === PHP_EOL
&& ($file_contents[$bounds[0] - 2] ?? null) === PHP_EOL
) {
$removed_lines = true;
$bounds[0] -= 2;
}
if (($file_contents[$bounds[0] - 1] ?? null) === PHP_EOL
&& ($file_contents[$bounds[0] - 2] ?? null) === PHP_EOL
) {
$removed_lines = true;
$bounds[0] -= 2;
}
if (!$removed_lines
&& ($file_contents[$bounds[1]] ?? null) === PHP_EOL
&& ($file_contents[$bounds[1] + 1] ?? null) === PHP_EOL
) {
$bounds[1] += 2;
if (!$removed_lines
&& ($file_contents[$bounds[1]] ?? null) === PHP_EOL
&& ($file_contents[$bounds[1] + 1] ?? null) === PHP_EOL
) {
$bounds[1] += 2;
}
}
self::add(

0 comments on commit f51b073

Please sign in to comment.
You can’t perform that action at this time.