dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge "Http::getProxy() method to get proxy configuration"
[lhc/web/wiklou.git]
/
includes
/
diff
/
DairikiDiff.php
diff --git
a/includes/diff/DairikiDiff.php
b/includes/diff/DairikiDiff.php
index
264c87f
..
6272e7e
100644
(file)
--- a/
includes/diff/DairikiDiff.php
+++ b/
includes/diff/DairikiDiff.php
@@
-26,7
+26,11
@@
*/
/**
*/
/**
- * @todo document
+ * The base class for all other DiffOp classes.
+ *
+ * The classes that extend DiffOp are: DiffOpCopy, DiffOpDelete, DiffOpAdd and
+ * DiffOpChange. FakeDiffOp also extends DiffOp, but it is not located in this file.
+ *
* @private
* @ingroup DifferenceEngine
*/
* @private
* @ingroup DifferenceEngine
*/
@@
-93,7
+97,9
@@
abstract class DiffOp {
}
/**
}
/**
- * @todo document
+ * Extends DiffOp. Used to mark strings that have been
+ * copied from one string array to the other.
+ *
* @private
* @ingroup DifferenceEngine
*/
* @private
* @ingroup DifferenceEngine
*/
@@
-117,7
+123,9
@@
class DiffOpCopy extends DiffOp {
}
/**
}
/**
- * @todo document
+ * Extends DiffOp. Used to mark strings that have been
+ * deleted from the first string array.
+ *
* @private
* @ingroup DifferenceEngine
*/
* @private
* @ingroup DifferenceEngine
*/
@@
-138,7
+146,9
@@
class DiffOpDelete extends DiffOp {
}
/**
}
/**
- * @todo document
+ * Extends DiffOp. Used to mark strings that have been
+ * added from the first string array.
+ *
* @private
* @ingroup DifferenceEngine
*/
* @private
* @ingroup DifferenceEngine
*/
@@
-159,7
+169,9
@@
class DiffOpAdd extends DiffOp {
}
/**
}
/**
- * @todo document
+ * Extends DiffOp. Used to mark strings that have been
+ * changed from the first string array (both added and subtracted).
+ *
* @private
* @ingroup DifferenceEngine
*/
* @private
* @ingroup DifferenceEngine
*/
@@
-208,10
+220,10
@@
class DiffEngine {
protected $xchanged, $ychanged;
protected $xchanged, $ychanged;
- protected $xv =
array(), $yv = array()
;
- protected $xind =
array(), $yind = array()
;
+ protected $xv =
[], $yv = []
;
+ protected $xind =
[], $yind = []
;
- protected $seq =
array(), $in_seq = array()
;
+ protected $seq =
[], $in_seq = []
;
protected $lcs = 0;
protected $lcs = 0;
@@
-234,14
+246,14
@@
class DiffEngine {
$n_from = count( $from_lines );
$n_to = count( $to_lines );
$n_from = count( $from_lines );
$n_to = count( $to_lines );
- $edits =
array()
;
+ $edits =
[]
;
$xi = $yi = 0;
while ( $xi < $n_from || $yi < $n_to ) {
$xi = $yi = 0;
while ( $xi < $n_from || $yi < $n_to ) {
- assert(
'$yi < $n_to || $this->xchanged[$xi]'
);
- assert(
'$xi < $n_from || $this->ychanged[$yi]'
);
+ assert(
$yi < $n_to || $this->xchanged[$xi]
);
+ assert(
$xi < $n_from || $this->ychanged[$yi]
);
// Skip matching "snake".
// Skip matching "snake".
- $copy =
array()
;
+ $copy =
[]
;
while ( $xi < $n_from && $yi < $n_to
&& !$this->xchanged[$xi] && !$this->ychanged[$yi]
) {
while ( $xi < $n_from && $yi < $n_to
&& !$this->xchanged[$xi] && !$this->ychanged[$yi]
) {
@@
-253,12
+265,12
@@
class DiffEngine {
}
// Find deletes & adds.
}
// Find deletes & adds.
- $delete =
array()
;
+ $delete =
[]
;
while ( $xi < $n_from && $this->xchanged[$xi] ) {
$delete[] = $from_lines[$xi++];
}
while ( $xi < $n_from && $this->xchanged[$xi] ) {
$delete[] = $from_lines[$xi++];
}
- $add =
array()
;
+ $add =
[]
;
while ( $yi < $n_to && $this->ychanged[$yi] ) {
$add[] = $to_lines[$yi++];
}
while ( $yi < $n_to && $this->ychanged[$yi] ) {
$add[] = $to_lines[$yi++];
}
@@
-293,12
+305,12
@@
class DiffEngine {
// old diff
$n_from = count( $from_lines );
$n_to = count( $to_lines );
// old diff
$n_from = count( $from_lines );
$n_to = count( $to_lines );
- $this->xchanged = $this->ychanged =
array()
;
- $this->xv = $this->yv =
array()
;
- $this->xind = $this->yind =
array()
;
-
unset( $this->seq )
;
-
unset( $this->in_seq )
;
-
unset( $this->lcs )
;
+ $this->xchanged = $this->ychanged =
[]
;
+ $this->xv = $this->yv =
[]
;
+ $this->xind = $this->yind =
[]
;
+
$this->seq = []
;
+
$this->in_seq = []
;
+
$this->lcs = 0
;
// Skip leading common lines.
for ( $skip = 0; $skip < $n_from && $skip < $n_to; $skip++ ) {
// Skip leading common lines.
for ( $skip = 0; $skip < $n_from && $skip < $n_to; $skip++ ) {
@@
-394,7
+406,7
@@
class DiffEngine {
// Things seems faster (I'm not sure I understand why)
// when the shortest sequence in X.
$flip = true;
// Things seems faster (I'm not sure I understand why)
// when the shortest sequence in X.
$flip = true;
- list( $xoff, $xlim, $yoff, $ylim ) =
array( $yoff, $ylim, $xoff, $xlim )
;
+ list( $xoff, $xlim, $yoff, $ylim ) =
[ $yoff, $ylim, $xoff, $xlim ]
;
}
if ( $flip ) {
}
if ( $flip ) {
@@
-409,8
+421,8
@@
class DiffEngine {
$this->lcs = 0;
$this->seq[0] = $yoff - 1;
$this->lcs = 0;
$this->seq[0] = $yoff - 1;
- $this->in_seq =
array()
;
- $ymids[0] =
array()
;
+ $this->in_seq =
[]
;
+ $ymids[0] =
[]
;
$numer = $xlim - $xoff + $nchunks - 1;
$x = $xoff;
$numer = $xlim - $xoff + $nchunks - 1;
$x = $xoff;
@@
-436,7
+448,7
@@
class DiffEngine {
while ( list( , $y ) = each( $matches ) ) {
if ( empty( $this->in_seq[$y] ) ) {
$k = $this->lcsPos( $y );
while ( list( , $y ) = each( $matches ) ) {
if ( empty( $this->in_seq[$y] ) ) {
$k = $this->lcsPos( $y );
- assert(
'$k > 0'
);
+ assert(
$k > 0
);
$ymids[$k] = $ymids[$k - 1];
break;
}
$ymids[$k] = $ymids[$k - 1];
break;
}
@@
-444,7
+456,7
@@
class DiffEngine {
while ( list( , $y ) = each( $matches ) ) {
if ( $y > $this->seq[$k - 1] ) {
while ( list( , $y ) = each( $matches ) ) {
if ( $y > $this->seq[$k - 1] ) {
- assert(
'$y < $this->seq[$k]'
);
+ assert(
$y < $this->seq[$k]
);
// Optimization: this is a common case:
// next match is just replacing previous match.
$this->in_seq[$this->seq[$k]] = false;
// Optimization: this is a common case:
// next match is just replacing previous match.
$this->in_seq[$this->seq[$k]] = false;
@@
-452,23
+464,23
@@
class DiffEngine {
$this->in_seq[$y] = 1;
} elseif ( empty( $this->in_seq[$y] ) ) {
$k = $this->lcsPos( $y );
$this->in_seq[$y] = 1;
} elseif ( empty( $this->in_seq[$y] ) ) {
$k = $this->lcsPos( $y );
- assert(
'$k > 0'
);
+ assert(
$k > 0
);
$ymids[$k] = $ymids[$k - 1];
}
}
}
}
$ymids[$k] = $ymids[$k - 1];
}
}
}
}
- $seps[] = $flip ?
array( $yoff, $xoff ) : array( $xoff, $yoff )
;
+ $seps[] = $flip ?
[ $yoff, $xoff ] : [ $xoff, $yoff ]
;
$ymid = $ymids[$this->lcs];
for ( $n = 0; $n < $nchunks - 1; $n++ ) {
$x1 = $xoff + (int)( ( $numer + ( $xlim - $xoff ) * $n ) / $nchunks );
$y1 = $ymid[$n] + 1;
$ymid = $ymids[$this->lcs];
for ( $n = 0; $n < $nchunks - 1; $n++ ) {
$x1 = $xoff + (int)( ( $numer + ( $xlim - $xoff ) * $n ) / $nchunks );
$y1 = $ymid[$n] + 1;
- $seps[] = $flip ?
array( $y1, $x1 ) : array( $x1, $y1 )
;
+ $seps[] = $flip ?
[ $y1, $x1 ] : [ $x1, $y1 ]
;
}
}
- $seps[] = $flip ?
array( $ylim, $xlim ) : array( $xlim, $ylim )
;
+ $seps[] = $flip ?
[ $ylim, $xlim ] : [ $xlim, $ylim ]
;
- return
array( $this->lcs, $seps )
;
+ return
[ $this->lcs, $seps ]
;
}
/**
}
/**
@@
-495,7
+507,7
@@
class DiffEngine {
}
}
}
}
- assert(
'$ypos != $this->seq[$end]'
);
+ assert(
$ypos != $this->seq[$end]
);
$this->in_seq[$this->seq[$end]] = false;
$this->seq[$end] = $ypos;
$this->in_seq[$this->seq[$end]] = false;
$this->seq[$end] = $ypos;
@@
-583,7
+595,7
@@
class DiffEngine {
$i = 0;
$j = 0;
$i = 0;
$j = 0;
- assert(
'count($lines) == count($changed)'
);
+ assert(
count( $lines ) == count( $changed )
);
$len = count( $lines );
$other_len = count( $other_changed );
$len = count( $lines );
$other_len = count( $other_changed );
@@
-604,7
+616,7
@@
class DiffEngine {
}
while ( $i < $len && !$changed[$i] ) {
}
while ( $i < $len && !$changed[$i] ) {
- assert(
'$j < $other_len && ! $other_changed[$j]'
);
+ assert(
$j < $other_len && ! $other_changed[$j]
);
$i++;
$j++;
while ( $j < $other_len && $other_changed[$j] ) {
$i++;
$j++;
while ( $j < $other_len && $other_changed[$j] ) {
@@
-641,11
+653,11
@@
class DiffEngine {
while ( $start > 0 && $changed[$start - 1] ) {
$start--;
}
while ( $start > 0 && $changed[$start - 1] ) {
$start--;
}
- assert(
'$j > 0'
);
+ assert(
$j > 0
);
while ( $other_changed[--$j] ) {
continue;
}
while ( $other_changed[--$j] ) {
continue;
}
- assert(
'$j >= 0 && !$other_changed[$j]'
);
+ assert(
$j >= 0 && !$other_changed[$j]
);
}
/*
}
/*
@@
-669,7
+681,7
@@
class DiffEngine {
$i++;
}
$i++;
}
- assert(
'$j < $other_len && ! $other_changed[$j]'
);
+ assert(
$j < $other_len && ! $other_changed[$j]
);
$j++;
if ( $j < $other_len && $other_changed[$j] ) {
$corresponding = $i;
$j++;
if ( $j < $other_len && $other_changed[$j] ) {
$corresponding = $i;
@@
-687,11
+699,11
@@
class DiffEngine {
while ( $corresponding < $i ) {
$changed[--$start] = 1;
$changed[--$i] = 0;
while ( $corresponding < $i ) {
$changed[--$start] = 1;
$changed[--$i] = 0;
- assert(
'$j > 0'
);
+ assert(
$j > 0
);
while ( $other_changed[--$j] ) {
continue;
}
while ( $other_changed[--$j] ) {
continue;
}
- assert(
'$j >= 0 && !$other_changed[$j]'
);
+ assert(
$j >= 0 && !$other_changed[$j]
);
}
}
}
}
}
}
@@
-743,7
+755,7
@@
class Diff {
*/
public function reverse() {
$rev = $this;
*/
public function reverse() {
$rev = $this;
- $rev->edits =
array()
;
+ $rev->edits =
[]
;
/** @var DiffOp $edit */
foreach ( $this->edits as $edit ) {
$rev->edits[] = $edit->reverse();
/** @var DiffOp $edit */
foreach ( $this->edits as $edit ) {
$rev->edits[] = $edit->reverse();
@@
-794,7
+806,7
@@
class Diff {
* @return string[] The original sequence of strings.
*/
public function orig() {
* @return string[] The original sequence of strings.
*/
public function orig() {
- $lines =
array()
;
+ $lines =
[]
;
foreach ( $this->edits as $edit ) {
if ( $edit->orig ) {
foreach ( $this->edits as $edit ) {
if ( $edit->orig ) {
@@
-814,7
+826,7
@@
class Diff {
* @return string[] The sequence of strings.
*/
public function closing() {
* @return string[] The sequence of strings.
*/
public function closing() {
- $lines =
array()
;
+ $lines =
[]
;
foreach ( $this->edits as $edit ) {
if ( $edit->closing ) {
foreach ( $this->edits as $edit ) {
if ( $edit->closing ) {
@@
-855,8
+867,8
@@
class MappedDiff extends Diff {
public function __construct( $from_lines, $to_lines,
$mapped_from_lines, $mapped_to_lines ) {
public function __construct( $from_lines, $to_lines,
$mapped_from_lines, $mapped_to_lines ) {
- assert(
'count( $from_lines ) == count( $mapped_from_lines )'
);
- assert(
'count( $to_lines ) == count( $mapped_to_lines )'
);
+ assert(
count( $from_lines ) == count( $mapped_from_lines )
);
+ assert(
count( $to_lines ) == count( $mapped_to_lines )
);
parent::__construct( $mapped_from_lines, $mapped_to_lines );
parent::__construct( $mapped_from_lines, $mapped_to_lines );
@@
-891,7
+903,7
@@
class HWLDFWordAccumulator {
public $insClass = ' class="diffchange diffchange-inline"';
public $delClass = ' class="diffchange diffchange-inline"';
public $insClass = ' class="diffchange diffchange-inline"';
public $delClass = ' class="diffchange diffchange-inline"';
- private $lines =
array()
;
+ private $lines =
[]
;
private $line = '';
private $group = '';
private $tag = '';
private $line = '';
private $group = '';
private $tag = '';
@@
-947,7
+959,7
@@
class HWLDFWordAccumulator {
$this->flushLine( $tag );
$word = substr( $word, 1 );
}
$this->flushLine( $tag );
$word = substr( $word, 1 );
}
- assert(
'!strstr( $word, "\n" )'
);
+ assert(
!strstr( $word, "\n" )
);
$this->group .= $word;
}
}
$this->group .= $word;
}
}
@@
-990,8
+1002,8
@@
class WordLevelDiff extends MappedDiff {
*/
private function split( $lines ) {
*/
private function split( $lines ) {
- $words =
array()
;
- $stripped =
array()
;
+ $words =
[]
;
+ $stripped =
[]
;
$first = true;
foreach ( $lines as $line ) {
# If the line is too long, just pretend the entire line is one big word
$first = true;
foreach ( $lines as $line ) {
# If the line is too long, just pretend the entire line is one big word
@@
-1006,7
+1018,7
@@
class WordLevelDiff extends MappedDiff {
$words[] = $line;
$stripped[] = $line;
} else {
$words[] = $line;
$stripped[] = $line;
} else {
- $m =
array()
;
+ $m =
[]
;
if ( preg_match_all( '/ ( [^\S\n]+ | [0-9_A-Za-z\x80-\xff]+ | . ) (?: (?!< \n) [^\S\n])? /xs',
$line, $m )
) {
if ( preg_match_all( '/ ( [^\S\n]+ | [0-9_A-Za-z\x80-\xff]+ | . ) (?: (?!< \n) [^\S\n])? /xs',
$line, $m )
) {
@@
-1020,7
+1032,7
@@
class WordLevelDiff extends MappedDiff {
}
}
}
}
- return
array( $words, $stripped )
;
+ return
[ $words, $stripped ]
;
}
/**
}
/**