Fix most PHP CodeSniffer warnings in includes/api
authorSiebrand Mazeland <siebrand@kitano.nl>
Mon, 28 Sep 2015 11:15:17 +0000 (13:15 +0200)
committerSiebrand Mazeland <siebrand@kitano.nl>
Mon, 28 Sep 2015 12:24:52 +0000 (14:24 +0200)
Change-Id: I01bb3e4c96d6034a5b6c18728bb0574c710ea9db

15 files changed:
includes/api/ApiBase.php
includes/api/ApiCreateAccount.php
includes/api/ApiFeedContributions.php
includes/api/ApiFormatJson.php
includes/api/ApiHelp.php
includes/api/ApiMain.php
includes/api/ApiModuleManager.php
includes/api/ApiPageSet.php
includes/api/ApiQueryAllImages.php
includes/api/ApiQueryBase.php
includes/api/ApiQueryImageInfo.php
includes/api/ApiQueryLogEvents.php
includes/api/ApiQueryRandom.php
includes/api/ApiQueryUserInfo.php
includes/api/ApiUpload.php

index 64dc9a3..5a1099e 100644 (file)
@@ -1071,7 +1071,9 @@ abstract class ApiBase extends ContextSource {
         * @param int $botMax Maximum value for sysops/bots
         * @param bool $enforceLimits Whether to enforce (die) if value is outside limits
         */
-       protected function validateLimit( $paramName, &$value, $min, $max, $botMax = null, $enforceLimits = false ) {
+       protected function validateLimit( $paramName, &$value, $min, $max, $botMax = null,
+               $enforceLimits = false
+       ) {
                if ( !is_null( $min ) && $value < $min ) {
                        $msg = $this->encodeParamName( $paramName ) . " may not be less than $min (set to $value)";
                        $this->warnOrDie( $msg, $enforceLimits );
index 5443fac..00b7de9 100644 (file)
@@ -118,7 +118,9 @@ class ApiCreateAccount extends ApiBase {
                                        'createaccount-title',
                                        'createaccount-text'
                                ) );
-                       } elseif ( $this->getConfig()->get( 'EmailAuthentication' ) && Sanitizer::validateEmail( $user->getEmail() ) ) {
+                       } elseif ( $this->getConfig()->get( 'EmailAuthentication' ) &&
+                               Sanitizer::validateEmail( $user->getEmail() )
+                       ) {
                                // Send out an email authentication message if needed
                                $status->merge( $user->sendConfirmationMail() );
                        }
index 2df5f9f..9c3945e 100644 (file)
@@ -56,7 +56,8 @@ class ApiFeedContributions extends ApiBase {
                }
 
                $msg = wfMessage( 'Contributions' )->inContentLanguage()->text();
-               $feedTitle = $config->get( 'Sitename' ) . ' - ' . $msg . ' [' . $config->get( 'LanguageCode' ) . ']';
+               $feedTitle = $config->get( 'Sitename' ) . ' - ' . $msg .
+                       ' [' . $config->get( 'LanguageCode' ) . ']';
                $feedUrl = SpecialPage::getTitleFor( 'Contributions', $params['user'] )->getFullURL();
 
                $target = $params['user'] == 'newbies'
index be1b12c..a319be3 100644 (file)
@@ -93,7 +93,8 @@ class ApiFormatJson extends ApiFormatBase {
                                        break;
 
                                default:
-                                       $this->dieUsage( __METHOD__ . ': Unknown value for \'formatversion\'', 'unknownformatversion' );
+                                       $this->dieUsage( __METHOD__ .
+                                               ': Unknown value for \'formatversion\'', 'unknownformatversion' );
                        }
                }
                $data = $this->getResult()->getResultData( null, $transform );
index f6d124f..abec828 100644 (file)
@@ -703,7 +703,12 @@ class ApiHelp extends ApiBase {
                                                $submodules[] = $manager->getModule( $name );
                                        }
                                }
-                               $help['submodules'] .= self::getHelpInternal( $context, $submodules, $suboptions, $haveModules );
+                               $help['submodules'] .= self::getHelpInternal(
+                                       $context,
+                                       $submodules,
+                                       $suboptions,
+                                       $haveModules
+                               );
                                $numSubmodules = count( $submodules );
                        }
 
index 95ad3ba..8e0ba8b 100644 (file)
@@ -618,10 +618,13 @@ class ApiMain extends ApiBase {
 
                        $response->header( "Access-Control-Allow-Origin: $originHeader" );
                        $response->header( 'Access-Control-Allow-Credentials: true' );
-                       $response->header( "Timing-Allow-Origin: $originHeader" ); # http://www.w3.org/TR/resource-timing/#timing-allow-origin
+                       // http://www.w3.org/TR/resource-timing/#timing-allow-origin
+                       $response->header( "Timing-Allow-Origin: $originHeader" );
 
                        if ( !$preflight ) {
-                               $response->header( 'Access-Control-Expose-Headers: MediaWiki-API-Error, Retry-After, X-Database-Lag' );
+                               $response->header(
+                                       'Access-Control-Expose-Headers: MediaWiki-API-Error, Retry-After, X-Database-Lag'
+                               );
                        }
                }
 
@@ -977,7 +980,8 @@ class ApiMain extends ApiBase {
                                )
                        ) {
                                $this->dieUsage(
-                                       "The '{$module->encodeParamName( 'token' )}' parameter was found in the query string, but must be in the POST body",
+                                       "The '{$module->encodeParamName( 'token' )}' parameter was " .
+                                               'found in the query string, but must be in the POST body',
                                        'mustposttoken'
                                );
                        }
index a0300ab..ba6c144 100644 (file)
@@ -196,7 +196,9 @@ class ApiModuleManager extends ContextSource {
                        $instance = call_user_func( $factory, $this->mParent, $name );
 
                        if ( !$instance instanceof $class ) {
-                               throw new MWException( "The factory function for module $name did not return an instance of $class!" );
+                               throw new MWException(
+                                       "The factory function for module $name did not return an instance of $class!"
+                               );
                        }
                } else {
                        // create instance from class name
index 1415b79..ceb0905 100644 (file)
@@ -58,7 +58,8 @@ class ApiPageSet extends ApiBase {
        private $mGoodTitles = array();
        private $mMissingPages = array(); // [ns][dbkey] => fake page_id
        private $mMissingTitles = array();
-       private $mInvalidTitles = array(); // [fake_page_id] => array( 'title' => $title, 'invalidreason' => $reason )
+       /** @var array [fake_page_id] => array( 'title' => $title, 'invalidreason' => $reason ) */
+       private $mInvalidTitles = array();
        private $mMissingPageIDs = array();
        private $mRedirectTitles = array();
        private $mSpecialTitles = array();
index 381938b..877423e 100644 (file)
@@ -350,7 +350,8 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase {
                                ApiBase::PARAM_DFLT => 'timestamp|url',
                                ApiBase::PARAM_ISMULTI => true,
                                ApiBase::PARAM_HELP_MSG => 'apihelp-query+imageinfo-param-prop',
-                               ApiBase::PARAM_HELP_MSG_PER_VALUE => ApiQueryImageInfo::getPropertyMessages( $this->propertyFilter ),
+                               ApiBase::PARAM_HELP_MSG_PER_VALUE =>
+                                       ApiQueryImageInfo::getPropertyMessages( $this->propertyFilter ),
                        ),
                        'prefix' => null,
                        'minsize' => array(
index c66e21b..c4592c8 100644 (file)
@@ -421,7 +421,14 @@ abstract class ApiQueryBase extends ApiBase {
                $this->addFields( 'ipb_deleted' );
 
                if ( $showBlockInfo ) {
-                       $this->addFields( array( 'ipb_id', 'ipb_by', 'ipb_by_text', 'ipb_reason', 'ipb_expiry', 'ipb_timestamp' ) );
+                       $this->addFields( array(
+                               'ipb_id',
+                               'ipb_by',
+                               'ipb_by_text',
+                               'ipb_reason',
+                               'ipb_expiry',
+                               'ipb_timestamp'
+                       ) );
                }
 
                // Don't show hidden names
index c769024..736ac45 100644 (file)
@@ -339,7 +339,8 @@ class ApiQueryImageInfo extends ApiQueryBase {
                // in the actual normalised version, only if we can actually normalise them,
                // so we use the functions scope to throw away the normalisations.
                if ( !$h->normaliseParams( $image, $finalParams ) ) {
-                       $this->dieUsage( "Could not normalise image parameters for " . $image->getName(), "urlparamnormal" );
+                       $this->dieUsage( 'Could not normalise image parameters for ' .
+                               $image->getName(), 'urlparamnormal' );
                }
        }
 
index d87ad1e..38be99a 100644 (file)
@@ -365,7 +365,10 @@ class ApiQueryLogEvents extends ApiQueryBase {
         */
        private function getAllowedLogActions() {
                $config = $this->getConfig();
-               return array_keys( array_merge( $config->get( 'LogActions' ), $config->get( 'LogActionsHandlers' ) ) );
+               return array_keys( array_merge(
+                       $config->get( 'LogActions' ),
+                       $config->get( 'LogActionsHandlers' )
+               ) );
        }
 
        public function getCacheMode( $params ) {
index 8e7031c..e553d12 100644 (file)
@@ -152,7 +152,8 @@ class ApiQueryRandom extends ApiQueryGeneratorBase {
                        $end = null;
                }
 
-               list( $left, $continue ) = $this->runQuery( $resultPageSet, $params['limit'], $start, $startId, $end );
+               list( $left, $continue ) =
+                       $this->runQuery( $resultPageSet, $params['limit'], $start, $startId, $end );
                if ( $end === null && $continue === null ) {
                        // Wrap around. We do this even if $left === 0 for continuation
                        // (saving a DB query in this rare case probably isn't worth the
index 251c42b..f916537 100644 (file)
@@ -149,7 +149,9 @@ class ApiQueryUserInfo extends ApiQueryBase {
                        $vals['ratelimits'] = $this->getRateLimits();
                }
 
-               if ( isset( $this->prop['realname'] ) && !in_array( 'realname', $this->getConfig()->get( 'HiddenPrefs' ) ) ) {
+               if ( isset( $this->prop['realname'] ) &&
+                       !in_array( 'realname', $this->getConfig()->get( 'HiddenPrefs' ) )
+               ) {
                        $vals['realname'] = $user->getRealName();
                }
 
index 398337b..b621cb0 100644 (file)
@@ -45,7 +45,8 @@ class ApiUpload extends ApiBase {
                $this->mParams = $this->extractRequestParams();
                $request = $this->getMain()->getRequest();
                // Check if async mode is actually supported (jobs done in cli mode)
-               $this->mParams['async'] = ( $this->mParams['async'] && $this->getConfig()->get( 'EnableAsyncUploads' ) );
+               $this->mParams['async'] = ( $this->mParams['async'] &&
+                       $this->getConfig()->get( 'EnableAsyncUploads' ) );
                // Add the uploaded file to the params array
                $this->mParams['file'] = $request->getFileName( 'file' );
                $this->mParams['chunk'] = $request->getFileName( 'chunk' );
@@ -605,16 +606,29 @@ class ApiUpload extends ApiBase {
 
                switch ( $exceptionType ) {
                        case 'UploadStashFileNotFoundException':
-                               $this->dieUsage( 'Could not find the file in the stash: ' . $e->getMessage(), 'stashedfilenotfound' );
+                               $this->dieUsage(
+                                       'Could not find the file in the stash: ' . $e->getMessage(),
+                                       'stashedfilenotfound'
+                               );
                                break;
                        case 'UploadStashBadPathException':
-                               $this->dieUsage( 'File key of improper format or otherwise invalid: ' . $e->getMessage(), 'stashpathinvalid' );
+                               $this->dieUsage(
+                                       'File key of improper format or otherwise invalid: ' . $e->getMessage(),
+                                       'stashpathinvalid'
+                               );
                                break;
                        case 'UploadStashFileException':
-                               $this->dieUsage( 'Could not store upload in the stash: ' . $e->getMessage(), 'stashfilestorage' );
+                               $this->dieUsage(
+                                       'Could not store upload in the stash: ' . $e->getMessage(),
+                                       'stashfilestorage'
+                               );
                                break;
                        case 'UploadStashZeroLengthFileException':
-                               $this->dieUsage( 'File is of zero length, and could not be stored in the stash: ' . $e->getMessage(), 'stashzerolength' );
+                               $this->dieUsage(
+                                       'File is of zero length, and could not be stored in the stash: ' .
+                                               $e->getMessage(),
+                                       'stashzerolength'
+                               );
                                break;
                        case 'UploadStashNotLoggedInException':
                                $this->dieUsage( 'Not logged in: ' . $e->getMessage(), 'stashnotloggedin' );