From 17a50027b14689075f119a84b203d7137531d4a7 Mon Sep 17 00:00:00 2001 From: Christian Schnegelberger Date: Sat, 20 Apr 2024 19:06:18 +0200 Subject: [PATCH 1/2] [ticket/17306] Change type description for get_context() PHPBB3-17306 --- phpBB/includes/functions_content.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index 1824533f22..40e1b64239 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -320,7 +320,7 @@ function bump_topic_allowed($forum_id, $topic_bumped, $last_post_time, $topic_po * Generates a text with approx. the specified length which contains the specified words and their context * * @param string $text The full text from which context shall be extracted -* @param string $words An array of words which should be contained in the result, has to be a valid part of a PCRE pattern (escape with preg_quote!) +* @param array $words An array of words which should be contained in the result, has to be a valid part of a PCRE pattern (escape with preg_quote!) * @param int $length The desired length of the resulting text, however the result might be shorter or longer than this value * * @return string Context of the specified words separated by "..." From 8f1a777c5f32434ce1eaee9a79738bb71f4ad108 Mon Sep 17 00:00:00 2001 From: Christian Schnegelberger Date: Sat, 20 Apr 2024 19:06:18 +0200 Subject: [PATCH 2/2] [ticket/17306] Add type declaration to get_context and array for $words PHPBB3-17306 --- phpBB/includes/functions_content.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index 2f81c0db8d..941b2eb246 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -324,7 +324,7 @@ function bump_topic_allowed($forum_id, $topic_bumped, $last_post_time, $topic_po * * @return string Context of the specified words separated by "..." */ -function get_context($text, $words, $length = 400) +function get_context(string $text, array $words, int $length = 400) { // first replace all whitespaces with single spaces $text = preg_replace('/ +/', ' ', strtr($text, "\t\n\r\x0C ", ' '));