Skip to content

Commit b309ccc

Browse files
committed
[ticket/16955] Clean up reset_password and user_loader
PHPBB3-16955
1 parent 067ccdd commit b309ccc

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

ucp/controller/reset_password.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
use phpbb\language\language;
2323
use phpbb\log\log_interface;
2424
use phpbb\passwords\manager;
25-
use phpbb\request\request_interface;
25+
use phpbb\request\request;
2626
use phpbb\template\template;
2727
use phpbb\user;
2828
use Symfony\Component\HttpFoundation\Response;
@@ -53,7 +53,7 @@ class reset_password
5353
/** @var manager */
5454
protected $passwords_manager;
5555

56-
/** @var request_interface */
56+
/** @var request */
5757
protected $request;
5858

5959
/** @var template */
@@ -81,7 +81,7 @@ class reset_password
8181
* @param language $language
8282
* @param log_interface $log
8383
* @param manager $passwords_manager
84-
* @param request_interface $request
84+
* @param request $request
8585
* @param template $template
8686
* @param user $user
8787
* @param string $users_table
@@ -90,7 +90,7 @@ class reset_password
9090
*/
9191
public function __construct(config $config, driver_interface $db, dispatcher $dispatcher, helper $helper,
9292
language $language, log_interface $log, manager $passwords_manager,
93-
request_interface $request, template $template, user $user, string $users_table,
93+
request $request, template $template, user $user, string $users_table,
9494
string $root_path, string $php_ext)
9595
{
9696
$this->config = $config;

user_loader.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,10 @@ public function load_user_by_username($username)
132132
* @param bool $query Should we query the database if this user has not yet been loaded?
133133
* Typically this should be left as false and you should make sure
134134
* you load users ahead of time with load_users()
135-
* @return array|bool Row from the database of the user or Anonymous if the user wasn't loaded/does not exist
135+
* @return array|false Row from the database of the user or Anonymous if the user wasn't loaded/does not exist
136136
* or bool False if the anonymous user was not loaded
137137
*/
138-
public function get_user($user_id, $query = false)
138+
public function get_user(int $user_id, bool $query = false)
139139
{
140140
if (isset($this->users[$user_id]))
141141
{
@@ -162,14 +162,14 @@ public function get_user($user_id, $query = false)
162162
* colour (for obtaining the user colour)
163163
* full (for obtaining a html string representing a coloured link to the users profile)
164164
* no_profile (the same as full but forcing no profile link)
165-
* @param string $guest_username Optional parameter to specify the guest username. It will be used in favor of the GUEST language variable then.
166-
* @param string $custom_profile_url Optional parameter to specify a profile url. The user id get appended to this url as &u={user_id}
165+
* @param string|bool $guest_username Optional parameter to specify the guest username. It will be used in favor of the GUEST language variable then.
166+
* @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}
167167
* @param bool $query Should we query the database if this user has not yet been loaded?
168168
* Typically this should be left as false and you should make sure
169169
* you load users ahead of time with load_users()
170170
* @return string
171171
*/
172-
public function get_username($user_id, $mode, $guest_username = false, $custom_profile_url = false, $query = false)
172+
public function get_username(int $user_id, string $mode, $guest_username = false, $custom_profile_url = false, bool $query = false): string
173173
{
174174
if (!($user = $this->get_user($user_id, $query)))
175175
{
@@ -215,11 +215,11 @@ public function get_avatar($user_id, $query = false, $lazy = false)
215215
* you load users ahead of time with load_users()
216216
* @return array Array with keys 'rank_title', 'rank_img', and 'rank_img_src'
217217
*/
218-
public function get_rank($user_id, $query = false)
218+
public function get_rank(int $user_id, bool $query = false): array
219219
{
220220
if (!($user = $this->get_user($user_id, $query)))
221221
{
222-
return '';
222+
return [];
223223
}
224224

225225
if (!function_exists('phpbb_get_user_rank'))
@@ -233,7 +233,7 @@ public function get_rank($user_id, $query = false)
233233
'rank_img_src',
234234
);
235235

236-
$user_rank_data = phpbb_get_user_rank($user, (($user['user_id'] == ANONYMOUS) ? false : $user['user_posts']));
236+
$user_rank_data = phpbb_get_user_rank($user, ($user['user_id'] == ANONYMOUS ? false : $user['user_posts']));
237237
$rank['rank_title'] = $user_rank_data['title'];
238238
$rank['rank_img'] = $user_rank_data['img'];
239239
$rank['rank_img_src'] = $user_rank_data['img_src'];

0 commit comments

Comments
 (0)