phpBB API Documentation
Class

diff

class diff

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

Modified by phpBB Group 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($from_content, $to_content, $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 49
public diff($from_content, $to_content, $preserve_cr = true)

Computes diffs between sequences of strings.

Parameters

$from_content
$to_content
$preserve_cr

at line 58
public get_diff()

Returns the array of differences.

at line 70
public integer count_added_lines()

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

Return Value

integer The number of new lines

at line 93
public integer count_deleted_lines()

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

Return Value

integer The number of deleted lines

at line 122
public 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 149
public boolean is_empty()

Checks for an empty diff.

Return Value

boolean True if two sequences were identical.

at line 191
public integer lcs()

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

This is mostly for diagnostic purposes.

Return Value

integer The length of the LCS.

at line 214
public 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 237
public 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 259
public trim_newlines(string $line, integer $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.
integer $key The index of the line in the array. Not used.

at line 269
public _check($from_lines, $to_lines)

Checks a diff for validity.

This is here only for debugging purposes.

Parameters

$from_lines
$to_lines