Prechádzať zdrojové kódy

Fix iterators abstractions for HSCAN and ZSCAN when using PHP 7.2.

Closes #448.
Daniele Alessandri 8 rokov pred
rodič
commit
858fa336a8

+ 3 - 5
src/Collection/Iterator/HashKey.php

@@ -50,11 +50,9 @@ class HashKey extends CursorBasedIterator
      */
     protected function extractNext()
     {
-        if ($kv = each($this->elements)) {
-            $this->position = $kv[0];
-            $this->current = $kv[1];
+        $this->position = key($this->elements);
+        $this->current = current($this->elements);
 
-            unset($this->elements[$this->position]);
-        }
+        unset($this->elements[$this->position]);
     }
 }

+ 3 - 5
src/Collection/Iterator/SortedSetKey.php

@@ -50,11 +50,9 @@ class SortedSetKey extends CursorBasedIterator
      */
     protected function extractNext()
     {
-        if ($kv = each($this->elements)) {
-            $this->position = $kv[0];
-            $this->current = $kv[1];
+        $this->position = key($this->elements);
+        $this->current = current($this->elements);
 
-            unset($this->elements[$this->position]);
-        }
+        unset($this->elements[$this->position]);
     }
 }