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.10 2004/11/01 11:51:15 mdjukic Exp $

Located in /inc/class_diff.php (line 22)


	
			
Direct descendents
Class Description
Text_MappedDiff $Horde: framework/Text_Diff/Diff.php,v 1.10 2004/11/01 11:51:15 mdjukic Exp $
Variable Summary
array $_edits
Method Summary
Text_Diff Text_Diff (array $from_lines, array $to_lines)
void getDiff ()
array getFinal ()
array getOriginal ()
boolean isEmpty ()
int lcs ()
void _check ( $from_lines,  $to_lines)
void _trimNewlines ( &$line, integer $key, string $line)
Variables
array $_edits (line 29)

Array of changes.

Methods
Constructor Text_Diff (line 38)

Computes diffs between sequences of strings.

Text_Diff Text_Diff (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.
getDiff (line 58)

Returns the array of differences.

void getDiff ()
getFinal (line 159)

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 139)

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 100)

Checks for an empty diff.

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

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

This is mostly for diagnostic purposed.

  • return: The length of the LCS.
int lcs ()
reverse (line 77)

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 ()
_check (line 189)

Checks a diff for validity.

This is here only for debugging purposes.

void _check ( $from_lines,  $to_lines)
  • $from_lines
  • $to_lines
_trimNewlines (line 179)

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

Documentation generated on Thu, 31 May 2007 23:33:57 -0400 by phpDocumentor 1.3.2