From 9e491c01d53eac3e0a00f6e24c1da056a9ed97e2 Mon Sep 17 00:00:00 2001
From: Andreas Gohr <andi@splitbrain.org>
Date: Fri, 12 May 2017 19:25:31 +0200
Subject: [PATCH] replaced some more each calls

There are still some left in the DifferenceEngine code
---
 inc/JpegMeta.php          | 11 ++++-------
 inc/feedcreator.class.php |  2 +-
 inc/html.php              |  3 +--
 inc/parser/handler.php    | 12 +++++++++---
 4 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/inc/JpegMeta.php b/inc/JpegMeta.php
index ca59eb05f..d667ce303 100644
--- a/inc/JpegMeta.php
+++ b/inc/JpegMeta.php
@@ -2037,8 +2037,7 @@ class JpegMeta {
         $ifdEntries = array();
         $entryCount = 0;
 
-        reset($EXIFNames);
-        while (list($tag, $name) = each($EXIFNames)) {
+        foreach($EXIFNames as $tag => $name) {
             $type = $EXIFTypeInfo[$tag][0];
             $count = $EXIFTypeInfo[$tag][1];
             $value = null;
@@ -2578,9 +2577,7 @@ class JpegMeta {
 
         $IPTCNames =& $this->_iptcNameTags();
 
-        reset($this->_info['iptc']);
-
-        while (list($label) = each($this->_info['iptc'])) {
+        foreach($this->_info['iptc'] as $label => $value) {
             $value =& $this->_info['iptc'][$label];
             $type = -1;
 
@@ -2969,8 +2966,8 @@ class JpegMeta {
     /*************************************************************/
     function _names2Tags($tags2Names) {
         $names2Tags = array();
-        reset($tags2Names);
-        while (list($tag, $name) = each($tags2Names)) {
+
+        foreach($tags2Names as $tag => $name) {
             $names2Tags[$name] = $tag;
         }
 
diff --git a/inc/feedcreator.class.php b/inc/feedcreator.class.php
index fe444b39b..926bdc8db 100644
--- a/inc/feedcreator.class.php
+++ b/inc/feedcreator.class.php
@@ -1315,7 +1315,7 @@ class MBOXCreator extends FeedCreator {
         $eol = "\r\n";
         $escape = "=";
         $output = "";
-        while( list(, $line) = each($lines) ) {
+        foreach($lines as $line) {
             //$line = rtrim($line); // remove trailing white space -> no =20\r\n necessary
             $linlen = strlen($line);
             $newline = "";
diff --git a/inc/html.php b/inc/html.php
index 70ba4dcfe..2897d01c1 100644
--- a/inc/html.php
+++ b/inc/html.php
@@ -208,8 +208,7 @@ function html_btn($name, $id, $akey, $params, $method='get', $tooltip='', $label
     $ret .= '<form class="button btn_'.$name.'" method="'.$method.'" action="'.$script.'"><div class="no">';
 
     if(is_array($params)){
-        reset($params);
-        while (list($key, $val) = each($params)) {
+        foreach($params as $key => $val) {
             $ret .= '<input type="hidden" name="'.$key.'" ';
             $ret .= 'value="'.htmlspecialchars($val).'" />';
         }
diff --git a/inc/parser/handler.php b/inc/parser/handler.php
index 02d2e6689..e31bf05cd 100644
--- a/inc/parser/handler.php
+++ b/inc/parser/handler.php
@@ -57,10 +57,16 @@ class Doku_Handler {
         array_push($this->calls,array('document_end',array(),$last_call[2]));
     }
 
+    /**
+     * fetch the current call and advance the pointer to the next one
+     *
+     * @return bool|mixed
+     */
     function fetch() {
-        $call = each($this->calls);
-        if ( $call ) {
-            return $call['value'];
+        $call = current($this->calls);
+        if($call !== false) {
+            next($this->calls); //advance the pointer
+            return $call;
         }
         return false;
     }
-- 
GitLab