MMOframework
Pourquoi l'IA Playground Bibliothèques Documentation Rechercher Agence
FR EN
Index

DiffHunk

MMO\git\helpers · 1 symbole · générée le 27 Oct 2026

class

DiffHunk

DiffHunk.php:15

One hunk of a DiffFile: a run of changed lines with the unchanged lines around them, as git's @@ -oldStart,oldCount +newStart,newCount @@ context introduces it.

class MMO\git\helpers\DiffHunk implements JsonSerializable
Espace de noms
MMO\git\helpers
Implémente
JsonSerializable
$hunk = $diff->getFile('src/Git.php')->hunks[0]; echo "lines {$hunk->newStart} to ", $hunk->newStart + $hunk->newCount - 1, " ({$hunk->context})\n";

Index

context readonly
lines
newCount readonly
newStart readonly
oldCount readonly
oldStart readonly
additions()
deletions()
jsonSerialize()
Parse($lines, $i) staticRead a hunk from git's output, its @@ line at $lines[$i], and leave $i on the line after it.
__construct($oldStart, $oldCount, $newStart, $newCount, $context)

Propriétés6

context

readonly
readonly string $context
Type
string

lines

array $lines = []
Type
array

newCount

readonly
readonly int $newCount
Type
int

newStart

readonly
readonly int $newStart
Type
int

oldCount

readonly
readonly int $oldCount
Type
int

oldStart

readonly
readonly int $oldStart
Type
int

Méthodes5

additions()

DiffHunk.php:89
function additions(): int
retourneinthow many lines this hunk adds

deletions()

DiffHunk.php:94
function deletions(): int
retourneinthow many lines this hunk removes

Parse($lines, $i)

staticDiffHunk.php:44

Read a hunk from git's output, its @@ line at $lines[$i], and leave $i on the line after it.

static function Parse(array $lines, int &$i): selfThe hunk's lines are counted from its header rather than recognised by their first character, so a line of the file that reads `diff --git` or `@@` is still the file's.
$linesarraygit's output, line by line
$iintthe hunk's @@ line; on return, the first line after the hunk
retourneself
lèvewhen $lines[$i] is not a hunk header

__construct($oldStart, $oldCount, $newStart, $newCount, $context)

DiffHunk.php:26
function __construct( int $oldStart, int $oldCount, int $newStart, int $newCount, string $context = '' )
$oldStartintthe first line of the hunk in the old file (0 when the old side has none)
$oldCountinthow many lines it covers there
$newStartintthe first line of the hunk in the new file (0 when the new side has none)
$newCountinthow many lines it covers there
$context = ''stringwhat git prints after the second @@: usually the enclosing function's first line