StrictUnifiedDiffOutputBuilder
in package
implements
DiffOutputBuilderInterface
FinalYes
Strict Unified diff output builder.
Generates (strict) Unified diff's (unidiffs) with hunks.
Table of Contents
Interfaces
- DiffOutputBuilderInterface
- Defines how an output builder should take a generated diff array and return a string representation of that diff.
Properties
- $changed : bool
- $collapseRanges : bool
- $commonLineThreshold : int
- $contextLines : int
- $default : array<string|int, mixed>
- $header : string
Methods
- __construct() : mixed
- getDiff() : string
- assertString() : void
- assertStringOrNull() : void
- writeDiffHunks() : void
- writeHunk() : void
Properties
$changed
private
bool
$changed
$collapseRanges
private
bool
$collapseRanges
$commonLineThreshold
private
int
$commonLineThreshold
Tags
$contextLines
private
int
$contextLines
Tags
$default
private
static array<string|int, mixed>
$default
= [
'collapseRanges' => true,
// ranges of length one are rendered with the trailing `,1`
'commonLineThreshold' => 6,
// number of same lines before ending a new hunk and creating a new one (if needed)
'contextLines' => 3,
// like `diff: -u, -U NUM, --unified[=NUM]`, for patch/git apply compatibility best to keep at least @ 3
'fromFile' => null,
'fromFileDate' => null,
'toFile' => null,
'toFileDate' => null,
]
$header
private
string
$header
Methods
__construct()
public
__construct([array<string|int, mixed> $options = [] ]) : mixed
Parameters
- $options : array<string|int, mixed> = []
getDiff()
public
getDiff(array<string|int, mixed> $diff) : string
Parameters
- $diff : array<string|int, mixed>
Return values
stringassertString()
private
assertString(array<string|int, mixed> $options, string $option) : void
Parameters
- $options : array<string|int, mixed>
- $option : string
assertStringOrNull()
private
assertStringOrNull(array<string|int, mixed> $options, string $option) : void
Parameters
- $options : array<string|int, mixed>
- $option : string
writeDiffHunks()
private
writeDiffHunks(mixed $output, array<string|int, mixed> $diff) : void
Parameters
- $output : mixed
- $diff : array<string|int, mixed>
writeHunk()
private
writeHunk(array<string|int, mixed> $diff, int $diffStartIndex, int $diffEndIndex, int $fromStart, int $fromRange, int $toStart, int $toRange, mixed $output) : void
Parameters
- $diff : array<string|int, mixed>
- $diffStartIndex : int
- $diffEndIndex : int
- $fromStart : int
- $fromRange : int
- $toStart : int
- $toRange : int
- $output : mixed