Class Text_Diff

Description

Text_Diff

General API for generating and formatting diffs - the differences between two sequences of strings.

The PHP diff code used in this package was originally written by Geoffrey T. Dairiki and is used with his permission.

$Horde: framework/Text_Diff/Diff.php,v 1.17 2006/02/06 00:16:09 jan Exp $

Located in /sources/diff.php (line 83)


	
			
Direct descendents
Class Description
Text_MappedDiff $Horde: framework/Text_Diff/Diff.php,v 1.17 2006/02/06 00:16:09 jan Exp $
Text_Diff3 A class for computing three way diffs.
Variable Summary
array $_edits
Method Summary
Text_Diff Text_Diff ( $engine,  $params, array $from_lines, array $to_lines)
void getDiff ()
array getFinal ()
array getOriginal ()
boolean isEmpty ()
integer lcs ()
void trimNewlines ( &$line, integer $key, string $line)
void _check ( $from_lines,  $to_lines)
Variables
array $_edits (line 90)

Array of changes.

Methods
Constructor Text_Diff (line 99)

Computes diffs between sequences of strings.

Text_Diff Text_Diff ( $engine,  $params, array $from_lines, array $to_lines)
  • array $from_lines: An array of strings. Typically these are lines from a file.
  • array $to_lines: An array of strings.
  • $engine
  • $params
getDiff (line 121)

Returns the array of differences.

void getDiff ()
getFinal (line 212)

Gets the final set of lines.

This reconstructs the $to_lines parameter passed to the constructor.

  • return: The sequence of strings.
array getFinal ()
getOriginal (line 194)

Gets the original set of lines.

This reconstructs the $from_lines parameter passed to the constructor.

  • return: The original sequence of strings.
array getOriginal ()
isEmpty (line 159)

Checks for an empty diff.

  • return: True if two sequences were identical.
boolean isEmpty ()
lcs (line 176)

Computes the length of the Longest Common Subsequence (LCS).

This is mostly for diagnostic purposes.

  • return: The length of the LCS.
integer lcs ()
reverse (line 140)

Computes a reversed diff.

Example:

  1.  $diff=new Text_Diff($lines1$lines2);
  2.  $rev=$diff->reverse();

  • return: A Diff object representing the inverse of the original diff. Note that we purposely don't return a reference here, since this essentially is a clone() method.
Text_Diff &reverse ()
trimNewlines (line 230)

Removes trailing newlines from a line of text. This is meant to be used with array_walk().

void trimNewlines ( &$line, integer $key, string $line)
  • string $line: The line to trim.
  • integer $key: The index of the line in the array. Not used.
  • &$line
_check (line 240)

Checks a diff for validity.

This is here only for debugging purposes.

void _check ( $from_lines,  $to_lines)
  • $from_lines
  • $to_lines

Documentation generated on Sun, 02 Jan 2011 23:13:00 +0000 by phpDocumentor 1.4.3