jenkins-bot has submitted this change and it was merged.

Change subject: Add some return type hints
......................................................................


Add some return type hints

Remove a couple of unused variables

Improve some existing parameter type hints

__method__ -> __METHOD__

Change-Id: I3e9bb75dbc01505cc3ffee24d5c9edd81d0f0632
---
M CirrusSearch.body.php
M CirrusSearchAnalysisConfigBuilder.php
M CirrusSearchMappingConfigBuilder.php
M CirrusSearchUpdater.php
M forceSearchIndex.php
M updateOneSearchIndexConfig.php
M updateSearchIndexConfig.php
7 files changed, 79 insertions(+), 23 deletions(-)

Approvals:
  Manybubbles: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/CirrusSearch.body.php b/CirrusSearch.body.php
index c4dfdca..c78aaca 100644
--- a/CirrusSearch.body.php
+++ b/CirrusSearch.body.php
@@ -47,11 +47,14 @@
         */
        private static $updated = array();
 
+       /**
+        * @return \Elastica\Client|null
+        */
        public static function getClient() {
                if ( self::$client != null ) {
                        return self::$client;
                }
-               global $wgCirrusSearchServers, $wgCirrusSearchMaxRetries;
+               global $wgCirrusSearchServers;
 
                // Setup the Elastica endpoints
                $servers = array();
@@ -100,15 +103,21 @@
                return CirrusSearch::getIndex( $type )->getType( 
CirrusSearch::PAGE_TYPE_NAME );
        }
 
+       /**
+        * @param $ns
+        * @param $search
+        * @param $limit
+        * @param $results
+        * @return bool
+        */
        public static function prefixSearch( $ns, $search, $limit, &$results ) {
                wfDebugLog( 'CirrusSearch', "Prefix searching:  $search" );
                // Boilerplate
-               $nsNames = 
RequestContext::getMain()->getLanguage()->getNamespaces();
                $query = new Elastica\Query();
                $query->setFields( array( 'id', 'title', 'namespace' ) );
 
                // Query params
-               $query->setLimit( $limit );
+               $query->setSize( $limit );
                $query->setFilter( CirrusSearch::buildNamespaceFilter( $ns ) );
                $indexType = CirrusSearch::pickIndexTypeFromNamespaces( $ns );
                $match = new \Elastica\Query\Match();
@@ -144,10 +153,14 @@
                return false;
        }
 
+       /**
+        * @param string $term
+        * @return CirrusSearchResultSet|null|SearchResultSet|Status
+        */
        public function searchText( $term ) {
                wfDebugLog( 'CirrusSearch', "Searching:  $term" );
                global $wgCirrusSearchPhraseSuggestMaxErrors, 
$wgCirrusSearchPhraseSuggestConfidence;
-               
+
                $originalTerm = $term;
 
                // Ignore leading ~ because it is used to force displaying 
search results but not to effect them
@@ -165,7 +178,7 @@
                        $query->setFrom( $this->offset );
                }
                if( $this->limit ) {
-                       $query->setLimit( $this->limit );
+                       $query->setSize( $this->limit );
                }
                $filters[] = CirrusSearch::buildNamespaceFilter( 
$this->namespaces );
                $indexType = CirrusSearch::pickIndexTypeFromNamespaces( 
$this->namespaces );
@@ -290,6 +303,7 @@
         * Filter a query to only return results in given namespace(s)
         *
         * @param array $ns Array of namespaces
+        * @return \Elastica\Filter\Terms|null
         */
        private static function buildNamespaceFilter( array $ns ) {
                if ( $ns !== null && count( $ns ) ) {
@@ -393,6 +407,9 @@
                }
        }
 
+       /**
+        * @param $linkUpdate LinksUpdate
+        */
        public static function linksUpdateCompletedHook( $linkUpdate ) {
                $title = $linkUpdate->getTitle();
                $articleId = $title->getArticleID();
@@ -441,7 +458,7 @@
  * A set of results from Elasticsearch.
  */
 class CirrusSearchResultSet extends SearchResultSet {
-       private $result, $docs, $hits, $totalHits, $suggestionQuery, 
$suggestionSnippet;
+       private $result, $hits, $totalHits, $suggestionQuery, 
$suggestionSnippet;
 
        public function __construct( $res ) {
                $this->result = $res;
@@ -500,7 +517,7 @@
                $current = $this->result->current();
                if ( $current ) {
                        $this->result->next();
-                       return new CirrusSearchResult( $current );      
+                       return new CirrusSearchResult( $current );
                }
                return false;
        }
diff --git a/CirrusSearchAnalysisConfigBuilder.php 
b/CirrusSearchAnalysisConfigBuilder.php
index 4f1588b..d65d06b 100644
--- a/CirrusSearchAnalysisConfigBuilder.php
+++ b/CirrusSearchAnalysisConfigBuilder.php
@@ -20,6 +20,9 @@
 class CirrusSearchAnalysisConfigBuilder {
        private $language;
 
+       /**
+        * @return array
+        */
        public static function build() {
                $builder = new CirrusSearchAnalysisConfigBuilder();
                return $builder->buildConfig();
diff --git a/CirrusSearchMappingConfigBuilder.php 
b/CirrusSearchMappingConfigBuilder.php
index 68d7772..45021f0 100644
--- a/CirrusSearchMappingConfigBuilder.php
+++ b/CirrusSearchMappingConfigBuilder.php
@@ -18,6 +18,10 @@
  * http://www.gnu.org/copyleft/gpl.html
  */
 class CirrusSearchMappingConfigBuilder {
+
+       /**
+        * @return array
+        */
        public static function build() {
                $builder = new CirrusSearchMappingConfigBuilder();
                return $builder->buildConfig();
@@ -44,10 +48,10 @@
 
        /**
         * Build a string field.
-        * @param name string Name of the field.  Required if extra is not 
falsy.
-        * @param extra array Extra analyzers for this field beyond the basic 
string type.  If not falsy the
+        * @param $name string|null Name of the field.  Required if extra is 
not false.
+        * @param $extra array|null Extra analyzers for this field beyond the 
basic string type.  If not falsy the
         *              field will be a multi_field.
-        * @param willHighlight Will this field be highlighted?  Defaults to 
false.
+        * @param $willHighlight bool Will this field be highlighted?  Defaults 
to false.
         * @return array definition of the field
         */
        private function buildStringField( $name = null, $extra = null, 
$willHighlight = false ) {
@@ -71,4 +75,4 @@
                return $field;
        }
 
-}
\ No newline at end of file
+}
diff --git a/CirrusSearchUpdater.php b/CirrusSearchUpdater.php
index 482b951..1412c85 100644
--- a/CirrusSearchUpdater.php
+++ b/CirrusSearchUpdater.php
@@ -44,6 +44,10 @@
                wfProfileOut( __METHOD__ );
        }
 
+       /**
+        * @param $indexType
+        * @param $documents array
+        */
        private static function sendDocuments( $indexType, $documents ) {
                wfProfileIn( __METHOD__ );
 
@@ -66,6 +70,11 @@
                wfProfileOut( __METHOD__ );
        }
 
+       /**
+        * @param $revision Revision
+        * @param $text string
+        * @return \Elastica\Document
+        */
        public static function buildDocumentforRevision( $revision, $text ) {
                global $wgCirrusSearchIndexedRedirects;
                wfProfileIn( __METHOD__ );
@@ -104,7 +113,7 @@
        /**
         * Delete pages from the elasticsearch index
         *
-        * @param array $pageIds An array of ids to delete
+        * @param array $pages An array of ids to delete
         */
        public static function deletePages( $pages ) {
                wfProfileIn( __METHOD__ );
@@ -115,6 +124,10 @@
                wfProfileOut( __METHOD__ );
        }
 
+       /**
+        * @param $indexType
+        * @param $ids array
+        */
        private static function sendDeletes( $indexType, $ids ) {
                wfProfileIn( __METHOD__ );
 
diff --git a/forceSearchIndex.php b/forceSearchIndex.php
index 0105930..ac38969 100644
--- a/forceSearchIndex.php
+++ b/forceSearchIndex.php
@@ -132,7 +132,10 @@
         * Find $this->mBatchSize revisions who are the latest for a page and 
were
         * made after (minUpdate,minId) and before maxUpdate.
         *
-        * @return an array of the last update timestamp, id, revision, and 
text that was found.
+        * @param $minUpdate
+        * @param $minId
+        * @param $maxUpdate
+        * @return array An array of the last update timestamp, id, revision, 
and text that was found.
         *    Sometimes rev and text are null - those record should be used to 
determine new
         *    inputs for this function but should not by synced to the search 
index.
         */
@@ -211,7 +214,11 @@
        /**
         * Find $this->mBatchSize deletes who were deleted after 
(minUpdate,minNamespace,minTitle) and before maxUpdate.
         *
-        * @return an array of the last update timestamp and id that were found
+        * @param $minUpdate
+        * @param $minNamespace
+        * @param $minTitle
+        * @param $maxUpdate
+        * @return array An array of the last update timestamp and id that were 
found
         */
        private function findDeletes( $minUpdate, $minNamespace, $minTitle, 
$maxUpdate ) {
                wfProfileIn( __METHOD__ );
diff --git a/updateOneSearchIndexConfig.php b/updateOneSearchIndexConfig.php
index 56718fc..d2c26a5 100644
--- a/updateOneSearchIndexConfig.php
+++ b/updateOneSearchIndexConfig.php
@@ -49,6 +49,9 @@
                self::addSharedOptions( $this );
        }
 
+       /**
+        * @param $maintenance Maintenance
+        */
        public static function addSharedOptions( $maintenance ) {
                $maintenance->addOption( 'rebuild', 'Blow away the identified 
index and rebuild it from ' .
                        'scratch.' );
@@ -159,6 +162,13 @@
                        } );
                }
        }
+
+       /**
+        * @param $prefix
+        * @param $settings
+        * @param $required array
+        * @return bool
+        */
        private function vaActualMatchRequired( $prefix, $settings, $required ) 
{
                foreach( $required as $key => $value ) {
                        $settingsKey = $prefix . '.' . $key;
@@ -202,6 +212,11 @@
                }
        }
 
+       /**
+        * @param $actual
+        * @param $required array
+        * @return bool
+        */
        private function vmActualMatchRequired( $actual, $required ) {
                foreach( $required as $key => $value ) {
                        if ( !array_key_exists( $key, $actual ) ) {
@@ -313,30 +328,29 @@
                $this->output( $this->indent . "About to reindex 
$totalDocsToReindex documents\n" );
                $operationStartTime = microtime( true );
                $completed = 0;
-               $rate = 0;
 
                while ( true ) {
-                       wfProfileIn( __method__ . '::receiveDocs' );
+                       wfProfileIn( __METHOD__ . '::receiveDocs' );
                        $result = $this->getIndex()->search( array(), array(
                                'scroll_id' => 
$result->getResponse()->getScrollId(),
                                'scroll' => '10m'
                        ) );
-                       wfProfileOut( __method__ . '::receiveDocs' );
+                       wfProfileOut( __METHOD__ . '::receiveDocs' );
                        if ( !$result->count() ) {
                                $this->output( $this->indent . "All done\n" );
                                break;
                        }
-                       wfProfileIn( __method__ . '::packageDocs' );
+                       wfProfileIn( __METHOD__ . '::packageDocs' );
                        $documents = array();
                        while ( $result->current() ) {
                                $documents[] = new \Elastica\Document( 
$result->current()->getId(), $result->current()->getSource() );
                                $result->next();
                        }
-                       wfProfileOut( __method__ . '::packageDocs' );
-                       wfProfileIn( __method__ . '::sendDocs' );
+                       wfProfileOut( __METHOD__ . '::packageDocs' );
+                       wfProfileIn( __METHOD__ . '::sendDocs' );
                        $updateResult = $this->getPageType()->addDocuments( 
$documents );
                        wfDebugLog( 'CirrusSearch', 'Update completed in ' . 
$updateResult->getEngineTime() . ' (engine) millis' );
-                       wfProfileOut( __method__ . '::sendDocs' );
+                       wfProfileOut( __METHOD__ . '::sendDocs' );
                        $completed += $result->count();
                        $rate = round( $completed / ( microtime( true ) - 
$operationStartTime ) );
                        $this->output( $this->indent . "Reindexed 
$completed/$totalDocsToReindex documents at $rate/second\n");
diff --git a/updateSearchIndexConfig.php b/updateSearchIndexConfig.php
index dfb6ffb..c3c3113 100644
--- a/updateSearchIndexConfig.php
+++ b/updateSearchIndexConfig.php
@@ -27,8 +27,6 @@
  * Update the elasticsearch configuration for this index.
  */
 class UpdateSearchIndexConfig extends Maintenance {
-       private $returnCode = 0;
-
        public function __construct() {
                parent::__construct();
                $this->addDescription( "Update the configuration or contents of 
all search indecies." );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I3e9bb75dbc01505cc3ffee24d5c9edd81d0f0632
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: Reedy <re...@wikimedia.org>
Gerrit-Reviewer: Demon <ch...@wikimedia.org>
Gerrit-Reviewer: Manybubbles <never...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to