aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/diff
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes/diff')
-rw-r--r--phpBB/includes/diff/diff.php102
-rw-r--r--phpBB/includes/diff/engine.php10
-rw-r--r--phpBB/includes/diff/renderer.php26
3 files changed, 69 insertions, 69 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);
}
}
diff --git a/phpBB/includes/diff/engine.php b/phpBB/includes/diff/engine.php
index bc21b3b9ba..757fdadde9 100644
--- a/phpBB/includes/diff/engine.php
+++ b/phpBB/includes/diff/engine.php
@@ -84,8 +84,8 @@ class diff_engine
$to_lines = explode("\n", preg_replace('#[\n\r]+#', "\n", $to_lines));
}
- $n_from = sizeof($from_lines);
- $n_to = sizeof($to_lines);
+ $n_from = count($from_lines);
+ $n_to = count($to_lines);
$this->xchanged = $this->ychanged = $this->xv = $this->yv = $this->xind = $this->yind = array();
unset($this->seq, $this->in_seq, $this->lcs);
@@ -145,7 +145,7 @@ class diff_engine
}
// Find the LCS.
- $this->_compareseq(0, sizeof($this->xv), 0, sizeof($this->yv));
+ $this->_compareseq(0, count($this->xv), 0, count($this->yv));
// Merge edits when possible.
if ($this->skip_whitespace_changes)
@@ -444,8 +444,8 @@ class diff_engine
$i = 0;
$j = 0;
- $len = sizeof($lines);
- $other_len = sizeof($other_changed);
+ $len = count($lines);
+ $other_len = count($other_changed);
while (1)
{
diff --git a/phpBB/includes/diff/renderer.php b/phpBB/includes/diff/renderer.php
index 6b7f07cf9c..8a8b0c295e 100644
--- a/phpBB/includes/diff/renderer.php
+++ b/phpBB/includes/diff/renderer.php
@@ -56,7 +56,7 @@ class diff_renderer
/**
* Constructor.
*/
- function diff_renderer($params = array())
+ function __construct($params = array())
{
foreach ($params as $param => $value)
{
@@ -128,8 +128,8 @@ class diff_renderer
if (is_array($block))
{
// How many lines to keep as context from the copy block.
- $keep = ($i == sizeof($diffs) - 1) ? $ntrail : $nlead + $ntrail;
- if (sizeof($edit->orig) <= $keep)
+ $keep = ($i == count($diffs) - 1) ? $ntrail : $nlead + $ntrail;
+ if (count($edit->orig) <= $keep)
{
// We have less lines in the block than we want for context => keep the whole block.
$block[] = $edit;
@@ -156,9 +156,9 @@ class diff_renderer
if (!is_array($block))
{
// Extract context lines from the preceding copy block.
- $context = array_slice($context, sizeof($context) - $nlead);
- $x0 = $xi - sizeof($context);
- $y0 = $yi - sizeof($context);
+ $context = array_slice($context, count($context) - $nlead);
+ $x0 = $xi - count($context);
+ $y0 = $yi - count($context);
$block = array();
if ($context)
@@ -169,8 +169,8 @@ class diff_renderer
$block[] = $edit;
}
- $xi += ($edit->orig) ? sizeof($edit->orig) : 0;
- $yi += ($edit->final) ? sizeof($edit->final) : 0;
+ $xi += ($edit->orig) ? count($edit->orig) : 0;
+ $yi += ($edit->final) ? count($edit->final) : 0;
}
if (is_array($block))
@@ -433,7 +433,7 @@ class diff_renderer_inline extends diff_renderer
{
array_walk($lines, array(&$this, '_encode'));
$lines[0] = $this->_ins_prefix . $lines[0];
- $lines[sizeof($lines) - 1] .= $this->_ins_suffix;
+ $lines[count($lines) - 1] .= $this->_ins_suffix;
return $this->_lines($lines, ' ', false);
}
@@ -441,7 +441,7 @@ class diff_renderer_inline extends diff_renderer
{
array_walk($lines, array(&$this, '_encode'));
$lines[0] = $this->_del_prefix . $lines[0];
- $lines[sizeof($lines) - 1] .= $this->_del_suffix;
+ $lines[count($lines) - 1] .= $this->_del_suffix;
return $this->_lines($lines, ' ', false);
}
@@ -617,7 +617,7 @@ class diff_renderer_side_by_side extends diff_renderer
$this->render($diff);
// Is the diff empty?
- if (!sizeof($this->lines))
+ if (!count($this->lines))
{
$output .= '<tr><th colspan="2">' . $user->lang['NO_VISIBLE_CHANGES'] . '</th></tr>';
}
@@ -672,8 +672,8 @@ class diff_renderer_side_by_side extends diff_renderer
case 'change':
// Pop the old/new stacks one by one, until both are empty.
- $oldsize = sizeof($change['old']);
- $newsize = sizeof($change['new']);
+ $oldsize = count($change['old']);
+ $newsize = count($change['new']);
$left = $right = '';
for ($row = 0, $row_max = max($oldsize, $newsize); $row < $row_max; ++$row)