Fix most PHP CodeSniffer warnings in includes/api
Change-Id: I01bb3e4c96d6034a5b6c18728bb0574c710ea9db
This commit is contained in:
parent
f1576acb3e
commit
0fdb0ce284
15 changed files with 68 additions and 21 deletions
|
|
@ -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 );
|
||||
|
|
|
|||
|
|
@ -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() );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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' );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 ) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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' );
|
||||
|
|
|
|||
Loading…
Reference in a new issue