Преглед изворни кода

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

Closes #488.
Daniele Alessandri пре 7 година
родитељ
комит
157f658f0b
3 измењених фајлова са 9 додато и 10 уклоњено
  1. 3 0
      CHANGELOG.md
  2. 3 5
      src/Collection/Iterator/HashKey.php
  3. 3 5
      src/Collection/Iterator/SortedSetKey.php

+ 3 - 0
CHANGELOG.md

@@ -4,6 +4,9 @@ v1.1.2 (2017-xx-xx)
 - __FIX__: pure CRC16 implementation failed to calculate the correct hash when
   the input value passed to the `hash()` method is an integer (PR #450).
 
+- __FIX__: make PHP iterator abstractions for `ZSCAN` and `HSCAN` working with
+  PHP 7.2 due to a breaking change, namely the removal of `each()` (PR #448).
+
 
 v1.1.1 (2016-06-16)
 ================================================================================

+ 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]);
     }
 }