Stop using each()

The each() function has been deprecated as of PHP 7.2.0. Use foreach
loops instead.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
This commit is contained in:
Lukas Fleischer 2018-05-12 13:35:11 +02:00
parent 8838490665
commit 4b8b2e3eb1
11 changed files with 29 additions and 29 deletions

View file

@ -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"]);

View file

@ -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>

View file

@ -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 {

View file

@ -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="&lt;-- <?= __("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") ?> --&gt;" />
</fieldset>
</form>

View file

@ -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>

View file

@ -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; ?>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>