mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 12:40:01 +01:00
MDL-60281 general: function each() is deprecated in PHP7.2
This commit is contained in:
parent
484b43f456
commit
33683bc80c
@ -267,7 +267,7 @@ abstract class calculable {
|
||||
|
||||
foreach ($arrays as $array) {
|
||||
reset($base);
|
||||
while (list($key, $value) = each($array)) {
|
||||
foreach ($array as $key => $value) {
|
||||
if (is_array($value) && !empty($base[$key]) && is_array($base[$key])) {
|
||||
$base[$key] = $this->array_merge_recursive_keep_keys($base[$key], $value);
|
||||
} else {
|
||||
|
@ -2359,8 +2359,10 @@ function get_user_timezone($tz = 99) {
|
||||
$tz = 99;
|
||||
|
||||
// Loop while $tz is, empty but not zero, or 99, and there is another timezone is the array.
|
||||
while (((empty($tz) && !is_numeric($tz)) || $tz == 99) && $next = each($timezones)) {
|
||||
$tz = $next['value'];
|
||||
foreach ($timezones as $nextvalue) {
|
||||
if ((empty($tz) && !is_numeric($tz)) || $tz == 99) {
|
||||
$tz = $nextvalue;
|
||||
}
|
||||
}
|
||||
return is_numeric($tz) ? (float) $tz : $tz;
|
||||
}
|
||||
|
@ -954,7 +954,7 @@ EOD;
|
||||
|
||||
$result = true;
|
||||
|
||||
while (list($localpath, $destpath) = each($filelist)) {
|
||||
foreach ($filelist as $localpath => $destpath) {
|
||||
|
||||
$localpath = rtrim($localpath, "/");
|
||||
$destpath = rtrim($destpath, "/");
|
||||
@ -1011,7 +1011,7 @@ EOD;
|
||||
|
||||
$result = true;
|
||||
|
||||
while (list($remotepath, $localpath) = each($filelist)) {
|
||||
foreach ($filelist as $remotepath => $localpath) {
|
||||
|
||||
$localpath = rtrim($localpath, "/");
|
||||
$remotepath = rtrim($remotepath, "/");
|
||||
|
@ -1398,7 +1398,8 @@ class core_message_api_testcase extends core_message_messagelib_testcase {
|
||||
$this->markTestSkipped("No message processors found");
|
||||
}
|
||||
|
||||
list($name, $processor) = each($processors);
|
||||
$name = key($processors);
|
||||
$processor = current($processors);
|
||||
$testprocessor = \core_message\api::get_message_processor($name);
|
||||
$this->assertEquals($processor->name, $testprocessor->name);
|
||||
$this->assertEquals($processor->enabled, $testprocessor->enabled);
|
||||
@ -1431,7 +1432,8 @@ class core_message_api_testcase extends core_message_messagelib_testcase {
|
||||
if (empty($processors)) {
|
||||
$this->markTestSkipped("No message processors found");
|
||||
}
|
||||
list($name, $testprocessor) = each($processors);
|
||||
$name = key($processors);
|
||||
$testprocessor = current($processors);
|
||||
|
||||
// Enable.
|
||||
\core_message\api::update_processor_status($testprocessor, 1);
|
||||
@ -1457,7 +1459,8 @@ class core_message_api_testcase extends core_message_messagelib_testcase {
|
||||
if (empty($processors)) {
|
||||
$this->markTestSkipped("No message processors found");
|
||||
}
|
||||
list($name, $testprocessor) = each($processors);
|
||||
$name = key($processors);
|
||||
$testprocessor = current($processors);
|
||||
|
||||
// Enable.
|
||||
\core_message\api::update_processor_status($testprocessor, 1);
|
||||
|
@ -154,14 +154,15 @@ class quiz_statistics_question_stats_testcase extends basic_testcase {
|
||||
public function get_fields_from_csv($line) {
|
||||
$line = trim($line);
|
||||
$items = preg_split('!,!', $line);
|
||||
while (list($key) = each($items)) {
|
||||
$cnt = count($items);
|
||||
for ($key = 0; $key < $cnt; $key++) {
|
||||
if ($items[$key]!='') {
|
||||
if ($start = ($items[$key]{0}=='"')) {
|
||||
$items[$key] = substr($items[$key], 1);
|
||||
while (!$end = ($items[$key]{strlen($items[$key])-1}=='"')) {
|
||||
$item = $items[$key];
|
||||
unset($items[$key]);
|
||||
list($key) = each($items);
|
||||
$key++;
|
||||
$items[$key] = $item . ',' . $items[$key];
|
||||
}
|
||||
$items[$key] = substr($items[$key], 0, strlen($items[$key])-1);
|
||||
|
@ -217,7 +217,7 @@ if (!empty($command)) {
|
||||
$datamodel['[comments]'] = 'cmi.comments';
|
||||
$datarows = explode("\r\n", $aiccdata);
|
||||
reset($datarows);
|
||||
while ((list(, $datarow) = each($datarows)) !== false) {
|
||||
foreach ($datarows as $datarow) {
|
||||
if (($equal = strpos($datarow, '=')) !== false) {
|
||||
$element = strtolower(trim(substr($datarow, 0, $equal)));
|
||||
$value = trim(substr($datarow, $equal + 1));
|
||||
|
@ -88,7 +88,7 @@
|
||||
|
||||
$options = explode(",",$question->options);
|
||||
|
||||
while (list($key,) = each($options)) {
|
||||
foreach ($options as $key => $unused) {
|
||||
$buckets1[$key] = 0;
|
||||
$buckets2[$key] = 0;
|
||||
}
|
||||
|
@ -539,7 +539,7 @@ function survey_print_multi($question) {
|
||||
|
||||
echo "<tr class=\"smalltext\"><th scope=\"row\">$strresponses</th>";
|
||||
echo "<th scope=\"col\" class=\"hresponse\">". get_string('notyetanswered', 'survey'). "</th>";
|
||||
while (list ($key, $val) = each ($options)) {
|
||||
foreach ($options as $key => $val) {
|
||||
echo "<th scope=\"col\" class=\"hresponse\">$val</th>\n";
|
||||
}
|
||||
echo "</tr>\n";
|
||||
|
@ -247,14 +247,14 @@ class _WikiDiffEngine
|
||||
continue;
|
||||
$matches = $ymatches[$line];
|
||||
reset($matches);
|
||||
while (list ($junk, $y) = each($matches))
|
||||
foreach ($matches as $y)
|
||||
if (empty($this->in_seq[$y])) {
|
||||
$k = $this->_lcs_pos($y);
|
||||
USE_ASSERTS_IN_WIKI && assert($k > 0);
|
||||
$ymids[$k] = $ymids[$k-1];
|
||||
break;
|
||||
}
|
||||
while (list ($junk, $y) = each($matches)) {
|
||||
}
|
||||
foreach ($matches as $y) {
|
||||
if ($y > $this->seq[$k-1]) {
|
||||
USE_ASSERTS_IN_WIKI && assert($y < $this->seq[$k]);
|
||||
// Optimization: this is a common case:
|
||||
|
@ -126,7 +126,8 @@ class workshop_random_allocator implements workshop_allocator {
|
||||
$allreviewers = $reviewers[0];
|
||||
$allreviewersreloaded = false;
|
||||
foreach ($newallocations as $newallocation) {
|
||||
list($reviewerid, $authorid) = each($newallocation);
|
||||
$reviewerid = key($newallocation);
|
||||
$authorid = current($newallocation);
|
||||
$a = new stdClass();
|
||||
if (isset($allreviewers[$reviewerid])) {
|
||||
$a->reviewername = fullname($allreviewers[$reviewerid]);
|
||||
@ -324,7 +325,8 @@ class workshop_random_allocator implements workshop_allocator {
|
||||
$submissions = $this->workshop->get_submissions($authorids);
|
||||
$submissions = $this->index_submissions_by_authors($submissions);
|
||||
foreach ($newallocations as $newallocation) {
|
||||
list($reviewerid, $authorid) = each($newallocation);
|
||||
$reviewerid = key($newallocation);
|
||||
$authorid = current($newallocation);
|
||||
if (!isset($submissions[$authorid])) {
|
||||
throw new moodle_exception('unabletoallocateauthorwithoutsubmission', 'workshop');
|
||||
}
|
||||
@ -408,7 +410,8 @@ class workshop_random_allocator implements workshop_allocator {
|
||||
continue;
|
||||
}
|
||||
foreach ($newallocations as $newallocation) {
|
||||
list($nrid, $naid) = each($newallocation);
|
||||
$nrid = key($newallocation);
|
||||
$naid = current($newallocation);
|
||||
if (array($arid, $aaid) == array($nrid, $naid)) {
|
||||
// re-allocation found - let us continue with the next assessment
|
||||
$keepids[$assessmentid] = null;
|
||||
|
@ -187,7 +187,7 @@ class calculator {
|
||||
// foreach ($this->questions as $qid => $question).
|
||||
$slots = $this->stats->get_all_slots();
|
||||
$this->progress->start_progress('', count($slots), 1);
|
||||
while (list(, $slot) = each($slots)) {
|
||||
foreach ($slots as $slot) {
|
||||
$this->stats->for_slot($slot)->sort_variants();
|
||||
$this->progress->increment_progress();
|
||||
$nextslot = current($slots);
|
||||
|
Loading…
x
Reference in New Issue
Block a user