Parses unified or context diffs output from eg. the diff utility.

Example: $patch = file_get_contents('example.patch'); $diff = new Text_Diff('string', array($patch)); $renderer = new Text_Diff_Renderer_inline(); echo $renderer->render($diff);

Copyright 2005 Örjan Persson o@42mm.org Copyright 2005-2010 The Horde Project (http://www.horde.org/)

See the enclosed file COPYING for license information (LGPL). If you did not receive this file, see http://opensource.org/licenses/lgpl-license.php.

author Örjan Persson
package Text_Diff
since 0.2.0

 Methods

Parses a unified or context diff.

diff(string $diff, string $mode = 'autodetect') : array

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.

Parameters

$diff

string

The diff content.

$mode

string

The diff mode of the content in $diff. One of 'context', 'unified', or 'autodetect'.

Returns

arrayList of all diff operations.

Parses an array containing the context diff.

parseContextDiff(array $diff) : array

Parameters

$diff

array

Array of lines.

Returns

arrayList of all diff operations.

Parses an array containing the unified diff.

parseUnifiedDiff(array $diff) : array

Parameters

$diff

array

Array of lines.

Returns

arrayList of all diff operations.