本文整理汇总了PHP中Diff::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP Diff::__construct方法的具体用法?PHP Diff::__construct怎么用?PHP Diff::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Diff
的用法示例。
在下文中一共展示了Diff::__construct方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param string[] $linesBefore
* @param string[] $linesAfter
*/
public function __construct($linesBefore, $linesAfter)
{
list($wordsBefore, $wordsBeforeStripped) = $this->split($linesBefore);
list($wordsAfter, $wordsAfterStripped) = $this->split($linesAfter);
try {
parent::__construct($wordsBeforeStripped, $wordsAfterStripped);
} catch (ComplexityException $ex) {
// Too hard to diff, just show whole paragraph(s) as changed
$this->edits = [new DiffOpChange($linesBefore, $linesAfter)];
}
$xi = $yi = 0;
$editCount = count($this->edits);
for ($i = 0; $i < $editCount; $i++) {
$orig =& $this->edits[$i]->orig;
if (is_array($orig)) {
$orig = array_slice($wordsBefore, $xi, count($orig));
$xi += count($orig);
}
$closing =& $this->edits[$i]->closing;
if (is_array($closing)) {
$closing = array_slice($wordsAfter, $yi, count($closing));
$yi += count($closing);
}
}
}
示例2: __construct
/**
* 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 $from_lines array An array of strings.
* (Typically these are lines from a file.)
*
* @param $to_lines array An array of strings.
*
* @param $mapped_from_lines array 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 $mapped_to_lines array 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);
}
}
}
示例3: __construct
/**
* @param string[] $linesBefore
* @param string[] $linesAfter
*/
public function __construct($linesBefore, $linesAfter)
{
list($wordsBefore, $wordsBeforeStripped) = $this->split($linesBefore);
list($wordsAfter, $wordsAfterStripped) = $this->split($linesAfter);
parent::__construct($wordsBeforeStripped, $wordsAfterStripped);
$xi = $yi = 0;
$editCount = count($this->edits);
for ($i = 0; $i < $editCount; $i++) {
$orig =& $this->edits[$i]->orig;
if (is_array($orig)) {
$orig = array_slice($wordsBefore, $xi, count($orig));
$xi += count($orig);
}
$closing =& $this->edits[$i]->closing;
if (is_array($closing)) {
$closing = array_slice($wordsAfter, $yi, count($closing));
$yi += count($closing);
}
}
}
示例4: __construct
/**
* Constructor.
*
* Computes diff between sequences of strings.
*
* This can be used to compute things like
* case-insensitve diffs, or diffs which ignore
* changes in white-space.
*
* @param string[] $from_lines An array of strings.
* Typically these are lines from a file.
* @param string[] $to_lines An array of strings.
* @param string[] $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 string[] $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)
{
wfProfileIn(__METHOD__);
assert('count( $from_lines ) == count( $mapped_from_lines )');
assert('count( $to_lines ) == count( $mapped_to_lines )');
parent::__construct($mapped_from_lines, $mapped_to_lines);
$xi = $yi = 0;
$editCount = count($this->edits);
for ($i = 0; $i < $editCount; $i++) {
$orig =& $this->edits[$i]->orig;
if (is_array($orig)) {
$orig = array_slice($from_lines, $xi, count($orig));
$xi += count($orig);
}
$closing =& $this->edits[$i]->closing;
if (is_array($closing)) {
$closing = array_slice($to_lines, $yi, count($closing));
$yi += count($closing);
}
}
wfProfileOut(__METHOD__);
}
示例5: __construct
public function __construct(array $operations = array())
{
parent::__construct($operations, true);
}
示例6: __construct
/**
* Constructor.
*
* Computes diff between sequences of strings.
*
* This can be used to compute things like
* case-insensitve diffs, or diffs which ignore
* changes in white-space.
*
* @param $from_lines array An array of strings.
* (Typically these are lines from a file.)
*
* @param $to_lines array An array of strings.
*
* @param $mapped_from_lines array 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 $mapped_to_lines array 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;
// Optimizing loop invariants:
// http://phplens.com/lens/php-book/optimizing-debugging-php.php
for ($i = 0, $max = sizeof($this->edits); $i < $max; $i++) {
$orig =& $this->edits[$i]->orig;
if (is_array($orig)) {
$orig = array_slice($from_lines, $xi, sizeof($orig));
$xi += sizeof($orig);
}
$final =& $this->edits[$i]->final;
if (is_array($final)) {
$final = array_slice($to_lines, $yi, sizeof($final));
$yi += sizeof($final);
}
}
}