Skip to content

Commit 6bed665

Browse files
committed
Don't hard-code newline char (ref #2261)
1 parent aa4c0c2 commit 6bed665

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Standards/PSR2/Sniffs/Files/EndFileNewlineSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function process(File $phpcsFile, $stackPtr)
5757
$error = 'Expected 1 newline at end of file; 0 found';
5858
$fix = $phpcsFile->addFixableError($error, $lastToken, 'NoneFound');
5959
if ($fix === true) {
60-
$phpcsFile->fixer->addContent($lastToken, "\n");
60+
$phpcsFile->fixer->addNewline($lastToken);
6161
}
6262

6363
$phpcsFile->recordMetric($stackPtr, 'Number of newlines at EOF', '0');
@@ -90,7 +90,7 @@ public function process(File $phpcsFile, $stackPtr)
9090
$phpcsFile->fixer->replaceToken($i, '');
9191
}
9292

93-
$phpcsFile->fixer->replaceToken($lastToken, "\n");
93+
$phpcsFile->fixer->replaceToken($lastToken, $phpcsFile->eolChar);
9494
$phpcsFile->fixer->endChangeset();
9595
}
9696
}

0 commit comments

Comments
 (0)