From f994817f6b0283260792e822fe891bc3f7330c44 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Thu, 24 Apr 2014 21:50:01 +0200 Subject: [PATCH] Pass phpcs-strict on various files in includes/ These files have all had treatment before, and these occurrences have either been missed or have been introduced after. Change-Id: I06cdab4616b5bff47c85152df28f18c861730a23 --- includes/api/ApiParse.php | 9 ++- includes/api/ApiQueryPrefixSearch.php | 4 +- includes/api/ApiQueryRedirects.php | 5 +- includes/api/ApiQuerySearch.php | 8 ++- includes/cache/LocalisationCache.php | 1 - includes/composer/ComposerPackageModifier.php | 9 ++- includes/diff/DairikiDiff.php | 2 + includes/exception/MWException.php | 7 +- includes/filerepo/file/LocalFile.php | 5 +- includes/htmlform/HTMLForm.php | 4 +- includes/installer/MssqlInstaller.php | 70 ++++++++++++++----- includes/jobqueue/JobQueueFederated.php | 2 + includes/media/Bitmap_ClientOnly.php | 3 + 13 files changed, 97 insertions(+), 32 deletions(-) diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php index 97f0009f00..a7cc436ce1 100644 --- a/includes/api/ApiParse.php +++ b/includes/api/ApiParse.php @@ -363,7 +363,8 @@ class ApiParse extends ApiBase { } if ( isset( $prop['limitreportdata'] ) ) { - $result_array['limitreportdata'] = $this->formatLimitReportData( $p_result->getLimitReportData() ); + $result_array['limitreportdata'] = + $this->formatLimitReportData( $p_result->getLimitReportData() ); } if ( isset( $prop['limitreporthtml'] ) ) { $limitreportHtml = EditPage::getPreviewLimitReport( $p_result ); @@ -488,7 +489,11 @@ class ApiParse extends ApiBase { if ( $title ) { $entry['url'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT ); // localised language name in user language (maybe set by uselang=) - $entry['langname'] = Language::fetchLanguageName( $title->getInterwiki(), $this->getLanguage()->getCode() ); + $entry['langname'] = Language::fetchLanguageName( + $title->getInterwiki(), + $this->getLanguage()->getCode() + ); + // native language name $entry['autonym'] = Language::fetchLanguageName( $title->getInterwiki() ); } diff --git a/includes/api/ApiQueryPrefixSearch.php b/includes/api/ApiQueryPrefixSearch.php index eaa9c01f22..4abd7f0ee6 100644 --- a/includes/api/ApiQueryPrefixSearch.php +++ b/includes/api/ApiQueryPrefixSearch.php @@ -93,8 +93,8 @@ class ApiQueryPrefixSearch extends ApiQueryGeneratorBase { ApiBase::PARAM_DFLT => 10, ApiBase::PARAM_TYPE => 'limit', ApiBase::PARAM_MIN => 1, - ApiBase::PARAM_MAX => 100, // Non-standard value for compatibility - // with action=opensearch + // Non-standard value for compatibility with action=opensearch + ApiBase::PARAM_MAX => 100, ApiBase::PARAM_MAX2 => 200, ), ); diff --git a/includes/api/ApiQueryRedirects.php b/includes/api/ApiQueryRedirects.php index cd98c52b0f..2ed7d30f90 100644 --- a/includes/api/ApiQueryRedirects.php +++ b/includes/api/ApiQueryRedirects.php @@ -116,7 +116,10 @@ class ApiQueryRedirects extends ApiQueryGeneratorBase { $this->dieUsageMsg( 'show' ); } $this->addWhereIf( "rd_fragment != $emptyString", isset( $show['fragment'] ) ); - $this->addWhereIf( "rd_fragment = $emptyString OR rd_fragment IS NULL", isset( $show['!fragment'] ) ); + $this->addWhereIf( + "rd_fragment = $emptyString OR rd_fragment IS NULL", + isset( $show['!fragment'] ) + ); } $map = $pageSet->getAllTitlesByNamespace(); diff --git a/includes/api/ApiQuerySearch.php b/includes/api/ApiQuerySearch.php index 660055c156..8eceb6f084 100644 --- a/includes/api/ApiQuerySearch.php +++ b/includes/api/ApiQuerySearch.php @@ -222,8 +222,12 @@ class ApiQuerySearch extends ApiQueryGeneratorBase { ); // Add item to results and see whether it fits - $fit = $apiResult->addValue( array( 'query', 'interwiki' . $this->getModuleName(), $result->getInterwikiPrefix() ), - null, $vals ); + $fit = $apiResult->addValue( + array( 'query', 'interwiki' . $this->getModuleName(), $result->getInterwikiPrefix() ), + null, + $vals + ); + if ( !$fit ) { // We hit the limit. We can't really provide any meaningful // pagination info so just bail out diff --git a/includes/cache/LocalisationCache.php b/includes/cache/LocalisationCache.php index 1c36ec0055..3bbf1bb89e 100644 --- a/includes/cache/LocalisationCache.php +++ b/includes/cache/LocalisationCache.php @@ -691,7 +691,6 @@ class LocalisationCache { global $IP; wfProfileIn( __METHOD__ ); - // This reads in the PHP i18n file with non-messages l10n data $fileName = Language::getMessagesFileName( $code ); if ( !file_exists( $fileName ) ) { diff --git a/includes/composer/ComposerPackageModifier.php b/includes/composer/ComposerPackageModifier.php index ae8baf2b4b..64c69ef529 100644 --- a/includes/composer/ComposerPackageModifier.php +++ b/includes/composer/ComposerPackageModifier.php @@ -16,7 +16,9 @@ class ComposerPackageModifier { protected $versionNormalizer; protected $versionFetcher; - public function __construct( Package $package, ComposerVersionNormalizer $versionNormalizer, MediaWikiVersionFetcher $versionFetcher ) { + public function __construct( Package $package, + ComposerVersionNormalizer $versionNormalizer, MediaWikiVersionFetcher $versionFetcher + ) { $this->package = $package; $this->versionNormalizer = $versionNormalizer; $this->versionFetcher = $versionFetcher; @@ -48,7 +50,10 @@ class ComposerPackageModifier { $mvVersion = $this->versionFetcher->fetchVersion(); $mvVersion = $this->versionNormalizer->normalizeSuffix( $mvVersion ); - $version = new VersionConstraint( '==', $this->versionNormalizer->normalizeLevelCount( $mvVersion ) ); + $version = new VersionConstraint( + '==', + $this->versionNormalizer->normalizeLevelCount( $mvVersion ) + ); $version->setPrettyString( $mvVersion ); return $version; diff --git a/includes/diff/DairikiDiff.php b/includes/diff/DairikiDiff.php index 0e38d689be..a4c0168fea 100644 --- a/includes/diff/DairikiDiff.php +++ b/includes/diff/DairikiDiff.php @@ -424,7 +424,9 @@ class DiffEngine { } $x1 = $xoff + (int)( ( $numer + ( $xlim - $xoff ) * $chunk ) / $nchunks ); + // @codingStandardsIgnoreFile Ignore Squiz.WhiteSpace.SemicolonSpacing.Incorrect for ( ; $x < $x1; $x++ ) { + // @codingStandardsIgnoreEnd $line = $flip ? $this->yv[$x] : $this->xv[$x]; if ( empty( $ymatches[$line] ) ) { continue; diff --git a/includes/exception/MWException.php b/includes/exception/MWException.php index 2b8cb00e49..82303b91f6 100644 --- a/includes/exception/MWException.php +++ b/includes/exception/MWException.php @@ -135,7 +135,8 @@ class MWException extends Exception { if ( $wgShowExceptionDetails ) { return '

' . nl2br( htmlspecialchars( MWExceptionHandler::getLogMessage( $this ) ) ) . - '

Backtrace:

' . nl2br( htmlspecialchars( MWExceptionHandler::getRedactedTraceAsString( $this ) ) ) . + '

Backtrace:

' . + nl2br( htmlspecialchars( MWExceptionHandler::getRedactedTraceAsString( $this ) ) ) . "

\n"; } else { return "
" . @@ -222,7 +223,9 @@ class MWException extends Exception { echo "\n" . '' . // Mimick OutputPage::setPageTitle behaviour - '' . htmlspecialchars( $this->msg( 'pagetitle', "$1 - $wgSitename", $this->getPageTitle() ) ) . '' . + '' . + htmlspecialchars( $this->msg( 'pagetitle', "$1 - $wgSitename", $this->getPageTitle() ) ) . + '' . '' . "\n"; diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php index f89dc3d285..3cb918f107 100644 --- a/includes/filerepo/file/LocalFile.php +++ b/includes/filerepo/file/LocalFile.php @@ -1458,7 +1458,6 @@ class LocalFile extends File { wfProfileOut( __METHOD__ . '-edit' ); - if ( $reupload ) { # Delete old thumbnails wfProfileIn( __METHOD__ . '-purge' ); @@ -1911,7 +1910,9 @@ class LocalFile extends File { $key = $this->repo->getSharedCacheKey( 'file-volatile', md5( $this->getName() ) ); if ( $key ) { - if ( $this->lastMarkedVolatile && ( time() - $this->lastMarkedVolatile ) <= self::VOLATILE_TTL ) { + if ( $this->lastMarkedVolatile + && ( time() - $this->lastMarkedVolatile ) <= self::VOLATILE_TTL + ) { return true; // sanity } return ( $wgMemc->get( $key ) !== false ); diff --git a/includes/htmlform/HTMLForm.php b/includes/htmlform/HTMLForm.php index 10c9ce03c1..019eb2b62a 100644 --- a/includes/htmlform/HTMLForm.php +++ b/includes/htmlform/HTMLForm.php @@ -338,8 +338,10 @@ class HTMLForm extends ContextSource { } if ( !$class ) { - throw new MWException( "Descriptor with no class for $fieldname: " . print_r( $descriptor, true ) ); + throw new MWException( "Descriptor with no class for $fieldname: " + . print_r( $descriptor, true ) ); } + return $class; } diff --git a/includes/installer/MssqlInstaller.php b/includes/installer/MssqlInstaller.php index 248a6e41ad..51db148a1e 100644 --- a/includes/installer/MssqlInstaller.php +++ b/includes/installer/MssqlInstaller.php @@ -45,7 +45,9 @@ class MssqlInstaller extends DatabaseInstaller { '_WebWindowsAuthentication' => 'sqlauth', ); - public $minimumVersion = '9.00.1399'; // SQL Server 2005 RTM (TODO: are SQL Express version numbers different?) + // SQL Server 2005 RTM + // @todo Are SQL Express version numbers different?) + public $minimumVersion = '9.00.1399'; // These are schema-level privs // Note: the web user will be created will full permissions if possible, this permission @@ -135,7 +137,12 @@ class MssqlInstaller extends DatabaseInstaller { public function submitConnectForm() { // Get variables from the request. - $newValues = $this->setVarsFromRequest( array( 'wgDBserver', 'wgDBname', 'wgDBmwschema', 'wgDBprefix' ) ); + $newValues = $this->setVarsFromRequest( array( + 'wgDBserver', + 'wgDBname', + 'wgDBmwschema', + 'wgDBprefix' + ) ); // Validate them. $status = Status::newGood(); @@ -163,7 +170,11 @@ class MssqlInstaller extends DatabaseInstaller { } // User box - $this->setVarsFromRequest( array( '_InstallUser', '_InstallPassword', '_InstallWindowsAuthentication' ) ); + $this->setVarsFromRequest( array( + '_InstallUser', + '_InstallPassword', + '_InstallWindowsAuthentication' + ) ); // Try to connect $status = $this->getConnection(); @@ -309,7 +320,8 @@ class MssqlInstaller extends DatabaseInstaller { if ( $this->schemaExists( $this->getVar( 'wgDBmwschema' ) ) ) { // wgDBmwschema is validated to only contain alphanumeric + underscore, so this is safe - $res = $conn->query( "SELECT permission_name FROM sys.fn_my_permissions( '{$this->getVar( 'wgDBmwschema' )}', 'SCHEMA' )" ); + $res = $conn->query( "SELECT permission_name FROM sys.fn_my_permissions( " + . "'{$this->getVar( 'wgDBmwschema' )}', 'SCHEMA' )" ); foreach ( $res as $row ) { $schemaPrivs[$row->permission_name] = true; @@ -320,9 +332,11 @@ class MssqlInstaller extends DatabaseInstaller { // Now check all the grants we'll need to be doing to see if we can foreach ( $this->webUserPrivs as $permission ) { if ( ( isset( $schemaPrivs[$permission] ) && $schemaPrivs[$permission] ) - || ( isset( $dbPrivs[$implied[$permission][0]] ) && $dbPrivs[$implied[$permission][0]] ) - || ( isset( $serverPrivs[$implied[$permission][1]] ) && $serverPrivs[$implied[$permission][1]] ) ) { - + || ( isset( $dbPrivs[$implied[$permission][0]] ) + && $dbPrivs[$implied[$permission][0]] ) + || ( isset( $serverPrivs[$implied[$permission][1]] ) + && $serverPrivs[$implied[$permission][1]] ) + ) { unset( $grantOptions[$permission] ); } } @@ -344,8 +358,11 @@ class MssqlInstaller extends DatabaseInstaller { } else { $noCreateMsg = 'config-db-web-no-create-privs'; } + $wrapperStyle = $this->getVar( '_SameAccount' ) ? 'display: none' : ''; - $displayStyle = $this->getVar( '_WebWindowsAuthentication' ) == 'windowsauth' ? 'display: none' : ''; + $displayStyle = $this->getVar( '_WebWindowsAuthentication' ) == 'windowsauth' + ? 'display: none' + : ''; $s = Html::openElement( 'fieldset' ) . Html::element( 'legend', array(), wfMessage( 'config-db-web-account' )->text() ) . $this->getCheckBox( @@ -390,9 +407,13 @@ class MssqlInstaller extends DatabaseInstaller { * @return Status */ public function submitSettingsForm() { - $this->setVarsFromRequest( - array( 'wgDBuser', 'wgDBpassword', '_SameAccount', '_CreateDBAccount', '_WebWindowsAuthentication' ) - ); + $this->setVarsFromRequest( array( + 'wgDBuser', + 'wgDBpassword', + '_SameAccount', + '_CreateDBAccount', + '_WebWindowsAuthentication' + ) ); if ( $this->getVar( '_SameAccount' ) ) { $this->setVar( '_WebWindowsAuthentication', $this->getVar( '_InstallWindowsAuthentication' ) ); @@ -408,7 +429,10 @@ class MssqlInstaller extends DatabaseInstaller { $this->setVar( 'wgDBWindowsAuthentication', false ); } - if ( $this->getVar( '_CreateDBAccount' ) && $this->getVar( '_WebWindowsAuthentication' ) == 'sqlauth' && strval( $this->getVar( 'wgDBpassword' ) ) == '' ) { + if ( $this->getVar( '_CreateDBAccount' ) + && $this->getVar( '_WebWindowsAuthentication' ) == 'sqlauth' + && strval( $this->getVar( 'wgDBpassword' ) ) == '' + ) { return Status::newFatal( 'config-db-password-empty', $this->getVar( 'wgDBuser' ) ); } @@ -471,13 +495,22 @@ class MssqlInstaller extends DatabaseInstaller { $dbName = $this->getVar( 'wgDBname' ); $schemaName = $this->getVar( 'wgDBmwschema' ); if ( !$this->databaseExists( $dbName ) ) { - $conn->query( "CREATE DATABASE " . $conn->addIdentifierQuotes( $dbName ), __METHOD__ ); + $conn->query( + "CREATE DATABASE " . $conn->addIdentifierQuotes( $dbName ), + __METHOD__ + ); $conn->selectDB( $dbName ); if ( !$this->schemaExists( $schemaName ) ) { - $conn->query( "CREATE SCHEMA " . $conn->addIdentifierQuotes( $schemaName ), __METHOD__ ); + $conn->query( + "CREATE SCHEMA " . $conn->addIdentifierQuotes( $schemaName ), + __METHOD__ + ); } if ( !$this->catalogExists( $schemaName ) ) { - $conn->query( "CREATE FULLTEXT CATALOG " . $conn->addIdentifierQuotes( $schemaName ), __METHOD__ ); + $conn->query( + "CREATE FULLTEXT CATALOG " . $conn->addIdentifierQuotes( $schemaName ), + __METHOD__ + ); } } $this->setupSchemaVars(); @@ -529,7 +562,9 @@ class MssqlInstaller extends DatabaseInstaller { try { $this->db->begin(); $this->db->selectDB( 'master' ); - $logintype = $this->getVar( '_WebWindowsAuthentication' ) == 'windowsauth' ? 'FROM WINDOWS' : "WITH PASSWORD = $escPass"; + $logintype = $this->getVar( '_WebWindowsAuthentication' ) == 'windowsauth' + ? 'FROM WINDOWS' + : "WITH PASSWORD = $escPass"; $this->db->query( "CREATE LOGIN $escUser $logintype" ); $this->db->selectDB( $dbName ); $this->db->query( "CREATE USER $escUser FOR LOGIN $escUser WITH DEFAULT_SCHEMA = $escSchema" ); @@ -603,7 +638,8 @@ class MssqlInstaller extends DatabaseInstaller { $searchindex = $this->db->tableName( 'searchindex' ); $schema = $this->db->addIdentifierQuotes( $this->getVar( 'wgDBmwschema' ) ); try { - $this->db->query( "CREATE FULLTEXT INDEX ON $searchindex (si_title, si_text) KEY INDEX si_page ON $schema" ); + $this->db->query( "CREATE FULLTEXT INDEX ON $searchindex (si_title, si_text) " + . "KEY INDEX si_page ON $schema" ); } catch ( DBQueryError $dqe ) { $status->fatal( 'config-install-tables-failed', $dqe->getText() ); } diff --git a/includes/jobqueue/JobQueueFederated.php b/includes/jobqueue/JobQueueFederated.php index 9d46a00c85..9b4c315ea8 100644 --- a/includes/jobqueue/JobQueueFederated.php +++ b/includes/jobqueue/JobQueueFederated.php @@ -221,7 +221,9 @@ class JobQueueFederated extends JobQueue { // Try to insert the jobs and update $partitionsTry on any failures. // Retry to insert any remaning jobs again, ignoring the bad partitions. $jobsLeft = $jobs; + // @codingStandardsIgnoreStart Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed for ( $i = $this->maxPartitionsTry; $i > 0 && count( $jobsLeft ); --$i ) { + // @codingStandardsIgnoreEnd try { $partitionRing->getLiveRing(); } catch ( UnexpectedValueException $e ) { diff --git a/includes/media/Bitmap_ClientOnly.php b/includes/media/Bitmap_ClientOnly.php index c105c4281e..b91fb8aa67 100644 --- a/includes/media/Bitmap_ClientOnly.php +++ b/includes/media/Bitmap_ClientOnly.php @@ -29,7 +29,10 @@ * * @ingroup Media */ +// @codingStandardsIgnoreStart Squiz.Classes.ValidClassName.NotCamelCaps class BitmapHandler_ClientOnly extends BitmapHandler { + // @codingStandardsIgnoreEnd + /** * @param File $image * @param array $params -- 2.20.1