Replace MysqlSearchEngine::getStopWords() by ::isStopWord()
authorTim Düsterhus <duesterhus@woltlab.com>
Wed, 27 Apr 2022 07:18:47 +0000 (09:18 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Wed, 27 Apr 2022 07:18:47 +0000 (09:18 +0200)
wcfsetup/install/files/lib/system/search/mysql/MysqlSearchEngine.class.php

index 7c958fce1f200bd61c791cf8363a8ef8ef27ff29..a4202569291c19ea1ade982ca2e076c579b841d6 100644 (file)
@@ -191,7 +191,7 @@ class MysqlSearchEngine extends AbstractSearchEngine
                 // - the word is longer than the min token size, or
                 // - the word is quoted.
                 if (
-                    !\in_array($word, $this->getStopWords())
+                    !$this->isStopWord($word)
                     && (
                         $word[0] === '"'
                         || \strlen($word) >= $this->getMinTokenSize()
@@ -565,48 +565,48 @@ class MysqlSearchEngine extends AbstractSearchEngine
         return $this->minTokenSize;
     }
 
-    /**
-     * @return string[]
-     */
-    private function getStopWords(): array
+    private function isStopWord(string $word): bool
     {
-        return [
-            'a',
-            'about',
-            'an',
-            'are',
-            'as',
-            'at',
-            'be',
-            'by',
-            'com',
-            'de',
-            'en',
-            'for',
-            'from',
-            'how',
-            'i',
-            'in',
-            'is',
-            'it',
-            'la',
-            'of',
-            'on',
-            'or',
-            'that',
-            'the',
-            'this',
-            'to',
-            'was',
-            'what',
-            'when',
-            'where',
-            'who',
-            'will',
-            'with',
-            'und',
-            'the',
-            'www',
-        ];
+        return \in_array(
+            $word,
+            [
+                'a',
+                'about',
+                'an',
+                'are',
+                'as',
+                'at',
+                'be',
+                'by',
+                'com',
+                'de',
+                'en',
+                'for',
+                'from',
+                'how',
+                'i',
+                'in',
+                'is',
+                'it',
+                'la',
+                'of',
+                'on',
+                'or',
+                'that',
+                'the',
+                'this',
+                'to',
+                'was',
+                'what',
+                'when',
+                'where',
+                'who',
+                'will',
+                'with',
+                'und',
+                'the',
+                'www',
+            ]
+        );
     }
 }