ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 1286 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 1298 of file class.WordLevelDiff.php.

1301 {
1302  public $edits;
1303 

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

1404  {
1405  if ($edit->closing) {
1406  array_splice($lines, sizeof($lines), 0, $edit->closing);
1407  }
1408  }
1409  return $lines;
1410  }
1411 
1417  public function _check($from_lines, $to_lines)
1418  {
1419  $fname = 'Diff::_check';
1420  //wfProfileIn( $fname );
1421  if (serialize($from_lines) != serialize($this->orig())) {
1422  trigger_error("Reconstructed original doesn't match", E_USER_ERROR);
1423  }
1424  if (serialize($to_lines) != serialize($this->closing())) {
1425  trigger_error("Reconstructed closing doesn't match", E_USER_ERROR);
1426  }
1427 
1428  $rev = $this->reverse();
1429  if (serialize($to_lines) != serialize($rev->orig())) {
1430  trigger_error("Reversed original doesn't match", E_USER_ERROR);
1431  }
1432  if (serialize($from_lines) != serialize($rev->closing())) {
1433  trigger_error("Reversed closing doesn't match", E_USER_ERROR);
1434  }
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 1386 of file class.WordLevelDiff.php.

1401  {

◆ isEmpty()

Diff::isEmpty ( )

Check for empty diff.

Returns
bool True iff two sequences were identical.

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

1330  {
1331  $rev = $this;
1332  $rev->edits = array();
1333  foreach ($this->edits as $edit) {
1334  $rev->edits[] = $edit->reverse();
1335  }
1336  return $rev;
1337  }
1338 

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

1347  {
1348  return false;
1349  }
1350  }
1351  return true;
1352  }
1353 

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

1381  {

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

1330  {

Field Documentation

◆ $edits

Diff::$edits

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


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