Fix CodeSniffer errors and warnings
authorSiebrand Mazeland <s.mazeland@xs4all.nl>
Wed, 5 Feb 2014 10:20:17 +0000 (11:20 +0100)
committerSiebrand Mazeland <s.mazeland@xs4all.nl>
Wed, 5 Feb 2014 10:20:17 +0000 (11:20 +0100)
Change-Id: Idc74e34634d88625773fb8f73315f61edfa67e28

18 files changed:
includes/api/ApiMain.php
includes/api/ApiPageSet.php
includes/api/ApiQueryAllCategories.php
includes/api/ApiQueryAllLinks.php
includes/api/ApiQueryAllPages.php
includes/api/ApiQueryDeletedrevs.php
includes/api/ApiQueryImageInfo.php
includes/api/ApiQuerySiteinfo.php
includes/api/ApiQueryUserContributions.php
includes/api/ApiRevisionDelete.php
includes/api/ApiWatch.php
includes/db/DatabaseMssql.php
includes/db/DatabasePostgres.php
includes/filebackend/SwiftFileBackend.php
includes/htmlform/HTMLForm.php
includes/installer/MysqlUpdater.php
includes/installer/PostgresUpdater.php
includes/installer/SqliteUpdater.php

index 81b5e9f..2684f51 100644 (file)
@@ -39,7 +39,6 @@
  * @ingroup API
  */
 class ApiMain extends ApiBase {
-
        /**
         * When no format parameter is given, this format will be used
         */
@@ -1148,7 +1147,10 @@ class ApiMain extends ApiBase {
                        array( 'code' => 'maxlag', 'info' => 'Waiting for host: x seconds lagged' ),
                        array( 'code' => 'maxlag', 'info' => 'Waiting for a database server: x seconds lagged' ),
                        array( 'code' => 'assertuserfailed', 'info' => 'Assertion that the user is logged in failed' ),
-                       array( 'code' => 'assertbotfailed', 'info' => 'Assertion that the user has the bot right failed' ),
+                       array(
+                               'code' => 'assertbotfailed',
+                               'info' => 'Assertion that the user has the bot right failed'
+                       ),
                ) );
        }
 
index 36dd726..4ecf029 100644 (file)
@@ -39,7 +39,6 @@
  * @since 1.21 derives from ApiBase instead of ApiQueryBase
  */
 class ApiPageSet extends ApiBase {
-
        /**
         * Constructor flag: The new instance of ApiPageSet will ignore the 'generator=' parameter
         * @since 1.21
@@ -536,7 +535,9 @@ class ApiPageSet extends ApiBase {
         * @return array Array suitable for inclusion in the response
         * @since 1.23
         */
-       public function getInvalidTitlesAndRevisions( $invalidChecks = array( 'invalidTitles', 'special', 'missingIds', 'missingRevIds', 'missingTitles', 'interwikiTitles' ) ) {
+       public function getInvalidTitlesAndRevisions( $invalidChecks = array( 'invalidTitles',
+               'special', 'missingIds', 'missingRevIds', 'missingTitles', 'interwikiTitles' )
+       ) {
                $result = array();
                if ( in_array( "invalidTitles", $invalidChecks ) ) {
                        self::addValues( $result, $this->getInvalidTitles(), 'invalid', 'title' );
index 6bf8075..44bf0cb 100644 (file)
@@ -67,8 +67,12 @@ class ApiQueryAllCategories extends ApiQueryGeneratorBase {
                }
 
                $dir = ( $params['dir'] == 'descending' ? 'older' : 'newer' );
-               $from = ( $params['from'] === null ? null : $this->titlePartToKey( $params['from'], NS_CATEGORY ) );
-               $to = ( $params['to'] === null ? null : $this->titlePartToKey( $params['to'], NS_CATEGORY ) );
+               $from = ( $params['from'] === null
+                       ? null
+                       : $this->titlePartToKey( $params['from'], NS_CATEGORY ) );
+               $to = ( $params['to'] === null
+                       ? null
+                       : $this->titlePartToKey( $params['to'], NS_CATEGORY ) );
                $this->addWhereRange( 'cat_title', $dir, $from, $to );
 
                $min = $params['min'];
index 5be304d..13f766e 100644 (file)
@@ -154,7 +154,6 @@ class ApiQueryAllLinks extends ApiQueryGeneratorBase {
                        $this->titlePartToKey( $params['to'], $params['namespace'] ) );
                $this->addWhereRange( $pfx . $fieldTitle, 'newer', $from, $to );
 
-
                if ( isset( $params['prefix'] ) ) {
                        $this->addWhere( $pfx . $fieldTitle . $db->buildLike( $this->titlePartToKey(
                                $params['prefix'], $params['namespace'] ), $db->anyString() ) );
index 430dd51..501154a 100644 (file)
@@ -87,8 +87,12 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase {
 
                $this->addWhereFld( 'page_namespace', $params['namespace'] );
                $dir = ( $params['dir'] == 'descending' ? 'older' : 'newer' );
-               $from = ( $params['from'] === null ? null : $this->titlePartToKey( $params['from'], $params['namespace'] ) );
-               $to = ( $params['to'] === null ? null : $this->titlePartToKey( $params['to'], $params['namespace'] ) );
+               $from = ( $params['from'] === null
+                       ? null
+                       : $this->titlePartToKey( $params['from'], $params['namespace'] ) );
+               $to = ( $params['to'] === null
+                       ? null
+                       : $this->titlePartToKey( $params['to'], $params['namespace'] ) );
                $this->addWhereRange( 'page_title', $dir, $from, $to );
 
                if ( isset( $params['prefix'] ) ) {
index 7585ba7..365fe3f 100644 (file)
@@ -176,8 +176,12 @@ class ApiQueryDeletedrevs extends ApiQueryBase {
                } elseif ( $mode == 'all' ) {
                        $this->addWhereFld( 'ar_namespace', $params['namespace'] );
 
-                       $from = $params['from'] === null ? null : $this->titlePartToKey( $params['from'], $params['namespace'] );
-                       $to = $params['to'] === null ? null : $this->titlePartToKey( $params['to'], $params['namespace'] );
+                       $from = $params['from'] === null
+                               ? null
+                               : $this->titlePartToKey( $params['from'], $params['namespace'] );
+                       $to = $params['to'] === null
+                               ? null
+                               : $this->titlePartToKey( $params['to'], $params['namespace'] );
                        $this->addWhereRange( 'ar_title', $dir, $from, $to );
 
                        if ( isset( $params['prefix'] ) ) {
index baee9b1..95c1420 100644 (file)
@@ -677,7 +677,8 @@ class ApiQueryImageInfo extends ApiQueryBase {
                                ' (requires url and param ' . $modulePrefix . 'urlwidth)',
                        'mediatype' =>      ' mediatype     - Adds the media type of the image',
                        'metadata' =>       ' metadata      - Lists Exif metadata for the version of the image',
-                       'commonmetadata' => ' commonmetadata - Lists file format generic metadata for the version of the image',
+                       'commonmetadata' => ' commonmetadata - Lists file format generic metadata ' .
+                               'for the version of the image',
                        'extmetadata' =>    ' extmetadata   - Lists formatted metadata combined ' .
                                'from multiple sources. Results are HTML formatted.',
                        'archivename' =>    ' archivename   - Adds the file name of the archive ' .
index 07561ca..a9a5f5f 100644 (file)
@@ -573,12 +573,20 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                                                        $ret['vcs-url'] = isset( $svnInfo['viewvc-url'] ) ? $svnInfo['viewvc-url'] : '';
                                                }
                                        }
+
                                        if ( SpecialVersion::getExtLicenseFileName( $extensionPath ) ) {
                                                $ret['license-name'] = isset( $ext['license-name'] ) ? $ext['license-name'] : '';
-                                               $ret['license'] = SpecialPage::getTitleFor( 'Version', "License/{$ext['name']}" )->getLinkURL();
+                                               $ret['license'] = SpecialPage::getTitleFor(
+                                                       'Version',
+                                                       "License/{$ext['name']}"
+                                               )->getLinkURL();
                                        }
+
                                        if ( SpecialVersion::getExtAuthorsFileName( $extensionPath ) ) {
-                                               $ret['credits'] = SpecialPage::getTitleFor( 'Version', "Credits/{$ext['name']}" )->getLinkURL();
+                                               $ret['credits'] = SpecialPage::getTitleFor(
+                                                       'Version',
+                                                       "Credits/{$ext['name']}"
+                                               )->getLinkURL();
                                        }
                                }
                                $data[] = $ret;
index 7896a2c..b492d9a 100644 (file)
@@ -360,7 +360,13 @@ class ApiQueryContributions extends ApiQueryBase {
                                $vals['commenthidden'] = '';
                                $anyHidden = true;
                        }
-                       if ( Revision::userCanBitfield( $row->rev_deleted, Revision::DELETED_COMMENT, $this->getUser() ) ) {
+
+                       $userCanView = Revision::userCanBitfield(
+                               $row->rev_deleted,
+                               Revision::DELETED_COMMENT, $this->getUser()
+                       );
+
+                       if ( $userCanView ) {
                                if ( $this->fld_comment ) {
                                        $vals['comment'] = $row->rev_comment;
                                }
index 55d59f4..9ba30d7 100644 (file)
@@ -97,14 +97,19 @@ class ApiRevisionDelete extends ApiBase {
                $data = $this->extractStatusInfo( $status );
                $data['target'] = $targetObj->getFullText();
                $data['items'] = array();
+
                foreach ( $status->itemStatuses as $id => $s ) {
                        $data['items'][$id] = $this->extractStatusInfo( $s );
                        $data['items'][$id]['id'] = $id;
                }
+
                $list->reloadFromMaster();
+               // @codingStandardsIgnoreStart Avoid function calls in a FOR loop test part
                for ( $item = $list->reset(); $list->current(); $item = $list->next() ) {
                        $data['items'][$item->getId()] += $item->getApiData( $this->getResult() );
                }
+               // @codingStandardsIgnoreEnd
+
                $data['items'] = array_values( $data['items'] );
                $result->setIndexedTagName( $data['items'], 'i' );
                $result->addValue( null, $this->getModuleName(), $data );
@@ -232,10 +237,12 @@ class ApiRevisionDelete extends ApiBase {
 
        public function getExamples() {
                return array(
-                       'api.php?action=revisiondelete&target=Main%20Page&type=revision&ids=12345&hide=content&token=123ABC'
-                       => 'Hide content for revision 12345 on the Main Page',
-                       'api.php?action=revisiondelete&type=logging&ids=67890&hide=content|comment|user&reason=BLP%20violation&token=123ABC'
-                       => 'Hide all data on log entry 67890 with the reason "BLP violation"',
+                       'api.php?action=revisiondelete&target=Main%20Page&type=revision&ids=12345&' .
+                               'hide=content&token=123ABC'
+                               => 'Hide content for revision 12345 on the Main Page',
+                       'api.php?action=revisiondelete&type=logging&ids=67890&hide=content|comment|user&' .
+                               'reason=BLP%20violation&token=123ABC'
+                               => 'Hide all data on log entry 67890 with the reason "BLP violation"',
                );
        }
 
index 09f9356..d0049ff 100644 (file)
@@ -48,12 +48,20 @@ class ApiWatch extends ApiBase {
                // title is still supported for backward compatibility
                if ( !isset( $params['title'] ) ) {
                        $pageSet->execute();
-                       $res = $pageSet->getInvalidTitlesAndRevisions( array( 'invalidTitles', 'special', 'missingIds', 'missingRevIds', 'interwikiTitles' ) );
+                       $res = $pageSet->getInvalidTitlesAndRevisions( array(
+                               'invalidTitles',
+                               'special',
+                               'missingIds',
+                               'missingRevIds',
+                               'interwikiTitles'
+                       ) );
+
                        foreach ( $pageSet->getMissingTitles() as $title ) {
                                $r = $this->watchTitle( $title, $user, $params );
                                $r['missing'] = 1;
                                $res[] = $r;
                        }
+
                        foreach ( $pageSet->getGoodTitles() as $title ) {
                                $r = $this->watchTitle( $title, $user, $params );
                                $res[] = $r;
@@ -64,9 +72,13 @@ class ApiWatch extends ApiBase {
                        $extraParams = array_keys( array_filter( $pageSet->extractRequestParams(), function ( $x ) {
                                return $x !== null && $x !== false;
                        } ) );
+
                        if ( $extraParams ) {
                                $p = $this->getModulePrefix();
-                               $this->dieUsage( "The parameter {$p}title can not be used with ".  implode( ", ", $extraParams ), 'invalidparammix' );
+                               $this->dieUsage(
+                                       "The parameter {$p}title can not be used with " . implode( ", ", $extraParams ),
+                                       'invalidparammix'
+                               );
                        }
 
                        $title = Title::newFromText( $params['title'] );
@@ -78,7 +90,9 @@ class ApiWatch extends ApiBase {
                $this->getResult()->addValue( null, $this->getModuleName(), $res );
        }
 
-       private function watchTitle( Title $title, User $user, array $params, $compatibilityMode = false ) {
+       private function watchTitle( Title $title, User $user, array $params,
+               $compatibilityMode = false
+       ) {
                if ( !$title->isWatchable() ) {
                        return array( 'title' => $title->getPrefixedText(), 'watchable' => 0 );
                }
@@ -116,7 +130,6 @@ class ApiWatch extends ApiBase {
                        $this->getContext()->setLanguage( $oldLang ); // Reset language to $oldLang
                }
 
-
                if ( !$status->isOK() ) {
                        if ( $compatibilityMode ) {
                                $this->dieStatus( $status );
index 9636da5..8826683 100644 (file)
@@ -984,7 +984,9 @@ class DatabaseMssql extends DatabaseBase {
         * @param array $join_conds
         * @return string
         */
-       protected function tableNamesWithUseIndexOrJOIN( $tables, $use_index = array(), $join_conds = array() ) {
+       protected function tableNamesWithUseIndexOrJOIN( $tables, $use_index = array(),
+               $join_conds = array()
+       ) {
                $ret = array();
                $retJOIN = array();
                $use_index_safe = is_array( $use_index ) ? $use_index : array();
index 6475c8f..c8830d3 100644 (file)
@@ -827,7 +827,9 @@ __INDEXATTR__;
         * can be locked. That means tables in an outer join cannot be FOR UPDATE locked. Trying to do
         * so causes a DB error. This wrapper checks which tables can be locked and adjusts it accordingly.
         */
-       function selectSQLText( $table, $vars, $conds = '', $fname = __METHOD__, $options = array(), $join_conds = array() ) {
+       function selectSQLText( $table, $vars, $conds = '', $fname = __METHOD__,
+               $options = array(), $join_conds = array()
+       ) {
                if ( is_array( $options ) ) {
                        $forUpdateKey = array_search( 'FOR UPDATE', $options );
                        if ( $forUpdateKey !== false && $join_conds ) {
@@ -1063,7 +1065,7 @@ __INDEXATTR__;
 
        /**
         * Return the next in a sequence, save the value for retrieval via insertId()
-        * 
+        *
         * @param string $seqName
         * @return int|null
         */
@@ -1564,7 +1566,7 @@ SQL;
 
                if ( isset( $options['FOR UPDATE'] ) ) {
                        $postLimitTail .= ' FOR UPDATE OF ' . implode( ', ', $options['FOR UPDATE'] );
-               } else if ( isset( $noKeyOptions['FOR UPDATE'] ) ) {
+               } elseif ( isset( $noKeyOptions['FOR UPDATE'] ) ) {
                        $postLimitTail .= ' FOR UPDATE';
                }
 
index f3b9664..c3d2de8 100644 (file)
@@ -1218,7 +1218,8 @@ class SwiftFileBackend extends FileBackendStore {
                }
 
                // Run all requests for the first stage, then the next, and so on
-               for ( $stage = 0; $stage < count( $httpReqsByStage ); ++$stage ) {
+               $reqCount = count( $httpReqsByStage );
+               for ( $stage = 0; $stage < $reqCount; ++$stage ) {
                        $httpReqs = $this->http->runMulti( $httpReqsByStage[$stage] );
                        foreach ( $httpReqs as $index => $httpReq ) {
                                // Run the callback for each request of this operation
index 1e8da45..f3b7ce7 100644 (file)
@@ -812,8 +812,14 @@ class HTMLForm extends ContextSource {
                        if ( $this->isVForm() ) {
                                // mw-ui-block is necessary because the buttons aren't necessarily in an
                                // immediate child div of the vform.
-                               // TODO Let client specify if the primary submit button is progressive or destructive
-                               array_push( $attribs['class'], 'mw-ui-button', 'mw-ui-big', 'mw-ui-constructive', 'mw-ui-block' );
+                               // @todo Let client specify if the primary submit button is progressive or destructive
+                               array_push(
+                                       $attribs['class'],
+                                       'mw-ui-button',
+                                       'mw-ui-big',
+                                       'mw-ui-constructive',
+                                       'mw-ui-block'
+                               );
                        }
 
                        $html .= Xml::submitButton( $this->getSubmitText(), $attribs ) . "\n";
index 9dfbff8..33ff65e 100644 (file)
@@ -28,7 +28,6 @@
  * @since 1.17
  */
 class MysqlUpdater extends DatabaseUpdater {
-
        protected function getCoreUpdateList() {
                return array(
                        array( 'disableContentHandlerUseDB' ),
@@ -246,8 +245,9 @@ class MysqlUpdater extends DatabaseUpdater {
 
                        // 1.23
                        array( 'addField', 'recentchanges', 'rc_source', 'patch-rc_source.sql' ),
-                       array( 'addIndex', 'logging', 'log_user_text_type_time',  'patch-logging_user_text_type_time_index.sql' ),
-                       array( 'addIndex', 'logging', 'log_user_text_time',  'patch-logging_user_text_time_index.sql' ),
+                       array( 'addIndex', 'logging', 'log_user_text_type_time',
+                               'patch-logging_user_text_type_time_index.sql' ),
+                       array( 'addIndex', 'logging', 'log_user_text_time', 'patch-logging_user_text_time_index.sql' ),
                        array( 'addField', 'page', 'page_links_updated', 'patch-page_links_updated.sql' ),
                );
        }
index cd5a8ad..7841fca 100644 (file)
@@ -260,7 +260,8 @@ class PostgresUpdater extends DatabaseUpdater {
                        array( 'addPgIndex', 'job', 'job_cmd_token', '(job_cmd, job_token, job_random)' ),
                        array( 'addPgIndex', 'job', 'job_cmd_token_id', '(job_cmd, job_token, job_id)' ),
                        array( 'addPgIndex', 'filearchive', 'fa_sha1', '(fa_sha1)' ),
-                       array( 'addPgIndex', 'logging', 'logging_user_text_type_time', '(log_user_text, log_type, log_timestamp)' ),
+                       array( 'addPgIndex', 'logging', 'logging_user_text_type_time',
+                               '(log_user_text, log_type, log_timestamp)' ),
                        array( 'addPgIndex', 'logging', 'logging_user_text_time', '(log_user_text, log_timestamp)' ),
 
                        array( 'checkIndex', 'pagelink_unique', array(
index 3db3758..5d4f6de 100644 (file)
@@ -123,7 +123,8 @@ class SqliteUpdater extends DatabaseUpdater {
 
                        // 1.23
                        array( 'addField', 'recentchanges', 'rc_source', 'patch-rc_source.sql' ),
-                       array( 'addIndex', 'logging', 'log_user_text_type_time',  'patch-logging_user_text_type_time_index.sql' ),
+                       array( 'addIndex', 'logging', 'log_user_text_type_time',
+                               'patch-logging_user_text_type_time_index.sql' ),
                        array( 'addIndex', 'logging', 'log_user_text_time',  'patch-logging_user_text_time_index.sql' ),
                        array( 'addField', 'page', 'page_links_updated', 'patch-page_links_updated.sql' ),
                );