Reedy has uploaded a new change for review.

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


Change subject: More function level type hints
......................................................................

More function level type hints

Change-Id: I04491de9ca63c7d71f515817c7f0141049461e95
---
M CirrusSearch.body.php
M CirrusSearchSearcher.php
M CirrusSearchTextSanitizer.php
M CirrusSearchUpdater.php
4 files changed, 86 insertions(+), 8 deletions(-)


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

diff --git a/CirrusSearch.body.php b/CirrusSearch.body.php
index 0168dba..163f08e 100644
--- a/CirrusSearch.body.php
+++ b/CirrusSearch.body.php
@@ -43,6 +43,11 @@
                return $searcher->searchText( $term, $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." );
@@ -51,6 +56,10 @@
                CirrusSearchUpdater::updateFromTitleAndText( $id, $title, $text 
);
        }
 
+       /**
+        * @param int $id
+        * @param String $title
+        */
        public function updateTitle( $id, $title ) {
                $loadedTitle = Title::newFromID( $id );
                if ( $loadedTitle === null ) {
@@ -60,10 +69,20 @@
                CirrusSearchUpdater::updateFromTitle( $loadedTitle );
        }
 
+       /**
+        * @param int $id
+        * @param String $title
+        */
        public function delete( $id, $title ) {
                CirrusSearchUpdater::deletePages( array( $id ) );
        }
 
+       /**
+        * @param Title $t
+        * @param Content $c
+        * @param null $parserOutput
+        * @return mixed|string
+        */
        public function getTextFromContent( Title $t, Content $c = null, 
$parserOutput = null ) {
                $text = parent::getTextFromContent( $t, $c );
                if( $c ) {
@@ -79,6 +98,9 @@
                return $text;
        }
 
+       /**
+        * @return bool
+        */
        public function textAlreadyUpdatedForIndex() {
                return true;
        }
diff --git a/CirrusSearchSearcher.php b/CirrusSearchSearcher.php
index 64bdcae..37ca0c7 100644
--- a/CirrusSearchSearcher.php
+++ b/CirrusSearchSearcher.php
@@ -58,6 +58,11 @@
         */
        private $description;
 
+       /**
+        * @param $offset
+        * @param $limit
+        * @param $namespaces
+        */
        public function __construct( $offset, $limit, $namespaces ) {
                $this->offset = $offset;
                $this->limit = $limit;
@@ -73,8 +78,9 @@
 
        /**
         * Perform a prefix search.
-        * @param $search
-        * @param array(string) of titles
+        * @param array $search array(string) of titles
+        * @throws UsageException
+        * @return \CirrusSearchResultSet|null|\SearchResultSet|\Status
         */
        public function prefixSearch( $search ) {
                $requestLength = strlen( $search );
@@ -189,7 +195,7 @@
        }
 
        /**
-        * @param $id article id to search
+        * @param int $id Article id to search
         * @return CirrusSearchResultSet|null|SearchResultSet|Status
         */
        public function moreLikeThisArticle( $id ) {
@@ -378,7 +384,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\CustomScore Query 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 );
@@ -388,16 +394,33 @@
 interface CirrusSearchResultsType {
        function getFields();
        function getHighlightingConfiguration();
+
+       /**
+        * @param $result
+        */
        function transformElasticsearchResult( $result );
 }
 
 class CirrusSearchTitleResultsType {
+
+       /**
+        * @return array
+        */
        public function getFields() {
                return array( 'namespace', 'title' );
        }
+
+       /**
+        * @return null
+        */
        public function getHighlightingConfiguration() {
                return null;
        }
+
+       /**
+        * @param $result
+        * @return array
+        */
        public function transformElasticsearchResult( $result ) {
                $results = array();
                foreach( $result->getResults() as $r ) {
@@ -408,9 +431,17 @@
 }
 
 class CirrusSearchFullTextResultsType {
+
+       /**
+        * @return array
+        */
        public function getFields() {
                return array( 'id', 'title', 'namespace', 'redirect' );
        }
+
+       /**
+        * @return array
+        */
        public function getHighlightingConfiguration() {
                return array(
                        'pre_tags' => array( 
CirrusSearchSearcher::HIGHLIGHT_PRE ),
@@ -423,6 +454,11 @@
                        ),
                );
        }
+
+       /**
+        * @param $result
+        * @return CirrusSearchResultSet
+        */
        public function transformElasticsearchResult( $result ) {
                return new CirrusSearchResultSet( $result );
        }
@@ -434,6 +470,9 @@
 class CirrusSearchResultSet extends SearchResultSet {
        private $result, $hits, $totalHits, $suggestionQuery, 
$suggestionSnippet;
 
+       /**
+        * @param $res
+        */
        public function __construct( $res ) {
                $this->result = $res;
                $this->hits = $res->count();
@@ -600,6 +639,10 @@
                );
        }
 
+       /**
+        * @param string $highlighted
+        * @return string
+        */
        private function stripHighlighting( $highlighted ) {
                $markers = array( CirrusSearchSearcher::HIGHLIGHT_PRE, 
CirrusSearchSearcher::HIGHLIGHT_POST );
                return str_replace( $markers, '', $highlighted );
diff --git a/CirrusSearchTextSanitizer.php b/CirrusSearchTextSanitizer.php
index 83a08c7..16474ef 100644
--- a/CirrusSearchTextSanitizer.php
+++ b/CirrusSearchTextSanitizer.php
@@ -30,7 +30,7 @@
         * Get sanitized text from a Title.
         * @param Title $t
         * @param ParserOutput $po
-        * @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, ParserOutput 
$po = null ) {
                if ( !$po ) {
diff --git a/CirrusSearchUpdater.php b/CirrusSearchUpdater.php
index 7a1d640..95848ef 100644
--- a/CirrusSearchUpdater.php
+++ b/CirrusSearchUpdater.php
@@ -166,9 +166,16 @@
                wfProfileOut( __METHOD__ );
        }
 
+       /**
+        * @param array $page
+        * @return \Elastica\Document
+        */
        private static function buildDocumentforRevision( $page ) {
                global $wgCirrusSearchIndexedRedirects;
                wfProfileIn( __METHOD__ );
+               /**
+                * @var WikiPage $page
+                */
                $page = $page[ 'page' ];
                $title = $page->getTitle();
                $parserOutput = $page->getParserOutput( new ParserOptions(), 
$page->getRevision()->getId() );
@@ -197,6 +204,9 @@
                $redirectTitles = $title->getLinksTo( array( 'limit' => 
$wgCirrusSearchIndexedRedirects ), 'redirect', 'rd' );
                $redirects = array();
                $redirectLinks = 0;
+               /**
+                * @var Title $redirect
+                */
                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()) {
@@ -227,6 +237,9 @@
                return $doc;
        }
 
+       /**
+        * @return array|null
+        */
        private static function getIgnoredHeadings() {
                if ( self::$ignoredHeadings === null ) {
                        $source = wfMessage( 'cirrussearch-ignored-headings' 
)->inContentLanguage();
@@ -245,8 +258,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 int An integer count
         */
        private static function countLinksToTitle( $title ) {
                global $wgMemc, $wgCirrusSearchLinkCountCacheTime;
@@ -285,7 +298,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/84482
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I04491de9ca63c7d71f515817c7f0141049461e95
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