diff options
author | Derky <derky@phpbb.com> | 2018-01-04 21:20:46 +0100 |
---|---|---|
committer | Derky <derky@phpbb.com> | 2018-01-04 21:20:46 +0100 |
commit | 2fcb8ab87fb30c57b106695859c2661fc3cc2837 (patch) | |
tree | 4e2a1437ff2cc9b3ca742716047660bf0367c824 /phpBB/includes/diff | |
parent | 0ff5f9fa0edf9ac3125cc4e871609a90cee1cfac (diff) | |
parent | c1ec6517bfe0f080ad052e727073794583464bfb (diff) | |
download | forums-2fcb8ab87fb30c57b106695859c2661fc3cc2837.tar forums-2fcb8ab87fb30c57b106695859c2661fc3cc2837.tar.gz forums-2fcb8ab87fb30c57b106695859c2661fc3cc2837.tar.bz2 forums-2fcb8ab87fb30c57b106695859c2661fc3cc2837.tar.xz forums-2fcb8ab87fb30c57b106695859c2661fc3cc2837.zip |
Merge pull request #5069 from marc1706/ticket/14972-rhea
[ticket/14972] Backport for PHP 7.2 compatibility
Diffstat (limited to 'phpBB/includes/diff')
-rw-r--r-- | phpBB/includes/diff/diff.php | 80 | ||||
-rw-r--r-- | phpBB/includes/diff/engine.php | 10 | ||||
-rw-r--r-- | phpBB/includes/diff/renderer.php | 24 |
3 files changed, 57 insertions, 57 deletions
diff --git a/phpBB/includes/diff/diff.php b/phpBB/includes/diff/diff.php index d307880c4b..68c6c6e6a8 100644 --- a/phpBB/includes/diff/diff.php +++ b/phpBB/includes/diff/diff.php @@ -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]; @@ -332,7 +332,7 @@ class mapped_diff extends diff */ function mapped_diff(&$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; } @@ -340,20 +340,20 @@ class mapped_diff extends diff parent::diff($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; } } @@ -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]; @@ -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]; @@ -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..c12ff3b7d5 100644 --- a/phpBB/includes/diff/renderer.php +++ b/phpBB/includes/diff/renderer.php @@ -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) |