Skip to content

Commit a46fcaa

Browse files
committed
Replace usages of each() by foreach / current()&key()
1 parent 031dcf0 commit a46fcaa

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

lib/ConnectionPool.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public function getReadyConnection() {
112112
$this->addConnection();
113113
}
114114

115-
while (list($key, $conn) = each($this->ready)) {
115+
foreach ($this->ready as $key => &$conn) {
116116
unset($this->ready[$key]);
117117
if ($conn->isReady()) {
118118
return $conn;

lib/Processor.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ private function ready() {
137137
$cb = $this->ready;
138138
$this->out[] = null;
139139
} else {
140-
list($key, $cb) = each($this->onReady);
141-
unset($this->onReady[$key]);
140+
$cb = current($this->onReady);
141+
unset($this->onReady[key($this->onReady)]);
142142
}
143143
if (isset($cb) && is_callable($cb)) {
144144
$cb();
@@ -188,8 +188,8 @@ public function onInit() {
188188

189189
/** @return Deferred */
190190
private function getDeferred() {
191-
list($key, $deferred) = each($this->deferreds);
192-
unset($this->deferreds[$key]);
191+
$deferred = current($this->deferreds);
192+
unset($this->deferreds[key($this->deferreds)]);
193193
return $deferred;
194194
}
195195

lib/ResultProxy.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ public function rowFetched($row) {
4242
if ($row !== null) {
4343
$this->rows[$this->fetchedRows++] = $row;
4444
}
45-
list($key, list($entry, , $cb)) = each($this->deferreds[ResultProxy::SINGLE_ROW_FETCH]);
46-
if ($key !== null) {
47-
unset($this->deferreds[ResultProxy::SINGLE_ROW_FETCH][$key]);
45+
list($entry, , $cb) = current($this->deferreds[ResultProxy::SINGLE_ROW_FETCH]);
46+
if ($entry !== null) {
47+
unset($this->deferreds[ResultProxy::SINGLE_ROW_FETCH][key($this->deferreds[ResultProxy::SINGLE_ROW_FETCH])]);
4848
$entry->succeed($cb && $row ? $cb($row) : $row);
4949
}
5050
}

0 commit comments

Comments
 (0)