Skip to content
PHP Ecosystem
Explore

ReapplyService

API reference › Scaffold › Services › ReapplyService

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

Rewrites tracked files from their provider stubs; without force it merges append and prepend files and skips ejected, adopted, user-modified and existing preserve files; it always skips orphaned files.

MethodDescriptionDefined by
run()Reapplies the tracked files that match the filters and records their new hashes in scaffold-lock.json, or only prints what would change with $dryRun, ending with a summary line.ReapplyService
public function run(PHPForge\Scaffold\Config\ProjectContext $context, PHPForge\Scaffold\Console\OutputWriter $out, string $file = '', string $provider = '', bool $force = false, bool $dryRun = false, bool $exitCode = false): int

Reapplies the tracked files that match the filters and records their new hashes in scaffold-lock.json, or only prints what would change with $dryRun, ending with a summary line.

Parameters

ParameterTypeDescription
$contextPHPForge\Scaffold\Config\ProjectContextProject to reapply.
$outPHPForge\Scaffold\Console\OutputWriterOutput sink.
$filestringDestination path to reapply, or an empty string for every tracked file.
$providerstringProvider package name to reapply, or an empty string for every provider.
$forceboolWhether to overwrite every matching file with its stub, including ejected, adopted, user-modified, preserve, append and prepend files, and to clear the ejected and adopted flags.
$dryRunboolWhether to print the diff of every file that would change instead of writing anything.
$exitCodeboolWhether a dry run returns 1 when any file would change.

Returns

int: 1 when a filter matches no tracked file or an entry was skipped for an error (unsafe entry, provider not allowed, missing stub, unknown mode, read, hash or write failure), or with $dryRun and $exitCode when any file would change; 0 otherwise, including user-modified, preserve, ejected and orphaned skips.

Throws