From dd5c3e2b276985d3cf00e75dcb4fe8b3e6e71d5f Mon Sep 17 00:00:00 2001 From: Phy <git@phy25.com> Date: Wed, 20 Dec 2017 20:20:20 +0800 Subject: [PATCH] remove deprecated each calls in libraries --- inc/DifferenceEngine.php | 48 +++++++++++++++++++++------------------- inc/JpegMeta.php | 8 +++---- 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/inc/DifferenceEngine.php b/inc/DifferenceEngine.php index 37b55e10d..933e0c1ee 100644 --- a/inc/DifferenceEngine.php +++ b/inc/DifferenceEngine.php @@ -270,27 +270,29 @@ class _DiffEngine { if (empty($ymatches[$line])) continue; $matches = $ymatches[$line]; - reset($matches); - while (list ($junk, $y) = each($matches)) - if (empty($this->in_seq[$y])) { - $k = $this->_lcs_pos($y); - USE_ASSERTS && assert($k > 0); - $ymids[$k] = $ymids[$k-1]; - break; - } - while (list ($junk, $y) = each($matches)) { - if ($y > $this->seq[$k-1]) { - USE_ASSERTS && 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; - $this->seq[$k] = $y; - $this->in_seq[$y] = 1; - } - else if (empty($this->in_seq[$y])) { - $k = $this->_lcs_pos($y); - USE_ASSERTS && assert($k > 0); - $ymids[$k] = $ymids[$k-1]; + $switch = false; + foreach ($matches as $y) { + if(!$switch) { + if (empty($this->in_seq[$y])) { + $k = $this->_lcs_pos($y); + USE_ASSERTS && assert($k > 0); + $ymids[$k] = $ymids[$k-1]; + $switch = true; + } + }else{ + if ($y > $this->seq[$k-1]) { + USE_ASSERTS && 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; + $this->seq[$k] = $y; + $this->in_seq[$y] = 1; + } + else if (empty($this->in_seq[$y])) { + $k = $this->_lcs_pos($y); + USE_ASSERTS && assert($k > 0); + $ymids[$k] = $ymids[$k-1]; + } } } } @@ -876,10 +878,10 @@ class DiffFormatter { /** * Escape string - * + * * Override this method within other formatters if escaping required. * Base class requires $str to be returned WITHOUT escaping. - * + * * @param $str string Text string to escape * @return string The escaped string. */ diff --git a/inc/JpegMeta.php b/inc/JpegMeta.php index d667ce303..94c276cfa 100644 --- a/inc/JpegMeta.php +++ b/inc/JpegMeta.php @@ -2522,13 +2522,13 @@ class JpegMeta { $pos = 14; reset($this->_info['adobe']['raw']); - while (list($key) = each($this->_info['adobe']['raw'])) { + foreach ($this->_info['adobe']['raw'] as $value){ $pos = $this->_write8BIM( $data, $pos, - $this->_info['adobe']['raw'][$key]['type'], - $this->_info['adobe']['raw'][$key]['header'], - $this->_info['adobe']['raw'][$key]['data'] ); + $value['type'], + $value['header'], + $value['data'] ); } } -- GitLab