Follow-up 6d4e1547: Hard-deprecate these functions
[lhc/web/wiklou.git] / includes / libs / HashRing.php
index be40965..21558f7 100644 (file)
  * @since 1.22
  */
 class HashRing {
-       /** @var Array (location => weight) */
+       /** @var array (location => weight) */
        protected $sourceMap = [];
-       /** @var Array (location => (start, end)) */
+       /** @var array (location => (start, end)) */
        protected $ring = [];
 
        /** @var HashRing|null */
        protected $liveRing;
-       /** @var Array (location => UNIX timestamp) */
+       /** @var array (location => UNIX timestamp) */
        protected $ejectionExpiries = [];
        /** @var int UNIX timestamp */
        protected $ejectionNextExpiry = INF;
@@ -116,11 +116,12 @@ class HashRing {
                // If more locations are requested, wrap-around and keep adding them
                reset( $this->ring );
                while ( count( $locations ) < $limit ) {
-                       list( $location, ) = each( $this->ring );
+                       $location = key( $this->ring );
                        if ( $location === $primaryLocation ) {
                                break; // don't go in circles
                        }
                        $locations[] = $location;
+                       next( $this->ring );
                }
 
                return $locations;