[PATCH] Stop using each()
Lukas Fleischer
lfleischer at archlinux.org
Sat May 12 11:40:27 UTC 2018
The each() function has been deprecated as of PHP 7.2.0. Use foreach
loops instead.
Signed-off-by: Lukas Fleischer <lfleischer at archlinux.org>
---
web/html/rss.php | 2 +-
web/html/voters.php | 4 ++--
web/template/account_edit_form.php | 4 ++--
web/template/account_search_results.php | 12 ++++++------
web/template/pkg_comments.php | 4 ++--
web/template/pkg_details.php | 12 ++++++------
web/template/pkg_search_results.php | 4 ++--
web/template/pkgbase_details.php | 4 ++--
web/template/pkgreq_results.php | 4 ++--
web/template/tu_last_votes_list.php | 4 ++--
web/template/tu_list.php | 4 ++--
11 files changed, 29 insertions(+), 29 deletions(-)
diff --git a/web/html/rss.php b/web/html/rss.php
index 8585d81..d6e7825 100644
--- a/web/html/rss.php
+++ b/web/html/rss.php
@@ -40,7 +40,7 @@ $rss->image = $image;
#Get the latest packages and add items for them
$packages = latest_pkgs(20);
-while (list($indx, $row) = each($packages)) {
+foreach ($packages as $indx => $row) {
$item = new FeedItem();
$item->title = $row["Name"];
$item->link = "{$protocol}://{$host}" . get_pkg_uri($row["Name"]);
diff --git a/web/html/voters.php b/web/html/voters.php
index 997186d..bacbcfc 100644
--- a/web/html/voters.php
+++ b/web/html/voters.php
@@ -16,14 +16,14 @@ if (has_credential(CRED_PKGBASE_LIST_VOTERS)):
<h2>Votes for <a href="<?= get_pkgbase_uri($pkgbase_name); ?>"><?= $pkgbase_name ?></a></h2>
<div class="boxbody">
<ul>
- <?php while (list($indx, $row) = each($votes)): ?>
+ <?php foreach ($votes as $indx => $row): ?>
<li>
<a href="<?= get_user_uri($row['Username']); ?>"><?= htmlspecialchars($row['Username']) ?></a>
<?php if ($row["VoteTS"] > 0): ?>
(<?= date("Y-m-d H:i", intval($row["VoteTS"])) ?>)
<?php endif; ?>
</li>
- <?php endwhile; ?>
+ <?php endforeach; ?>
</ul>
</div>
</div>
diff --git a/web/template/account_edit_form.php b/web/template/account_edit_form.php
index 833e74a..6eff81b 100644
--- a/web/template/account_edit_form.php
+++ b/web/template/account_edit_form.php
@@ -122,7 +122,7 @@
<select name="L" id="id_language">
<?php
reset($SUPPORTED_LANGS);
- while (list($code, $lang) = each($SUPPORTED_LANGS)) {
+ foreach ($SUPPORTED_LANGS as $code => $lang) {
if ($L == $code) {
print "<option value=\"".$code."\" selected=\"selected\"> ".$lang."</option>"."\n";
} else {
@@ -137,7 +137,7 @@
<select name="TZ" id="id_timezone">
<?php
$timezones = generate_timezone_list();
- while (list($key, $val) = each($timezones)) {
+ foreach ($timezones as $key => $val) {
if ($TZ == $key) {
print "<option value=\"".$key."\" selected=\"selected\"> ".$val."</option>\n";
} else {
diff --git a/web/template/account_search_results.php b/web/template/account_search_results.php
index 43f2d1d..81cd818 100644
--- a/web/template/account_search_results.php
+++ b/web/template/account_search_results.php
@@ -18,7 +18,7 @@ else:
</thead>
<?php
$i = 0;
- while (list($indx, $row) = each($userinfo)):
+ foreach ($userinfo as $indx => $row):
if ($i % 2):
$c = "even";
else:
@@ -51,7 +51,7 @@ else:
</tr>
<?php
$i++;
- endwhile;
+ endforeach;
?>
</table>
@@ -64,10 +64,10 @@ else:
<input type="hidden" name="O" value="<?= ($OFFSET-$HITS_PER_PAGE) ?>" />
<?php
reset($search_vars);
- while (list($k, $ind) = each($search_vars)):
+ foreach ($search_vars as $k => $ind):
?>
<input type="hidden" name="<?= $ind ?>" value="<?= ${$ind} ?>" />
- <?php endwhile; ?>
+ <?php endforeach; ?>
<input type="submit" class="button" value="<-- <?= __("Less") ?>" />
</fieldset>
</form>
@@ -79,10 +79,10 @@ else:
<input type="hidden" name="O" value="<?= ($OFFSET+$HITS_PER_PAGE) ?>" />
<?php
reset($search_vars);
- while (list($k, $ind) = each($search_vars)):
+ foreach ($search_vars as $k => $ind):
?>
<input type="hidden" name="<?= $ind ?>" value="<?= ${$ind} ?>" />
- <?php endwhile; ?>
+ <?php endforeach; ?>
<input type="submit" class="button" value="<?= __("More") ?> -->" />
</fieldset>
</form>
diff --git a/web/template/pkg_comments.php b/web/template/pkg_comments.php
index 7d9bedc..3e5e5cc 100644
--- a/web/template/pkg_comments.php
+++ b/web/template/pkg_comments.php
@@ -15,7 +15,7 @@ if (!isset($count)) {
<?php endif; ?>
</h3>
- <?php while (list($indx, $row) = each($comments)): ?>
+ <?php foreach ($comments as $indx => $row): ?>
<?php
$date_fmtd = date('Y-m-d H:i', $row['CommentTS']);
if ($row['UserName']) {
@@ -113,7 +113,7 @@ if (!isset($count)) {
<?php endif; ?>
</div>
</div>
- <?php endwhile; ?>
+ <?php endforeach; ?>
<?php if ($count > 10 && !isset($_GET['comments']) && !isset($pinned)): ?>
<h3>
diff --git a/web/template/pkg_details.php b/web/template/pkg_details.php
index 8a93417..650c245 100644
--- a/web/template/pkg_details.php
+++ b/web/template/pkg_details.php
@@ -276,9 +276,9 @@ endif;
<h3><?= __('Dependencies') . " (" . count($deps) . ")"?></h3>
<?php if (count($deps) > 0): ?>
<ul id="pkgdepslist">
-<?php while (list($k, $darr) = each($deps)): ?>
+<?php foreach ($deps as $k => $darr): ?>
<li><?= pkg_depend_link($darr[0], $darr[1], $darr[2], $darr[3], $darr[4], $darr[5]); ?></li>
-<?php endwhile; ?>
+<?php endforeach; ?>
</ul>
<?php endif; ?>
</div>
@@ -286,9 +286,9 @@ endif;
<h3><?= __('Required by') . " (" . count($requiredby) . ")"?></h3>
<?php if (count($requiredby) > 0): ?>
<ul id="pkgreqslist">
- <?php while (list($k, $darr) = each($requiredby)): ?>
+ <?php foreach ($requiredby as $k => $darr): ?>
<li><?= pkg_requiredby_link($darr[0], $darr[1], $darr[2], $darr[3], $row['Name']); ?></li>
- <?php endwhile; ?>
+ <?php endforeach; ?>
</ul>
<?php endif; ?>
</div>
@@ -298,9 +298,9 @@ endif;
<?php if (count($sources) > 0): ?>
<div>
<ul id="pkgsrcslist">
- <?php while (list($k, $src) = each($sources)): ?>
+ <?php foreach ($sources as $k => $src): ?>
<li><?= pkg_source_link($src[0], $src[1], urlencode($row['BaseName'])) ?></li>
- <?php endwhile; ?>
+ <?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
diff --git a/web/template/pkg_search_results.php b/web/template/pkg_search_results.php
index d7512b1..7c5ad03 100644
--- a/web/template/pkg_search_results.php
+++ b/web/template/pkg_search_results.php
@@ -66,7 +66,7 @@ if (!$result): ?>
</thead>
<tbody>
- <?php while (list($indx, $row) = each($searchresults)): ?>
+ <?php foreach ($searchresults as $indx => $row): ?>
<tr class="<?= ($indx % 2 == 0) ? 'odd' : 'even' ?>">
<?php if ($SID && $show_headers): ?>
<td><input type="checkbox" name="IDs[<?= $row["PackageBaseID"] ?>]" value="1" /></td>
@@ -100,7 +100,7 @@ if (!$result): ?>
<?php endif; ?>
</td>
</tr>
- <?php endwhile; ?>
+ <?php endforeach; ?>
</tbody>
</table>
diff --git a/web/template/pkgbase_details.php b/web/template/pkgbase_details.php
index de55da0..8a6e2b4 100644
--- a/web/template/pkgbase_details.php
+++ b/web/template/pkgbase_details.php
@@ -126,10 +126,10 @@ endif;
<?php if (count($pkgs) > 0): ?>
<ul>
<?php
- while (list($k, $pkg) = each($pkgs)):
+ foreach ($pkgs as $k => $pkg):
?>
<li><a href="<?= htmlspecialchars(get_pkg_uri($pkg), ENT_QUOTES); ?>" title="<?= __('View packages details for').' '. htmlspecialchars($pkg) ?>"><?= htmlspecialchars($pkg) ?></a></li>
- <?php endwhile; ?>
+ <?php endforeach; ?>
</ul>
<?php endif; ?>
</div>
diff --git a/web/template/pkgreq_results.php b/web/template/pkgreq_results.php
index e02cff3..1a565c3 100644
--- a/web/template/pkgreq_results.php
+++ b/web/template/pkgreq_results.php
@@ -36,7 +36,7 @@
</thead>
<tbody>
- <?php while (list($indx, $row) = each($results)): ?>
+ <?php foreach ($results as $indx => $row): ?>
<?php
$idle_time = config_get_int('options', 'request_idle_time');
$due = ($row['Open'] && time() - intval($row['RequestTS']) > $idle_time);
@@ -100,7 +100,7 @@
<td><?= __("unknown") ?></td>
<?php endif; ?>
</tr>
- <?php endwhile; ?>
+ <?php endforeach; ?>
</tbody>
</table>
diff --git a/web/template/tu_last_votes_list.php b/web/template/tu_last_votes_list.php
index 5cff248..6e85258 100644
--- a/web/template/tu_last_votes_list.php
+++ b/web/template/tu_last_votes_list.php
@@ -11,7 +11,7 @@
<tbody>
<?php if (empty($result)): ?>
<tr><td align="center" colspan="0"><?= __("No results found.") ?></td></tr>
- <?php else: while (list($indx, $row) = each($result)):
+ <?php else: foreach ($result as $indx => $row):
if ($indx % 2):
$c = "even";
else:
@@ -28,7 +28,7 @@
</td>
</tr>
<?php
- endwhile;
+ endforeach;
endif;
?>
</tbody>
diff --git a/web/template/tu_list.php b/web/template/tu_list.php
index b7253f9..204c89e 100644
--- a/web/template/tu_list.php
+++ b/web/template/tu_list.php
@@ -26,7 +26,7 @@
</thead>
<tbody>
- <?php while (list($indx, $row) = each($result)): ?>
+ <?php foreach ($result as $indx => $row): ?>
<?php
if ($indx % 2) {
$c = "even";
@@ -60,7 +60,7 @@
<?php endif; ?>
</td>
</tr>
- <?php endwhile; ?>
+ <?php endforeach; ?>
</tbody>
</table>
--
2.17.0
More information about the aur-dev
mailing list