Commit 7206f5d9 authored by catch's avatar catch

Issue #2885309 by vaplas, drewklein, pk188, alexpott, Ayesh, arunkumark,...

Issue #2885309 by vaplas, drewklein, pk188, alexpott, Ayesh, arunkumark, andypost, klausi, xjm, mondrake: [PHP 7.2] each() function is deprecated
parent 9830ef98
......@@ -1003,7 +1003,7 @@ function _drupal_shutdown_function() {
chdir(DRUPAL_ROOT);
try {
while (list($key, $callback) = each($callbacks)) {
foreach ($callbacks as &$callback) {
call_user_func_array($callback['callback'], $callback['arguments']);
}
}
......
......@@ -201,28 +201,29 @@ protected function _diag($xoff, $xlim, $yoff, $ylim, $nchunks) {
continue;
}
$matches = $ymatches[$line];
reset($matches);
while (list ($junk, $y) = each($matches)) {
if (empty($this->in_seq[$y])) {
$k = $this->_lcs_pos($y);
$this::USE_ASSERTS && assert($k > 0);
$ymids[$k] = $ymids[$k - 1];
break;
}
}
while (list ($junk, $y) = each($matches)) {
if ($y > $this->seq[$k - 1]) {
$this::USE_ASSERTS && assert($y < $this->seq[$k]);
// Optimization: this is a common case:
// next match is just replacing previous match.
$this->in_seq[$this->seq[$k]] = FALSE;
$this->seq[$k] = $y;
$this->in_seq[$y] = 1;
foreach ($matches as $y) {
if (!isset($found_empty)) {
if (empty($this->in_seq[$y])) {
$k = $this->_lcs_pos($y);
$this::USE_ASSERTS && assert($k > 0);
$ymids[$k] = $ymids[$k - 1];
$found_empty = TRUE;
}
}
elseif (empty($this->in_seq[$y])) {
$k = $this->_lcs_pos($y);
$this::USE_ASSERTS && assert($k > 0);
$ymids[$k] = $ymids[$k - 1];
else {
if ($y > $this->seq[$k - 1]) {
$this::USE_ASSERTS && assert($y < $this->seq[$k]);
// Optimization: this is a common case:
// next match is just replacing previous match.
$this->in_seq[$this->seq[$k]] = FALSE;
$this->seq[$k] = $y;
$this->in_seq[$y] = 1;
}
elseif (empty($this->in_seq[$y])) {
$k = $this->_lcs_pos($y);
$this::USE_ASSERTS && assert($k > 0);
$ymids[$k] = $ymids[$k - 1];
}
}
}
}
......
......@@ -93,8 +93,8 @@ public function install(array $module_list, $enable_dependencies = TRUE) {
}
// Add dependencies to the list. The new modules will be processed as
// the while loop continues.
while (list($module) = each($module_list)) {
// the foreach loop continues.
foreach ($module_list as $module => $value) {
foreach (array_keys($module_data[$module]->requires) as $dependency) {
if (!isset($module_data[$dependency])) {
// The dependency does not exist.
......@@ -340,9 +340,9 @@ public function uninstall(array $module_list, $uninstall_dependents = TRUE) {
if ($uninstall_dependents) {
// Add dependent modules to the list. The new modules will be processed as
// the while loop continues.
// the foreach loop continues.
$profile = drupal_get_profile();
while (list($module) = each($module_list)) {
foreach ($module_list as $module => $value) {
foreach (array_keys($module_data[$module]->required_by) as $dependent) {
if (!isset($module_data[$dependent])) {
// The dependent module does not exist.
......
......@@ -121,9 +121,9 @@ public function install(array $theme_list, $install_dependencies = TRUE) {
return TRUE;
}
while (list($theme) = each($theme_list)) {
foreach ($theme_list as $theme => $value) {
// Add dependencies to the list. The new themes will be processed as
// the while loop continues.
// the parent foreach loop continues.
foreach (array_keys($theme_data[$theme]->requires) as $dependency) {
if (!isset($theme_data[$dependency])) {
// The dependency does not exist.
......
......@@ -39,12 +39,14 @@ public function prevLink(array $book_link) {
if ($book_link['pid'] == 0) {
return NULL;
}
// Assigning the array to $flat resets the array pointer for use with each().
$flat = $this->bookManager->bookTreeGetFlat($book_link);
reset($flat);
$curr = NULL;
do {
$prev = $curr;
list($key, $curr) = each($flat);
$key = key($flat);
$curr = current($flat);
next($flat);
} while ($key && $key != $book_link['nid']);
if ($key == $book_link['nid']) {
......@@ -78,10 +80,11 @@ public function prevLink(array $book_link) {
* $book_link.
*/
public function nextLink(array $book_link) {
// Assigning the array to $flat resets the array pointer for use with each().
$flat = $this->bookManager->bookTreeGetFlat($book_link);
reset($flat);
do {
list($key,) = each($flat);
$key = key($flat);
next($flat);
} while ($key && $key != $book_link['nid']);
if ($key == $book_link['nid']) {
......
......@@ -160,11 +160,7 @@ protected function checkFixedLanguageTypes() {
foreach ($this->languageManager()->getDefinedLanguageTypesInfo() as $type => $info) {
if (!in_array($type, $configurable) && isset($info['fixed'])) {
$negotiation = $this->config('language.types')->get('negotiation.' . $type . '.enabled');
$equal = count($info['fixed']) == count($negotiation);
while ($equal && list($id) = each($negotiation)) {
list(, $info_id) = each($info['fixed']);
$equal = $info_id == $id;
}
$equal = array_keys($negotiation) === array_values($info['fixed']);
$this->assertTrue($equal, format_string('language negotiation for %type is properly set up', ['%type' => $type]));
}
}
......
......@@ -388,7 +388,7 @@ protected function buildModuleList(FormStateInterface $form_state) {
}
// Add all dependencies to a list.
while (list($module) = each($modules['install'])) {
foreach ($modules['install'] as $module => $value) {
foreach (array_keys($data[$module]->requires) as $dependency) {
if (!isset($modules['install'][$dependency]) && !$this->moduleHandler->moduleExists($dependency)) {
$modules['dependencies'][$module][$dependency] = $data[$dependency]->info['name'];
......
......@@ -72,7 +72,7 @@ public function testInstallUninstall() {
// Go through each module in the list and try to install and uninstall
// it with its dependencies.
while (list($name, $module) = each($all_modules)) {
foreach ($all_modules as $name => $module) {
$was_installed_list = \Drupal::moduleHandler()->getModuleList();
// Start a list of modules that we expect to be installed this time.
......
......@@ -104,7 +104,9 @@ public function getForm(ViewEntityInterface $view, $display_id, $js) {
// Retrieve the first form from the stack without changing the integer keys,
// as they're being used for the "2 of 3" progress indicator.
reset($view->stack);
list($key, $top) = each($view->stack);
$key = key($view->stack);
$top = current($view->stack);
next($view->stack);
unset($view->stack[$key]);
if (array_shift($top) != $identifier) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment