From 036b949cd9bec52f678ed7317c2b0ba41d668c6e Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Fri, 9 May 2014 21:34:55 +0200 Subject: [PATCH] Pass phpcs-strict on includes/specials/ (3/3) Change-Id: I9502370c6b53f5a5c8cffc3d15516c560e709e64 --- includes/specials/SpecialNewimages.php | 2 +- includes/specials/SpecialNewpages.php | 6 +- includes/specials/SpecialProtectedpages.php | 13 +++- includes/specials/SpecialRevisiondelete.php | 69 ++++++++++++++++----- includes/specials/SpecialRunJobs.php | 5 +- includes/specials/SpecialSearch.php | 29 ++++++--- 6 files changed, 92 insertions(+), 32 deletions(-) diff --git a/includes/specials/SpecialNewimages.php b/includes/specials/SpecialNewimages.php index 6891b16b07..147d176d4b 100644 --- a/includes/specials/SpecialNewimages.php +++ b/includes/specials/SpecialNewimages.php @@ -76,7 +76,7 @@ class NewFilesPager extends ReverseChronologicalPager { /** * @var ImageGallery */ - var $gallery; + protected $gallery; function __construct( IContextSource $context, $par = null ) { $this->like = $context->getRequest()->getText( 'like' ); diff --git a/includes/specials/SpecialNewpages.php b/includes/specials/SpecialNewpages.php index 66ec693cd5..505a1ecc46 100644 --- a/includes/specials/SpecialNewpages.php +++ b/includes/specials/SpecialNewpages.php @@ -27,15 +27,12 @@ * @ingroup SpecialPage */ class SpecialNewpages extends IncludableSpecialPage { - // Stored objects - /** * @var FormOptions */ protected $opts; protected $customFilters; - // Some internal settings protected $showNavigation = false; public function __construct() { @@ -394,7 +391,8 @@ class SpecialNewpages extends IncludableSpecialPage { $oldTitleText = $this->msg( 'rc-old-title' )->params( $oldTitleText )->escaped(); } - return "{$time} {$dm}{$plink} {$hist} {$dm}{$length} {$dm}{$ulink} {$comment} {$tagDisplay} {$oldTitleText}\n"; + return "{$time} {$dm}{$plink} {$hist} {$dm}{$length} " + . "{$dm}{$ulink} {$comment} {$tagDisplay} {$oldTitleText}\n"; } /** diff --git a/includes/specials/SpecialProtectedpages.php b/includes/specials/SpecialProtectedpages.php index 6edf2c00d0..7554e37b1a 100644 --- a/includes/specials/SpecialProtectedpages.php +++ b/includes/specials/SpecialProtectedpages.php @@ -27,7 +27,6 @@ * @ingroup SpecialPage */ class SpecialProtectedpages extends SpecialPage { - protected $IdLevel = 'level'; protected $IdType = 'type'; @@ -438,7 +437,11 @@ class ProtectedPagesPager extends TablePager { ); } else { $username = UserCache::singleton()->getProp( $value, 'name' ); - if ( LogEventsList::userCanBitfield( $row->log_deleted, LogPage::DELETED_USER, $this->getUser() ) ) { + if ( LogEventsList::userCanBitfield( + $row->log_deleted, + LogPage::DELETED_USER, + $this->getUser() + ) ) { if ( $username === false ) { $formatted = htmlspecialchars( $value ); } else { @@ -473,7 +476,11 @@ class ProtectedPagesPager extends TablePager { $this->msg( 'protectedpages-unknown-reason' )->escaped() ); } else { - if ( LogEventsList::userCanBitfield( $row->log_deleted, LogPage::DELETED_COMMENT, $this->getUser() ) ) { + if ( LogEventsList::userCanBitfield( + $row->log_deleted, + LogPage::DELETED_COMMENT, + $this->getUser() + ) ) { $formatted = Linker::formatComment( $value !== null ? $value : '' ); } else { $formatted = $this->msg( 'rev-deleted-comment' )->escaped(); diff --git a/includes/specials/SpecialRevisiondelete.php b/includes/specials/SpecialRevisiondelete.php index 3cda8c679a..797f588a0d 100644 --- a/includes/specials/SpecialRevisiondelete.php +++ b/includes/specials/SpecialRevisiondelete.php @@ -132,7 +132,9 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { // $this->ids = array_map( 'intval', $this->ids ); $this->ids = array_unique( array_filter( $this->ids ) ); - if ( $request->getVal( 'action' ) == 'historysubmit' || $request->getVal( 'action' ) == 'revisiondelete' ) { + if ( $request->getVal( 'action' ) == 'historysubmit' + || $request->getVal( 'action' ) == 'revisiondelete' + ) { // For show/hide form submission from history page // Since we are access through index.php?title=XXX&action=historysubmit // getFullTitle() will contain the target title and not our title @@ -162,7 +164,11 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { $this->mIsAllowed = $user->isAllowed( RevisionDeleter::getRestriction( $this->typeName ) ); # Allow the list type to adjust the passed target - $this->targetObj = RevisionDeleter::suggestTarget( $this->typeName, $this->targetObj, $this->ids ); + $this->targetObj = RevisionDeleter::suggestTarget( + $this->typeName, + $this->targetObj, + $this->ids + ); $this->otherReason = $request->getVal( 'wpReason' ); # We need a target page! @@ -277,7 +283,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { /** * Show a deleted file version requested by the visitor. - * TODO Mostly copied from Special:Undelete. Refactor. + * @todo Mostly copied from Special:Undelete. Refactor. * @param string $archiveName */ protected function tryShowFile( $archiveName ) { @@ -326,7 +332,9 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { # a user without appropriate permissions can toddle off and # nab the image, and Squid will serve it $this->getRequest()->response()->header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', 0 ) . ' GMT' ); - $this->getRequest()->response()->header( 'Cache-Control: no-cache, no-store, max-age=0, must-revalidate' ); + $this->getRequest()->response()->header( + 'Cache-Control: no-cache, no-store, max-age=0, must-revalidate' + ); $this->getRequest()->response()->header( 'Pragma: no-cache' ); $key = $oimage->getStorageKey(); @@ -364,14 +372,18 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { $numRevisions = 0; // Live revisions... $list = $this->getList(); + // @codingStandardsIgnoreStart Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed for ( $list->reset(); $list->current(); $list->next() ) { + // @codingStandardsIgnoreEnd $item = $list->current(); + if ( !$item->canView() ) { if ( !$this->submitClicked ) { throw new PermissionsError( 'suppressrevision' ); } $userAllowed = false; } + $numRevisions++; $this->getOutput()->addHTML( $item->getHTML() ); } @@ -413,7 +425,12 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { Xml::label( $this->msg( 'revdelete-otherreason' )->text(), 'wpReason' ) . '' . '' . - Xml::input( 'wpReason', 60, $this->otherReason, array( 'id' => 'wpReason', 'maxlength' => 100 ) ) . + Xml::input( + 'wpReason', + 60, + $this->otherReason, + array( 'id' => 'wpReason', 'maxlength' => 100 ) + ) . '' . "\n" . '' . @@ -454,10 +471,15 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { */ protected function addUsageText() { // Messages: revdelete-text-text, revdelete-text-file, logdelete-text - $this->getOutput()->wrapWikiMsg( "$1\n$2", $this->typeLabels['text'], 'revdelete-text-others' ); + $this->getOutput()->wrapWikiMsg( + "$1\n$2", $this->typeLabels['text'], + 'revdelete-text-others' + ); + if ( $this->getUser()->isAllowed( 'suppressrevision' ) ) { $this->getOutput()->addWikiMsg( 'revdelete-suppress-text' ); } + if ( $this->mIsAllowed ) { $this->getOutput()->addWikiMsg( 'revdelete-confirm' ); } @@ -473,26 +495,38 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { if ( $list->length() == 1 ) { $list->reset(); $bitfield = $list->current()->getBits(); // existing field + if ( $this->submitClicked ) { $bitfield = RevisionDeleter::extractBitfield( $this->extractBitParams(), $bitfield ); } + foreach ( $this->checks as $item ) { // Messages: revdelete-hide-text, revdelete-hide-image, revdelete-hide-name, // revdelete-hide-comment, revdelete-hide-user, revdelete-hide-restricted list( $message, $name, $field ) = $item; - $innerHTML = Xml::checkLabel( $this->msg( $message )->text(), $name, $name, $bitfield & $field ); + $innerHTML = Xml::checkLabel( + $this->msg( $message )->text(), + $name, + $name, + $bitfield & $field + ); + if ( $field == Revision::DELETED_RESTRICTED ) { $innerHTML = "$innerHTML"; } + $line = Xml::tags( 'td', array( 'class' => 'mw-input' ), $innerHTML ); $html .= "$line\n"; } } else { // Otherwise, use tri-state radios $html .= ''; - $html .= '' . $this->msg( 'revdelete-radio-same' )->escaped() . ''; - $html .= '' . $this->msg( 'revdelete-radio-unset' )->escaped() . ''; - $html .= '' . $this->msg( 'revdelete-radio-set' )->escaped() . ''; + $html .= '' + . $this->msg( 'revdelete-radio-same' )->escaped() . ''; + $html .= '' + . $this->msg( 'revdelete-radio-unset' )->escaped() . ''; + $html .= '' + . $this->msg( 'revdelete-radio-set' )->escaped() . ''; $html .= "\n"; foreach ( $this->checks as $item ) { // Messages: revdelete-hide-text, revdelete-hide-image, revdelete-hide-name, @@ -535,16 +569,20 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { return false; } $bitParams = $this->extractBitParams(); - $listReason = $this->getRequest()->getText( 'wpRevDeleteReasonList', 'other' ); // from dropdown + // from dropdown + $listReason = $this->getRequest()->getText( 'wpRevDeleteReasonList', 'other' ); $comment = $listReason; if ( $comment != 'other' && $this->otherReason != '' ) { // Entry from drop down menu + additional comment - $comment .= $this->msg( 'colon-separator' )->inContentLanguage()->text() . $this->otherReason; + $comment .= $this->msg( 'colon-separator' )->inContentLanguage()->text() + . $this->otherReason; } elseif ( $comment == 'other' ) { $comment = $this->otherReason; } # Can the user set this field? - if ( $bitParams[Revision::DELETED_RESTRICTED] == 1 && !$this->getUser()->isAllowed( 'suppressrevision' ) ) { + if ( $bitParams[Revision::DELETED_RESTRICTED] == 1 + && !$this->getUser()->isAllowed( 'suppressrevision' ) + ) { throw new PermissionsError( 'suppressrevision' ); } # If the save went through, go to success message... @@ -567,7 +605,10 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { protected function success() { // Messages: revdelete-success, logdelete-success $this->getOutput()->setPageTitle( $this->msg( 'actioncomplete' ) ); - $this->getOutput()->wrapWikiMsg( "\n$1\n", $this->typeLabels['success'] ); + $this->getOutput()->wrapWikiMsg( + "\n$1\n", + $this->typeLabels['success'] + ); $this->wasSaved = true; $this->revDelList->reloadFromMaster(); $this->showForm(); diff --git a/includes/specials/SpecialRunJobs.php b/includes/specials/SpecialRunJobs.php index 10e7009d9b..63eff36ca3 100644 --- a/includes/specials/SpecialRunJobs.php +++ b/includes/specials/SpecialRunJobs.php @@ -66,12 +66,13 @@ class SpecialRunJobs extends UnlistedSpecialPage { // Constant-time signature verification // http://www.emerose.com/timing-attacks-explained - // @todo: make a common method for this + // @todo Make a common method for this if ( !is_string( $rSig ) || strlen( $rSig ) !== strlen( $cSig ) ) { $verified = false; } else { $result = 0; - for ( $i = 0; $i < strlen( $cSig ); $i++ ) { + $cSigLength = strlen( $cSig ); + for ( $i = 0; $i < $cSigLength; $i++ ) { $result |= ord( $cSig[$i] ) ^ ord( $rSig[$i] ); } $verified = ( $result == 0 ); diff --git a/includes/specials/SpecialSearch.php b/includes/specials/SpecialSearch.php index c2b5f9bdaf..2713a5f998 100644 --- a/includes/specials/SpecialSearch.php +++ b/includes/specials/SpecialSearch.php @@ -226,7 +226,11 @@ class SpecialSearch extends SpecialPage { $out->addHTML( Xml::openElement( 'fieldset' ) . Xml::element( 'legend', null, $this->msg( 'search-external' )->text() ) . - Xml::element( 'p', array( 'class' => 'mw-searchdisabled' ), $this->msg( 'searchdisabled' )->text() ) . + Xml::element( + 'p', + array( 'class' => 'mw-searchdisabled' ), + $this->msg( 'searchdisabled' )->text() + ) . $this->msg( 'googlesearch' )->rawParams( htmlspecialchars( $term ), 'UTF-8', @@ -284,7 +288,8 @@ class SpecialSearch extends SpecialPage { $stParams ); - $this->didYouMeanHtml = '
' . $this->msg( 'search-suggest' )->rawParams( $suggestLink )->text() . '
'; + $this->didYouMeanHtml = '
' + . $this->msg( 'search-suggest' )->rawParams( $suggestLink )->text() . '
'; } if ( !wfRunHooks( 'SpecialSearchResultsPrepend', array( $this, $out, $term ) ) ) { @@ -363,7 +368,10 @@ class SpecialSearch extends SpecialPage { // Show the create link ahead $this->showCreateLink( $title, $num, $titleMatches, $textMatches ); if ( $totalRes > $this->limit || $this->offset ) { - $prevnext = $this->getLanguage()->viewPrevNext( $this->getPageTitle(), $this->offset, $this->limit, + $prevnext = $this->getLanguage()->viewPrevNext( + $this->getPageTitle(), + $this->offset, + $this->limit, $this->powerSearchOptions() + array( 'search' => $term ), max( $titleMatchesNum, $textMatchesNum ) < $this->limit ); @@ -444,7 +452,11 @@ class SpecialSearch extends SpecialPage { } else { $messageName = 'searchmenu-new-nocreate'; } - $params = array( $messageName, wfEscapeWikiText( $title->getPrefixedText() ), Message::numParam( $num ) ); + $params = array( + $messageName, + wfEscapeWikiText( $title->getPrefixedText() ), + Message::numParam( $num ) + ); wfRunHooks( 'SpecialSearchCreateLink', array( $title, &$params ) ); // Extensions using the hook might still return an empty $messageName @@ -708,7 +720,8 @@ class SpecialSearch extends SpecialPage { &$score, &$size, &$date, &$related, &$html ) ) ) { - $html = "
  • {$link} {$redirect} {$section} {$fileMatch}
    {$extract}\n" . + $html = "
  • " . + "{$link} {$redirect} {$section} {$fileMatch}
    {$extract}\n" . "
    {$score}{$size} - {$date}{$related}
    " . "
  • \n"; } @@ -734,7 +747,8 @@ class SpecialSearch extends SpecialPage { // work out custom project captions $customCaptions = array(); - $customLines = explode( "\n", $this->msg( 'search-interwiki-custom' )->text() ); // format per line : + // format per line : + $customLines = explode( "\n", $this->msg( 'search-interwiki-custom' )->text() ); foreach ( $customLines as $line ) { $parts = explode( ":", $line, 2 ); if ( count( $parts ) == 2 ) { // validate line @@ -756,8 +770,7 @@ class SpecialSearch extends SpecialPage { } } - - // TODO: should support paging in a non-confusing way (not sure how though, maybe via ajax).. + // @todo Should support paging in a non-confusing way (not sure how though, maybe via ajax).. $out .= "\n"; // convert the whole thing to desired language variant -- 2.20.1