Pass phpcs-strict on includes/specials/ (3/3)
authorSiebrand Mazeland <siebrand@kitano.nl>
Fri, 9 May 2014 19:34:55 +0000 (21:34 +0200)
committerSiebrand <siebrand@kitano.nl>
Sat, 10 May 2014 14:17:39 +0000 (14:17 +0000)
Change-Id: I9502370c6b53f5a5c8cffc3d15516c560e709e64

includes/specials/SpecialNewimages.php
includes/specials/SpecialNewpages.php
includes/specials/SpecialProtectedpages.php
includes/specials/SpecialRevisiondelete.php
includes/specials/SpecialRunJobs.php
includes/specials/SpecialSearch.php

index 6891b16..147d176 100644 (file)
@@ -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' );
index 66ec693..505a1ec 100644 (file)
  * @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 "<li{$css}>{$time} {$dm}{$plink} {$hist} {$dm}{$length} {$dm}{$ulink} {$comment} {$tagDisplay} {$oldTitleText}</li>\n";
+               return "<li{$css}>{$time} {$dm}{$plink} {$hist} {$dm}{$length} "
+                       . "{$dm}{$ulink} {$comment} {$tagDisplay} {$oldTitleText}</li>\n";
        }
 
        /**
index 6edf2c0..7554e37 100644 (file)
@@ -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();
index 3cda8c6..797f588 100644 (file)
@@ -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' ) .
                                        '</td>' .
                                        '<td class="mw-input">' .
-                                               Xml::input( 'wpReason', 60, $this->otherReason, array( 'id' => 'wpReason', 'maxlength' => 100 ) ) .
+                                               Xml::input(
+                                                       'wpReason',
+                                                       60,
+                                                       $this->otherReason,
+                                                       array( 'id' => 'wpReason', 'maxlength' => 100 )
+                                               ) .
                                        '</td>' .
                                "</tr><tr>\n" .
                                        '<td></td>' .
@@ -454,10 +471,15 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
         */
        protected function addUsageText() {
                // Messages: revdelete-text-text, revdelete-text-file, logdelete-text
-               $this->getOutput()->wrapWikiMsg( "<strong>$1</strong>\n$2", $this->typeLabels['text'], 'revdelete-text-others' );
+               $this->getOutput()->wrapWikiMsg(
+                       "<strong>$1</strong>\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 = "<b>$innerHTML</b>";
                                }
+
                                $line = Xml::tags( 'td', array( 'class' => 'mw-input' ), $innerHTML );
                                $html .= "<tr>$line</tr>\n";
                        }
                } else {
                        // Otherwise, use tri-state radios
                        $html .= '<tr>';
-                       $html .= '<th class="mw-revdel-checkbox">' . $this->msg( 'revdelete-radio-same' )->escaped() . '</th>';
-                       $html .= '<th class="mw-revdel-checkbox">' . $this->msg( 'revdelete-radio-unset' )->escaped() . '</th>';
-                       $html .= '<th class="mw-revdel-checkbox">' . $this->msg( 'revdelete-radio-set' )->escaped() . '</th>';
+                       $html .= '<th class="mw-revdel-checkbox">'
+                               . $this->msg( 'revdelete-radio-same' )->escaped() . '</th>';
+                       $html .= '<th class="mw-revdel-checkbox">'
+                               . $this->msg( 'revdelete-radio-unset' )->escaped() . '</th>';
+                       $html .= '<th class="mw-revdel-checkbox">'
+                               . $this->msg( 'revdelete-radio-set' )->escaped() . '</th>';
                        $html .= "<th></th></tr>\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( "<span class=\"success\">\n$1\n</span>", $this->typeLabels['success'] );
+               $this->getOutput()->wrapWikiMsg(
+                       "<span class=\"success\">\n$1\n</span>",
+                       $this->typeLabels['success']
+               );
                $this->wasSaved = true;
                $this->revDelList->reloadFromMaster();
                $this->showForm();
index 10e7009..63eff36 100644 (file)
@@ -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 );
index c2b5f9b..2713a5f 100644 (file)
@@ -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 = '<div class="searchdidyoumean">' . $this->msg( 'search-suggest' )->rawParams( $suggestLink )->text() . '</div>';
+                       $this->didYouMeanHtml = '<div class="searchdidyoumean">'
+                               . $this->msg( 'search-suggest' )->rawParams( $suggestLink )->text() . '</div>';
                }
 
                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 = "<li><div class='mw-search-result-heading'>{$link} {$redirect} {$section} {$fileMatch}</div> {$extract}\n" .
+                       $html = "<li><div class='mw-search-result-heading'>" .
+                               "{$link} {$redirect} {$section} {$fileMatch}</div> {$extract}\n" .
                                "<div class='mw-search-result-data'>{$score}{$size} - {$date}{$related}</div>" .
                                "</li>\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 <iwprefix>:<caption>
+               // format per line <iwprefix>:<caption>
+               $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 .= "</ul></div>\n";
 
                // convert the whole thing to desired language variant