From 190459c76656a9e9e79b7a2b588bc49f6cbf4013 Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Sun, 4 Nov 2018 02:03:56 +0100 Subject: [PATCH] Refactor each() function to foreach() The each() function has been deprecated since PHP 7.2 and shouldn't be used anymore: - http://php.net/manual/en/function.each.php --- bin/bumpRelease | 3 ++- include/check_email_func.php | 2 +- mailing-lists.php | 2 +- mirror.php | 3 +-- releases/index.php | 3 ++- ug.php | 9 +++++++-- 6 files changed, 14 insertions(+), 8 deletions(-) diff --git a/bin/bumpRelease b/bin/bumpRelease index a4d383de6..4c502911a 100755 --- a/bin/bumpRelease +++ b/bin/bumpRelease @@ -21,7 +21,8 @@ if (isset($_SERVER['argv'][2])) { $info = $RELEASES[$major][$version]; } else { // Calling without a minor will just grab the most recent minor. - list($version, $info) = each($RELEASES[$major]); + $version = key($RELEASES[$major]); + $info = current($RELEASES[$major]); } $info["date"] = ${"PHP_{$major}_DATE"}; diff --git a/include/check_email_func.php b/include/check_email_func.php index ea1c09632..8f617f34d 100644 --- a/include/check_email_func.php +++ b/include/check_email_func.php @@ -13,7 +13,7 @@ $test_add = array ( "asasasd324324@php.net", "jcastagnetto-delete-this-@yahoo.com", "wrong-address-with@@@@-remove_me-and-some-i-hate_SPAM-stuff"); -while (list(,$v) = each($test_add)) { +foreach ($test_add as $v) { echo "The address: $v (".clean_AntiSpam($v).") is"; if (!is_emailable_address(clean_AntiSPAM($v))) echo " not"; diff --git a/mailing-lists.php b/mailing-lists.php index e0edbb566..5b944156d 100644 --- a/mailing-lists.php +++ b/mailing-lists.php @@ -302,7 +302,7 @@ if (isset($_POST['maillist'])) { function output_lists_table($mailing_lists) { echo '', "\n"; - while ( list(, $listinfo) = each($mailing_lists)) { + foreach ($mailing_lists as $listinfo) { if (!is_array($listinfo)) { echo "" . "\n"; diff --git a/mirror.php b/mirror.php index 5ab28a203..00e526b35 100644 --- a/mirror.php +++ b/mirror.php @@ -23,8 +23,7 @@ if (is_official_mirror()) { // Iterate through possible mirror provider logo types in priority order $types = array("gif", "jpg", "png"); - while (list(,$ext) = each($types)) { - + foreach ($types as $ext) { // Check if file exists for this type if (file_exists("backend/mirror." . $ext)) { diff --git a/releases/index.php b/releases/index.php index bb4531d47..de4bf86e3 100644 --- a/releases/index.php +++ b/releases/index.php @@ -52,7 +52,8 @@ if (isset($_GET["serialize"]) || isset($_GET["json"])) { } } else { foreach($RELEASES as $major => $release) { - list($version, $r) = each($release); + $version = key($release); + $r = current($release); $r["version"] = $version; $machineReadable[$major] = $r; } diff --git a/ug.php b/ug.php index 02345ac03..53efd11da 100644 --- a/ug.php +++ b/ug.php @@ -42,7 +42,11 @@ function ug_get_next_even_from_ical_array($ical) { $data = array(); foreach($ical as $line) { if ($line == "BEGIN:VEVENT") { - do { + foreach ($ical as $n => $line) { + if ("END:VEVENT" == $line) { + break; + } + if ($line[0] == " ") { // data continued from previous key $data[$lastkey] .= ltrim($line); @@ -50,7 +54,8 @@ function ug_get_next_even_from_ical_array($ical) { list($lastkey, $value) = explode(":", $line, 2); $data[$lastkey] = $value; } - } while((list($n, $line) = each($ical)) && $line != "END:VEVENT"); + } + break; } }
{$listinfo}ModeratedArchiveNewsgroupNormalDigest