Merge "Http::getProxy() method to get proxy configuration"
[lhc/web/wiklou.git] / includes / api / ApiQuerySearch.php
index 32607a5..2eb5d14 100644 (file)
@@ -125,27 +125,27 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
                        if ( isset( $searchInfo['totalhits'] ) ) {
                                $totalhits = $matches->getTotalHits();
                                if ( $totalhits !== null ) {
-                                       $apiResult->addValue( array( 'query', 'searchinfo' ),
+                                       $apiResult->addValue( [ 'query', 'searchinfo' ],
                                                'totalhits', $totalhits );
                                }
                        }
                        if ( isset( $searchInfo['suggestion'] ) && $matches->hasSuggestion() ) {
-                               $apiResult->addValue( array( 'query', 'searchinfo' ),
+                               $apiResult->addValue( [ 'query', 'searchinfo' ],
                                        'suggestion', $matches->getSuggestionQuery() );
-                               $apiResult->addValue( array( 'query', 'searchinfo' ),
+                               $apiResult->addValue( [ 'query', 'searchinfo' ],
                                        'suggestionsnippet', $matches->getSuggestionSnippet() );
                        }
                        if ( isset( $searchInfo['rewrittenquery'] ) && $matches->hasRewrittenQuery() ) {
-                               $apiResult->addValue( array( 'query', 'searchinfo' ),
+                               $apiResult->addValue( [ 'query', 'searchinfo' ],
                                        'rewrittenquery', $matches->getQueryAfterRewrite() );
-                               $apiResult->addValue( array( 'query', 'searchinfo' ),
+                               $apiResult->addValue( [ 'query', 'searchinfo' ],
                                        'rewrittenquerysnippet', $matches->getQueryAfterRewriteSnippet() );
                        }
                }
 
                // Add the search results to the result
                $terms = $wgContLang->convertForSearchResult( $matches->termMatches() );
-               $titles = array();
+               $titles = [];
                $count = 0;
                $result = $matches->next();
 
@@ -165,7 +165,7 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
 
                        $title = $result->getTitle();
                        if ( $resultPageSet === null ) {
-                               $vals = array();
+                               $vals = [];
                                ApiQueryBase::addTitleInfo( $vals, $title );
 
                                if ( isset( $prop['snippet'] ) ) {
@@ -207,7 +207,7 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
                                }
 
                                // Add item to results and see whether it fits
-                               $fit = $apiResult->addValue( array( 'query', $this->getModuleName() ),
+                               $fit = $apiResult->addValue( [ 'query', $this->getModuleName() ],
                                        null, $vals );
                                if ( !$fit ) {
                                        $this->setContinueEnumParameter( 'offset', $params['offset'] + $count - 1 );
@@ -237,15 +237,15 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
                                        $title = $result->getTitle();
 
                                        if ( $resultPageSet === null ) {
-                                               $vals = array(
+                                               $vals = [
                                                        'namespace' => $result->getInterwikiNamespaceText(),
                                                        'title' => $title->getText(),
                                                        'url' => $title->getFullUrl(),
-                                               );
+                                               ];
 
                                                // Add item to results and see whether it fits
                                                $fit = $apiResult->addValue(
-                                                       array( 'query', 'interwiki' . $this->getModuleName(), $result->getInterwikiPrefix() ),
+                                                       [ 'query', 'interwiki' . $this->getModuleName(), $result->getInterwikiPrefix() ],
                                                        null,
                                                        $vals
                                                );
@@ -263,19 +263,19 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
                                }
                        }
                        if ( $totalhits !== null ) {
-                               $apiResult->addValue( array( 'query', 'interwikisearchinfo' ),
+                               $apiResult->addValue( [ 'query', 'interwikisearchinfo' ],
                                        'totalhits', $totalhits );
                        }
                }
 
                if ( $resultPageSet === null ) {
-                       $apiResult->addIndexedTagName( array(
+                       $apiResult->addIndexedTagName( [
                                'query', $this->getModuleName()
-                       ), 'p' );
+                       ], 'p' );
                        if ( $hasInterwikiResults ) {
-                               $apiResult->addIndexedTagName( array(
+                               $apiResult->addIndexedTagName( [
                                        'query', 'interwiki' . $this->getModuleName()
-                               ), 'p' );
+                               ], 'p' );
                        }
                } else {
                        $resultPageSet->setRedirectMergePolicy( function ( $current, $new ) {
@@ -287,7 +287,7 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
                        $resultPageSet->populateFromTitles( $titles );
                        $offset = $params['offset'] + 1;
                        foreach ( $titles as $index => $title ) {
-                               $resultPageSet->setGeneratorData( $title, array( 'index' => $index + $offset ) );
+                               $resultPageSet->setGeneratorData( $title, [ 'index' => $index + $offset ] );
                        }
                }
        }
@@ -297,36 +297,35 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
        }
 
        public function getAllowedParams() {
-               $params = array(
-                       'search' => array(
+               $params = [
+                       'search' => [
                                ApiBase::PARAM_TYPE => 'string',
                                ApiBase::PARAM_REQUIRED => true
-                       ),
-                       'namespace' => array(
+                       ],
+                       'namespace' => [
                                ApiBase::PARAM_DFLT => NS_MAIN,
                                ApiBase::PARAM_TYPE => 'namespace',
                                ApiBase::PARAM_ISMULTI => true,
-                       ),
-                       'what' => array(
-                               ApiBase::PARAM_DFLT => null,
-                               ApiBase::PARAM_TYPE => array(
+                       ],
+                       'what' => [
+                               ApiBase::PARAM_TYPE => [
                                        'title',
                                        'text',
                                        'nearmatch',
-                               )
-                       ),
-                       'info' => array(
+                               ]
+                       ],
+                       'info' => [
                                ApiBase::PARAM_DFLT => 'totalhits|suggestion|rewrittenquery',
-                               ApiBase::PARAM_TYPE => array(
+                               ApiBase::PARAM_TYPE => [
                                        'totalhits',
                                        'suggestion',
                                        'rewrittenquery',
-                               ),
+                               ],
                                ApiBase::PARAM_ISMULTI => true,
-                       ),
-                       'prop' => array(
+                       ],
+                       'prop' => [
                                ApiBase::PARAM_DFLT => 'size|wordcount|timestamp|snippet',
-                               ApiBase::PARAM_TYPE => array(
+                               ApiBase::PARAM_TYPE => [
                                        'size',
                                        'wordcount',
                                        'timestamp',
@@ -340,48 +339,48 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
                                        'categorysnippet',
                                        'score', // deprecated
                                        'hasrelated', // deprecated
-                               ),
+                               ],
                                ApiBase::PARAM_ISMULTI => true,
-                               ApiBase::PARAM_HELP_MSG_PER_VALUE => array(),
-                       ),
-                       'offset' => array(
+                               ApiBase::PARAM_HELP_MSG_PER_VALUE => [],
+                       ],
+                       'offset' => [
                                ApiBase::PARAM_DFLT => 0,
                                ApiBase::PARAM_HELP_MSG => 'api-help-param-continue',
-                       ),
-                       'limit' => array(
+                       ],
+                       'limit' => [
                                ApiBase::PARAM_DFLT => 10,
                                ApiBase::PARAM_TYPE => 'limit',
                                ApiBase::PARAM_MIN => 1,
-                               ApiBase::PARAM_MAX => ApiBase::LIMIT_SML1,
-                               ApiBase::PARAM_MAX2 => ApiBase::LIMIT_SML2
-                       ),
+                               ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1,
+                               ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
+                       ],
                        'interwiki' => false,
                        'enablerewrites' => false,
-               );
+               ];
 
                $alternatives = SearchEngine::getSearchTypes();
                if ( count( $alternatives ) > 1 ) {
                        if ( $alternatives[0] === null ) {
                                $alternatives[0] = self::BACKEND_NULL_PARAM;
                        }
-                       $params['backend'] = array(
+                       $params['backend'] = [
                                ApiBase::PARAM_DFLT => $this->getConfig()->get( 'SearchType' ),
                                ApiBase::PARAM_TYPE => $alternatives,
-                       );
+                       ];
                }
 
                return $params;
        }
 
        protected function getExamplesMessages() {
-               return array(
+               return [
                        'action=query&list=search&srsearch=meaning'
                                => 'apihelp-query+search-example-simple',
                        'action=query&list=search&srwhat=text&srsearch=meaning'
                                => 'apihelp-query+search-example-text',
                        'action=query&generator=search&gsrsearch=meaning&prop=info'
                                => 'apihelp-query+search-example-generator',
-               );
+               ];
        }
 
        public function getHelpUrls() {