parse($gitDiff); foreach ($bundle->files() as $file) { echo "Changed: {$file->oldPath}\n"; if (isset($file->headers['index'])) { echo " Index: {$file->headers['index']}\n"; } echo ' Hunks: '.count($file->result->hunks())."\n"; } echo "\n=== 2. Generate Git-Compatible Patch ===\n"; $old = 'function test() { return false; }'; $new = 'function test() { return true; }'; $result = Diff::build()->compare($old, $new); $headers = [ 'diff' => 'diff --git a/file.txt b/file.txt', 'index' => 'index abc123..def456 100644', ]; $file = new DiffFile('file.txt', 'file.txt', $result, $headers); $bundle = new DiffBundle([$file]); $emitter = new UnifiedEmitter(); echo $emitter->emit($bundle)."\n";