From a46fcaa3a5cd459398c5dba7314516a5d5cf7545 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Wed, 5 Jul 2017 18:33:28 +0200 Subject: [PATCH] Replace usages of each() by foreach / current()&key() --- lib/ConnectionPool.php | 2 +- lib/Processor.php | 8 ++++---- lib/ResultProxy.php | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/ConnectionPool.php b/lib/ConnectionPool.php index 948130b..697d655 100644 --- a/lib/ConnectionPool.php +++ b/lib/ConnectionPool.php @@ -112,7 +112,7 @@ public function getReadyConnection() { $this->addConnection(); } - while (list($key, $conn) = each($this->ready)) { + foreach ($this->ready as $key => &$conn) { unset($this->ready[$key]); if ($conn->isReady()) { return $conn; diff --git a/lib/Processor.php b/lib/Processor.php index 6771569..97ccab8 100644 --- a/lib/Processor.php +++ b/lib/Processor.php @@ -137,8 +137,8 @@ private function ready() { $cb = $this->ready; $this->out[] = null; } else { - list($key, $cb) = each($this->onReady); - unset($this->onReady[$key]); + $cb = current($this->onReady); + unset($this->onReady[key($this->onReady)]); } if (isset($cb) && is_callable($cb)) { $cb(); @@ -188,8 +188,8 @@ public function onInit() { /** @return Deferred */ private function getDeferred() { - list($key, $deferred) = each($this->deferreds); - unset($this->deferreds[$key]); + $deferred = current($this->deferreds); + unset($this->deferreds[key($this->deferreds)]); return $deferred; } diff --git a/lib/ResultProxy.php b/lib/ResultProxy.php index 5245cc6..226fa79 100644 --- a/lib/ResultProxy.php +++ b/lib/ResultProxy.php @@ -42,9 +42,9 @@ public function rowFetched($row) { if ($row !== null) { $this->rows[$this->fetchedRows++] = $row; } - list($key, list($entry, , $cb)) = each($this->deferreds[ResultProxy::SINGLE_ROW_FETCH]); - if ($key !== null) { - unset($this->deferreds[ResultProxy::SINGLE_ROW_FETCH][$key]); + list($entry, , $cb) = current($this->deferreds[ResultProxy::SINGLE_ROW_FETCH]); + if ($entry !== null) { + unset($this->deferreds[ResultProxy::SINGLE_ROW_FETCH][key($this->deferreds[ResultProxy::SINGLE_ROW_FETCH])]); $entry->succeed($cb && $row ? $cb($row) : $row); } }