aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/diff/diff.php
diff options
context:
space:
mode:
authorstevendegroote <stevendegroote@gmail.com>2019-09-17 23:15:54 +0200
committerstevendegroote <stevendegroote@gmail.com>2019-09-17 23:15:54 +0200
commitf8967fec78d826ea8d9ca34f65966ff8a7674b47 (patch)
treef9c5f408e7764ec6343e084e7fc6d62d07e3400f /phpBB/includes/diff/diff.php
parentce93b224107a65b43253c36812b636321eb55a78 (diff)
parent4db585a4cb2e5359074a82ef088574609155294b (diff)
downloadforums-f8967fec78d826ea8d9ca34f65966ff8a7674b47.tar
forums-f8967fec78d826ea8d9ca34f65966ff8a7674b47.tar.gz
forums-f8967fec78d826ea8d9ca34f65966ff8a7674b47.tar.bz2
forums-f8967fec78d826ea8d9ca34f65966ff8a7674b47.tar.xz
forums-f8967fec78d826ea8d9ca34f65966ff8a7674b47.zip
Merge branch '3.2.x' into ticket/16159
Diffstat (limited to 'phpBB/includes/diff/diff.php')
-rw-r--r--phpBB/includes/diff/diff.php102
1 files changed, 51 insertions, 51 deletions
diff --git a/phpBB/includes/diff/diff.php b/phpBB/includes/diff/diff.php
index d307880c4b..d8ae9d77ac 100644
--- a/phpBB/includes/diff/diff.php
+++ b/phpBB/includes/diff/diff.php
@@ -50,7 +50,7 @@ class diff
* @param array &$to_content An array of strings.
* @param bool $preserve_cr If true, \r is replaced by a new line in the diff output
*/
- function diff(&$from_content, &$to_content, $preserve_cr = true)
+ function __construct(&$from_content, &$to_content, $preserve_cr = true)
{
$diff_engine = new diff_engine();
$this->_edits = $diff_engine->diff($from_content, $to_content, $preserve_cr);
@@ -75,7 +75,7 @@ class diff
{
$count = 0;
- for ($i = 0, $size = sizeof($this->_edits); $i < $size; $i++)
+ for ($i = 0, $size = count($this->_edits); $i < $size; $i++)
{
$edit = $this->_edits[$i];
@@ -98,7 +98,7 @@ class diff
{
$count = 0;
- for ($i = 0, $size = sizeof($this->_edits); $i < $size; $i++)
+ for ($i = 0, $size = count($this->_edits); $i < $size; $i++)
{
$edit = $this->_edits[$i];
@@ -136,7 +136,7 @@ class diff
$rev->_edits = array();
- for ($i = 0, $size = sizeof($this->_edits); $i < $size; $i++)
+ for ($i = 0, $size = count($this->_edits); $i < $size; $i++)
{
$edit = $this->_edits[$i];
$rev->_edits[] = $edit->reverse();
@@ -152,7 +152,7 @@ class diff
*/
function is_empty()
{
- for ($i = 0, $size = sizeof($this->_edits); $i < $size; $i++)
+ for ($i = 0, $size = count($this->_edits); $i < $size; $i++)
{
$edit = $this->_edits[$i];
@@ -168,8 +168,8 @@ class diff
$final = $edit->final;
// We can simplify one case where the array is usually supposed to be empty...
- if (sizeof($orig) == 1 && trim($orig[0]) === '') $orig = array();
- if (sizeof($final) == 1 && trim($final[0]) === '') $final = array();
+ if (count($orig) == 1 && trim($orig[0]) === '') $orig = array();
+ if (count($final) == 1 && trim($final[0]) === '') $final = array();
if (!$orig && !$final)
{
@@ -196,13 +196,13 @@ class diff
{
$lcs = 0;
- for ($i = 0, $size = sizeof($this->_edits); $i < $size; $i++)
+ for ($i = 0, $size = count($this->_edits); $i < $size; $i++)
{
$edit = $this->_edits[$i];
if (is_a($edit, 'diff_op_copy'))
{
- $lcs += sizeof($edit->orig);
+ $lcs += count($edit->orig);
}
}
return $lcs;
@@ -219,13 +219,13 @@ class diff
{
$lines = array();
- for ($i = 0, $size = sizeof($this->_edits); $i < $size; $i++)
+ for ($i = 0, $size = count($this->_edits); $i < $size; $i++)
{
$edit = $this->_edits[$i];
if ($edit->orig)
{
- array_splice($lines, sizeof($lines), 0, $edit->orig);
+ array_splice($lines, count($lines), 0, $edit->orig);
}
}
return $lines;
@@ -242,13 +242,13 @@ class diff
{
$lines = array();
- for ($i = 0, $size = sizeof($this->_edits); $i < $size; $i++)
+ for ($i = 0, $size = count($this->_edits); $i < $size; $i++)
{
$edit = $this->_edits[$i];
if ($edit->final)
{
- array_splice($lines, sizeof($lines), 0, $edit->final);
+ array_splice($lines, count($lines), 0, $edit->final);
}
}
return $lines;
@@ -296,7 +296,7 @@ class diff
$prevtype = null;
- for ($i = 0, $size = sizeof($this->_edits); $i < $size; $i++)
+ for ($i = 0, $size = count($this->_edits); $i < $size; $i++)
{
$edit = $this->_edits[$i];
@@ -330,30 +330,30 @@ class mapped_diff extends diff
* compared when computing the diff.
* @param array $mapped_to_lines This array should have the same number of elements as $to_lines.
*/
- function mapped_diff(&$from_lines, &$to_lines, &$mapped_from_lines, &$mapped_to_lines)
+ function __construct(&$from_lines, &$to_lines, &$mapped_from_lines, &$mapped_to_lines)
{
- if (sizeof($from_lines) != sizeof($mapped_from_lines) || sizeof($to_lines) != sizeof($mapped_to_lines))
+ if (count($from_lines) != count($mapped_from_lines) || count($to_lines) != count($mapped_to_lines))
{
return false;
}
- parent::diff($mapped_from_lines, $mapped_to_lines);
+ parent::__construct($mapped_from_lines, $mapped_to_lines);
$xi = $yi = 0;
- for ($i = 0; $i < sizeof($this->_edits); $i++)
+ for ($i = 0; $i < count($this->_edits); $i++)
{
$orig = &$this->_edits[$i]->orig;
if (is_array($orig))
{
- $orig = array_slice($from_lines, $xi, sizeof($orig));
- $xi += sizeof($orig);
+ $orig = array_slice($from_lines, $xi, count($orig));
+ $xi += count($orig);
}
$final = &$this->_edits[$i]->final;
if (is_array($final))
{
- $final = array_slice($to_lines, $yi, sizeof($final));
- $yi += sizeof($final);
+ $final = array_slice($to_lines, $yi, count($final));
+ $yi += count($final);
}
}
}
@@ -377,12 +377,12 @@ class diff_op
function norig()
{
- return ($this->orig) ? sizeof($this->orig) : 0;
+ return ($this->orig) ? count($this->orig) : 0;
}
function nfinal()
{
- return ($this->final) ? sizeof($this->final) : 0;
+ return ($this->final) ? count($this->final) : 0;
}
}
@@ -394,7 +394,7 @@ class diff_op
*/
class diff_op_copy extends diff_op
{
- function diff_op_copy($orig, $final = false)
+ function __construct($orig, $final = false)
{
if (!is_array($final))
{
@@ -419,7 +419,7 @@ class diff_op_copy extends diff_op
*/
class diff_op_delete extends diff_op
{
- function diff_op_delete($lines)
+ function __construct($lines)
{
$this->orig = $lines;
$this->final = false;
@@ -440,7 +440,7 @@ class diff_op_delete extends diff_op
*/
class diff_op_add extends diff_op
{
- function diff_op_add($lines)
+ function __construct($lines)
{
$this->final = $lines;
$this->orig = false;
@@ -461,7 +461,7 @@ class diff_op_add extends diff_op
*/
class diff_op_change extends diff_op
{
- function diff_op_change($orig, $final)
+ function __construct($orig, $final)
{
$this->orig = $orig;
$this->final = $final;
@@ -498,7 +498,7 @@ class diff3 extends diff
* @param bool $preserve_cr If true, \r\n and bare \r are replaced by a new line
* in the diff output
*/
- function diff3(&$orig, &$final1, &$final2, $preserve_cr = true)
+ function __construct(&$orig, &$final1, &$final2, $preserve_cr = true)
{
$diff_engine = new diff_engine();
@@ -517,7 +517,7 @@ class diff3 extends diff
{
$conflicts = 0;
- for ($i = 0, $size = sizeof($this->_edits); $i < $size; $i++)
+ for ($i = 0, $size = count($this->_edits); $i < $size; $i++)
{
$edit = $this->_edits[$i];
@@ -550,7 +550,7 @@ class diff3 extends diff
$lines = array();
- for ($i = 0, $size = sizeof($this->_edits); $i < $size; $i++)
+ for ($i = 0, $size = count($this->_edits); $i < $size; $i++)
{
$edit = $this->_edits[$i];
@@ -590,7 +590,7 @@ class diff3 extends diff
{
$lines = array();
- for ($i = 0, $size = sizeof($this->_edits); $i < $size; $i++)
+ for ($i = 0, $size = count($this->_edits); $i < $size; $i++)
{
$edit = $this->_edits[$i];
@@ -614,7 +614,7 @@ class diff3 extends diff
{
$lines = array();
- for ($i = 0, $size = sizeof($this->_edits); $i < $size; $i++)
+ for ($i = 0, $size = count($this->_edits); $i < $size; $i++)
{
$edit = $this->_edits[$i];
@@ -638,7 +638,7 @@ class diff3 extends diff
{
$conflicts = array();
- for ($i = 0, $size = sizeof($this->_edits); $i < $size; $i++)
+ for ($i = 0, $size = count($this->_edits); $i < $size; $i++)
{
$edit = $this->_edits[$i];
@@ -754,7 +754,7 @@ class diff3 extends diff
*/
class diff3_op
{
- function diff3_op($orig = false, $final1 = false, $final2 = false)
+ function __construct($orig = false, $final1 = false, $final2 = false)
{
$this->orig = $orig ? $orig : array();
$this->final1 = $final1 ? $final1 : array();
@@ -803,9 +803,9 @@ class diff3_op
function solve_prepare()
{
// We can simplify one case where the array is usually supposed to be empty...
- if (sizeof($this->orig) == 1 && trim($this->orig[0]) === '') $this->orig = array();
- if (sizeof($this->final1) == 1 && trim($this->final1[0]) === '') $this->final1 = array();
- if (sizeof($this->final2) == 1 && trim($this->final2[0]) === '') $this->final2 = array();
+ if (count($this->orig) == 1 && trim($this->orig[0]) === '') $this->orig = array();
+ if (count($this->final1) == 1 && trim($this->final1[0]) === '') $this->final1 = array();
+ if (count($this->final2) == 1 && trim($this->final2[0]) === '') $this->final2 = array();
// Now we only can have the case where the only difference between arrays are newlines, so compare all cases
@@ -848,10 +848,10 @@ class diff3_op
$_final1 = &$this->$final1;
// Ok, we basically search for $orig in $final1
- $compare_seq = sizeof($_orig);
+ $compare_seq = count($_orig);
// Go through the conflict code
- for ($i = 0, $j = 0, $size = sizeof($_final1); $i < $size; $i++, $j = $i)
+ for ($i = 0, $j = 0, $size = count($_final1); $i < $size; $i++, $j = $i)
{
$line = $_final1[$i];
$skip = 0;
@@ -895,7 +895,7 @@ class diff3_op
// CASE ONE: orig changed into final2, but modified/unknown code in final1.
// IF orig is found "as is" in final1 we replace the code directly in final1 and populate this as final2/merge
- if (sizeof($this->orig) && sizeof($this->final2))
+ if (count($this->orig) && count($this->final2))
{
$result = $this->_compare_conflict_seq('orig', 'final1', 'final2');
@@ -915,7 +915,7 @@ class diff3_op
}
// Try to solve $Id$ issues. ;)
- if (sizeof($this->orig) == 1 && sizeof($this->final1) == 1 && sizeof($this->final2) == 1)
+ if (count($this->orig) == 1 && count($this->final1) == 1 && count($this->final2) == 1)
{
$match = '#^' . preg_quote('* @version $Id: ', '#') . '[a-z\._\- ]+[0-9]+ [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9\:Z]+ [a-z0-9_\- ]+\$$#';
@@ -939,9 +939,9 @@ class diff3_op
}
// The same is true for a line at the end. ;)
- if (sizeof($this->orig) && sizeof($this->final2) && sizeof($this->orig) === sizeof($this->final2) && trim($this->orig[sizeof($this->orig)-1]) === '' && trim($this->final2[sizeof($this->final2)-1]) === '')
+ if (count($this->orig) && count($this->final2) && count($this->orig) === count($this->final2) && trim($this->orig[count($this->orig)-1]) === '' && trim($this->final2[count($this->final2)-1]) === '')
{
- unset($this->orig[sizeof($this->orig)-1], $this->final2[sizeof($this->final2)-1]);
+ unset($this->orig[count($this->orig)-1], $this->final2[count($this->final2)-1]);
$this->orig = array_values($this->orig);
$this->final2 = array_values($this->final2);
@@ -972,7 +972,7 @@ class diff3_op
}
// CASE TWO: Added lines from orig to final2 but final1 had added lines too. Just merge them.
- if (!sizeof($this->orig) && $this->final1 !== $this->final2 && sizeof($this->final1) && sizeof($this->final2))
+ if (!count($this->orig) && $this->final1 !== $this->final2 && count($this->final1) && count($this->final2))
{
$result = $this->_compare_conflict_seq('final2', 'final1');
@@ -1001,7 +1001,7 @@ class diff3_op
}
// CASE THREE: Removed lines (orig has the to-remove line(s), but final1 has additional lines which does not need to be removed). Just remove orig from final1 and then use final1 as final2/merge
- if (!sizeof($this->final2) && sizeof($this->orig) && sizeof($this->final1) && $this->orig !== $this->final1)
+ if (!count($this->final2) && count($this->orig) && count($this->final1) && $this->orig !== $this->final1)
{
$result = $this->_compare_conflict_seq('orig', 'final1');
@@ -1011,11 +1011,11 @@ class diff3_op
}
// First of all, try to find the code in orig in final1. ;)
- $compare_seq = sizeof($this->orig);
+ $compare_seq = count($this->orig);
$begin = $end = -1;
$j = 0;
- for ($i = 0, $size = sizeof($this->final1); $i < $size; $i++)
+ for ($i = 0, $size = count($this->final1); $i < $size; $i++)
{
$line = $this->final1[$i];
@@ -1066,7 +1066,7 @@ class diff3_op
*/
class diff3_op_copy extends diff3_op
{
- function diff3_op_copy($lines = false)
+ function __construct($lines = false)
{
$this->orig = $lines ? $lines : array();
$this->final1 = &$this->orig;
@@ -1092,7 +1092,7 @@ class diff3_op_copy extends diff3_op
*/
class diff3_block_builder
{
- function diff3_block_builder()
+ function __construct()
{
$this->_init();
}
@@ -1147,6 +1147,6 @@ class diff3_block_builder
function _append(&$array, $lines)
{
- array_splice($array, sizeof($array), 0, $lines);
+ array_splice($array, count($array), 0, $lines);
}
}