From fcae4a0126cdd5470ce50fb1e5f3400daa0d6dfc Mon Sep 17 00:00:00 2001 From: Bugo Date: Tue, 16 Jan 2024 05:46:51 +0500 Subject: [PATCH] Fix type errors on calling ssi_examples.php Signed-off-by: Bugo --- Sources/Lang.php | 8 ++++++-- Sources/ServerSideIncludes.php | 18 +++++++++++------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Sources/Lang.php b/Sources/Lang.php index f0754baa87..812d8d2227 100644 --- a/Sources/Lang.php +++ b/Sources/Lang.php @@ -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? diff --git a/Sources/ServerSideIncludes.php b/Sources/ServerSideIncludes.php index ad5c3fe82d..fdf36e4637 100644 --- a/Sources/ServerSideIncludes.php +++ b/Sources/ServerSideIncludes.php @@ -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']); @@ -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']), ['
' => ' '])); + $row['body'] = strip_tags(strtr(BBCodeParser::load()->parse($row['body'], (bool) $row['smileys_enabled'], $row['id_msg']), ['
' => ' '])); if (Utils::entityStrlen($row['body']) > 128) { $row['body'] = Utils::entitySubstr($row['body'], 0, 128) . '...'; @@ -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} @@ -1339,6 +1339,8 @@ public static function boardStats(string $output_method = 'echo'): ?array ', Lang::$txt['total_topics'], ': ', Lang::numberFormat($totals['topics']), '
', Lang::$txt['total_cats'], ': ', Lang::numberFormat($totals['categories']), '
', Lang::$txt['total_boards'], ': ', Lang::numberFormat($totals['boards']); + + return null; } /** @@ -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); } /** @@ -1823,6 +1825,8 @@ public static function quickSearch(string $output_method = 'echo'): ?string
'; + + return null; } /** @@ -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'], @@ -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';