class MappedDiff
Same name in other branches
- 9 core/lib/Drupal/Component/Diff/MappedDiff.php \Drupal\Component\Diff\MappedDiff
- 10 core/lib/Drupal/Component/Diff/MappedDiff.php \Drupal\Component\Diff\MappedDiff
- 11.x core/lib/Drupal/Component/Diff/MappedDiff.php \Drupal\Component\Diff\MappedDiff
FIXME: bad name. @todo document @private @subpackage DifferenceEngine
Hierarchy
- class \Drupal\Component\Diff\Diff
- class \Drupal\Component\Diff\MappedDiff extends \Drupal\Component\Diff\Diff
Expanded class hierarchy of MappedDiff
File
-
core/
lib/ Drupal/ Component/ Diff/ MappedDiff.php, line 11
Namespace
Drupal\Component\DiffView source
class MappedDiff extends Diff {
/**
* Constructor.
*
* Computes diff between sequences of strings.
*
* This can be used to compute things like
* case-insensitive diffs, or diffs which ignore
* changes in white-space.
*
* @param array $from_lines
* An array of strings.
* (Typically these are lines from a file.)
* @param array $to_lines
* An array of strings.
* @param array $mapped_from_lines
* This array should have the same size number of elements as $from_lines.
* The elements in $mapped_from_lines and $mapped_to_lines are what is
* actually compared when computing the diff.
* @param array $mapped_to_lines
* This array should have the same number of elements as $to_lines.
*/
public function __construct($from_lines, $to_lines, $mapped_from_lines, $mapped_to_lines) {
assert(sizeof($from_lines) == sizeof($mapped_from_lines));
assert(sizeof($to_lines) == sizeof($mapped_to_lines));
parent::__construct($mapped_from_lines, $mapped_to_lines);
$xi = $yi = 0;
for ($i = 0; $i < sizeof($this->edits); $i++) {
$orig =& $this->edits[$i]->orig;
if (is_array($orig)) {
$orig = array_slice($from_lines, $xi, sizeof($orig));
$xi += sizeof($orig);
}
$closing =& $this->edits[$i]->closing;
if (is_array($closing)) {
$closing = array_slice($to_lines, $yi, sizeof($closing));
$yi += sizeof($closing);
}
}
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
Diff::$edits | protected | property | The list of differences as an array of diff operations. | ||
Diff::check | public | function | Check a Diff for validity. | ||
Diff::closing | public | function | Gets the closing set of lines. | 1 | |
Diff::getEdits | public | function | Gets the list of differences as an array of diff operations. | ||
Diff::isEmpty | public | function | Check for empty diff. | ||
Diff::lcs | public | function | Compute the length of the Longest Common Subsequence (LCS). | ||
Diff::orig | public | function | Gets the original set of lines. | 1 | |
Diff::reverse | public | function | Compute reversed Diff. | ||
MappedDiff::__construct | public | function | Constructor. | Overrides Diff::__construct | 1 |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.