class diff

Code from pear.php.net, Text_Diff-1.1.0 package http://pear.php.net/package/Text_Diff/

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 [email protected] Copyright 2004-2008 The Horde Project (http://www.horde.org/)

Properties

array $_edits

Array of changes.

Methods

__construct(array $from_content, array $to_content, bool $preserve_cr = true)

Computes diffs between sequences of strings.

get_diff()

Returns the array of differences.

int
count_added_lines()

returns the number of new (added) lines in a given diff.

int
count_deleted_lines()

Returns the number of deleted (removed) lines in a given diff.

reverse()

Computes a reversed diff.

bool
is_empty()

Checks for an empty diff.

int
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, int $key)

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

_check($from_lines, $to_lines)

Checks a diff for validity.

Details

at line 53
__construct(array $from_content, array $to_content, bool $preserve_cr = true)

Computes diffs between sequences of strings.

Parameters

array $from_content

An array of strings. Typically these are lines from a file.

array $to_content

An array of strings.

bool $preserve_cr

If true, \r is replaced by a new line in the diff output

at line 62
get_diff()

Returns the array of differences.

at line 74
int count_added_lines()

Since: Text_Diff 1.1.0

returns the number of new (added) lines in a given diff.

Return Value

int

The number of new lines

at line 97
int count_deleted_lines()

Since: Text_Diff 1.1.0

Returns the number of deleted (removed) lines in a given diff.

Return Value

int

The number of deleted lines

at line 126
diff reverse()

Computes a reversed diff.

Example:

$diff = new diff($lines1, $lines2);
$rev = $diff->reverse();

Return Value

diff

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.

at line 153
bool is_empty()

Checks for an empty diff.

Return Value

bool

True if two sequences were identical.

at line 201
int lcs()

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

This is mostly for diagnostic purposes.

Return Value

int

The length of the LCS.

at line 224
array get_original()

Gets the original set of lines.

This reconstructs the $from_lines parameter passed to the constructor.

Return Value

array

The original sequence of strings.

at line 247
array get_final()

Gets the final set of lines.

This reconstructs the $to_lines parameter passed to the constructor.

Return Value

array

The sequence of strings.

at line 269
trim_newlines(string $line, int $key)

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

Parameters

string $line

The line to trim.

int $key

The index of the line in the array. Not used.

at line 279
_check($from_lines, $to_lines)

Checks a diff for validity.

This is here only for debugging purposes.

Parameters

$from_lines
$to_lines