1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-31 05:50:42 +02:00

[ticket/13713] Add type hints and clean up code

PHPBB3-13713
This commit is contained in:
Marc Alexander
2021-05-04 21:23:21 +02:00
parent 794b77971c
commit ed291843f2
10 changed files with 102 additions and 79 deletions

View File

@@ -23,7 +23,7 @@ class friend extends base_user
*
* @param \phpbb\user $user
*/
public function set_user(\phpbb\user $user)
public function set_user(\phpbb\user $user): void
{
$this->user = $user;
}
@@ -31,29 +31,28 @@ class friend extends base_user
/**
* {@inheritdoc}
*/
protected function query($keyword, $topic_id)
protected function query(string $keyword, int $topic_id): string
{
/*
* For optimization purposes all friends are returned regardless of the keyword
* Names filtering is done on the frontend
* Results will be cached on a per-user basis
*/
$query = $this->db->sql_build_query('SELECT', [
'SELECT' => 'u.username_clean, u.user_id',
'FROM' => [
return $this->db->sql_build_query('SELECT', [
'SELECT' => 'u.username_clean, u.user_id',
'FROM' => [
USERS_TABLE => 'u',
],
'LEFT_JOIN' => [
[
'FROM' => [ZEBRA_TABLE => 'z'],
'ON' => 'u.user_id = z.zebra_id'
'FROM' => [ZEBRA_TABLE => 'z'],
'ON' => 'u.user_id = z.zebra_id'
]
],
'WHERE' => 'z.friend = 1 AND z.user_id = ' . (int) $this->user->data['user_id'] . '
'WHERE' => 'z.friend = 1 AND z.user_id = ' . (int) $this->user->data['user_id'] . '
AND ' . $this->db->sql_in_set('u.user_type', [USER_NORMAL, USER_FOUNDER]) . '
AND u.username_clean ' . $this->db->sql_like_expression($keyword . $this->db->get_any_char()),
'ORDER_BY' => 'u.user_lastvisit DESC'
'ORDER_BY' => 'u.user_lastvisit DESC'
]);
return $query;
}
}