From 3f0a2a94c9d2046972ff8106f796e71f3abb1868 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Mon, 12 May 2014 16:42:51 +0200 Subject: [PATCH] Make phpcs-strict pass on includes/ (6/~10) Change-Id: I566183b5d660a55bb3b2aa7186aaed5355ead2c6 --- includes/Block.php | 42 +++++++++--- includes/Categoryfinder.php | 36 ++++++---- includes/Collation.php | 25 +++++-- includes/ImagePage.php | 130 ++++++++++++++++++++++++++---------- includes/MWTimestamp.php | 66 +++++++++++++----- includes/MagicWord.php | 83 +++++++++++++++++------ includes/MimeMagic.php | 49 ++++++++------ includes/ProtectionForm.php | 71 +++++++++++++------- includes/QueryPage.php | 30 ++++----- includes/RevisionList.php | 28 +++++--- includes/SkinTemplate.php | 2 +- 11 files changed, 386 insertions(+), 176 deletions(-) diff --git a/includes/Block.php b/includes/Block.php index d9fa54def0..b6976b0c2f 100644 --- a/includes/Block.php +++ b/includes/Block.php @@ -20,16 +20,37 @@ * @file */ class Block { - /* public*/ var $mReason, $mTimestamp, $mAuto, $mExpiry, $mHideName; + /** @var string */ + public $mReason; - protected - $mId, - $mFromMaster, + /** @var bool|string */ + public $mTimestamp; - $mBlockEmail, - $mDisableUsertalk, - $mCreateAccount, - $mParentBlockId; + /** @var int */ + public $mAuto; + + /** @var bool|string */ + public $mExpiry; + + public $mHideName; + + /** @var int */ + public $mParentBlockId; + + /** @var int */ + protected $mId; + + /** @var bool */ + protected $mFromMaster; + + /** @var bool */ + protected $mBlockEmail; + + /** @var bool */ + protected $mDisableUsertalk; + + /** @var bool */ + protected $mCreateAccount; /** @var User|string */ protected $target; @@ -57,9 +78,8 @@ class Block { const TYPE_ID = 5; /** - * Constructor - * @todo FIXME: Don't know what the best format to have for this constructor is, but fourteen - * optional parameters certainly isn't it. + * @todo FIXME: Don't know what the best format to have for this constructor + * is, but fourteen optional parameters certainly isn't it. */ function __construct( $address = '', $user = 0, $by = 0, $reason = '', $timestamp = 0, $auto = 0, $expiry = '', $anonOnly = 0, $createAccount = 0, $enableAutoblock = 0, diff --git a/includes/Categoryfinder.php b/includes/Categoryfinder.php index 720f6f8f30..b9cbc9a3f5 100644 --- a/includes/Categoryfinder.php +++ b/includes/Categoryfinder.php @@ -43,22 +43,30 @@ * */ class Categoryfinder { - var $articles = array(); # The original article IDs passed to the seed function - var $deadend = array(); # Array of DBKEY category names for categories that don't have a page - var $parents = array(); # Array of [ID => array()] - var $next = array(); # Array of article/category IDs - var $targets = array(); # Array of DBKEY category names - var $name2id = array(); - var $mode; # "AND" or "OR" + /** @var int[] The original article IDs passed to the seed function */ + protected $articles = array(); - /** - * @var DatabaseBase - */ - var $dbr; # Read-DB slave + /** @var array Array of DBKEY category names for categories that don't have a page */ + protected $deadend = array(); + + /** @var array Array of [ID => array()] */ + protected $parents = array(); + + /** @var array Array of article/category IDs */ + protected $next = array(); + + /** @var array Array of DBKEY category names */ + protected $targets = array(); + + /** @var array */ + protected $name2id = array(); + + /** @var "AND" or "OR" */ + protected $mode; + + /** @var DatabaseBase Read-DB slave */ + protected $dbr; - /** - * Constructor (currently empty). - */ function __construct() { } diff --git a/includes/Collation.php b/includes/Collation.php index 4c85e52ab7..4e0c6a47b7 100644 --- a/includes/Collation.php +++ b/includes/Collation.php @@ -21,7 +21,7 @@ */ abstract class Collation { - static $instance; + private static $instance; /** * @return Collation @@ -108,7 +108,8 @@ abstract class Collation { } class UppercaseCollation extends Collation { - var $lang; + private $lang; + function __construct() { // Get a language object so that we can use the generic UTF-8 uppercase // function there @@ -153,8 +154,20 @@ class IdentityCollation extends Collation { class IcuCollation extends Collation { const FIRST_LETTER_VERSION = 2; - var $primaryCollator, $mainCollator, $locale, $digitTransformLanguage; - var $firstLetterData; + /** @var Collator */ + private $primaryCollator; + + /** @var Collator */ + private $mainCollator; + + /** @var */ + private $locale; + + /** @var Language */ + protected $digitTransformLanguage; + + /** @var array */ + private $firstLetterData; /** * Unified CJK blocks. @@ -165,7 +178,7 @@ class IcuCollation extends Collation { * is pretty useless for sorting Chinese text anyway. Japanese and Korean * blocks are not included here, because they are smaller and more useful. */ - static $cjkBlocks = array( + private static $cjkBlocks = array( array( 0x2E80, 0x2EFF ), // CJK Radicals Supplement array( 0x2F00, 0x2FDF ), // Kangxi Radicals array( 0x2FF0, 0x2FFF ), // Ideographic Description Characters @@ -204,7 +217,7 @@ class IcuCollation extends Collation { * Empty arrays are intended; this signifies that the data for the language is * available and that there are, in fact, no additional letters to consider. */ - static $tailoringFirstLetters = array( + private static $tailoringFirstLetters = array( // Verified by native speakers 'be' => array( "Ё" ), 'be-tarask' => array( "Ё" ), diff --git a/includes/ImagePage.php b/includes/ImagePage.php index 8444223a50..a38b1956f6 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -26,18 +26,17 @@ * @ingroup Media */ class ImagePage extends Article { - - /** - * @var File - */ + /** @var File */ private $displayImg; - /** - * @var FileRepo - */ + + /** @var FileRepo */ private $repo; + + /** @var bool */ private $fileLoaded; - var $mExtraDescription = false; + /** @var bool */ + protected $mExtraDescription = false; /** * @param Title $title @@ -106,7 +105,10 @@ class ImagePage extends Article { $out = $this->getContext()->getOutput(); $request = $this->getContext()->getRequest(); $diff = $request->getVal( 'diff' ); - $diffOnly = $request->getBool( 'diffonly', $this->getContext()->getUser()->getOption( 'diffonly' ) ); + $diffOnly = $request->getBool( + 'diffonly', + $this->getContext()->getUser()->getOption( 'diffonly' ) + ); if ( $this->getTitle()->getNamespace() != NS_FILE || ( $diff !== null && $diffOnly ) ) { parent::view(); @@ -126,8 +128,11 @@ class ImagePage extends Article { // mTitle is not the same as the redirect target so it is // probably the redirect page itself. Fake the redirect symbol $out->setPageTitle( $this->getTitle()->getPrefixedText() ); - $out->addHTML( $this->viewRedirect( Title::makeTitle( NS_FILE, $this->mPage->getFile()->getName() ), - /* $appendSubtitle */ true, /* $forceKnown */ true ) ); + $out->addHTML( $this->viewRedirect( + Title::makeTitle( NS_FILE, $this->mPage->getFile()->getName() ), + /* $appendSubtitle */ true, + /* $forceKnown */ true ) + ); $this->mPage->doViewUpdates( $this->getContext()->getUser(), $this->getOldID() ); return; } @@ -338,18 +343,23 @@ class ImagePage extends Article { # image # "Download high res version" link below the image - # $msgsize = wfMessage( 'file-info-size', $width_orig, $height_orig, Linker::formatSize( $this->displayImg->getSize() ), $mime )->escaped(); + # $msgsize = wfMessage( 'file-info-size', $width_orig, $height_orig, + # Linker::formatSize( $this->displayImg->getSize() ), $mime )->escaped(); # We'll show a thumbnail of this image if ( $width > $maxWidth || $height > $maxHeight ) { # Calculate the thumbnail size. # First case, the limiting factor is the width, not the height. - if ( $width / $height >= $maxWidth / $maxHeight ) { // FIXME: Possible division by 0. bug 36911 - $height = round( $height * $maxWidth / $width ); // FIXME: Possible division by 0. bug 36911 + /** @todo // FIXME: Possible division by 0. bug 36911 */ + if ( $width / $height >= $maxWidth / $maxHeight ) { + /** @todo // FIXME: Possible division by 0. bug 36911 */ + $height = round( $height * $maxWidth / $width ); $width = $maxWidth; # Note that $height <= $maxHeight now. } else { - $newwidth = floor( $width * $maxHeight / $height ); // FIXME: Possible division by 0. bug 36911 - $height = round( $height * $newwidth / $width ); // FIXME: Possible division by 0. bug 36911 + /** @todo // FIXME: Possible division by 0. bug 36911 */ + $newwidth = floor( $width * $maxHeight / $height ); + /** @todo // FIXME: Possible division by 0. bug 36911 */ + $height = round( $height * $newwidth / $width ); $width = $newwidth; # Note that $height <= $maxHeight now, but might not be identical # because of rounding. @@ -424,7 +434,11 @@ class ImagePage extends Article { $thumbnail = $this->displayImg->transform( $params ); Linker::processResponsiveImages( $this->displayImg, $thumbnail, $params ); - $anchorclose = Html::rawElement( 'div', array( 'class' => 'mw-filepage-resolutioninfo' ), $msgsmall ); + $anchorclose = Html::rawElement( + 'div', + array( 'class' => 'mw-filepage-resolutioninfo' ), + $msgsmall + ); $isMulti = $this->displayImg->isMultipage() && $this->displayImg->pageCount() > 1; if ( $isMulti ) { @@ -453,8 +467,14 @@ class ImagePage extends Article { array(), array( 'page' => $page - 1 ) ); - $thumb1 = Linker::makeThumbLinkObj( $this->getTitle(), $this->displayImg, $link, $label, 'none', - array( 'page' => $page - 1 ) ); + $thumb1 = Linker::makeThumbLinkObj( + $this->getTitle(), + $this->displayImg, + $link, + $label, + 'none', + array( 'page' => $page - 1 ) + ); } else { $thumb1 = ''; } @@ -467,8 +487,14 @@ class ImagePage extends Article { array(), array( 'page' => $page + 1 ) ); - $thumb2 = Linker::makeThumbLinkObj( $this->getTitle(), $this->displayImg, $link, $label, 'none', - array( 'page' => $page + 1 ) ); + $thumb2 = Linker::makeThumbLinkObj( + $this->getTitle(), + $this->displayImg, + $link, + $label, + 'none', + array( 'page' => $page + 1 ) + ); } else { $thumb2 = ''; } @@ -519,11 +545,13 @@ class ImagePage extends Article { // The dirmark, however, must not be immediately adjacent // to the filename, because it can get copied with it. // See bug 25277. + // @codingStandardsIgnoreStart Ignore long line $out->addWikiText( <<{$medialink} $dirmark$longDesc
$warning
EOT - ); + ); + // @codingStandardsIgnoreEnd } else { $out->addWikiText( <<{$medialink} {$dirmark}$longDesc @@ -690,17 +718,29 @@ EOT # "Upload a new version of this file" link $canUpload = $this->getTitle()->userCan( 'upload', $this->getContext()->getUser() ); - if ( $canUpload && UploadBase::userCanReUpload( $this->getContext()->getUser(), $this->mPage->getFile()->name ) ) { - $ulink = Linker::makeExternalLink( $this->getUploadUrl(), wfMessage( 'uploadnewversion-linktext' )->text() ); - $out->addHTML( "
  • {$ulink}
  • \n" ); + if ( $canUpload && UploadBase::userCanReUpload( + $this->getContext()->getUser(), + $this->mPage->getFile()->name ) + ) { + $ulink = Linker::makeExternalLink( + $this->getUploadUrl(), + wfMessage( 'uploadnewversion-linktext' )->text() + ); + $out->addHTML( "
  • " + . "
    {$ulink}
  • \n" ); } else { - $out->addHTML( "
  • " . $this->getContext()->msg( 'upload-disallowed-here' )->escaped() . "
  • \n" ); + $out->addHTML( "
  • " + . $this->getContext()->msg( 'upload-disallowed-here' )->escaped() . "
  • \n" ); } $out->addHTML( "\n" ); } - protected function closeShowImage() { } # For overloading + /** + * For overloading + */ + protected function closeShowImage() { + } /** * If the page we've just displayed is in the "Image" namespace, @@ -1013,7 +1053,11 @@ EOT if ( !$haveDefaultLang ) { // Its hard to know if the content is really in the default language, or // if its just unmarked content that could be in any language. - $opts = Xml::option( wfMessage( 'img-lang-default' )->text(), $defaultLang, $defaultLang === $curLang ) . $opts; + $opts = Xml::option( + wfMessage( 'img-lang-default' )->text(), + $defaultLang, + $defaultLang === $curLang + ) . $opts; } if ( !$haveCurrentLang && $defaultLang !== $curLang ) { $name = Language::fetchLanguageName( $curLang, $this->getContext()->getLanguage()->getCode() ); @@ -1025,7 +1069,11 @@ EOT $opts = Xml::option( $display, $curLang, true ) . $opts; } - $select = Html::rawElement( 'select', array( 'id' => 'mw-imglangselector', 'name' => 'lang' ), $opts ); + $select = Html::rawElement( + 'select', + array( 'id' => 'mw-imglangselector', 'name' => 'lang' ), + $opts + ); $submit = Xml::submitButton( wfMessage( 'img-lang-go' )->text() ); $formContents = wfMessage( 'img-lang-info' )->rawParams( $select, $submit )->parse() @@ -1100,13 +1148,15 @@ class ImageHistoryList extends ContextSource { * @return string */ public function beginImageHistoryList( $navLinks = '' ) { - return Xml::element( 'h2', array( 'id' => 'filehistory' ), $this->msg( 'filehist' )->text() ) . "\n" + return Xml::element( 'h2', array( 'id' => 'filehistory' ), $this->msg( 'filehist' )->text() ) + . "\n" . "
    \n" . $this->msg( 'filehist-help' )->parseAsBlock() . $navLinks . "\n" . Xml::openElement( 'table', array( 'class' => 'wikitable filehistory' ) ) . "\n" . '' - . ( $this->current->isLocal() && ( $this->getUser()->isAllowedAny( 'delete', 'deletedhistory' ) ) ? '' : '' ) + . ( $this->current->isLocal() + && ( $this->getUser()->isAllowedAny( 'delete', 'deletedhistory' ) ) ? '' : '' ) . '' . $this->msg( 'filehist-datetime' )->escaped() . '' . ( $this->showThumb ? '' . $this->msg( 'filehist-thumb' )->escaped() . '' : '' ) . '' . $this->msg( 'filehist-dimensions' )->escaped() . '' @@ -1212,7 +1262,8 @@ class ImageHistoryList extends ContextSource { $row .= ""; if ( !$file->userCan( File::DELETED_FILE, $user ) ) { # Don't link to unviewable files - $row .= '' . $lang->userTimeAndDate( $timestamp, $user ) . ''; + $row .= '' + . $lang->userTimeAndDate( $timestamp, $user ) . ''; } elseif ( $file->isDeleted( File::DELETED_FILE ) ) { if ( $local ) { $this->preventClickjacking(); @@ -1234,7 +1285,11 @@ class ImageHistoryList extends ContextSource { $row .= '' . $url . ''; } else { $url = $iscur ? $this->current->getUrl() : $this->current->getArchiveUrl( $img ); - $row .= Xml::element( 'a', array( 'href' => $url ), $lang->userTimeAndDate( $timestamp, $user ) ); + $row .= Xml::element( + 'a', + array( 'href' => $url ), + $lang->userTimeAndDate( $timestamp, $user ) + ); } $row .= ""; @@ -1256,7 +1311,8 @@ class ImageHistoryList extends ContextSource { $row .= ''; // Hide deleted usernames if ( $file->isDeleted( File::DELETED_USER ) ) { - $row .= '' . $this->msg( 'rev-deleted-user' )->escaped() . ''; + $row .= '' + . $this->msg( 'rev-deleted-user' )->escaped() . ''; } else { if ( $local ) { $row .= Linker::userLink( $userId, $userText ); @@ -1272,9 +1328,11 @@ class ImageHistoryList extends ContextSource { // Don't show deleted descriptions if ( $file->isDeleted( File::DELETED_COMMENT ) ) { - $row .= '' . $this->msg( 'rev-deleted-comment' )->escaped() . ''; + $row .= '' . + $this->msg( 'rev-deleted-comment' )->escaped() . ''; } else { - $row .= '' . Linker::formatComment( $description, $this->title ) . ''; + $row .= '' . + Linker::formatComment( $description, $this->title ) . ''; } $rowClass = null; diff --git a/includes/MWTimestamp.php b/includes/MWTimestamp.php index c7451643a2..447dde3cb9 100644 --- a/includes/MWTimestamp.php +++ b/includes/MWTimestamp.php @@ -77,7 +77,8 @@ class MWTimestamp { $da = array(); $strtime = ''; - if ( !$ts || $ts === "\0\0\0\0\0\0\0\0\0\0\0\0\0\0" ) { // We want to catch 0, '', null... but not date strings starting with a letter. + // We want to catch 0, '', null... but not date strings starting with a letter. + if ( !$ts || $ts === "\0\0\0\0\0\0\0\0\0\0\0\0\0\0" ) { $uts = time(); $strtime = "@$uts"; } elseif ( preg_match( '/^(\d{4})\-(\d\d)\-(\d\d) (\d\d):(\d\d):(\d\d)$/D', $ts, $da ) ) { @@ -93,18 +94,41 @@ class MWTimestamp { # TS_ORACLE // session altered to DD-MM-YYYY HH24:MI:SS.FF6 $strtime = preg_replace( '/(\d\d)\.(\d\d)\.(\d\d)(\.(\d+))?/', "$1:$2:$3", str_replace( '+00:00', 'UTC', $ts ) ); - } elseif ( preg_match( '/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.*\d*)?Z?$/', $ts, $da ) ) { + } elseif ( preg_match( + '/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.*\d*)?Z?$/', + $ts, + $da + ) ) { # TS_ISO_8601 - } elseif ( preg_match( '/^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})(?:\.*\d*)?Z?$/', $ts, $da ) ) { + } elseif ( preg_match( + '/^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})(?:\.*\d*)?Z?$/', + $ts, + $da + ) ) { #TS_ISO_8601_BASIC - } elseif ( preg_match( '/^(\d{4})\-(\d\d)\-(\d\d) (\d\d):(\d\d):(\d\d)\.*\d*[\+\- ](\d\d)$/', $ts, $da ) ) { + } elseif ( preg_match( + '/^(\d{4})\-(\d\d)\-(\d\d) (\d\d):(\d\d):(\d\d)\.*\d*[\+\- ](\d\d)$/', + $ts, + $da + ) ) { # TS_POSTGRES - } elseif ( preg_match( '/^(\d{4})\-(\d\d)\-(\d\d) (\d\d):(\d\d):(\d\d)\.*\d* GMT$/', $ts, $da ) ) { + } elseif ( preg_match( + '/^(\d{4})\-(\d\d)\-(\d\d) (\d\d):(\d\d):(\d\d)\.*\d* GMT$/', + $ts, + $da + ) ) { # TS_POSTGRES - } elseif ( preg_match( '/^[ \t\r\n]*([A-Z][a-z]{2},[ \t\r\n]*)?' . # Day of week - '\d\d?[ \t\r\n]*[A-Z][a-z]{2}[ \t\r\n]*\d{2}(?:\d{2})?' . # dd Mon yyyy - '[ \t\r\n]*\d\d[ \t\r\n]*:[ \t\r\n]*\d\d[ \t\r\n]*:[ \t\r\n]*\d\d/S', $ts ) ) { # hh:mm:ss - # TS_RFC2822, accepting a trailing comment. See http://www.squid-cache.org/mail-archive/squid-users/200307/0122.html / r77171 + } elseif ( preg_match( + # Day of week + '/^[ \t\r\n]*([A-Z][a-z]{2},[ \t\r\n]*)?' . + # dd Mon yyyy + '\d\d?[ \t\r\n]*[A-Z][a-z]{2}[ \t\r\n]*\d{2}(?:\d{2})?' . + # hh:mm:ss + '[ \t\r\n]*\d\d[ \t\r\n]*:[ \t\r\n]*\d\d[ \t\r\n]*:[ \t\r\n]*\d\d/S', + $ts + ) ) { + # TS_RFC2822, accepting a trailing comment. + # See http://www.squid-cache.org/mail-archive/squid-users/200307/0122.html / r77171 # The regex is a superset of rfc2822 for readability $strtime = strtok( $ts, ';' ); } elseif ( preg_match( '/^[A-Z][a-z]{5,8}, \d\d-[A-Z][a-z]{2}-\d{2} \d\d:\d\d:\d\d/', $ts ) ) { @@ -171,12 +195,17 @@ class MWTimestamp { * @since 1.20 * @since 1.22 Uses Language::getHumanTimestamp to produce the timestamp * - * @param MWTimestamp|null $relativeTo The base timestamp to compare to (defaults to now) - * @param User|null $user User the timestamp is being generated for (or null to use main context's user) - * @param Language|null $lang Language to use to make the human timestamp (or null to use main context's language) + * @param MWTimestamp|null $relativeTo The base timestamp to compare to + * (defaults to now). + * @param User|null $user User the timestamp is being generated for (or null + * to use main context's user). + * @param Language|null $lang Language to use to make the human timestamp + * (or null to use main context's language). * @return string Formatted timestamp */ - public function getHumanTimestamp( MWTimestamp $relativeTo = null, User $user = null, Language $lang = null ) { + public function getHumanTimestamp( MWTimestamp $relativeTo = null, + User $user = null, Language $lang = null + ) { if ( $relativeTo === null ) { $relativeTo = new self(); } @@ -298,11 +327,13 @@ class MWTimestamp { $ts = ''; $diff = $this->diff( $relativeTo ); - if ( wfRunHooks( 'GetRelativeTimestamp', array( &$ts, &$diff, $this, $relativeTo, $user, $lang ) ) ) { + if ( wfRunHooks( + 'GetRelativeTimestamp', + array( &$ts, &$diff, $this, $relativeTo, $user, $lang ) + ) ) { $seconds = ( ( ( $diff->days * 24 + $diff->h ) * 60 + $diff->i ) * 60 + $diff->s ); $ts = wfMessage( 'ago', $lang->formatDuration( $seconds, $chosenIntervals ) ) - ->inLanguage( $lang ) - ->text(); + ->inLanguage( $lang )->text(); } return $ts; @@ -322,7 +353,8 @@ class MWTimestamp { * * @since 1.22 * @param MWTimestamp $relativeTo Base time to calculate difference from - * @return DateInterval|bool The DateInterval object representing the difference between the two dates or false on failure + * @return DateInterval|bool The DateInterval object representing the + * difference between the two dates or false on failure */ public function diff( MWTimestamp $relativeTo ) { return $this->timestamp->diff( $relativeTo->timestamp ); diff --git a/includes/MagicWord.php b/includes/MagicWord.php index 47816675fa..cd75f0bd99 100644 --- a/includes/MagicWord.php +++ b/includes/MagicWord.php @@ -59,18 +59,40 @@ * @ingroup Parser */ class MagicWord { - /**#@+ - * @private - */ - var $mId, $mSynonyms, $mCaseSensitive; - var $mRegex = ''; - var $mRegexStart = ''; - var $mRegexStartToEnd = ''; - var $mBaseRegex = ''; - var $mVariableRegex = ''; - var $mVariableStartToEndRegex = ''; - var $mModified = false; - var $mFound = false; + /**#@-*/ + + /** @var int */ + public $mId; + + /** @var array */ + public $mSynonyms; + + /** @var bool */ + public $mCaseSensitive; + + /** @var string */ + private $mRegex = ''; + + /** @var string */ + private $mRegexStart = ''; + + /** @var string */ + private $mRegexStartToEnd = ''; + + /** @var string */ + private $mBaseRegex = ''; + + /** @var string */ + private $mVariableRegex = ''; + + /** @var string */ + private $mVariableStartToEndRegex = ''; + + /** @var bool */ + private $mModified = false; + + /** @var bool */ + private $mFound = false; static public $mVariableIDsInitialised = false; static public $mVariableIDs = array( @@ -507,7 +529,12 @@ class MagicWord { */ function matchAndRemove( &$text ) { $this->mFound = false; - $text = preg_replace_callback( $this->getRegex(), array( &$this, 'pregRemoveAndRecord' ), $text ); + $text = preg_replace_callback( + $this->getRegex(), + array( &$this, 'pregRemoveAndRecord' ), + $text + ); + return $this->mFound; } @@ -517,7 +544,12 @@ class MagicWord { */ function matchStartAndRemove( &$text ) { $this->mFound = false; - $text = preg_replace_callback( $this->getRegexStart(), array( &$this, 'pregRemoveAndRecord' ), $text ); + $text = preg_replace_callback( + $this->getRegexStart(), + array( &$this, 'pregRemoveAndRecord' ), + $text + ); + return $this->mFound; } @@ -541,7 +573,12 @@ class MagicWord { * @return string */ function replace( $replacement, $subject, $limit = -1 ) { - $res = preg_replace( $this->getRegex(), StringUtils::escapeRegexReplacement( $replacement ), $subject, $limit ); + $res = preg_replace( + $this->getRegex(), + StringUtils::escapeRegexReplacement( $replacement ), + $subject, + $limit + ); $this->mModified = $res !== $subject; return $res; } @@ -674,10 +711,18 @@ class MagicWord { * @ingroup Parser */ class MagicWordArray { - var $names = array(); - var $hash; - var $baseRegex, $regex; - var $matches; + /** @var array */ + public $names = array(); + + /** @var array */ + private $hash; + + private $baseRegex; + + private $regex; + + /** @todo Unused? */ + private $matches; /** * @param array $names diff --git a/includes/MimeMagic.php b/includes/MimeMagic.php index 3448c6aa5c..582ba60be2 100644 --- a/includes/MimeMagic.php +++ b/includes/MimeMagic.php @@ -142,30 +142,29 @@ END_STRING * of MimeMagic. Please use MimeMagic::singleton() to get that instance. */ class MimeMagic { - /** - * Mapping of media types to arrays of mime types. + * @var array Mapping of media types to arrays of mime types. * This is used by findMediaType and getMediaType, respectively */ - var $mMediaTypes = null; + protected $mMediaTypes = null; - /** Map of mime type aliases + /** @var array Map of mime type aliases */ - var $mMimeTypeAliases = null; + protected $mMimeTypeAliases = null; - /** map of mime types to file extensions (as a space separated list) + /** @var array Map of mime types to file extensions (as a space separated list) */ - var $mMimeToExt = null; + protected $mMimeToExt = null; - /** map of file extensions types to mime types (as a space separated list) + /** @var array Map of file extensions types to mime types (as a space separated list) */ - var $mExtToMime = null; + public $mExtToMime = null; - /** IEContentAnalyzer instance + /** @var IEContentAnalyzer */ - var $mIEAnalyzer; + protected $mIEAnalyzer; - /** The singleton instance + /** @var MimeMagic The singleton instance */ private static $instance = null; @@ -323,13 +322,13 @@ class MimeMagic { if ( count( $m ) > 1 ) { $main = $m[0]; - for ( $i = 1; $i < count( $m ); $i += 1 ) { + $mCount = count( $m ); + for ( $i = 1; $i < $mCount; $i += 1 ) { $mime = $m[$i]; $this->mMimeTypeAliases[$mime] = $main; } } } - } /** @@ -861,8 +860,10 @@ class MimeMagic { private function detectMimeType( $file, $ext = true ) { global $wgMimeDetectorCommand; - if ( $ext ) { # TODO: make $ext default to false. Or better, remove it. - wfDebug( __METHOD__ . ": WARNING: use of the \$ext parameter is deprecated. Use improveTypeFromExtension(\$mime, \$ext) instead.\n" ); + /** @todo Make $ext default to false. Or better, remove it. */ + if ( $ext ) { + wfDebug( __METHOD__ . ": WARNING: use of the \$ext parameter is deprecated. " + . "Use improveTypeFromExtension(\$mime, \$ext) instead.\n" ); } $m = null; @@ -892,13 +893,16 @@ class MimeMagic { } elseif ( function_exists( "mime_content_type" ) ) { # NOTE: this function is available since PHP 4.3.0, but only if - # PHP was compiled with --with-mime-magic or, before 4.3.2, with --enable-mime-magic. + # PHP was compiled with --with-mime-magic or, before 4.3.2, with + # --enable-mime-magic. # - # On Windows, you must set mime_magic.magicfile in php.ini to point to the mime.magic file bundled with PHP; - # sometimes, this may even be needed under linus/unix. + # On Windows, you must set mime_magic.magicfile in php.ini to point + # to the mime.magic file bundled with PHP; sometimes, this may even + # be needed under *nix. # - # Also note that this has been DEPRECATED in favor of the fileinfo extension by PECL, see above. - # see http://www.php.net/manual/en/ref.mime-magic.php for details. + # Also note that this has been DEPRECATED in favor of the fileinfo + # extension by PECL, see above. + # See http://www.php.net/manual/en/ref.mime-magic.php for details. $m = mime_content_type( $file ); } else { @@ -926,7 +930,8 @@ class MimeMagic { } if ( $ext ) { if ( $this->isRecognizableExtension( $ext ) ) { - wfDebug( __METHOD__ . ": refusing to guess mime type for .$ext file, we should have recognized it\n" ); + wfDebug( __METHOD__ . ": refusing to guess mime type for .$ext file, " + . "we should have recognized it\n" ); } else { $m = $this->guessTypesForExtension( $ext ); if ( $m ) { diff --git a/includes/ProtectionForm.php b/includes/ProtectionForm.php index ea359aa71f..d34ee034fb 100644 --- a/includes/ProtectionForm.php +++ b/includes/ProtectionForm.php @@ -27,35 +27,35 @@ * Handles the page protection UI and backend */ class ProtectionForm { - /** A map of action to restriction level, from request or default */ - var $mRestrictions = array(); + /** @var array A map of action to restriction level, from request or default */ + protected $mRestrictions = array(); - /** The custom/additional protection reason */ - var $mReason = ''; + /** @var string The custom/additional protection reason */ + protected $mReason = ''; - /** The reason selected from the list, blank for other/additional */ - var $mReasonSelection = ''; + /** @var string The reason selected from the list, blank for other/additional */ + protected $mReasonSelection = ''; - /** True if the restrictions are cascading, from request or existing protection */ - var $mCascade = false; + /** @var bool True if the restrictions are cascading, from request or existing protection */ + protected $mCascade = false; - /** Map of action to "other" expiry time. Used in preference to mExpirySelection. */ - var $mExpiry = array(); + /** @var array Map of action to "other" expiry time. Used in preference to mExpirySelection. */ + protected $mExpiry = array(); /** - * Map of action to value selected in expiry drop-down list. + * @var array Map of action to value selected in expiry drop-down list. * Will be set to 'othertime' whenever mExpiry is set. */ - var $mExpirySelection = array(); + protected $mExpirySelection = array(); - /** Permissions errors for the protect action */ - var $mPermErrors = array(); + /** @var array Permissions errors for the protect action */ + protected $mPermErrors = array(); - /** Types (i.e. actions) for which levels can be selected */ - var $mApplicableTypes = array(); + /** @var array Types (i.e. actions) for which levels can be selected */ + protected $mApplicableTypes = array(); - /** Map of action to the expiry time of the existing protection */ - var $mExistingExpiry = array(); + /** @var array Map of action to the expiry time of the existing protection */ + protected $mExistingExpiry = array(); function __construct( Page $article ) { global $wgUser; @@ -209,7 +209,10 @@ class ProtectionForm { if ( $this->mTitle->getRestrictionTypes() === array() ) { // No restriction types available for the current title // this might happen if an extension alters the available types - $wgOut->setPageTitle( wfMessage( 'protect-norestrictiontypes-title', $this->mTitle->getPrefixedText() ) ); + $wgOut->setPageTitle( wfMessage( + 'protect-norestrictiontypes-title', + $this->mTitle->getPrefixedText() + ) ); $wgOut->addWikiText( wfMessage( 'protect-norestrictiontypes-text' )->text() ); // Show the log in case protection was possible once @@ -226,13 +229,20 @@ class ProtectionForm { $titles .= '* [[:' . $title->getPrefixedText() . "]]\n"; } - $wgOut->wrapWikiMsg( "
    \n$1\n" . $titles . "
    ", array( 'protect-cascadeon', count( $cascadeSources ) ) ); + /** @todo FIXME: i18n issue, should use formatted number. */ + $wgOut->wrapWikiMsg( + "
    \n$1\n" . $titles . "
    ", + array( 'protect-cascadeon', count( $cascadeSources ) ) + ); } # Show an appropriate message if the user isn't allowed or able to change # the protection settings at this time if ( $this->disabled ) { - $wgOut->setPageTitle( wfMessage( 'protect-title-notallowed', $this->mTitle->getPrefixedText() ) ); + $wgOut->setPageTitle( + wfMessage( 'protect-title-notallowed', + $this->mTitle->getPrefixedText() ) + ); $wgOut->addWikiText( $wgOut->formatPermissionsErrorMessage( $this->mPermErrors, 'protect' ) ); } else { $wgOut->setPageTitle( wfMessage( 'protect-title', $this->mTitle->getPrefixedText() ) ); @@ -290,7 +300,13 @@ class ProtectionForm { $this->mCascade = $wgRequest->getBool( 'mwProtect-cascade' ); - $status = $this->mArticle->doUpdateRestrictions( $this->mRestrictions, $expiry, $this->mCascade, $reasonstr, $wgUser ); + $status = $this->mArticle->doUpdateRestrictions( + $this->mRestrictions, + $expiry, + $this->mCascade, + $reasonstr, + $wgUser + ); if ( !$status->isOK() ) { $this->show( $wgOut->parseInline( $status->getWikiText() ) ); @@ -403,7 +419,11 @@ class ProtectionForm { } $show = htmlspecialchars( $show ); $value = htmlspecialchars( $value ); - $expiryFormOptions .= Xml::option( $show, $value, $this->mExpirySelection[$action] === $value ) . "\n"; + $expiryFormOptions .= Xml::option( + $show, + $value, + $this->mExpirySelection[$action] === $value + ) . "\n"; } # Add expiry dropdown if ( $showProtectOptions && !$this->disabled ) { @@ -526,7 +546,10 @@ class ProtectionForm { } if ( !$this->disabled ) { - $out .= Html::hidden( 'wpEditToken', $wgUser->getEditToken( array( 'protect', $this->mTitle->getPrefixedDBkey() ) ) ); + $out .= Html::hidden( + 'wpEditToken', + $wgUser->getEditToken( array( 'protect', $this->mTitle->getPrefixedDBkey() ) ) + ); $out .= Xml::closeElement( 'form' ); $wgOut->addScript( $this->buildCleanupScript() ); } diff --git a/includes/QueryPage.php b/includes/QueryPage.php index cf0a644671..82dea0d96f 100644 --- a/includes/QueryPage.php +++ b/includes/QueryPage.php @@ -28,20 +28,14 @@ * @ingroup SpecialPage */ abstract class QueryPage extends SpecialPage { - /** - * Whether or not we want plain listoutput rather than an ordered list - * - * @var bool - */ - var $listoutput = false; + /** @var bool Whether or not we want plain listoutput rather than an ordered list */ + protected $listoutput = false; - /** - * The offset and limit in use, as passed to the query() function - * - * @var int - */ - var $offset = 0; - var $limit = 0; + /** @var int The offset and limit in use, as passed to the query() function */ + protected $offset = 0; + + /** @var int */ + protected $limit = 0; /** * The number of rows returned by the query. Reading this variable @@ -503,7 +497,7 @@ abstract class QueryPage extends SpecialPage { list( $this->limit, $this->offset ) = $this->getRequest()->getLimitOffset(); } - // TODO: Use doQuery() + // @todo Use doQuery() if ( !$this->isCached() ) { # select one extra row for navigation $res = $this->reallyDoQuery( $this->limit + 1, $this->offset ); @@ -595,7 +589,7 @@ abstract class QueryPage extends SpecialPage { * @param OutputPage $out OutputPage to print to * @param Skin $skin User skin to use * @param DatabaseBase $dbr Database (read) connection to use - * @param int $res Result pointer + * @param ResultWrapper $res Result pointer * @param int $num Number of available result rows * @param int $offset Paging offset */ @@ -610,7 +604,9 @@ abstract class QueryPage extends SpecialPage { # $res might contain the whole 1,000 rows, so we read up to # $num [should update this to use a Pager] + // @codingStandardsIgnoreStart Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed for ( $i = 0; $i < $num && $row = $res->fetchObject(); $i++ ) { + // @codingStandardsIgnoreEnd $line = $this->formatResult( $skin, $row ); if ( $line ) { $attr = ( isset( $row->usepatrol ) && $row->usepatrol && $row->patrolled == 0 ) @@ -668,7 +664,8 @@ abstract class QueryPage extends SpecialPage { * @param DatabaseBase $db * @param ResultWrapper $res */ - function preprocessResults( $db, $res ) {} + function preprocessResults( $db, $res ) { + } /** * Similar to above, but packaging in a syndicated feed instead of a web page @@ -687,6 +684,7 @@ abstract class QueryPage extends SpecialPage { $limit = min( $limit, $wgFeedLimit ); if ( isset( $wgFeedClasses[$class] ) ) { + /** @var RSSFeed|AtomFeed $feed */ $feed = new $wgFeedClasses[$class]( $this->feedTitle(), $this->feedDesc(), diff --git a/includes/RevisionList.php b/includes/RevisionList.php index 7c39617f82..d10b5412cb 100644 --- a/includes/RevisionList.php +++ b/includes/RevisionList.php @@ -24,12 +24,16 @@ * List for revision table items for a single page */ abstract class RevisionListBase extends ContextSource { - /** - * @var Title - */ - var $title; + /** @var Title */ + public $title; + + /** @var array */ + protected $ids; - var $ids, $res, $current; + protected $res; + + /** @var bool|object */ + protected $current; /** * Construct a revision list for a given title @@ -131,11 +135,11 @@ abstract class RevisionListBase extends ContextSource { * Abstract base class for revision items */ abstract class RevisionItemBase { - /** The parent RevisionListBase */ - var $list; + /** @var RevisionListBase The parent */ + protected $list; - /** The DB result row */ - var $row; + /** The database result row */ + protected $row; /** * @param RevisionListBase $list @@ -288,7 +292,11 @@ class RevisionList extends RevisionListBase { * Item class for a live revision table row */ class RevisionItem extends RevisionItemBase { - var $revision, $context; + /** @var Revision */ + protected $revision; + + /** @var RequestContext */ + protected $context; public function __construct( $list, $row ) { parent::__construct( $list, $row ); diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index d97d9d4f67..08816add7f 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -1255,7 +1255,7 @@ class SkinTemplate extends Skin { return $content_actions; } - /** + /** * build array of common navigation links * @return array */ -- 2.20.1