ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
Diff Class Reference
+ Inheritance diagram for Diff:
+ Collaboration diagram for Diff:

Public Member Functions

 __construct ($from_lines, $to_lines)
 Constructor. More...
 
 reverse ()
 Compute reversed Diff. More...
 
 isEmpty ()
 Check for empty diff. More...
 
 lcs ()
 Compute the length of the Longest Common Subsequence (LCS). More...
 
 orig ()
 Get the original set of lines. More...
 
 closing ()
 Get the closing set of lines. More...
 
 _check ($from_lines, $to_lines)
 Check a Diff for validity. More...
 

Data Fields

 $edits
 

Detailed Description

Definition at line 1188 of file class.WordLevelDiff.php.

Constructor & Destructor Documentation

◆ __construct()

Diff::__construct (   $from_lines,
  $to_lines 
)

Constructor.

Computes diff between sequences of strings.

Parameters
$from_linesarray An array of strings. (Typically these are lines from a file.)
$to_linesarray An array of strings.

Definition at line 1200 of file class.WordLevelDiff.php.

1203 {
1204  var $edits;

Member Function Documentation

◆ _check()

Diff::_check (   $from_lines,
  $to_lines 
)

Check a Diff for validity.

This is here only for debugging purposes.

Definition at line 1295 of file class.WordLevelDiff.php.

1297  {
1298  if ($edit->closing)
1299  array_splice($lines, sizeof($lines), 0, $edit->closing);
1300  }
1301  return $lines;
1302  }
1303 
1309  function _check ($from_lines, $to_lines) {
1310  $fname = 'Diff::_check';
1311  //wfProfileIn( $fname );
1312  if (serialize($from_lines) != serialize($this->orig()))
1313  trigger_error("Reconstructed original doesn't match", E_USER_ERROR);
1314  if (serialize($to_lines) != serialize($this->closing()))
1315  trigger_error("Reconstructed closing doesn't match", E_USER_ERROR);
1316 
1317  $rev = $this->reverse();
1318  if (serialize($to_lines) != serialize($rev->orig()))
1319  trigger_error("Reversed original doesn't match", E_USER_ERROR);
1320  if (serialize($from_lines) != serialize($rev->closing()))
closing()
Get the closing set of lines.
reverse()
Compute reversed Diff.
orig()
Get the original set of lines.
_check($from_lines, $to_lines)
Check a Diff for validity.

◆ closing()

Diff::closing ( )

Get the closing set of lines.

This reconstructs the $to_lines parameter passed to the constructor.

Returns
array The sequence of strings.

Definition at line 1280 of file class.WordLevelDiff.php.

1294  {

◆ isEmpty()

Diff::isEmpty ( )

Check for empty diff.

Returns
bool True iff two sequences were identical.

Definition at line 1230 of file class.WordLevelDiff.php.

References array.

1230  {
1231  $rev = $this;
1232  $rev->edits = array();
1233  foreach ($this->edits as $edit) {
1234  $rev->edits[] = $edit->reverse();
1235  }
1236  return $rev;
Create styles array
The data for the language used.

◆ 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 1245 of file class.WordLevelDiff.php.

1245  {
1246  if ($edit->type != 'copy')
1247  return false;
1248  }
1249  return true;
1250  }
1251 

◆ orig()

Diff::orig ( )

Get the original set of lines.

This reconstructs the $from_lines parameter passed to the constructor.

Returns
array The original sequence of strings.

Definition at line 1262 of file class.WordLevelDiff.php.

References array.

1276  {

◆ reverse()

Diff::reverse ( )

Compute reversed Diff.

SYNOPSIS:

 $diff = new Diff($lines1, $lines2);
 $rev = $diff->reverse();
Returns
object A Diff object representing the inverse of the original diff.

Definition at line 1216 of file class.WordLevelDiff.php.

1230  {

Field Documentation

◆ $edits

Diff::$edits

Definition at line 1190 of file class.WordLevelDiff.php.


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