From 163e4ad3227e61aae5d51a5dcf2355264d4bd48d Mon Sep 17 00:00:00 2001 From: Brendan Petty - Totally Web Services <40818011+brendanpetty@users.noreply.github.com> Date: Wed, 14 Feb 2024 14:35:50 +1100 Subject: [PATCH] Avoid deprecated message for null string PHP 8.1 gives this error if a null value makes its way to this method mb_strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/app/vendor/teamtnt/tntsearch/src/Support/Tokenizer.php on line 10 --- src/Support/Tokenizer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Support/Tokenizer.php b/src/Support/Tokenizer.php index 8166e27..2cef252 100644 --- a/src/Support/Tokenizer.php +++ b/src/Support/Tokenizer.php @@ -7,7 +7,7 @@ class Tokenizer extends AbstractTokenizer implements TokenizerInterface public function tokenize($text, $stopwords = []) { - $text = mb_strtolower($text); + $text = mb_strtolower($text ?? ''); $split = preg_split($this->getPattern(), $text, -1, PREG_SPLIT_NO_EMPTY); return array_diff($split, $stopwords); }