Reedy has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/83969


Change subject: Improve method parameter type hints
......................................................................

Improve method parameter type hints

Change-Id: Ibcb501b9ea1300dcf780ae2e48bf5d1a8ad583b7
---
M CirrusSearch.body.php
M CirrusSearchSearcher.php
M CirrusSearchTextSanitizer.php
M CirrusSearchUpdater.php
4 files changed, 73 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch 
refs/changes/69/83969/1

diff --git a/CirrusSearch.body.php b/CirrusSearch.body.php
index 0771f8a..6d1d8e4 100644
--- a/CirrusSearch.body.php
+++ b/CirrusSearch.body.php
@@ -28,6 +28,11 @@
                        $this->namespaces, $this->showRedirects );
        }
 
+       /**
+        * @param int $id
+        * @param String $title
+        * @param String $text
+        */
        public function update( $id, $title, $text ) {
                if ( $text === false || $text === null ) { // Can't just check 
falsy text because empty string is ok!
                        wfLogWarning( "Search update called with false or null 
text for $title.  Ignoring search update." );
@@ -36,6 +41,10 @@
                CirrusSearchUpdater::updateFromTitleAndText( $id, $title, $text 
);
        }
 
+       /**
+        * @param int $id
+        * @param String $title
+        */
        public function updateTitle( $id, $title ) {
                $loadedTitle = Title::newFromID( $id );
                if ( $loadedTitle === null ) {
@@ -45,10 +54,19 @@
                CirrusSearchUpdater::updateFromTitle( $loadedTitle );
        }
 
+       /**
+        * @param int $id
+        * @param String $title
+        */
        public function delete( $id, $title ) {
                CirrusSearchUpdater::deletePages( array( $id ) );
        }
 
+       /**
+        * @param Title $t
+        * @param Content $c
+        * @return mixed|string
+        */
        public function getTextFromContent( Title $t, Content $c = null ) {
                $text = parent::getTextFromContent( $t, $c );
                if( $c ) {
@@ -64,6 +82,9 @@
                return $text;
        }
 
+       /**
+        * @return bool
+        */
        public function textAlreadyUpdatedForIndex() {
                return true;
        }
diff --git a/CirrusSearchSearcher.php b/CirrusSearchSearcher.php
index 0aefbe2..ddd5147 100644
--- a/CirrusSearchSearcher.php
+++ b/CirrusSearchSearcher.php
@@ -48,7 +48,6 @@
                $query->setLimit( $limit );
                $mainFilter = new \Elastica\Filter\Bool();
                $mainFilter->addMust( self::buildNamespaceFilter( $ns ) );
-               $prefixFilterQuery = new \Elastica\Filter\Query();
                $match = new \Elastica\Query\Match();
                $match->setField( 'title.prefix', array(
                        'query' => substr( $search, 0, self::MAX_PREFIX_SEARCH 
),
@@ -340,7 +339,7 @@
        /**
         * Wrap query in link based boosts.
         * @param $query null|Elastica\Query optional query to boost.  if null 
the match_all is assumed
-        * @return query that will run $query and boost results based on links
+        * @return \Elastica\Query\AbstractQuery that will run $query and boost 
results based on links
         */
        private static function boostQuery( $query = null ) {
                return new \Elastica\Query\CustomScore( "_score * 
log10(doc['links'].value + doc['redirect_links'].value + 2)", $query );
@@ -382,6 +381,9 @@
                return $this->suggestionQuery;
        }
 
+       /**
+        * @return bool
+        */
        public function hasResults() {
                return $this->totalHits > 0;
        }
@@ -394,6 +396,9 @@
                return $this->hits;
        }
 
+       /**
+        * @return bool
+        */
        public function hasSuggestion() {
                return $this->suggestionQuery !== null;
        }
@@ -488,6 +493,9 @@
                return Title::makeTitleSafe( $redirect[ 'namespace' ], 
$redirect[ 'title' ] );
        }
 
+       /**
+        * @return Title
+        */
        private function findSectionTitle() {
                $heading = $this->stripHighlighting( $this->sectionSnippet );
                return Title::makeTitle(
@@ -497,31 +505,56 @@
                );
        }
 
+       /**
+        * @param $highlighted string
+        * @return string
+        */
        private function stripHighlighting( $highlighted ) {
                $markers = array( CirrusSearchSearcher::HIGHLIGHT_PRE, 
CirrusSearchSearcher::HIGHLIGHT_POST );
                return str_replace( $markers, '', $highlighted );
        }
 
+       /**
+        * @param array $terms
+        * @return String
+        */
        public function getTitleSnippet( $terms ) {
                return $this->titleSnippet;
        }
 
+       /**
+        * @return null|Title
+        */
        public function getRedirectTitle() {
                return $this->redirectTitle;
        }
 
+       /**
+        * @param array $terms
+        * @return String
+        */
        public function getRedirectSnippet( $terms ) {
                return $this->redirectSnipppet;
        }
 
+       /**
+        * @param array $terms
+        * @return string
+        */
        public function getTextSnippet( $terms ) {
                return $this->textSnippet;
        }
 
+       /**
+        * @return string
+        */
        public function getSectionSnippet() {
                return $this->sectionSnippet;
        }
 
+       /**
+        * @return null|Title
+        */
        function getSectionTitle() {
                return $this->sectionTitle;
        }
diff --git a/CirrusSearchTextSanitizer.php b/CirrusSearchTextSanitizer.php
index 635eb41..4112fef 100644
--- a/CirrusSearchTextSanitizer.php
+++ b/CirrusSearchTextSanitizer.php
@@ -29,7 +29,7 @@
        /**
         * Get sanitized text from a Title.
         * @param Title $t
-        * @return sanitized text from the title or null if we can't build the 
parser output
+        * @return string Sanitized text from the title or null if we can't 
build the parser output
         */
        public static function getSantizedTextFromTitle( Title $t ) {
                $article = new Article( $t, 0 );
diff --git a/CirrusSearchUpdater.php b/CirrusSearchUpdater.php
index 364aec2..4085794 100644
--- a/CirrusSearchUpdater.php
+++ b/CirrusSearchUpdater.php
@@ -167,9 +167,16 @@
                wfProfileOut( __METHOD__ );
        }
 
+       /**
+        * @param $page array
+        * @return \Elastica\Document
+        */
        private static function buildDocumentforRevision( $page ) {
                global $wgCirrusSearchIndexedRedirects;
                wfProfileIn( __METHOD__ );
+               /**
+                * @var $revision Revision
+                */
                $revision = $page[ 'rev' ];
                $text = $page[ 'text' ];
                $title = $revision->getTitle();
@@ -198,6 +205,9 @@
                $redirectTitles = $title->getLinksTo( array( 'limit' => 
$wgCirrusSearchIndexedRedirects ), 'redirect', 'rd' );
                $redirects = array();
                $redirectLinks = 0;
+               /**
+                * @var $redirect Title
+                */
                foreach ( $redirectTitles as $redirect ) {
                        // If the redirect is in main or the same namespace as 
the article the index it
                        if ( $redirect->getNamespace() === NS_MAIN && 
$redirect->getNamespace() === $title->getNamespace()) {
@@ -228,6 +238,9 @@
                return $doc;
        }
 
+       /**
+        * @return array|null
+        */
        private static function getIgnoredHeadings() {
                if ( self::$ignoredHeadings === null ) {
                        $source = wfMessage( 'cirrussearch-ignored-headings' 
)->inContentLanguage();
@@ -246,8 +259,8 @@
 
        /**
         * Count the links to $title directly in the slave db.
-        * @param $title a title
-        * @return an integer count
+        * @param $title Title A title
+        * @return integer count
         */
        private static function countLinksToTitle( $title ) {
                global $wgMemc, $wgCirrusSearchLinkCountCacheTime;
@@ -286,7 +299,7 @@
 
                // Build a big list of candidate pages who's links we should 
update
                $candidates = array();
-               foreach ( $linksUpdate->getParserOutput()->getLinks() as $ns => 
$ids ) {
+               foreach ( $linksUpdate->getParserOutput()->getLinks() as $ids ) 
{
                        foreach ( $ids as $id ) {
                                $candidates[] = $id;
                        }

-- 
To view, visit https://gerrit.wikimedia.org/r/83969
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibcb501b9ea1300dcf780ae2e48bf5d1a8ad583b7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: Reedy <re...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to