From c0c39640e47233231ad0a05c90f27255b8177a5c Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Sun, 11 May 2014 17:59:57 +0200 Subject: [PATCH] Make phpcs-strict pass on includes/ (5/~10) Change-Id: I259f3f11cfc22f3ed1693f9ebd5bd80491b8a6e8 --- includes/AutoLoader.php | 2 +- includes/Message.php | 2 +- includes/SiteStats.php | 23 +++- includes/SkinTemplate.php | 128 +++++++++++++-------- includes/Title.php | 2 +- includes/libs/JavaScriptMinifier.php | 1 + includes/libs/jsminplus.php | 1 + includes/libs/lessc.inc.php | 2 +- includes/specials/SpecialEditWatchlist.php | 6 +- includes/specials/SpecialWatchlist.php | 2 +- 10 files changed, 108 insertions(+), 61 deletions(-) diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index 0ee822588a..cb1a052cf4 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -135,7 +135,7 @@ $wgAutoloadLocalClasses = array( 'MagicWordArray' => 'includes/MagicWord.php', 'MailAddress' => 'includes/UserMailer.php', 'MediaWiki' => 'includes/Wiki.php', - 'MediaWiki_I18N' => 'includes/SkinTemplate.php', + 'MediaWikiI18N' => 'includes/SkinTemplate.php', 'MediaWikiVersionFetcher' => 'includes/MediaWikiVersionFetcher.php', 'Message' => 'includes/Message.php', 'MessageBlobStore' => 'includes/MessageBlobStore.php', diff --git a/includes/Message.php b/includes/Message.php index 179aca7863..8d4058e26b 100644 --- a/includes/Message.php +++ b/includes/Message.php @@ -963,7 +963,7 @@ class Message { $out = MessageCache::singleton()->parse( $string, $this->title, - /*linestart*/true, + /*linestart*/true, $this->interface, $this->language ); diff --git a/includes/SiteStats.php b/includes/SiteStats.php index 4685c3ed6b..4e737d136e 100644 --- a/includes/SiteStats.php +++ b/includes/SiteStats.php @@ -24,10 +24,20 @@ * Static accessor class for site_stats and related things */ class SiteStats { - static $row, $loaded = false; - static $jobs; - static $pageCount = array(); - static $groupMemberCounts = array(); + /** @var bool|ResultWrapper */ + private static $row; + + /** @var bool */ + private static $loaded = false; + + /** @var int */ + private static $jobs; + + /** @var int[] */ + private static $pageCount = array(); + + /** @var int[] */ + private static $groupMemberCounts = array(); static function recache() { self::load( true ); @@ -190,7 +200,10 @@ class SiteStats { if ( !isset( self::$jobs ) ) { $dbr = wfGetDB( DB_SLAVE ); self::$jobs = array_sum( JobQueueGroup::singleton()->getQueueSizes() ); - /* Zero rows still do single row read for row that doesn't exist, but people are annoyed by that */ + /** + * Zero rows still do single row read for row that doesn't exist, + * but people are annoyed by that + */ if ( self::$jobs == 1 ) { self::$jobs = 0; } diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index 24854d8212..e8fa9442cb 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -27,11 +27,11 @@ * @private * @ingroup Skins */ -class MediaWiki_I18N { - var $_context = array(); +class MediaWikiI18N { + private $context = array(); function set( $varName, $value ) { - $this->_context[$varName] = $value; + $this->context[$varName] = $value; } function translate( $value ) { @@ -46,7 +46,7 @@ class MediaWiki_I18N { while ( preg_match( '/\$([0-9]*?)/sm', $value, $m ) ) { list( $src, $var ) = $m; wfSuppressWarnings(); - $varValue = $this->_context[$var]; + $varValue = $this->context[$var]; wfRestoreWarnings(); $value = str_replace( $src, $varValue, $value ); } @@ -68,35 +68,29 @@ class MediaWiki_I18N { * @ingroup Skins */ class SkinTemplate extends Skin { - /**#@+ - * @private - */ - /** - * Name of our skin, it probably needs to be all lower case. Child classes - * should override the default. + * @var string Name of our skin, it probably needs to be all lower case. + * Child classes should override the default. */ - var $skinname = 'monobook'; + public $skinname = 'monobook'; /** - * Stylesheets set to use. Subdirectory in skins/ where various stylesheets - * are located. Child classes should override the default. + * @var string Stylesheets set to use. Subdirectory in skins/ where various + * stylesheets are located. Child classes should override the default. */ - var $stylename = 'monobook'; + public $stylename = 'monobook'; /** - * For QuickTemplate, the name of the subclass which will actually fill the - * template. Child classes should override the default. + * @var string For QuickTemplate, the name of the subclass which will + * actually fill the template. Child classes should override the default. */ - var $template = 'QuickTemplate'; + public $template = 'QuickTemplate'; /** - * Whether this skin use OutputPage::headElement() to generate the "" - * tag + * @var bool Whether this skin use OutputPage::headElement() to generate + * the "" tag. */ - var $useHeadElement = false; - - /**#@-*/ + public $useHeadElement = false; /** * Add specific styles for this skin @@ -187,7 +181,10 @@ class SkinTemplate extends Skin { 'lang' => $ilInterwikiCodeBCP47, 'hreflang' => $ilInterwikiCodeBCP47, ); - wfRunHooks( 'SkinTemplateGetLanguageLink', array( &$languageLink, $languageLinkTitle, $this->getTitle() ) ); + wfRunHooks( + 'SkinTemplateGetLanguageLink', + array( &$languageLink, $languageLinkTitle, $this->getTitle() ) + ); $languageLinks[] = $languageLink; } } @@ -402,7 +399,8 @@ class SkinTemplate extends Skin { // that interface elements are in a different language. $tpl->set( 'userlangattributes', '' ); $tpl->set( 'specialpageattributes', '' ); # obsolete - // Used by VectorBeta to insert HTML before content but after the heading for the page title. Defaults to empty string. + // Used by VectorBeta to insert HTML before content but after the + // heading for the page title. Defaults to empty string. $tpl->set( 'prebodyhtml', '' ); if ( $userLangCode !== $wgContLang->getHtmlCode() || $userLangDir !== $wgContLang->getDir() ) { @@ -561,9 +559,14 @@ class SkinTemplate extends Skin { // and output printfooter and debughtml separately $tpl->set( 'bodycontent', $tpl->data['bodytext'] ); - // Append printfooter and debughtml onto bodytext so that skins that were already - // using bodytext before they were split out don't suddenly start not outputting information - $tpl->data['bodytext'] .= Html::rawElement( 'div', array( 'class' => 'printfooter' ), "\n{$tpl->data['printfooter']}" ) . "\n"; + // Append printfooter and debughtml onto bodytext so that skins that + // were already using bodytext before they were split out don't suddenly + // start not outputting information. + $tpl->data['bodytext'] .= Html::rawElement( + 'div', + array( 'class' => 'printfooter' ), + "\n{$tpl->data['printfooter']}" + ) . "\n"; $tpl->data['bodytext'] .= $tpl->data['debughtml']; // allow extensions adding stuff after the page content. @@ -733,7 +736,8 @@ class SkinTemplate extends Skin { $login_url = array( 'text' => $this->msg( $loginlink )->text(), 'href' => self::makeSpecialUrl( 'Userlogin', $returnto ), - 'active' => $title->isSpecial( 'Userlogin' ) && ( $loginlink == 'nav-login-createaccount' || !$is_signup ), + 'active' => $title->isSpecial( 'Userlogin' ) + && ( $loginlink == 'nav-login-createaccount' || !$is_signup ), ); $createaccount_url = array( 'text' => $this->msg( 'pt-createaccount' )->text(), @@ -875,9 +879,10 @@ class SkinTemplate extends Skin { * links, however these are usually automatically generated by SkinTemplate * itself and are not necessary when using a hook. The only things these may * matter to are people modifying content_navigation after it's initial creation: - * - id: A "preferred" id, most skins are best off outputting this preferred id for best compatibility + * - id: A "preferred" id, most skins are best off outputting this preferred + * id for best compatibility. * - tooltiponly: This is set to true for some tabs in cases where the system - * believes that the accesskey should not be added to the tab. + * believes that the accesskey should not be added to the tab. * * @return array */ @@ -974,7 +979,9 @@ class SkinTemplate extends Skin { wfProfileIn( __METHOD__ . '-edit' ); // Checks if user can edit the current page if it exists or create it otherwise - if ( $title->quickUserCan( 'edit', $user ) && ( $title->exists() || $title->quickUserCan( 'create', $user ) ) ) { + if ( $title->quickUserCan( 'edit', $user ) + && ( $title->exists() || $title->quickUserCan( 'create', $user ) ) + ) { // Builds CSS class for talk page links $isTalkClass = $isTalk ? ' istalk' : ''; // Whether the user is editing the page @@ -985,14 +992,22 @@ class SkinTemplate extends Skin { && ( ( $isTalk && $this->isRevisionCurrent() ) || $out->showNewSectionLink() ); $section = $request->getVal( 'section' ); - if ( $title->exists() || ( $title->getNamespace() == NS_MEDIAWIKI && $title->getDefaultMessageText() !== false ) ) { + if ( $title->exists() + || ( $title->getNamespace() == NS_MEDIAWIKI + && $title->getDefaultMessageText() !== false + ) + ) { $msgKey = $isForeignFile ? 'edit-local' : 'edit'; } else { $msgKey = $isForeignFile ? 'create-local' : 'create'; } $content_navigation['views']['edit'] = array( - 'class' => ( $isEditing && ( $section !== 'new' || !$showNewSection ) ? 'selected' : '' ) . $isTalkClass, - 'text' => wfMessageFallback( "$skname-view-$msgKey", $msgKey )->setContext( $this->getContext() )->text(), + 'class' => ( $isEditing && ( $section !== 'new' || !$showNewSection ) + ? 'selected' + : '' + ) . $isTalkClass, + 'text' => wfMessageFallback( "$skname-view-$msgKey", $msgKey ) + ->setContext( $this->getContext() )->text(), 'href' => $title->getLocalURL( $this->editUrlOptions() ), 'primary' => !$isForeignFile, // don't collapse this in vector ); @@ -1003,7 +1018,8 @@ class SkinTemplate extends Skin { //$content_navigation['actions']['addsection'] $content_navigation['views']['addsection'] = array( 'class' => ( $isEditing && $section == 'new' ) ? 'selected' : false, - 'text' => wfMessageFallback( "$skname-action-addsection", 'addsection' )->setContext( $this->getContext() )->text(), + 'text' => wfMessageFallback( "$skname-action-addsection", 'addsection' ) + ->setContext( $this->getContext() )->text(), 'href' => $title->getLocalURL( 'action=edit§ion=new' ) ); } @@ -1012,7 +1028,8 @@ class SkinTemplate extends Skin { // Adds view source view link $content_navigation['views']['viewsource'] = array( 'class' => ( $onPage && $action == 'edit' ) ? 'selected' : false, - 'text' => wfMessageFallback( "$skname-action-viewsource", 'viewsource' )->setContext( $this->getContext() )->text(), + 'text' => wfMessageFallback( "$skname-action-viewsource", 'viewsource' ) + ->setContext( $this->getContext() )->text(), 'href' => $title->getLocalURL( $this->editUrlOptions() ), 'primary' => true, // don't collapse this in vector ); @@ -1025,7 +1042,8 @@ class SkinTemplate extends Skin { // Adds history view link $content_navigation['views']['history'] = array( 'class' => ( $onPage && $action == 'history' ) ? 'selected' : false, - 'text' => wfMessageFallback( "$skname-view-history", 'history_short' )->setContext( $this->getContext() )->text(), + 'text' => wfMessageFallback( "$skname-view-history", 'history_short' ) + ->setContext( $this->getContext() )->text(), 'href' => $title->getLocalURL( 'action=history' ), 'rel' => 'archives', ); @@ -1033,7 +1051,8 @@ class SkinTemplate extends Skin { if ( $title->quickUserCan( 'delete', $user ) ) { $content_navigation['actions']['delete'] = array( 'class' => ( $onPage && $action == 'delete' ) ? 'selected' : false, - 'text' => wfMessageFallback( "$skname-action-delete", 'delete' )->setContext( $this->getContext() )->text(), + 'text' => wfMessageFallback( "$skname-action-delete", 'delete' ) + ->setContext( $this->getContext() )->text(), 'href' => $title->getLocalURL( 'action=delete' ) ); } @@ -1042,7 +1061,8 @@ class SkinTemplate extends Skin { $moveTitle = SpecialPage::getTitleFor( 'Movepage', $title->getPrefixedDBkey() ); $content_navigation['actions']['move'] = array( 'class' => $this->getTitle()->isSpecial( 'Movepage' ) ? 'selected' : false, - 'text' => wfMessageFallback( "$skname-action-move", 'move' )->setContext( $this->getContext() )->text(), + 'text' => wfMessageFallback( "$skname-action-move", 'move' ) + ->setContext( $this->getContext() )->text(), 'href' => $moveTitle->getLocalURL() ); } @@ -1052,7 +1072,8 @@ class SkinTemplate extends Skin { $n = $title->isDeleted(); if ( $n ) { $undelTitle = SpecialPage::getTitleFor( 'Undelete' ); - // If the user can't undelete but can view deleted history show them a "View .. deleted" tab instead + // If the user can't undelete but can view deleted + // history show them a "View .. deleted" tab instead. $msgKey = $user->isAllowed( 'undelete' ) ? 'undelete' : 'viewdeleted'; $content_navigation['actions']['undelete'] = array( 'class' => $this->getTitle()->isSpecial( 'Undelete' ) ? 'selected' : false, @@ -1070,7 +1091,8 @@ class SkinTemplate extends Skin { $mode = $title->isProtected() ? 'unprotect' : 'protect'; $content_navigation['actions'][$mode] = array( 'class' => ( $onPage && $action == $mode ) ? 'selected' : false, - 'text' => wfMessageFallback( "$skname-action-$mode", $mode )->setContext( $this->getContext() )->text(), + 'text' => wfMessageFallback( "$skname-action-$mode", $mode ) + ->setContext( $this->getContext() )->text(), 'href' => $title->getLocalURL( "action=$mode" ) ); } @@ -1375,7 +1397,7 @@ abstract class QuickTemplate { */ function __construct() { $this->data = array(); - $this->translator = new MediaWiki_I18N(); + $this->translator = new MediaWikiI18N(); } /** @@ -1411,7 +1433,7 @@ abstract class QuickTemplate { } /** - * @param MediaWiki_I18N $t + * @param MediaWikiI18N $t */ public function setTranslator( &$t ) { $this->translator = &$t; @@ -1556,11 +1578,15 @@ abstract class BaseTemplate extends QuickTemplate { wfProfileIn( __METHOD__ ); $toolbox = array(); - if ( isset( $this->data['nav_urls']['whatlinkshere'] ) && $this->data['nav_urls']['whatlinkshere'] ) { + if ( isset( $this->data['nav_urls']['whatlinkshere'] ) + && $this->data['nav_urls']['whatlinkshere'] + ) { $toolbox['whatlinkshere'] = $this->data['nav_urls']['whatlinkshere']; $toolbox['whatlinkshere']['id'] = 't-whatlinkshere'; } - if ( isset( $this->data['nav_urls']['recentchangeslinked'] ) && $this->data['nav_urls']['recentchangeslinked'] ) { + if ( isset( $this->data['nav_urls']['recentchangeslinked'] ) + && $this->data['nav_urls']['recentchangeslinked'] + ) { $toolbox['recentchangeslinked'] = $this->data['nav_urls']['recentchangeslinked']; $toolbox['recentchangeslinked']['msg'] = 'recentchangeslinked-toolbox'; $toolbox['recentchangeslinked']['id'] = 't-recentchangeslinked'; @@ -1576,7 +1602,9 @@ abstract class BaseTemplate extends QuickTemplate { $toolbox['feeds']['links'][$key]['class'] = 'feedlink'; } } - foreach ( array( 'contributions', 'log', 'blockip', 'emailuser', 'userrights', 'upload', 'specialpages' ) as $special ) { + foreach ( array( 'contributions', 'log', 'blockip', 'emailuser', + 'userrights', 'upload', 'specialpages' ) as $special + ) { if ( isset( $this->data['nav_urls'][$special] ) && $this->data['nav_urls'][$special] ) { $toolbox[$special] = $this->data['nav_urls'][$special]; $toolbox[$special]['id'] = "t-$special"; @@ -1844,7 +1872,9 @@ abstract class BaseTemplate extends QuickTemplate { } while ( count( $wrapper ) > 0 ) { $element = array_pop( $wrapper ); - $html = Html::rawElement( $element['tag'], isset( $element['attributes'] ) ? $element['attributes'] : null, $html ); + $html = Html::rawElement( $element['tag'], isset( $element['attributes'] ) + ? $element['attributes'] + : null, $html ); } } @@ -1880,7 +1910,9 @@ abstract class BaseTemplate extends QuickTemplate { $attrs['class'] = $options['link-class']; } } - $html = Html::rawElement( isset( $attrs['href'] ) ? 'a' : $options['link-fallback'], $attrs, $html ); + $html = Html::rawElement( isset( $attrs['href'] ) + ? 'a' + : $options['link-fallback'], $attrs, $html ); } return $html; diff --git a/includes/Title.php b/includes/Title.php index 065a488b73..67958ff6bc 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -145,7 +145,7 @@ class Title { private $mNotificationTimestamp = array(); /** @var bool Whether a page has any subpages */ - var $mHasSubpages; + private $mHasSubpages; /** @var bool The (string) language code of the page's language and content code. */ private $mPageLanguage = false; diff --git a/includes/libs/JavaScriptMinifier.php b/includes/libs/JavaScriptMinifier.php index 998805ae9c..2990782ce1 100644 --- a/includes/libs/JavaScriptMinifier.php +++ b/includes/libs/JavaScriptMinifier.php @@ -1,4 +1,5 @@ getWatchlist(); $this->clearWatchlist(); $this->getUser()->invalidateCache(); - $this->successMessage = $this->msg( 'watchlistedit-clear-done' )->parse(); + $this->successMessage = $this->msg( 'watchlistedit-clear-done' )->parse(); $this->successMessage .= ' ' . $this->msg( 'watchlistedit-clear-removed' ) ->numParams( count( $current ) )->parse(); $this->showTitles( $current, $this->successMessage ); return true; -} + } /** * Print out a list of linked titles diff --git a/includes/specials/SpecialWatchlist.php b/includes/specials/SpecialWatchlist.php index bae5ab30b1..490e81f00b 100644 --- a/includes/specials/SpecialWatchlist.php +++ b/includes/specials/SpecialWatchlist.php @@ -51,7 +51,7 @@ class SpecialWatchlist extends ChangesListSpecialPage { if ( $mode === SpecialEditWatchlist::EDIT_RAW ) { $title = SpecialPage::getTitleFor( 'EditWatchlist', 'raw' ); } elseif ( $mode === SpecialEditWatchlist::EDIT_CLEAR ) { - $title = SpecialPage::getTitleFor( 'EditWatchlist', 'clear' ); + $title = SpecialPage::getTitleFor( 'EditWatchlist', 'clear' ); } else { $title = SpecialPage::getTitleFor( 'EditWatchlist' ); } -- 2.20.1