mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-24 03:35:01 +01:00
DiffConsoleFormatter - allow simpler diffs
This commit is contained in:
parent
3e74964fde
commit
7e14d1208e
@ -29,9 +29,19 @@ final class DiffConsoleFormatter
|
||||
}
|
||||
|
||||
public function format(string $diff): string
|
||||
{
|
||||
return $this->formatWithTemplate($diff, $this->template);
|
||||
}
|
||||
|
||||
public function bareFormat(string $diff): string
|
||||
{
|
||||
return $this->formatWithTemplate($diff, PHP_EOL .'%s' . PHP_EOL);
|
||||
}
|
||||
|
||||
private function formatWithTemplate(string $diff, string $template): string
|
||||
{
|
||||
return sprintf(
|
||||
$this->template,
|
||||
$template,
|
||||
implode(PHP_EOL, array_map(function ($string) {
|
||||
// make "+" lines green
|
||||
// make "-" lines red
|
||||
|
@ -50,7 +50,9 @@ final class DifferAndFormatter
|
||||
}
|
||||
|
||||
$diff = $this->bareDiffer->diff($old, $new);
|
||||
// impossible to configure - removed manually
|
||||
$diff = substr($diff, strlen("@@ @@ "));
|
||||
|
||||
return $this->diffConsoleFormatter->format($diff);
|
||||
return $this->diffConsoleFormatter->bareFormat($diff);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user