do not touch end newlines, keep only in tests

This commit is contained in:
Tomas Votruba 2018-11-09 13:36:58 +01:00
parent 1be856068b
commit f05c71c58d
3 changed files with 8 additions and 6 deletions

View File

@ -77,9 +77,7 @@ final class FileProcessor
[$newStmts, $oldStmts, $oldTokens] = $this->parseAndTraverseFileInfoToNodes($smartFileInfo);
$printedContent = $this->formatPerservingPrinter->printToString($newStmts, $oldStmts, $oldTokens);
return trim($printedContent) . PHP_EOL;
return $this->formatPerservingPrinter->printToString($newStmts, $oldStmts, $oldTokens);
}
/**

View File

@ -40,8 +40,6 @@ final class FormatPerservingPrinter
*/
public function printToString(array $newStmts, array $oldStmts, array $oldTokens): string
{
$printedContent = $this->betterStandardPrinter->printFormatPreserving($newStmts, $oldStmts, $oldTokens);
return trim($printedContent) . PHP_EOL;
return $this->betterStandardPrinter->printFormatPreserving($newStmts, $oldStmts, $oldTokens);
}
}

View File

@ -71,6 +71,7 @@ abstract class AbstractRectorTestCase extends TestCase
try {
$reconstructedFileContent = $this->fileProcessor->processFileToString(new SmartFileInfo($file));
$reconstructedFileContent = $this->normalizeEndNewline($reconstructedFileContent);
} catch (AnalysedCodeException $analysedCodeException) {
// change message to include responsible file
$message = sprintf('Analyze error in "%s" file:%s%s', $file, PHP_EOL, $analysedCodeException->getMessage());
@ -86,4 +87,9 @@ abstract class AbstractRectorTestCase extends TestCase
}
abstract protected function provideConfig(): string;
private function normalizeEndNewline(string $content): string
{
return trim($content) . PHP_EOL;
}
}