Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.0] Fix type errors on calling ssi_examples.php #8022

Merged
merged 1 commit into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Sources/Lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -592,13 +592,17 @@ public static function sentenceList(array $list): string
* Wrapper for number_format() that uses Lang::$txt['number_format'] to
* figure out the parameters to pass to number_format().
*
* @param int|float $number A number.
* @param int|float|string $number A number.
* @param int $decimals If set, will use the specified number of decimal
* places. Otherwise it's automatically determined.
* @return string A formatted number
*/
public static function numberFormat(int|float $number, ?int $decimals = null): string
public static function numberFormat(int|float|string $number, ?int $decimals = null): string
{
if (is_string($number)) {
$number = intval($number);
}

// Cache these values...
if (!isset(self::$decimal_separator)) {
// Not set for whatever reason?
Expand Down
18 changes: 11 additions & 7 deletions Sources/ServerSideIncludes.php
Original file line number Diff line number Diff line change
Expand Up @@ -495,12 +495,12 @@ public static function queryPosts(
$posts = [];

while ($row = Db::$db->fetch_assoc($request)) {
$topic = new Topic($row['id_topic'], [
$topic = new Topic((int) $row['id_topic'], [
'id_board' => $row['id_board'],
'id_first_msg' => $row['id_msg'],
]);

$row['body'] = BBCodeParser::load()->parse($row['body'], $row['smileys_enabled'], $row['id_msg']);
$row['body'] = BBCodeParser::load()->parse($row['body'], (bool) $row['smileys_enabled'], $row['id_msg']);

// Censor it!
Lang::censorText($row['subject']);
Expand Down Expand Up @@ -680,7 +680,7 @@ public static function recentTopics(int $num_recent = 8, ?array $exclude_boards
$posts = [];

while ($row = Db::$db->fetch_assoc($request)) {
$row['body'] = strip_tags(strtr(BBCodeParser::load()->parse($row['body'], $row['smileys_enabled'], $row['id_msg']), ['<br>' => '&#10;']));
$row['body'] = strip_tags(strtr(BBCodeParser::load()->parse($row['body'], (bool) $row['smileys_enabled'], $row['id_msg']), ['<br>' => '&#10;']));

if (Utils::entityStrlen($row['body']) > 128) {
$row['body'] = Utils::entitySubstr($row['body'], 0, 128) . '...';
Expand Down Expand Up @@ -1091,7 +1091,7 @@ public static function randomMember(string $random_type = '', string $output_met
}

// Get the lowest ID we're interested in.
$member_id = mt_rand(1, Config::$modSettings['latestMember']);
$member_id = mt_rand(1, (int) Config::$modSettings['latestMember']);

$where_query = '
id_member >= {int:selected_member}
Expand Down Expand Up @@ -1339,6 +1339,8 @@ public static function boardStats(string $output_method = 'echo'): ?array
', Lang::$txt['total_topics'], ': ', Lang::numberFormat($totals['topics']), ' <br>
', Lang::$txt['total_cats'], ': ', Lang::numberFormat($totals['categories']), '<br>
', Lang::$txt['total_boards'], ': ', Lang::numberFormat($totals['boards']);

return null;
}

/**
Expand Down Expand Up @@ -1438,7 +1440,7 @@ public static function logOnline(string $output_method = 'echo'): ?array
return self::whosOnline($output_method);
}

self::whosOnline($output_method);
return self::whosOnline($output_method);
}

/**
Expand Down Expand Up @@ -1823,6 +1825,8 @@ public static function quickSearch(string $output_method = 'echo'): ?string
<form action="', Config::$scripturl, '?action=search2" method="post" accept-charset="', Utils::$context['character_set'], '">
<input type="hidden" name="advanced" value="0"><input type="text" name="search" size="30"> <input type="submit" value="', Lang::$txt['search'], '" class="button">
</form>';

return null;
}

/**
Expand Down Expand Up @@ -2168,7 +2172,7 @@ public static function boardNews(?int $board = null, ?int $limit = null, ?int $s
$recycle_board = !empty(Config::$modSettings['recycle_enable']) && !empty(Config::$modSettings['recycle_board']) ? (int) Config::$modSettings['recycle_board'] : 0;

while ($row = Db::$db->fetch_assoc($request)) {
$topic = new Topic($row['id_topic'], [
$topic = new Topic((int) $row['id_topic'], [
'id_board' => $row['id_board'],
'num_replies' => $row['num_replies'],
'locked' => $row['locked'],
Expand Down Expand Up @@ -2197,7 +2201,7 @@ public static function boardNews(?int $board = null, ?int $limit = null, ?int $s
$row['body'] .= '...';
}

$row['body'] = BBCodeParser::load()->parse($row['body'], $row['smileys_enabled'], $row['id_msg']);
$row['body'] = BBCodeParser::load()->parse($row['body'], (bool) $row['smileys_enabled'], $row['id_msg']);

if (!empty($recycle_board) && $row['id_board'] == $recycle_board) {
$row['icon'] = 'recycled';
Expand Down
Loading