Skip to content

Commit

Permalink
Generate only 1, not 2 newlines at the end of baseline
Browse files Browse the repository at this point in the history
  • Loading branch information
VasekPurchart committed Apr 25, 2022
1 parent a1b0c89 commit bb88ea7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 0 additions & 1 deletion phpstan-baseline.neon
Expand Up @@ -409,4 +409,3 @@ parameters:
"""
count: 1
path: tests/PHPStan/Rules/Arrays/AppendedArrayKeyTypeRuleTest.php

9 changes: 8 additions & 1 deletion src/Command/ErrorFormatter/BaselineNeonErrorFormatter.php
Expand Up @@ -7,6 +7,7 @@
use PHPStan\Command\AnalysisResult;
use PHPStan\Command\Output;
use PHPStan\File\RelativePathHelper;
use PHPStan\ShouldNotHappenException;
use function ksort;
use function preg_quote;
use function substr;
Expand Down Expand Up @@ -70,11 +71,17 @@ public function formatErrors(
*/
private function getNeon(array $ignoreErrors): string
{
return Neon::encode([
$neon = Neon::encode([
'parameters' => [
'ignoreErrors' => $ignoreErrors,
],
], Neon::BLOCK);

if (substr($neon, -2) !== "\n\n") {
throw new ShouldNotHappenException();
}

return substr($neon, 0, -1);
}

}

0 comments on commit bb88ea7

Please sign in to comment.