From 1c02b1a7b5623d3f9e3d6359d7d9d554c81b5883 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 26 Dec 2022 14:56:51 +0100 Subject: [PATCH] [ticket/16955] Clean up reset_password and user_loader PHPBB3-16955 --- phpBB/phpbb/ucp/controller/reset_password.php | 8 ++++---- phpBB/phpbb/user_loader.php | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/phpBB/phpbb/ucp/controller/reset_password.php b/phpBB/phpbb/ucp/controller/reset_password.php index 10bc7c2d2f..98ab4ba781 100644 --- a/phpBB/phpbb/ucp/controller/reset_password.php +++ b/phpBB/phpbb/ucp/controller/reset_password.php @@ -22,7 +22,7 @@ use phpbb\exception\http_exception; use phpbb\language\language; use phpbb\log\log_interface; use phpbb\passwords\manager; -use phpbb\request\request_interface; +use phpbb\request\request; use phpbb\template\template; use phpbb\user; use Symfony\Component\HttpFoundation\Response; @@ -53,7 +53,7 @@ class reset_password /** @var manager */ protected $passwords_manager; - /** @var request_interface */ + /** @var request */ protected $request; /** @var template */ @@ -81,7 +81,7 @@ class reset_password * @param language $language * @param log_interface $log * @param manager $passwords_manager - * @param request_interface $request + * @param request $request * @param template $template * @param user $user * @param string $users_table @@ -90,7 +90,7 @@ class reset_password */ public function __construct(config $config, driver_interface $db, dispatcher $dispatcher, helper $helper, language $language, log_interface $log, manager $passwords_manager, - request_interface $request, template $template, user $user, string $users_table, + request $request, template $template, user $user, string $users_table, string $root_path, string $php_ext) { $this->config = $config; diff --git a/phpBB/phpbb/user_loader.php b/phpBB/phpbb/user_loader.php index 18aacce349..5d84a843a3 100644 --- a/phpBB/phpbb/user_loader.php +++ b/phpBB/phpbb/user_loader.php @@ -132,10 +132,10 @@ class user_loader * @param bool $query Should we query the database if this user has not yet been loaded? * Typically this should be left as false and you should make sure * you load users ahead of time with load_users() - * @return array|bool Row from the database of the user or Anonymous if the user wasn't loaded/does not exist + * @return array|false Row from the database of the user or Anonymous if the user wasn't loaded/does not exist * or bool False if the anonymous user was not loaded */ - public function get_user($user_id, $query = false) + public function get_user(int $user_id, bool $query = false) { if (isset($this->users[$user_id])) { @@ -162,14 +162,14 @@ class user_loader * colour (for obtaining the user colour) * full (for obtaining a html string representing a coloured link to the users profile) * no_profile (the same as full but forcing no profile link) - * @param string $guest_username Optional parameter to specify the guest username. It will be used in favor of the GUEST language variable then. - * @param string $custom_profile_url Optional parameter to specify a profile url. The user id get appended to this url as &u={user_id} + * @param string|bool $guest_username Optional parameter to specify the guest username. It will be used in favor of the GUEST language variable then. + * @param string|bool $custom_profile_url Optional parameter to specify a profile url. The user id get appended to this url as &u={user_id} * @param bool $query Should we query the database if this user has not yet been loaded? * Typically this should be left as false and you should make sure * you load users ahead of time with load_users() * @return string */ - public function get_username($user_id, $mode, $guest_username = false, $custom_profile_url = false, $query = false) + public function get_username(int $user_id, string $mode, $guest_username = false, $custom_profile_url = false, bool $query = false): string { if (!($user = $this->get_user($user_id, $query))) { @@ -215,11 +215,11 @@ class user_loader * you load users ahead of time with load_users() * @return array Array with keys 'rank_title', 'rank_img', and 'rank_img_src' */ - public function get_rank($user_id, $query = false) + public function get_rank(int $user_id, bool $query = false): array { if (!($user = $this->get_user($user_id, $query))) { - return ''; + return []; } if (!function_exists('phpbb_get_user_rank')) @@ -233,7 +233,7 @@ class user_loader 'rank_img_src', ); - $user_rank_data = phpbb_get_user_rank($user, (($user['user_id'] == ANONYMOUS) ? false : $user['user_posts'])); + $user_rank_data = phpbb_get_user_rank($user, ($user['user_id'] == ANONYMOUS ? false : $user['user_posts'])); $rank['rank_title'] = $user_rank_data['title']; $rank['rank_img'] = $user_rank_data['img']; $rank['rank_img_src'] = $user_rank_data['img_src'];