Update formatting on API classes, Part 3
authorSiebrand Mazeland <s.mazeland@xs4all.nl>
Thu, 14 Nov 2013 12:47:20 +0000 (13:47 +0100)
committerChad <chadh@wikimedia.org>
Thu, 14 Nov 2013 18:12:29 +0000 (18:12 +0000)
Change-Id: I526be68e21836201c992b391a81f4d41e1fa801e

includes/api/ApiOpenSearch.php
includes/api/ApiPageSet.php
includes/api/ApiParamInfo.php
includes/api/ApiParse.php
includes/api/ApiPatrol.php
includes/api/ApiProtect.php
includes/api/ApiPurge.php
includes/api/ApiQuery.php
includes/api/ApiQueryAllCategories.php
includes/api/ApiQueryAllImages.php

index 315ace3..433b743 100644 (file)
@@ -40,6 +40,7 @@ class ApiOpenSearch extends ApiBase {
                if ( in_array( $format, $allowed ) ) {
                        return $this->getMain()->createPrinterByName( $format );
                }
+
                return $this->getMain()->createPrinterByName( $allowed[0] );
        }
 
index b05cb2b..cfbc095 100644 (file)
@@ -244,6 +244,7 @@ class ApiPageSet extends ApiBase {
                if ( isset( $this->mParams['revids'] ) ) {
                        return 'revids';
                }
+
                return null;
        }
 
@@ -289,6 +290,7 @@ class ApiPageSet extends ApiBase {
                $this->mRequestedPageFields = array_diff_key( $this->mRequestedPageFields, $pageFlds );
 
                $pageFlds = array_merge( $pageFlds, $this->mRequestedPageFields );
+
                return array_keys( $pageFlds );
        }
 
@@ -391,6 +393,7 @@ class ApiPageSet extends ApiBase {
                if ( !empty( $values ) && $result ) {
                        $result->setIndexedTagName( $values, 'r' );
                }
+
                return $values;
        }
 
@@ -421,6 +424,7 @@ class ApiPageSet extends ApiBase {
                if ( !empty( $values ) && $result ) {
                        $result->setIndexedTagName( $values, 'n' );
                }
+
                return $values;
        }
 
@@ -451,6 +455,7 @@ class ApiPageSet extends ApiBase {
                if ( !empty( $values ) && $result ) {
                        $result->setIndexedTagName( $values, 'c' );
                }
+
                return $values;
        }
 
@@ -487,6 +492,7 @@ class ApiPageSet extends ApiBase {
                if ( !empty( $values ) && $result ) {
                        $result->setIndexedTagName( $values, 'i' );
                }
+
                return $values;
        }
 
@@ -522,6 +528,7 @@ class ApiPageSet extends ApiBase {
                if ( !empty( $values ) && $result ) {
                        $result->setIndexedTagName( $values, 'rev' );
                }
+
                return $values;
        }
 
@@ -642,7 +649,7 @@ class ApiPageSet extends ApiBase {
                // Get pageIDs data from the `page` table
                $this->profileDBIn();
                $res = $db->select( 'page', $this->getPageTableFields(), $set,
-                                       __METHOD__ );
+                       __METHOD__ );
                $this->profileDBOut();
 
                // Hack: get the ns:titles stored in array(ns => array(titles)) format
@@ -676,7 +683,7 @@ class ApiPageSet extends ApiBase {
                        // Get pageIDs data from the `page` table
                        $this->profileDBIn();
                        $res = $db->select( 'page', $this->getPageTableFields(), $set,
-                                               __METHOD__ );
+                               __METHOD__ );
                        $this->profileDBOut();
                }
 
@@ -886,6 +893,7 @@ class ApiPageSet extends ApiBase {
                                unset( $this->mPendingRedirectIDs[$id] );
                        }
                }
+
                return $lb;
        }
 
@@ -941,8 +949,9 @@ class ApiPageSet extends ApiBase {
                                // Variants checking
                                global $wgContLang;
                                if ( $this->mConvertTitles &&
-                                               count( $wgContLang->getVariants() ) > 1 &&
-                                               !$titleObj->exists() ) {
+                                       count( $wgContLang->getVariants() ) > 1 &&
+                                       !$titleObj->exists()
+                               ) {
                                        // Language::findVariantLink will modify titleText and titleObj into
                                        // the canonical variant if possible
                                        $titleText = is_string( $title ) ? $title : $titleObj->getPrefixedText();
@@ -1040,6 +1049,7 @@ class ApiPageSet extends ApiBase {
                                $result['generator'] = null;
                        }
                }
+
                return $result;
        }
 
@@ -1067,6 +1077,7 @@ class ApiPageSet extends ApiBase {
                        sort( $gens );
                        self::$generators = $gens;
                }
+
                return self::$generators;
        }
 
index 3e1a753..7ecf71f 100644 (file)
@@ -317,6 +317,7 @@ class ApiParamInfo extends ApiBase {
                sort( $querymodules );
                $formatmodules = $this->getMain()->getModuleManager()->getNames( 'format' );
                sort( $formatmodules );
+
                return array(
                        'modules' => array(
                                ApiBase::PARAM_ISMULTI => true,
index 301affb..91a3a99 100644 (file)
@@ -125,7 +125,7 @@ class ApiParse extends ApiBase {
                                                'action' => 'query',
                                                'redirects' => '',
                                        );
-                                       if ( !is_null ( $pageid ) ) {
+                                       if ( !is_null( $pageid ) ) {
                                                $reqParams['pageids'] = $pageid;
                                        } else { // $page
                                                $reqParams['titles'] = $page;
@@ -219,6 +219,7 @@ class ApiParse extends ApiBase {
                                        ApiResult::setContent( $result_array['wikitext'], $this->content->serialize( $format ) );
                                }
                                $result->addValue( null, $this->getModuleName(), $result_array );
+
                                return;
                        }
 
@@ -300,8 +301,8 @@ class ApiParse extends ApiBase {
 
                if ( isset( $prop['displaytitle'] ) ) {
                        $result_array['displaytitle'] = $p_result->getDisplayTitle() ?
-                                                       $p_result->getDisplayTitle() :
-                                                       $titleObj->getPrefixedText();
+                               $p_result->getDisplayTitle() :
+                               $titleObj->getPrefixedText();
                }
 
                if ( isset( $prop['headitems'] ) || isset( $prop['headhtml'] ) ) {
@@ -395,6 +396,7 @@ class ApiParse extends ApiBase {
                $popts->setIsSectionPreview( $params['sectionpreview'] );
 
                wfProfileOut( __METHOD__ );
+
                return $popts;
        }
 
@@ -425,6 +427,7 @@ class ApiParse extends ApiBase {
                        if ( $getWikitext ) {
                                $this->content = $page->getContent( Revision::RAW );
                        }
+
                        return $pout;
                }
        }
@@ -439,6 +442,7 @@ class ApiParse extends ApiBase {
                        $this->dieUsage( "Sections are not supported by " . $what, 'nosuchsection' );
                        $section = false;
                }
+
                return $section;
        }
 
@@ -456,6 +460,7 @@ class ApiParse extends ApiBase {
                        ApiResult::setContent( $entry, $bits[1] );
                        $result[] = $entry;
                }
+
                return $result;
        }
 
@@ -502,6 +507,7 @@ class ApiParse extends ApiBase {
        private function categoriesHtml( $categories ) {
                $context = $this->getContext();
                $context->getOutput()->addCategoryLinks( $categories );
+
                return $context->getSkin()->getCategories();
        }
 
@@ -554,6 +560,7 @@ class ApiParse extends ApiBase {
                                $result[] = $entry;
                        }
                }
+
                return $result;
        }
 
@@ -573,6 +580,7 @@ class ApiParse extends ApiBase {
                                $result[] = $entry;
                        }
                }
+
                return $result;
        }
 
@@ -584,6 +592,7 @@ class ApiParse extends ApiBase {
                        ApiResult::setContent( $entry, $content );
                        $result[] = $entry;
                }
+
                return $result;
        }
 
@@ -595,6 +604,7 @@ class ApiParse extends ApiBase {
                        ApiResult::setContent( $entry, $value );
                        $result[] = $entry;
                }
+
                return $result;
        }
 
@@ -606,6 +616,7 @@ class ApiParse extends ApiBase {
                        ApiResult::setContent( $entry, $link );
                        $result[] = $entry;
                }
+
                return $result;
        }
 
@@ -674,6 +685,7 @@ class ApiParse extends ApiBase {
        public function getParamDescription() {
                $p = $this->getModulePrefix();
                $wikitext = CONTENT_MODEL_WIKITEXT;
+
                return array(
                        'text' => "Text to parse. Use {$p}title or {$p}contentmodel to control the content model",
                        'summary' => 'Summary to parse',
@@ -736,6 +748,7 @@ class ApiParse extends ApiBase {
 
        public function getDescription() {
                $p = $this->getModulePrefix();
+
                return array(
                        'Parses content and returns parser output',
                        'See the various prop-Modules of action=query to get information from the current version of a page',
index bd2fde2..46bd94e 100644 (file)
@@ -123,7 +123,8 @@ class ApiPatrol extends ApiBase {
                                        'code' => 'notpatrollable',
                                        'info' => "The revision can't be patrolled as it's too old"
                                )
-               ) );
+                       )
+               );
        }
 
        public function needsToken() {
index 428eef3..25727d0 100644 (file)
@@ -90,9 +90,9 @@ class ApiProtect extends ApiBase {
                                $expiryarray[$p[0]] = $exp;
                        }
                        $resultProtections[] = array( $p[0] => $protections[$p[0]],
-                                       'expiry' => ( $expiryarray[$p[0]] == $db->getInfinity() ?
-                                                               'infinite' :
-                                                               wfTimestamp( TS_ISO_8601, $expiryarray[$p[0]] ) ) );
+                               'expiry' => ( $expiryarray[$p[0]] == $db->getInfinity() ?
+                                       'infinite' :
+                                       wfTimestamp( TS_ISO_8601, $expiryarray[$p[0]] ) ) );
                }
 
                $cascade = $params['cascade'];
@@ -167,16 +167,17 @@ class ApiProtect extends ApiBase {
 
        public function getParamDescription() {
                $p = $this->getModulePrefix();
+
                return array(
                        'title' => "Title of the page you want to (un)protect. Cannot be used together with {$p}pageid",
                        'pageid' => "ID of the page you want to (un)protect. Cannot be used together with {$p}title",
                        'token' => 'A protect token previously retrieved through prop=info',
                        'protections' => 'List of protection levels, formatted action=group (e.g. edit=sysop)',
                        'expiry' => array( 'Expiry timestamps. If only one timestamp is set, it\'ll be used for all protections.',
-                                       'Use \'infinite\', \'indefinite\' or \'never\', for a never-expiring protection.' ),
+                               'Use \'infinite\', \'indefinite\' or \'never\', for a never-expiring protection.' ),
                        'reason' => 'Reason for (un)protecting',
                        'cascade' => array( 'Enable cascading protection (i.e. protect pages included in this page)',
-                                       'Ignored if not all protection levels are \'sysop\' or \'protect\'' ),
+                               'Ignored if not all protection levels are \'sysop\' or \'protect\'' ),
                        'watch' => 'If set, add the page being (un)protected to your watchlist',
                        'watchlist' => 'Unconditionally add or remove the page from your watchlist, use preferences or do not change watch',
                );
index 0812ba5..4c7981e 100644 (file)
@@ -139,6 +139,7 @@ class ApiPurge extends ApiBase {
                if ( !isset( $this->mPageSet ) ) {
                        $this->mPageSet = new ApiPageSet( $this );
                }
+
                return $this->mPageSet;
        }
 
@@ -159,6 +160,7 @@ class ApiPurge extends ApiBase {
                if ( $flags ) {
                        $result += $this->getPageSet()->getFinalParams( $flags );
                }
+
                return $result;
        }
 
index e03837f..ea57196 100644 (file)
@@ -163,6 +163,7 @@ class ApiQuery extends ApiBase {
                        $this->mNamedDB[$name] = wfGetDB( $db, $groups );
                        $this->profileDBOut();
                }
+
                return $this->mNamedDB[$name];
        }
 
@@ -181,6 +182,7 @@ class ApiQuery extends ApiBase {
         */
        public function getModules() {
                wfDeprecated( __METHOD__, '1.21' );
+
                return $this->getModuleManager()->getNamesWithClasses();
        }
 
@@ -197,6 +199,7 @@ class ApiQuery extends ApiBase {
                                $gens[$name] = $class;
                        }
                }
+
                return $gens;
        }
 
@@ -216,8 +219,8 @@ class ApiQuery extends ApiBase {
        public function getCustomPrinter() {
                // If &exportnowrap is set, use the raw formatter
                if ( $this->getParameter( 'export' ) &&
-                               $this->getParameter( 'exportnowrap' ) )
-               {
+                       $this->getParameter( 'exportnowrap' )
+               {
                        return new ApiFormatRaw( $this->getMain(),
                                $this->getMain()->createPrinterByName( 'xml' ) );
                } else {
@@ -407,6 +410,7 @@ class ApiQuery extends ApiBase {
                        }
                }
                $this->dieContinueUsageIf( $completeModules !== null && count( $tmp ) !== 0 );
+
                return $modules;
        }
 
@@ -429,6 +433,7 @@ class ApiQuery extends ApiBase {
                } else { // private
                        $cacheMode = 'private';
                }
+
                return $cacheMode;
        }
 
@@ -514,10 +519,12 @@ class ApiQuery extends ApiBase {
                        ApiQueryBase::addTitleInfo( $vals, $title );
                        $vals['special'] = '';
                        if ( $title->isSpecialPage() &&
-                                       !SpecialPageFactory::exists( $title->getDBkey() ) ) {
+                               !SpecialPageFactory::exists( $title->getDBkey() )
+                       ) {
                                $vals['missing'] = '';
                        } elseif ( $title->getNamespace() == NS_MEDIA &&
-                                       !wfFindFile( $title ) ) {
+                               !wfFindFile( $title )
+                       ) {
                                $vals['missing'] = '';
                        }
                        $pages[$fakeId] = $vals;
@@ -566,6 +573,7 @@ class ApiQuery extends ApiBase {
                        $this->mGeneratorContinue = array();
                }
                $this->mGeneratorContinue[$paramName] = $paramValue;
+
                return true;
        }
 
@@ -638,6 +646,7 @@ class ApiQuery extends ApiBase {
                if ( $flags ) {
                        $result += $this->getPageSet()->getFinalParams( $flags );
                }
+
                return $result;
        }
 
index 3f5c6ee..5ef71f0 100644 (file)
@@ -109,7 +109,7 @@ class ApiQueryAllCategories extends ApiQueryGeneratorBase {
                $result = $this->getResult();
                $count = 0;
                foreach ( $res as $row ) {
-                       if ( ++ $count > $params['limit'] ) {
+                       if ( ++$count > $params['limit'] ) {
                                // We've reached the one extra which shows that there are additional cats to be had. Stop here...
                                $this->setContinueEnumParameter( 'continue', $row->cat_title );
                                break;
index ccc7a3a..5baee8d 100644 (file)
@@ -107,7 +107,7 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase {
                                }
                        }
                        if ( $params['filterbots'] != 'all' ) {
-                                       $this->dieUsage( "Parameter '{$prefix}filterbots' can only be used with {$prefix}sort=timestamp", 'badparams' );
+                               $this->dieUsage( "Parameter '{$prefix}filterbots' can only be used with {$prefix}sort=timestamp", 'badparams' );
                        }
 
                        // Pagination
@@ -156,7 +156,7 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase {
                                                'ug_user = img_user'
                                        )
                                ) ) );
-                               $groupCond = ( $params['filterbots'] == 'nobots' ? 'NULL': 'NOT NULL' );
+                               $groupCond = ( $params['filterbots'] == 'nobots' ? 'NULL' : 'NOT NULL' );
                                $this->addWhere( "ug_group IS $groupCond" );
                        }
                }
@@ -222,7 +222,7 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase {
                $count = 0;
                $result = $this->getResult();
                foreach ( $res as $row ) {
-                       if ( ++ $count > $limit ) {
+                       if ( ++$count > $limit ) {
                                // We've reached the one extra which shows that there are additional pages to be had. Stop here...
                                if ( $params['sort'] == 'name' ) {
                                        $this->setContinueEnumParameter( 'continue', $row->img_name );
@@ -326,6 +326,7 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase {
 
        public function getParamDescription() {
                $p = $this->getModulePrefix();
+
                return array(
                        'sort' => 'Property to sort by',
                        'dir' => 'The direction in which to list',
@@ -368,6 +369,7 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase {
 
        public function getPossibleErrors() {
                $p = $this->getModulePrefix();
+
                return array_merge( parent::getPossibleErrors(), array(
                        array( 'code' => 'params', 'info' => 'Use "gaifilterredir=nonredirects" option instead of "redirects" when using allimages as a generator' ),
                        array( 'code' => 'badparams', 'info' => "Parameter'{$p}start' can only be used with {$p}sort=timestamp" ),