Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bbf0683

Browse filesBrowse files
committed
External Libraries: Update the Text_Diff_Engine_native class for PHP 7.2 compatibility.
This removes usage of `each()` and usage of text strings passed to `assert()`. Props bor0 Fixes #41526 git-svn-id: https://develop.svn.wordpress.org/trunk@41633 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 345aac8 commit bbf0683
Copy full SHA for bbf0683

File tree

Expand file treeCollapse file tree

1 file changed

+11
-21
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+11
-21
lines changed
Open diff view settings
Collapse file

‎src/wp-includes/Text/Diff/Engine/native.php‎

Copy file name to clipboardExpand all lines: src/wp-includes/Text/Diff/Engine/native.php
+11-21Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
* Geoffrey T. Dairiki <dairiki@dairiki.org>. The original PHP version of this
1919
* code was written by him, and is used/adapted with his permission.
2020
*
21-
* Copyright 2004-2010 The Horde Project (http://www.horde.org/)
21+
* Copyright 2004-2017 Horde LLC (http://www.horde.org/)
2222
*
2323
* See the enclosed file COPYING for license information (LGPL). If you did
24-
* not receive this file, see http://opensource.org/licenses/lgpl-license.php.
24+
* not receive this file, see http://www.horde.org/licenses/lgpl21.
2525
*
2626
* @author Geoffrey T. Dairiki <dairiki@dairiki.org>
2727
* @package Text_Diff
@@ -189,27 +189,17 @@ function _diag ($xoff, $xlim, $yoff, $ylim, $nchunks)
189189
continue;
190190
}
191191
$matches = $ymatches[$line];
192-
reset($matches);
193-
while (list(, $y) = each($matches)) {
192+
foreach ($matches as $y) {
194193
if (empty($this->in_seq[$y])) {
195194
$k = $this->_lcsPos($y);
196195
assert($k > 0);
197196
$ymids[$k] = $ymids[$k - 1];
198197
break;
199-
}
200-
}
201-
while (list(, $y) = each($matches)) {
202-
if ($y > $this->seq[$k - 1]) {
198+
} elseif ($y > $this->seq[$k - 1]) {
203199
assert($y <= $this->seq[$k]);
204-
/* Optimization: this is a common case: next match is
205-
* just replacing previous match. */
206200
$this->in_seq[$this->seq[$k]] = false;
207201
$this->seq[$k] = $y;
208202
$this->in_seq[$y] = 1;
209-
} elseif (empty($this->in_seq[$y])) {
210-
$k = $this->_lcsPos($y);
211-
assert($k > 0);
212-
$ymids[$k] = $ymids[$k - 1];
213203
}
214204
}
215205
}
@@ -330,7 +320,7 @@ function _shiftBoundaries($lines, &$changed, $other_changed)
330320
$i = 0;
331321
$j = 0;
332322

333-
assert('count($lines) == count($changed)');
323+
assert(count($lines) == count($changed));
334324
$len = count($lines);
335325
$other_len = count($other_changed);
336326

@@ -351,7 +341,7 @@ function _shiftBoundaries($lines, &$changed, $other_changed)
351341
}
352342

353343
while ($i < $len && ! $changed[$i]) {
354-
assert('$j < $other_len && ! $other_changed[$j]');
344+
assert($j < $other_len && ! $other_changed[$j]);
355345
$i++; $j++;
356346
while ($j < $other_len && $other_changed[$j]) {
357347
$j++;
@@ -383,11 +373,11 @@ function _shiftBoundaries($lines, &$changed, $other_changed)
383373
while ($start > 0 && $changed[$start - 1]) {
384374
$start--;
385375
}
386-
assert('$j > 0');
376+
assert($j > 0);
387377
while ($other_changed[--$j]) {
388378
continue;
389379
}
390-
assert('$j >= 0 && !$other_changed[$j]');
380+
assert($j >= 0 && !$other_changed[$j]);
391381
}
392382

393383
/* Set CORRESPONDING to the end of the changed run, at the
@@ -408,7 +398,7 @@ function _shiftBoundaries($lines, &$changed, $other_changed)
408398
$i++;
409399
}
410400

411-
assert('$j < $other_len && ! $other_changed[$j]');
401+
assert($j < $other_len && ! $other_changed[$j]);
412402
$j++;
413403
if ($j < $other_len && $other_changed[$j]) {
414404
$corresponding = $i;
@@ -424,11 +414,11 @@ function _shiftBoundaries($lines, &$changed, $other_changed)
424414
while ($corresponding < $i) {
425415
$changed[--$start] = 1;
426416
$changed[--$i] = 0;
427-
assert('$j > 0');
417+
assert($j > 0);
428418
while ($other_changed[--$j]) {
429419
continue;
430420
}
431-
assert('$j >= 0 && !$other_changed[$j]');
421+
assert($j >= 0 && !$other_changed[$j]);
432422
}
433423
}
434424
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.