Remove usages of 'each', as it is deprecated in php 7.2
authorgggeek <giunta.gaetano@gmail.com>
Sun, 3 Sep 2017 19:11:32 +0000 (20:11 +0100)
committergggeek <giunta.gaetano@gmail.com>
Sun, 3 Sep 2017 19:11:32 +0000 (20:11 +0100)
demo/server/server.php
lib/xmlrpc.inc
src/Encoder.php
src/Helper/Http.php
src/Value.php
tests/3LocalhostTest.php

index b18cf46..1af2554 100644 (file)
@@ -351,7 +351,7 @@ function ageSorter($req)
     // hack, must make global as uksort() won't
     // allow us to pass any other auxiliary information
     uksort($agesorter_arr, 'agesorter_compare');
-    while (list($key, $val) = each($agesorter_arr)) {
+    foreach($agesorter_arr as $key => $val) {
         // recreate each struct element
         $v[] = new Value(
             array(
index 28b47d3..74ff080 100644 (file)
@@ -92,8 +92,8 @@ class xmlrpcval extends PhpXmlRpc\Value
         //if (is_object($o) && (get_class($o) == 'xmlrpcval' || is_subclass_of($o, 'xmlrpcval')))
         //{
         $ar = $o->me;
-        reset($ar);
-        list($typ, $val) = each($ar);
+        $val = reset($ar);
+        $typ = key($ar);
 
         return '<value>' . $this->serializedata($typ, $val) . "</value>\n";
         //}
@@ -106,16 +106,15 @@ class xmlrpcval extends PhpXmlRpc\Value
     public function getval()
     {
         // UNSTABLE
-        reset($this->me);
-        list($a, $b) = each($this->me);
+        $b = reset($this->me);
+        $a = key($this->me);
         // contributed by I Sofer, 2001-03-24
         // add support for nested arrays to scalarval
         // i've created a new method here, so as to
         // preserve back compatibility
 
         if (is_array($b)) {
-            @reset($b);
-            while (list($id, $cont) = @each($b)) {
+            foreach($b as $id => $cont) {
                 $b[$id] = $cont->scalarval();
             }
         }
@@ -123,12 +122,10 @@ class xmlrpcval extends PhpXmlRpc\Value
         // add support for structures directly encoding php objects
         if (is_object($b)) {
             $t = get_object_vars($b);
-            @reset($t);
-            while (list($id, $cont) = @each($t)) {
+            foreach($t as $id => $cont) { {
                 $t[$id] = $cont->scalarval();
             }
-            @reset($t);
-            while (list($id, $cont) = @each($t)) {
+            foreach($t as $id => $cont) {
                 @$b->$id = $cont;
             }
         }
index dfec15d..735c3ed 100644 (file)
@@ -36,8 +36,8 @@ class Encoder
         switch ($xmlrpcVal->kindOf()) {
             case 'scalar':
                 if (in_array('extension_api', $options)) {
-                    reset($xmlrpcVal->me);
-                    list($typ, $val) = each($xmlrpcVal->me);
+                    $val = reset($xmlrpcVal->me);
+                    $typ = key($xmlrpcVal->me);
                     switch ($typ) {
                         case 'dateTime.iso8601':
                             $xmlrpcVal->scalar = $val;
@@ -183,8 +183,7 @@ class Encoder
                     $xmlrpcVal = new Value($phpVal->format('Ymd\TH:i:s'), Value::$xmlrpcStruct);
                 } else {
                     $arr = array();
-                    reset($phpVal);
-                    while (list($k, $v) = each($phpVal)) {
+                    foreach($phpVal as $k => $v) {
                         $arr[$k] = $this->encode($v, $options);
                     }
                     $xmlrpcVal = new Value($arr, Value::$xmlrpcStruct);
index 2faf583..03a1ab6 100644 (file)
@@ -133,7 +133,7 @@ class Http
         }
         // be tolerant to line endings, and extra empty lines
         $ar = preg_split("/\r?\n/", trim(substr($data, 0, $pos)));
-        while (list(, $line) = @each($ar)) {
+        foreach($ar as $line) {
             // take care of multi-line headers and cookies
             $arr = explode(':', $line, 2);
             if (count($arr) > 1) {
index 97852b0..8747e69 100644 (file)
@@ -329,8 +329,8 @@ class Value implements \Countable, \IteratorAggregate, \ArrayAccess
      */
     public function serialize($charsetEncoding = '')
     {
-        reset($this->me);
-        list($typ, $val) = each($this->me);
+        $val = reset($this->me);
+        $typ = key($this->me);
 
         return '<value>' . $this->serializedata($typ, $val, $charsetEncoding) . "</value>\n";
     }
@@ -394,8 +394,7 @@ class Value implements \Countable, \IteratorAggregate, \ArrayAccess
      */
     public function scalarval()
     {
-        reset($this->me);
-        list(, $b) = each($this->me);
+        $b = reset($this->me);
 
         return $b;
     }
@@ -410,7 +409,7 @@ class Value implements \Countable, \IteratorAggregate, \ArrayAccess
     public function scalartyp()
     {
         reset($this->me);
-        list($a,) = each($this->me);
+        $a = key($this->me);
         if ($a == static::$xmlrpcI4) {
             $a = static::$xmlrpcInt;
         }
@@ -525,7 +524,7 @@ class Value implements \Countable, \IteratorAggregate, \ArrayAccess
             case 1:
 // todo: handle i4 vs int
                 reset($this->me);
-                list($type,) = each($this->me);
+                $type = key($this->me);
                 if ($type != $offset) {
                     throw new \Exception('');
                 }
@@ -575,8 +574,8 @@ class Value implements \Countable, \IteratorAggregate, \ArrayAccess
                 return isset($this->me['array'][$offset]) ? $this->me['array'][$offset] : null;
             case 1:
 // on bad type: null or exception?
-                reset($this->me);
-                list($type, $value) = each($this->me);
+                $value = reset($this->me);
+                $type = key($this->me);
                 return $type == $offset ? $value : null;
             default:
 // return null or exception?
index 0290dbf..118f10b 100644 (file)
@@ -411,7 +411,7 @@ And turned it into nylon';
             $got = '';
             $expected = '37210';
             $expect_array = array('ctLeftAngleBrackets', 'ctRightAngleBrackets', 'ctAmpersands', 'ctApostrophes', 'ctQuotes');
-            while (list(, $val) = each($expect_array)) {
+            foreach($expect_array as $val) {
                 $b = $v->structmem($val);
                 $got .= $b->me['int'];
             }