ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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 1283 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 1295 of file class.WordLevelDiff.php.

1298 {
1299  public $edits;
1300 

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

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

1398  {

◆ isEmpty()

Diff::isEmpty ( )

Check for empty diff.

Returns
bool True iff two sequences were identical.

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

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

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

1344  {
1345  return false;
1346  }
1347  }
1348  return true;
1349  }
1350 

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

1378  {

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

1327  {

Field Documentation

◆ $edits

Diff::$edits

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


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