DiffService
API reference › Scaffold › Services › DiffService
Renders Git-compatible unified diffs of what applying the provider would change in tracked files.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
renderPreview() | Writes the header and diff of one preview, no changes, or the line-ending notice. | DiffService |
run() | Renders what applying the provider would change in $file, or in every tracked, non-ejected file when $file is null, against the current disk content; orphans are reported, not diffed. | DiffService |
Method details
Section titled “Method details”renderPreview()
Section titled “renderPreview() ”public function renderPreview(PHPForge\Scaffold\Services\ApplyPreview $preview, PHPForge\Scaffold\Console\OutputWriter $out, bool $decorated = false): boolWrites the header and diff of one preview, no changes, or the line-ending notice.
Parameters
| Parameter | Type | Description |
|---|---|---|
$preview | ApplyPreview | Preview of the destination to render. |
$out | PHPForge\ | Output sink. |
$decorated | bool | Whether to wrap the diff lines in ANSI color escape codes. |
Returns
bool: true when applying the mapping would create or change the destination, false otherwise.
run()
Section titled “run() ”public function run(PHPForge\Scaffold\Config\ProjectContext $context, PHPForge\Scaffold\Console\OutputWriter $out, string|null $file = null, bool $decorated = false, bool $exitCode = false): intRenders what applying the provider would change in $file, or in every tracked, non-ejected file when $file
is null, against the current disk content; orphans are reported, not diffed.
Parameters
| Parameter | Type | Description |
|---|---|---|
$context | PHPForge\ | Project to inspect. |
$out | PHPForge\ | Output sink. |
$file | string| | Destination path as recorded in scaffold-lock.json, or null for every file. |
$decorated | bool | Whether to wrap the diff lines in ANSI color escape codes. |
$exitCode | bool | Whether to return 1 when applying the provider would change any file. |
Returns
int: 1 when the file is not tracked, an entry is unsafe, its provider is not allowed, or a file cannot be read, or with $exitCode when any file would change; 0 otherwise.
Throws
RuntimeException: when the lock file cannot be read.