StringEngine
in package
implements
DiffEngineInterface
Parses unified or context diffs output from eg. the diff utility.
Example:
$patch = file_get_contents('example.patch');
$diff = new Diff(new StringEngine($patch));
$renderer = new InlineRenderer;
echo $renderer->render($diff);
Copyright 2005 Örjan Persson o@42mm.org Copyright 2005-2017 Horde LLC (http://www.horde.org/)
See the enclosed file LICENSE for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.
Tags
Interfaces, Classes, Traits and Enums
- DiffEngineInterface
- Interface for Diff Engines
Table of Contents
- $diff : string
- $mode : string
- __construct() : mixed
- diff() : OperationList
- Parses a unified or context diff.
- parseContextDiff() : array<string|int, mixed>
- Parses an array containing the context diff.
- parseUnifiedDiff() : OperationList
- Parses an array containing the unified diff.
Properties
$diff
private
string
$diff
$mode
private
string
$mode
= 'autodetect'
Methods
__construct()
public
__construct(string $diff[, string $mode = 'autodetect' ]) : mixed
Parameters
- $diff : string
- $mode : string = 'autodetect'
Return values
mixed —diff()
Parses a unified or context diff.
public
diff() : OperationList
First param contains the whole diff and the second can be used to force a specific diff type. If the second parameter is 'autodetect', the diff will be examined to find out which type of diff this is.
Tags
Return values
OperationList —all changes made
parseContextDiff()
Parses an array containing the context diff.
public
parseContextDiff(array<string|int, mixed> &$diff) : array<string|int, mixed>
Parameters
- $diff : array<string|int, mixed>
-
Array of lines.
Return values
array<string|int, mixed> —List of all diff operations.
parseUnifiedDiff()
Parses an array containing the unified diff.
public
parseUnifiedDiff(array<string|int, mixed> $diff) : OperationList
Parameters
- $diff : array<string|int, mixed>
-
Array of lines.
Return values
OperationList —List of all diff operations.