class diff
Code from pear.php.net, TextDiff-1.1.0 package http://pear.php.net/package/TextDiff/
Modified by phpBB Limited to meet our coding standards and being able to integrate into phpBB
General API for generating and formatting diffs - the differences between two sequences of strings.
Copyright 2004 Geoffrey T. Dairiki dairiki@dairiki.org Copyright 2004-2008 The Horde Project (http://www.horde.org/)
Properties
array | $_edits | Array of changes. |
Methods
diff(array $from_content, array $to_content, bool $preserve_cr = true)
Computes diffs between sequences of strings. |
||
get_diff()
Returns the array of differences. |
||
integer |
count_added_lines()
returns the number of new (added) lines in a given diff. |
|
integer |
count_deleted_lines()
Returns the number of deleted (removed) lines in a given diff. |
|
diff |
reverse()
Computes a reversed diff. |
|
boolean |
is_empty()
Checks for an empty diff. |
|
integer |
lcs()
Computes the length of the Longest Common Subsequence (LCS). |
|
array |
get_original()
Gets the original set of lines. |
|
array |
get_final()
Gets the final set of lines. |
|
trim_newlines(string $line, integer $key)
Removes trailing newlines from a line of text. |
||
_check($from_lines, $to_lines)
Checks a diff for validity. |
Details
at line 53
public
diff(array $from_content, array $to_content, bool $preserve_cr = true)
Computes diffs between sequences of strings.
at line 62
public
get_diff()
Returns the array of differences.
at line 74
public integer
count_added_lines()
returns the number of new (added) lines in a given diff.
at line 97
public integer
count_deleted_lines()
Returns the number of deleted (removed) lines in a given diff.
at line 126
public diff
reverse()
Computes a reversed diff.
Example:
$diff = new diff($lines1, $lines2);
$rev = $diff->reverse();
at line 153
public boolean
is_empty()
Checks for an empty diff.
at line 195
public integer
lcs()
Computes the length of the Longest Common Subsequence (LCS).
This is mostly for diagnostic purposes.
at line 218
public array
get_original()
Gets the original set of lines.
This reconstructs the $from_lines parameter passed to the constructor.
at line 241
public array
get_final()
Gets the final set of lines.
This reconstructs the $to_lines parameter passed to the constructor.
at line 263
public
trim_newlines(string $line, integer $key)
Removes trailing newlines from a line of text.
This is meant to be used with array_walk().
at line 273
public
_check($from_lines, $to_lines)
Checks a diff for validity.
This is here only for debugging purposes.