Skip to content

Commit

Permalink
Replace usages of each() by foreach / current()&key()
Browse files Browse the repository at this point in the history
  • Loading branch information
bwoebi committed Jul 5, 2017
1 parent 031dcf0 commit a46fcaa
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/ConnectionPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions lib/Processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}

Expand Down
6 changes: 3 additions & 3 deletions lib/ResultProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down

0 comments on commit a46fcaa

Please sign in to comment.