Documentations › mmo.git › php › helpers Diff MMO\git\helpers · 1 symbol · generated 27 Oct 2026
What changed between two revisions, as git diff says it: one DiffFile per file, each with its
class MMO\git\helpers\Diff
implements JsonSerializable,
IteratorAggregate,
Countable Namespace MMO\git\helpersImplements JsonSerializable , IteratorAggregate , Countable See DiffHunk of DiffLine . Made by Repository::diff and Repository::diffCommit , or by Parse from any git diff output.It serializes to JSON as it is: `{from, to, additions, deletions, files: [...]}`. $diff = $repo->diff('v3.0.1', 'develop');
echo count($diff), ' files, +', $diff->additions(), ' -', $diff->deletions(), "\n";
foreach ($diff->getFile('src/Git.php')?->hunks ?? [] as $hunk) {
foreach ($hunk->lines as $line) {echo $line->type, $line->text, "\n";}
}
Methods8 function additions(): int returns int how many lines are added, all files together
function count(): int function deletions(): int returns int how many lines are removed, all files together
function getFile(string $path): ?MMO\git\helpers\DiffFile $path string a path from the repository's root, new or old returns null | DiffFile the file at $path, on the new side first
function getIterator(): ArrayIterator function jsonSerialize(): array Read the output of git diff (a patch, in git's own format -- not --color, not --word-diff).
static function Parse(string $output, ?string $from = null, ?string $to = null): self Paths are read as git writes them with its default `a/` and `b/` prefixes; [`Repository::diff`](https://mmoframework.fr/en/documentation/mmo.git/php/helpers/Repository.md#repository-diff) asks for
those whatever the configuration says. function __construct(?string $from = null, ?string $to = null) $from = null null | string the old revision $to = null null | string the new revision; null: the working tree