Merge "Permit case independent unit test directories"
[lhc/web/wiklou.git] / includes / search / SearchEngine.php
index 2fb4585..66e59e5 100644 (file)
@@ -79,7 +79,7 @@ abstract class SearchEngine {
         * be converted to final in 1.34. Override self::doSearchText().
         *
         * @param string $term Raw search term
-        * @return SearchResultSet|Status|null
+        * @return ISearchResultSet|Status|null
         */
        public function searchText( $term ) {
                return $this->maybePaginate( function () use ( $term ) {
@@ -91,7 +91,7 @@ abstract class SearchEngine {
         * Perform a full text search query and return a result set.
         *
         * @param string $term Raw search term
-        * @return SearchResultSet|Status|null
+        * @return ISearchResultSet|Status|null
         * @since 1.32
         */
        protected function doSearchText( $term ) {
@@ -136,7 +136,7 @@ abstract class SearchEngine {
         * be converted to final in 1.34. Override self::doSearchTitle().
         *
         * @param string $term Raw search term
-        * @return SearchResultSet|null
+        * @return ISearchResultSet|null
         */
        public function searchTitle( $term ) {
                return $this->maybePaginate( function () use ( $term ) {
@@ -148,7 +148,7 @@ abstract class SearchEngine {
         * Perform a title-only search query and return a result set.
         *
         * @param string $term Raw search term
-        * @return SearchResultSet|null
+        * @return ISearchResultSet|null
         * @since 1.32
         */
        protected function doSearchTitle( $term ) {
@@ -161,7 +161,7 @@ abstract class SearchEngine {
         * explicitly implement their own pagination.
         *
         * @param Closure $fn Takes no arguments
-        * @return SearchResultSet|Status<SearchResultSet>|null Result of calling $fn
+        * @return ISearchResultSet|Status<ISearchResultSet>|null Result of calling $fn
         */
        private function maybePaginate( Closure $fn ) {
                if ( $this instanceof PaginatingSearchEngine ) {
@@ -175,10 +175,10 @@ abstract class SearchEngine {
                }
 
                $resultSet = null;
-               if ( $resultSetOrStatus instanceof SearchResultSet ) {
+               if ( $resultSetOrStatus instanceof ISearchResultSet ) {
                        $resultSet = $resultSetOrStatus;
                } elseif ( $resultSetOrStatus instanceof Status &&
-                       $resultSetOrStatus->getValue() instanceof SearchResultSet
+                       $resultSetOrStatus->getValue() instanceof ISearchResultSet
                ) {
                        $resultSet = $resultSetOrStatus->getValue();
                }
@@ -433,10 +433,13 @@ abstract class SearchEngine {
        /**
         * Find snippet highlight settings for all users
         * @return array Contextlines, contextchars
+        * @deprecated in 1.34 use the SearchHighlighter constants directly
+        * @see SearchHighlighter::DEFAULT_CONTEXT_CHARS
+        * @see SearchHighlighter::DEFAULT_CONTEXT_LINES
         */
        public static function userHighlightPrefs() {
-               $contextlines = 2; // Hardcode this. Old defaults sucked. :)
-               $contextchars = 75; // same as above.... :P
+               $contextlines = SearchHighlighter::DEFAULT_CONTEXT_LINES;
+               $contextchars = SearchHighlighter::DEFAULT_CONTEXT_CHARS;
                return [ $contextlines, $contextchars ];
        }
 
@@ -486,6 +489,7 @@ abstract class SearchEngine {
         * @param Title $t Title we're indexing
         * @param Content|null $c Content of the page to index
         * @return string
+        * @deprecated since 1.34 use Content::getTextForSearchIndex directly
         */
        public function getTextFromContent( Title $t, Content $c = null ) {
                return $c ? $c->getTextForSearchIndex() : '';
@@ -497,6 +501,7 @@ abstract class SearchEngine {
         * rather silly handling, it should return true here instead.
         *
         * @return bool
+        * @deprecated since 1.34 no longer needed since getTextFromContent is being deprecated
         */
        public function textAlreadyUpdatedForIndex() {
                return false;
@@ -722,6 +727,7 @@ abstract class SearchEngine {
         * @param string $profileType the type of profiles
         * @param User|null $user the user requesting the list of profiles
         * @return array|null the list of profiles or null if none available
+        * @phan-return null|array{name:string,desc-message:string,default?:bool}
         */
        public function getProfiles( $profileType, User $user = null ) {
                return null;
@@ -784,9 +790,9 @@ abstract class SearchEngine {
        /**
         * Augment search results with extra data.
         *
-        * @param SearchResultSet $resultSet
+        * @param ISearchResultSet $resultSet
         */
-       public function augmentSearchResults( SearchResultSet $resultSet ) {
+       public function augmentSearchResults( ISearchResultSet $resultSet ) {
                $setAugmentors = [];
                $rowAugmentors = [];
                Hooks::run( "SearchResultsAugment", [ &$setAugmentors, &$rowAugmentors ] );
@@ -803,6 +809,10 @@ abstract class SearchEngine {
                        $setAugmentors[$name] = new PerRowAugmentor( $row );
                }
 
+               /**
+                * @var string $name
+                * @var ResultSetAugmentor $augmentor
+                */
                foreach ( $setAugmentors as $name => $augmentor ) {
                        $data = $augmentor->augmentAll( $resultSet );
                        if ( $data ) {