Skip to content

Commit

Permalink
fix: ensures final newline character in generated code
Browse files Browse the repository at this point in the history
For better diffs.
  • Loading branch information
ju1ius committed Dec 28, 2023
1 parent 46dd1c1 commit 30bdfdf
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Internal/CodeFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static function fix(string $input): string
{
$output = self::fixFunctionBraces($input);
$output = self::fixBlankLinesBetweenNamespaces($output);
return $output;
return self::ensureFinalNewLine($output);
}

private static function fixBlankLinesBetweenNamespaces(string $input): string
Expand All @@ -23,4 +23,12 @@ private static function fixFunctionBraces(string $input): string
{
return preg_replace('/\s+\{\s+}/', ' {}', $input);
}

private static function ensureFinalNewLine(string $input): string
{
if (!str_ends_with("\n", $input)) {
return $input . "\n";
}
return $input;
}
}

0 comments on commit 30bdfdf

Please sign in to comment.