[ticket/16955] Clean up group related classes for psalm

PHPBB3-16955
This commit is contained in:
Marc Alexander 2022-12-26 14:41:18 +01:00
parent c4d3e1aa7b
commit d9c179f9ef
No known key found for this signature in database
GPG key ID: 50E0D2423696F995
3 changed files with 34 additions and 20 deletions

View file

@ -119,6 +119,7 @@ class helper
public function get_name_string($mode, $group_id, $group_name, $group_colour = '', $custom_profile_url = false) public function get_name_string($mode, $group_id, $group_name, $group_colour = '', $custom_profile_url = false)
{ {
$s_is_bots = ($group_name === 'BOTS'); $s_is_bots = ($group_name === 'BOTS');
$group_name_string = null;
// This switch makes sure we only run code required for the mode // This switch makes sure we only run code required for the mode
switch ($mode) switch ($mode)

View file

@ -47,8 +47,9 @@ class legend implements \phpbb\groupposition\groupposition_interface
* Returns the group_legend for a given group, if the group exists. * Returns the group_legend for a given group, if the group exists.
* *
* @param int $group_id group_id of the group to be selected * @param int $group_id group_id of the group to be selected
*
* @return int position of the group * @return int position of the group
* @throws \phpbb\groupposition\exception * @throws exception
*/ */
public function get_group_value($group_id) public function get_group_value($group_id)
{ {
@ -62,7 +63,7 @@ class legend implements \phpbb\groupposition\groupposition_interface
if ($current_value === false) if ($current_value === false)
{ {
// Group not found. // Group not found.
throw new \phpbb\groupposition\exception('NO_GROUP'); throw new exception('NO_GROUP');
} }
return (int) $current_value; return (int) $current_value;
@ -215,7 +216,9 @@ class legend implements \phpbb\groupposition\groupposition_interface
* Get group type language var * Get group type language var
* *
* @param int $group_type group_type from the groups-table * @param int $group_type group_type from the groups-table
*
* @return string name of the language variable for the given group-type. * @return string name of the language variable for the given group-type.
* @throws exception If invalid group type is supplied
*/ */
public static function group_type_language($group_type) public static function group_type_language($group_type)
{ {
@ -231,6 +234,8 @@ class legend implements \phpbb\groupposition\groupposition_interface
return 'GROUP_SPECIAL'; return 'GROUP_SPECIAL';
case GROUP_FREE: case GROUP_FREE:
return 'GROUP_OPEN'; return 'GROUP_OPEN';
default:
throw new exception('NO_GROUP');
} }
} }
} }

View file

@ -58,8 +58,9 @@ class teampage implements \phpbb\groupposition\groupposition_interface
* Returns the teampage position for a given group, if the group exists. * Returns the teampage position for a given group, if the group exists.
* *
* @param int $group_id group_id of the group to be selected * @param int $group_id group_id of the group to be selected
*
* @return int position of the group * @return int position of the group
* @throws \phpbb\groupposition\exception * @throws exception
*/ */
public function get_group_value($group_id) public function get_group_value($group_id)
{ {
@ -76,7 +77,7 @@ class teampage implements \phpbb\groupposition\groupposition_interface
if ($row === false) if ($row === false)
{ {
// Group not found. // Group not found.
throw new \phpbb\groupposition\exception('NO_GROUP'); throw new exception('NO_GROUP');
} }
return (int) $row['teampage_position']; return (int) $row['teampage_position'];
@ -86,8 +87,9 @@ class teampage implements \phpbb\groupposition\groupposition_interface
* Returns the row for a given group, if the group exists. * Returns the row for a given group, if the group exists.
* *
* @param int $group_id group_id of the group to be selected * @param int $group_id group_id of the group to be selected
*
* @return array Data row of the group * @return array Data row of the group
* @throws \phpbb\groupposition\exception * @throws exception
*/ */
public function get_group_values($group_id) public function get_group_values($group_id)
{ {
@ -104,7 +106,7 @@ class teampage implements \phpbb\groupposition\groupposition_interface
if ($row === false) if ($row === false)
{ {
// Group not found. // Group not found.
throw new \phpbb\groupposition\exception('NO_GROUP'); throw new exception('NO_GROUP');
} }
return $row; return $row;
@ -114,8 +116,9 @@ class teampage implements \phpbb\groupposition\groupposition_interface
* Returns the teampage position for a given teampage item, if the item exists. * Returns the teampage position for a given teampage item, if the item exists.
* *
* @param int $teampage_id Teampage_id of the selected item * @param int $teampage_id Teampage_id of the selected item
*
* @return int Teampage position of the item * @return int Teampage position of the item
* @throws \phpbb\groupposition\exception * @throws exception
*/ */
public function get_teampage_value($teampage_id) public function get_teampage_value($teampage_id)
{ {
@ -129,7 +132,7 @@ class teampage implements \phpbb\groupposition\groupposition_interface
if ($current_value === false) if ($current_value === false)
{ {
// Group not found. // Group not found.
throw new \phpbb\groupposition\exception('NO_GROUP'); throw new exception('NO_GROUP');
} }
return (int) $current_value; return (int) $current_value;
@ -139,8 +142,9 @@ class teampage implements \phpbb\groupposition\groupposition_interface
* Returns the teampage row for a given teampage item, if the item exists. * Returns the teampage row for a given teampage item, if the item exists.
* *
* @param int $teampage_id Teampage_id of the selected item * @param int $teampage_id Teampage_id of the selected item
*
* @return array Teampage row of the item * @return array Teampage row of the item
* @throws \phpbb\groupposition\exception * @throws exception
*/ */
public function get_teampage_values($teampage_id) public function get_teampage_values($teampage_id)
{ {
@ -154,7 +158,7 @@ class teampage implements \phpbb\groupposition\groupposition_interface
if ($row === false) if ($row === false)
{ {
// Group not found. // Group not found.
throw new \phpbb\groupposition\exception('NO_GROUP'); throw new exception('NO_GROUP');
} }
return $row; return $row;
@ -568,7 +572,9 @@ class teampage implements \phpbb\groupposition\groupposition_interface
* Get group type language var * Get group type language var
* *
* @param int $group_type group_type from the groups-table * @param int $group_type group_type from the groups-table
*
* @return string name of the language variable for the given group-type. * @return string name of the language variable for the given group-type.
* @throws exception If invalid group type is supplied
*/ */
public static function group_type_language($group_type) public static function group_type_language($group_type)
{ {
@ -584,6 +590,8 @@ class teampage implements \phpbb\groupposition\groupposition_interface
return 'GROUP_SPECIAL'; return 'GROUP_SPECIAL';
case GROUP_FREE: case GROUP_FREE:
return 'GROUP_OPEN'; return 'GROUP_OPEN';
default:
throw new exception('NO_GROUP');
} }
} }
} }