MediaWiki REL1_37
Diff Class Reference

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

Inheritance diagram for Diff:
Collaboration diagram for Diff:

Public Member Functions

 __construct ( $from_lines, $to_lines)
 Computes diff between sequences of strings.
 
 closing ()
 Get the closing set of lines.
 
 getEdits ()
 
 isEmpty ()
 Check for empty diff.
 
 lcs ()
 Compute the length of the Longest Common Subsequence (LCS).
 
 orig ()
 Get the original set of lines.
 
 reverse ()
 Compute reversed Diff.
 

Public Attributes

DiffOp[] $edits
 

Protected Attributes

int $bailoutComplexity = 0
 If this diff complexity is exceeded, a ComplexityException is thrown 0 means no limit.
 

Detailed Description

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

@newable

Definition at line 32 of file Diff.php.

Constructor & Destructor Documentation

◆ __construct()

Diff::__construct (   $from_lines,
  $to_lines 
)

Computes diff between sequences of strings.

Stability: stable
to call
Todo:
Don't do work in the constructor, use a service to create diffs instead (T257472).
Parameters
string[]$from_linesAn array of strings. Typically these are lines from a file.
string[]$to_linesAn array of strings.
Exceptions

\MediaWiki\Diff\ComplexityException

Reimplemented in WordLevelDiff.

Definition at line 56 of file Diff.php.

References DiffEngine\setBailoutComplexity().

Member Function Documentation

◆ closing()

Diff::closing ( )

Get the closing set of lines.

This reconstructs the $to_lines parameter passed to the constructor.

Returns
string[] The sequence of strings.

Reimplemented in WordLevelDiff.

Definition at line 152 of file Diff.php.

References $lines.

◆ getEdits()

Diff::getEdits ( )
Returns
DiffOp[]

Definition at line 65 of file Diff.php.

References $edits.

◆ isEmpty()

Diff::isEmpty ( )

Check for empty diff.

Returns
bool True if two sequences were identical.

Definition at line 96 of file Diff.php.

◆ lcs()

Diff::lcs ( )

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

This is mostly for diagnostic purposed.

Returns
int The length of the LCS.

Definition at line 113 of file Diff.php.

◆ orig()

Diff::orig ( )

Get the original set of lines.

This reconstructs the $from_lines parameter passed to the constructor.

Returns
string[] The original sequence of strings.

Reimplemented in WordLevelDiff.

Definition at line 132 of file Diff.php.

References $lines.

◆ reverse()

Diff::reverse ( )

Compute reversed Diff.

SYNOPSIS:

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

Returns
self A Diff object representing the inverse of the original diff.

Definition at line 80 of file Diff.php.

Member Data Documentation

◆ $bailoutComplexity

int Diff::$bailoutComplexity = 0
protected

If this diff complexity is exceeded, a ComplexityException is thrown 0 means no limit.

Definition at line 43 of file Diff.php.

◆ $edits

DiffOp [] Diff::$edits

Definition at line 37 of file Diff.php.

Referenced by getEdits().


The documentation for this class was generated from the following file: