From 80de9f6a68d7b50eb5387cdc2b99624484e75201 Mon Sep 17 00:00:00 2001 From: rxu Date: Sun, 29 Dec 2019 18:56:36 +0700 Subject: [ticket/16277] Move from each() function PHPBB3-16277 --- phpBB/includes/acp/acp_permissions.php | 4 ++-- phpBB/includes/acp/auth.php | 21 +++++++-------------- phpBB/includes/diff/engine.php | 4 ++-- phpBB/includes/functions_convert.php | 3 ++- phpBB/includes/mcp/mcp_logs.php | 2 +- phpBB/includes/mcp/mcp_notes.php | 2 +- phpBB/includes/mcp/mcp_warn.php | 2 +- phpBB/includes/ucp/ucp_groups.php | 16 ++++++++-------- phpBB/mcp.php | 2 +- phpBB/phpbb/request/type_cast_helper.php | 3 ++- 10 files changed, 27 insertions(+), 32 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/acp/acp_permissions.php b/phpBB/includes/acp/acp_permissions.php index e683b1972e..59bf366c1b 100644 --- a/phpBB/includes/acp/acp_permissions.php +++ b/phpBB/includes/acp/acp_permissions.php @@ -694,8 +694,8 @@ class acp_permissions } // We loop through the auth settings defined in our submit - list($ug_id, ) = each($psubmit); - list($forum_id, ) = each($psubmit[$ug_id]); + $ug_id = key($psubmit); + $forum_id = key($psubmit[$ug_id]); $settings = $request->variable('setting', array(0 => array(0 => array('' => 0))), false, \phpbb\request\request_interface::POST); if (empty($settings) || empty($settings[$ug_id]) || empty($settings[$ug_id][$forum_id])) diff --git a/phpBB/includes/acp/auth.php b/phpBB/includes/acp/auth.php index b414a3121a..f203f9d3ba 100644 --- a/phpBB/includes/acp/auth.php +++ b/phpBB/includes/acp/auth.php @@ -460,8 +460,7 @@ class auth_admin extends \phpbb\auth\auth 'S_GROUP_MODE' => ($user_mode == 'group') ? true : false) ); - @reset($content_array); - while (list($ug_id, $ug_array) = each($content_array)) + foreach ($content_array as $ug_id => $ug_array) { // Build role dropdown options $current_role_id = (isset($cur_roles[$ug_id][$forum_id])) ? $cur_roles[$ug_id][$forum_id] : 0; @@ -471,8 +470,7 @@ class auth_admin extends \phpbb\auth\auth $s_role_options = ''; $current_role_id = (isset($cur_roles[$ug_id][$forum_id])) ? $cur_roles[$ug_id][$forum_id] : 0; - @reset($roles); - while (list($role_id, $role_row) = each($roles)) + foreach ($roles as $role_id => $role_row) { $role_description = (!empty($user->lang[$role_row['role_description']])) ? $user->lang[$role_row['role_description']] : nl2br($role_row['role_description']); $role_name = (!empty($user->lang[$role_row['role_name']])) ? $user->lang[$role_row['role_name']] : $role_row['role_name']; @@ -559,8 +557,7 @@ class auth_admin extends \phpbb\auth\auth 'S_GROUP_MODE' => ($user_mode == 'group') ? true : false) ); - @reset($content_array); - while (list($forum_id, $forum_array) = each($content_array)) + foreach ($content_array as $forum_id => $forum_array) { // Build role dropdown options $current_role_id = (isset($cur_roles[$ug_id][$forum_id])) ? $cur_roles[$ug_id][$forum_id] : 0; @@ -570,8 +567,7 @@ class auth_admin extends \phpbb\auth\auth $current_role_id = (isset($cur_roles[$ug_id][$forum_id])) ? $cur_roles[$ug_id][$forum_id] : 0; $s_role_options = ''; - @reset($roles); - while (list($role_id, $role_row) = each($roles)) + foreach ($roles as $role_id => $role_row) { $role_description = (!empty($user->lang[$role_row['role_description']])) ? $user->lang[$role_row['role_description']] : nl2br($role_row['role_description']); $role_name = (!empty($user->lang[$role_row['role_name']])) ? $user->lang[$role_row['role_name']] : $role_row['role_name']; @@ -1138,8 +1134,7 @@ class auth_admin extends \phpbb\auth\auth /* @var $phpbb_permissions \phpbb\permissions */ $phpbb_permissions = $phpbb_container->get('acl.permissions'); - @reset($category_array); - while (list($cat, $cat_array) = each($category_array)) + foreach ($category_array as $cat => $cat_array) { if (!$phpbb_permissions->category_defined($cat)) { @@ -1169,8 +1164,7 @@ class auth_admin extends \phpbb\auth\auth } unset($key_array, $values_array); */ - @reset($cat_array['permissions']); - while (list($permission, $allowed) = each($cat_array['permissions'])) + foreach ($cat_array['permissions'] as $permission => $allowed) { if (!$phpbb_permissions->permission_defined($permission)) { @@ -1237,8 +1231,7 @@ class auth_admin extends \phpbb\auth\auth $permissions = $permission_row[$forum_id]; ksort($permissions); - @reset($permissions); - while (list($permission, $auth_setting) = each($permissions)) + foreach ($permissions as $permission => $auth_setting) { $cat = $phpbb_permissions->get_permission_category($permission); diff --git a/phpBB/includes/diff/engine.php b/phpBB/includes/diff/engine.php index 757fdadde9..19e0bcf09e 100644 --- a/phpBB/includes/diff/engine.php +++ b/phpBB/includes/diff/engine.php @@ -285,7 +285,7 @@ class diff_engine $matches = $ymatches[$line]; reset($matches); - while (list(, $y) = each($matches)) + while ($y = current($matches)) { if (empty($this->in_seq[$y])) { @@ -296,7 +296,7 @@ class diff_engine } // no reset() here - while (list(, $y) = each($matches)) + while ($y = current($matches)) { if ($y > $this->seq[$k - 1]) { diff --git a/phpBB/includes/functions_convert.php b/phpBB/includes/functions_convert.php index df4c9b1875..96e108792d 100644 --- a/phpBB/includes/functions_convert.php +++ b/phpBB/includes/functions_convert.php @@ -1209,7 +1209,8 @@ function get_config() if (is_array($convert->config_schema['table_format'])) { $convert_config = array(); - list($key, $val) = each($convert->config_schema['table_format']); + $key = key($convert->config_schema['table_format']); + $val = current($convert->config_schema['table_format']); do { diff --git a/phpBB/includes/mcp/mcp_logs.php b/phpBB/includes/mcp/mcp_logs.php index 79f9d35ebe..dc098fceed 100644 --- a/phpBB/includes/mcp/mcp_logs.php +++ b/phpBB/includes/mcp/mcp_logs.php @@ -44,7 +44,7 @@ class mcp_logs if (is_array($action)) { - list($action, ) = each($action); + $action = key($action); } else { diff --git a/phpBB/includes/mcp/mcp_notes.php b/phpBB/includes/mcp/mcp_notes.php index a4c2356a43..74bd1f1f62 100644 --- a/phpBB/includes/mcp/mcp_notes.php +++ b/phpBB/includes/mcp/mcp_notes.php @@ -42,7 +42,7 @@ class mcp_notes if (is_array($action)) { - list($action, ) = each($action); + $action = key($action); } $this->page_title = 'MCP_NOTES'; diff --git a/phpBB/includes/mcp/mcp_warn.php b/phpBB/includes/mcp/mcp_warn.php index df175133fc..7a8599fedd 100644 --- a/phpBB/includes/mcp/mcp_warn.php +++ b/phpBB/includes/mcp/mcp_warn.php @@ -41,7 +41,7 @@ class mcp_warn if (is_array($action)) { - list($action, ) = each($action); + $action = key($action); } $this->page_title = 'MCP_WARN'; diff --git a/phpBB/includes/ucp/ucp_groups.php b/phpBB/includes/ucp/ucp_groups.php index 2423af86be..d574549093 100644 --- a/phpBB/includes/ucp/ucp_groups.php +++ b/phpBB/includes/ucp/ucp_groups.php @@ -136,7 +136,7 @@ class ucp_groups { trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page); } - list(, $row) = each($row); + $row = current($row); $sql = 'SELECT group_type FROM ' . GROUPS_TABLE . ' @@ -240,7 +240,7 @@ class ucp_groups { trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page); } - list(, $row) = each($row); + $row = current($row); if (!$row['group_leader']) { @@ -460,7 +460,7 @@ class ucp_groups { trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page); } - list(, $row) = each($row); + $row = current($row); if (!$row['group_leader']) { @@ -754,7 +754,7 @@ class ucp_groups { trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page); } - list(, $row) = each($row); + $row = current($row); if (!$row['group_leader']) { @@ -879,7 +879,7 @@ class ucp_groups { trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page); } - list(, $row) = each($row); + $row = current($row); if (!$row['group_leader']) { @@ -906,7 +906,7 @@ class ucp_groups { trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page); } - list(, $row) = each($row); + $row = current($row); if (!$row['group_leader']) { @@ -985,7 +985,7 @@ class ucp_groups { trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page); } - list(, $row) = each($row); + $row = current($row); if (!$row['group_leader']) { @@ -1046,7 +1046,7 @@ class ucp_groups { trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page); } - list(, $row) = each($row); + $row = current($row); if (!$row['group_leader']) { diff --git a/phpBB/mcp.php b/phpBB/mcp.php index 6215a675b4..c8fb0233ff 100644 --- a/phpBB/mcp.php +++ b/phpBB/mcp.php @@ -61,7 +61,7 @@ if ($forum_action !== '' && $request->variable('sort', false, false, \phpbb\requ if (count($action_ary)) { - list($action, ) = each($action_ary); + $action = key($action_ary); } unset($action_ary); diff --git a/phpBB/phpbb/request/type_cast_helper.php b/phpBB/phpbb/request/type_cast_helper.php index 912494998d..39d5908fd3 100644 --- a/phpBB/phpbb/request/type_cast_helper.php +++ b/phpBB/phpbb/request/type_cast_helper.php @@ -106,7 +106,8 @@ class type_cast_helper implements \phpbb\request\type_cast_helper_interface return; } - list($default_key, $default_value) = each($default); + $default_key = key($default); + $default_value = current($default); $key_type = gettype($default_key); $_var = $var; -- cgit v1.2.1