From 511d594bf6804bafb0c76b87f7f81f21dae86eea Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Mon, 18 Nov 2013 23:03:29 +0100 Subject: [PATCH] Address CodeSniffer errors and warnings Change-Id: Ie119db7d6d9e9eb3c1cd9c07b8f84fd155847c62 --- includes/changes/ChangesList.php | 39 ++++++++++++++++-------- includes/changes/EnhancedChangesList.php | 38 +++++++++++++++-------- includes/changes/OldChangesList.php | 3 +- includes/changes/RecentChange.php | 15 ++++++--- 4 files changed, 64 insertions(+), 31 deletions(-) diff --git a/includes/changes/ChangesList.php b/includes/changes/ChangesList.php index fe5bf782f1..a45bc5974a 100644 --- a/includes/changes/ChangesList.php +++ b/includes/changes/ChangesList.php @@ -23,7 +23,6 @@ */ class ChangesList extends ContextSource { - /** * @var Skin */ @@ -140,8 +139,8 @@ class ChangesList extends ContextSource { $flag = $map[$flag]; } - return "" . - $flagInfos[$flag]['letter'] . + return "" . $flagInfos[$flag]['letter'] . ''; } @@ -313,7 +312,9 @@ class ChangesList extends ContextSource { 'action' => 'history' ) ); - $s .= $this->msg( 'parentheses' )->rawParams( $diffhist )->escaped() . ' . . '; + // @todo FIXME: Hard coded ". .". Is there a message for this? Should there be? + $s .= $this->msg( 'parentheses' )->rawParams( $diffhist )->escaped() . + ' . . '; } /** @@ -353,8 +354,12 @@ class ChangesList extends ContextSource { * @return string HTML fragment */ public function getTimestamp( $rc ) { + // @todo FIXME: Hard coded ". .". Is there a message for this? Should there be? return $this->message['semicolon-separator'] . '' . - $this->getLanguage()->userTime( $rc->mAttribs['rc_timestamp'], $this->getUser() ) . ' . . '; + $this->getLanguage()->userTime( + $rc->mAttribs['rc_timestamp'], + $this->getUser() + ) . ' . . '; } /** @@ -375,7 +380,8 @@ class ChangesList extends ContextSource { */ public function insertUserRelatedLinks( &$s, &$rc ) { if ( $this->isDeleted( $rc, Revision::DELETED_USER ) ) { - $s .= ' ' . $this->msg( 'rev-deleted-user' )->escaped() . ''; + $s .= ' ' . + $this->msg( 'rev-deleted-user' )->escaped() . ''; } else { $s .= $this->getLanguage()->getDirMark() . Linker::userLink( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] ); @@ -405,7 +411,8 @@ class ChangesList extends ContextSource { public function insertComment( $rc ) { if ( $rc->mAttribs['rc_type'] != RC_MOVE && $rc->mAttribs['rc_type'] != RC_MOVE_OVER_REDIRECT ) { if ( $this->isDeleted( $rc, Revision::DELETED_COMMENT ) ) { - return ' ' . $this->msg( 'rev-deleted-comment' )->escaped() . ''; + return ' ' . + $this->msg( 'rev-deleted-comment' )->escaped() . ''; } else { return Linker::commentBlock( $rc->mAttribs['rc_comment'], $rc->getTitle() ); } @@ -435,7 +442,8 @@ class ChangesList extends ContextSource { static $cache = array(); if ( $count > 0 ) { if ( !isset( $cache[$count] ) ) { - $cache[$count] = $this->msg( 'number_of_watching_users_RCview' )->numParams( $count )->escaped(); + $cache[$count] = $this->msg( 'number_of_watching_users_RCview' ) + ->numParams( $count )->escaped(); } return $cache[$count]; } else { @@ -488,12 +496,16 @@ class ChangesList extends ContextSource { * @param $rc RecentChange */ public function insertRollback( &$s, &$rc ) { - if ( $rc->mAttribs['rc_type'] == RC_EDIT && $rc->mAttribs['rc_this_oldid'] && $rc->mAttribs['rc_cur_id'] ) { + if ( $rc->mAttribs['rc_type'] == RC_EDIT + && $rc->mAttribs['rc_this_oldid'] + && $rc->mAttribs['rc_cur_id'] + ) { $page = $rc->getTitle(); /** Check for rollback and edit permissions, disallow special pages, and only * show a link on the top-most revision */ - if ( $this->getUser()->isAllowed( 'rollback' ) && $rc->mAttribs['page_latest'] == $rc->mAttribs['rc_this_oldid'] ) - { + if ( $this->getUser()->isAllowed( 'rollback' ) + && $rc->mAttribs['page_latest'] == $rc->mAttribs['rc_this_oldid'] + ) { $rev = new Revision( array( 'title' => $page, 'id' => $rc->mAttribs['rc_this_oldid'], @@ -516,7 +528,10 @@ class ChangesList extends ContextSource { return; } - list( $tagSummary, $newClasses ) = ChangeTags::formatSummaryRow( $rc->mAttribs['ts_tags'], 'changeslist' ); + list( $tagSummary, $newClasses ) = ChangeTags::formatSummaryRow( + $rc->mAttribs['ts_tags'], + 'changeslist' + ); $classes = array_merge( $classes, $newClasses ); $s .= ' ' . $tagSummary; } diff --git a/includes/changes/EnhancedChangesList.php b/includes/changes/EnhancedChangesList.php index 3b724f1525..4d6a4e7c84 100644 --- a/includes/changes/EnhancedChangesList.php +++ b/includes/changes/EnhancedChangesList.php @@ -98,7 +98,8 @@ class EnhancedChangesList extends ChangesList { $logtitle = SpecialPage::getTitleFor( 'Log', $logType ); $logpage = new LogPage( $logType ); $logname = $logpage->getName()->escaped(); - $clink = $this->msg( 'parentheses' )->rawParams( Linker::linkKnown( $logtitle, $logname ) )->escaped(); + $clink = $this->msg( 'parentheses' ) + ->rawParams( Linker::linkKnown( $logtitle, $logname ) )->escaped(); } else { $clink = Linker::link( $cacheEntry->getTitle() ); } @@ -162,7 +163,8 @@ class EnhancedChangesList extends ChangesList { # Make user links if ( $this->isDeleted( $cacheEntry, Revision::DELETED_USER ) ) { - $cacheEntry->userlink = ' ' . $this->msg( 'rev-deleted-user' )->escaped() . ''; + $cacheEntry->userlink = ' ' . + $this->msg( 'rev-deleted-user' )->escaped() . ''; } else { $cacheEntry->userlink = Linker::userLink( $cacheEntry->mAttribs['rc_user'], @@ -286,7 +288,9 @@ class EnhancedChangesList extends ChangesList { $text = $userlink; $text .= $this->getLanguage()->getDirMark(); if ( $count > 1 ) { - $text .= ' ' . $this->msg( 'parentheses' )->rawParams( $this->getLanguage()->formatNum( $count ) . '×' )->escaped(); + // @todo FIXME: Hardcoded '×'. Should be a message. + $formattedCount = $this->getLanguage()->formatNum( $count ) . '×'; + $text .= ' ' . $this->msg( 'parentheses' )->rawParams( $formattedCount )->escaped(); } array_push( $users, $text ); } @@ -296,7 +300,8 @@ class EnhancedChangesList extends ChangesList { implode( $this->message['semicolon-separator'], $users ) )->escaped() . ''; - $tl = ''; + $tl = ''; $r .= "$tl"; # Main line @@ -312,7 +317,8 @@ class EnhancedChangesList extends ChangesList { # Article link if ( $namehidden ) { - $r .= ' ' . $this->msg( 'rev-deleted-event' )->escaped() . ''; + $r .= ' ' . + $this->msg( 'rev-deleted-event' )->escaped() . ''; } elseif ( $allLogs ) { $r .= $this->maybeWatchedLink( $block[0]->link, $block[0]->watched ); } else { @@ -473,7 +479,11 @@ class EnhancedChangesList extends ChangesList { $r .= $link . ''; if ( !$type == RC_LOG || $type == RC_NEW ) { - $r .= ' ' . $this->msg( 'parentheses' )->rawParams( $rcObj->curlink . $this->message['pipe-separator'] . $rcObj->lastlink )->escaped(); + $r .= ' ' . $this->msg( 'parentheses' )->rawParams( + $rcObj->curlink . + $this->message['pipe-separator'] . + $rcObj->lastlink + )->escaped(); } $r .= ' . . '; @@ -598,19 +608,21 @@ class EnhancedChangesList extends ChangesList { $logPage = new LogPage( $logType ); $logTitle = SpecialPage::getTitleFor( 'Log', $logType ); $logName = $logPage->getName()->escaped(); - $r .= $this->msg( 'parentheses' )->rawParams( Linker::linkKnown( $logTitle, $logName ) )->escaped(); + $r .= $this->msg( 'parentheses' ) + ->rawParams( Linker::linkKnown( $logTitle, $logName ) )->escaped(); } else { $this->insertArticleLink( $r, $rcObj, $rcObj->unpatrolled, $rcObj->watched ); } # Diff and hist links if ( $type != RC_LOG ) { $query['action'] = 'history'; - $r .= ' ' . $this->msg( 'parentheses' )->rawParams( $rcObj->difflink . $this->message['pipe-separator'] . Linker::linkKnown( - $rcObj->getTitle(), - $this->message['hist'], - array(), - $query - ) )->escaped(); + $r .= ' ' . $this->msg( 'parentheses' ) + ->rawParams( $rcObj->difflink . $this->message['pipe-separator'] . Linker::linkKnown( + $rcObj->getTitle(), + $this->message['hist'], + array(), + $query + ) )->escaped(); } $r .= ' . . '; # Character diff diff --git a/includes/changes/OldChangesList.php b/includes/changes/OldChangesList.php index a7fe9342ef..e9a6a43544 100644 --- a/includes/changes/OldChangesList.php +++ b/includes/changes/OldChangesList.php @@ -116,7 +116,8 @@ class OldChangesList extends ChangesList { } if ( $this->watchlist ) { - $classes[] = Sanitizer::escapeClass( 'watchlist-' . $rc->mAttribs['rc_namespace'] . '-' . $rc->mAttribs['rc_title'] ); + $classes[] = Sanitizer::escapeClass( 'watchlist-' . + $rc->mAttribs['rc_namespace'] . '-' . $rc->mAttribs['rc_title'] ); } if ( !wfRunHooks( 'OldChangesListRecentChangesLine', array( &$this, &$s, $rc, &$classes ) ) ) { diff --git a/includes/changes/RecentChange.php b/includes/changes/RecentChange.php index 48a8d03cb8..5c5907ddc0 100644 --- a/includes/changes/RecentChange.php +++ b/includes/changes/RecentChange.php @@ -406,7 +406,8 @@ class RecentChange { /** * Mark this RecentChange as patrolled * - * NOTE: Can also return 'rcpatroldisabled', 'hookaborted' and 'markedaspatrollederror-noautopatrol' as errors + * NOTE: Can also return 'rcpatroldisabled', 'hookaborted' and + * 'markedaspatrollederror-noautopatrol' as errors * @param $user User object doing the action * @param $auto Boolean: for automatic patrol * @return array of permissions errors, see Title::getUserPermissionsErrors() @@ -427,7 +428,9 @@ class RecentChange { } // Users without the 'autopatrol' right can't patrol their // own revisions - if ( $user->getName() == $this->getAttribute( 'rc_user_text' ) && !$user->isAllowed( 'autopatrol' ) ) { + if ( $user->getName() == $this->getAttribute( 'rc_user_text' ) + && !$user->isAllowed( 'autopatrol' ) + ) { $errors[] = array( 'markedaspatrollederror-noautopatrol' ); } if ( $errors ) { @@ -602,9 +605,10 @@ class RecentChange { * @return bool */ public static function notifyLog( $timestamp, &$title, &$user, $actionComment, $ip, $type, - $action, $target, $logComment, $params, $newId = 0, $actionCommentIRC = '' ) - { + $action, $target, $logComment, $params, $newId = 0, $actionCommentIRC = '' + ) { global $wgLogRestrictions; + # Don't add private logs to RC! if ( isset( $wgLogRestrictions[$type] ) && $wgLogRestrictions[$type] != '*' ) { return false; @@ -826,7 +830,8 @@ class RecentChange { global $wgRequest; if ( $ip ) { if ( !IP::isIPAddress( $ip ) ) { - throw new MWException( "Attempt to write \"" . $ip . "\" as an IP address into recent changes" ); + throw new MWException( "Attempt to write \"" . $ip . + "\" as an IP address into recent changes" ); } } else { $ip = $wgRequest->getIP(); -- 2.20.1