本文整理匯總了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);
}
}
}