-
-
Notifications
You must be signed in to change notification settings - Fork 0
FileDiffer
github-actions edited this page Apr 19, 2026
·
1 revision
Renders deterministic summaries and unified diffs for file comparisons.
- Full name:
\FastForward\DevTools\Resource\FileDiffer - This class is marked as final and can't be subclassed
- This class is a Final class
Creates a new file differ.
public __construct(\FastForward\DevTools\Filesystem\FilesystemInterface $filesystem, \FastForward\DevTools\Resource\DifferInterface $differ): mixedParameters:
| Parameter | Type | Description |
|---|---|---|
$filesystem |
\FastForward\DevTools\Filesystem\FilesystemInterface | the filesystem used to read compared file contents |
$differ |
\FastForward\DevTools\Resource\DifferInterface | the differ used to generate unified diffs |
Compares a source file against the target file that would be overwritten.
public diff(string $sourcePath, string $targetPath): \FastForward\DevTools\Resource\FileDiffParameters:
| Parameter | Type | Description |
|---|---|---|
$sourcePath |
string | the source file path that would replace the target |
$targetPath |
string | the existing target file path |
Return Value:
the rendered comparison result
Compares managed content against the current target contents.
public diffContents(string $sourceLabel, string $targetPath, string $sourceContent, string|null $targetContent, string|null $changedSummary = null): \FastForward\DevTools\Resource\FileDiffParameters:
| Parameter | Type | Description |
|---|---|---|
$sourceLabel |
string | the human-readable source label shown in summaries |
$targetPath |
string | the target file path |
$sourceContent |
string | the generated or source content |
$targetContent |
string|null | the current target content, or null when the target does not exist |
$changedSummary |
string|null | an optional changed-state summary override |
Return Value:
the rendered comparison result
Colorizes a unified diff for decorated console output.
public colorize(string $diff): stringParameters:
| Parameter | Type | Description |
|---|---|---|
$diff |
string | the plain unified diff |
Return Value:
the colorized diff using Symfony Console tags
Formats a diff payload for console output.
public formatForConsole(string|null $diff, bool $decorated): string|nullParameters:
| Parameter | Type | Description |
|---|---|---|
$diff |
string|null | the plain unified diff, if available |
$decorated |
bool | whether console decoration is enabled |
Return Value:
the diff payload ready for console output