class Diff (View source)

Class representing a 'diff' between two sequences of strings.

Properties

public static $html_cleaner_class
public $edits

Methods

public
__construct($from_lines, $to_lines)

Constructor.

public
object
reverse()

Compute reversed Diff.

public
bool
isEmpty()

Check for empty diff.

public
int
lcs()

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

public
array
orig()

Get the original set of lines.

public
array
finaltext()

Get the final set of lines.

public
_check($from_lines, $to_lines)

Check a Diff for validity.

public static 
cleanHTML(string $content, object $cleaner = null)

Attempt to clean invalid HTML, which messes up diffs.

public static 
string
compareHTML($from, $to, $escape = false)

No description

public static 
getHTMLChunks($content)

No description

Details

__construct($from_lines, $to_lines)

Constructor.

Computes diff between sequences of strings.

Parameters

$from_lines

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

$to_lines

array An array of strings.

object reverse()

Compute reversed Diff.

SYNOPSIS:

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

Return Value

object

A Diff object representing the inverse of the original diff.

bool isEmpty()

Check for empty diff.

Return Value

bool

True iff two sequences were identical.

int lcs()

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

This is mostly for diagnostic purposed.

Return Value

int

The length of the LCS.

array orig()

Get the original set of lines.

This reconstructs the $from_lines parameter passed to the constructor.

Return Value

array

The original sequence of strings.

array finaltext()

Get the final set of lines.

This reconstructs the $to_lines parameter passed to the constructor.

Return Value

array

The sequence of strings.

_check($from_lines, $to_lines)

Check a Diff for validity.

This is here only for debugging purposes.

Parameters

$from_lines
$to_lines

static cleanHTML(string $content, object $cleaner = null)

Attempt to clean invalid HTML, which messes up diffs.

This cleans code if possible, using an instance of HTMLCleaner

NB: By default, only extremely simple tidying is performed, by passing through DomDocument::loadHTML and saveXML

Parameters

string $content

HTML content

object $cleaner

Optional instance of a HTMLCleaner class to use, overriding self::$html_cleaner_class

static string compareHTML($from, $to, $escape = false)

No description

Parameters

$from
$to
$escape

Return Value

string

static getHTMLChunks($content)

No description

Parameters

$content