Skip to content
PHP Ecosystem
Explore

DiffService

API reference › Scaffold › Services › DiffService

final classPHPForge\Scaffold\Services\DiffService
Sourcesrc/Services/DiffService.php

Renders Git-compatible unified diffs of what applying the provider would change in tracked files.

MethodDescriptionDefined 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
public function renderPreview(PHPForge\Scaffold\Services\ApplyPreview $preview, PHPForge\Scaffold\Console\OutputWriter $out, bool $decorated = false): bool

Writes the header and diff of one preview, no changes, or the line-ending notice.

Parameters

ParameterTypeDescription
$previewApplyPreviewPreview of the destination to render.
$outPHPForge\Scaffold\Console\OutputWriterOutput sink.
$decoratedboolWhether 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.

public function run(PHPForge\Scaffold\Config\ProjectContext $context, PHPForge\Scaffold\Console\OutputWriter $out, string|null $file = null, bool $decorated = false, bool $exitCode = false): int

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.

Parameters

ParameterTypeDescription
$contextPHPForge\Scaffold\Config\ProjectContextProject to inspect.
$outPHPForge\Scaffold\Console\OutputWriterOutput sink.
$filestring|nullDestination path as recorded in scaffold-lock.json, or null for every file.
$decoratedboolWhether to wrap the diff lines in ANSI color escape codes.
$exitCodeboolWhether 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