diff options
author | Kunal Mehta <legoktm@member.fsf.org> | 2017-07-22 18:24:09 -0700 |
---|---|---|
committer | Kunal Mehta <legoktm@member.fsf.org> | 2017-07-22 18:24:09 -0700 |
commit | d1cf48a397edbbe9c6a63d6f83861d676f686d07 (patch) | |
tree | 5786bc42e1a7b5eb336040286b965ef262244195 | |
parent | de5e6e666945a8708bb3df48ac309e6d0d691e74 (diff) | |
download | mediawikicore-d1cf48a397edbbe9c6a63d6f83861d676f686d07.tar.gz mediawikicore-d1cf48a397edbbe9c6a63d6f83861d676f686d07.zip |
build: Update mediawiki/mediawiki-codesniffer to 0.10.1
And auto-fix all errors.
The `<exclude-pattern>` stanzas are now included in the default ruleset
and don't need to be repeated.
Change-Id: I928af549dc88ac2c6cb82058f64c7c7f3111598a
62 files changed, 493 insertions, 497 deletions
diff --git a/composer.json b/composer.json index 83fcda0cd5ce..d04e9f5c5285 100644 --- a/composer.json +++ b/composer.json @@ -53,7 +53,7 @@ "jakub-onderka/php-parallel-lint": "0.9.2", "jetbrains/phpstorm-stubs": "dev-master#1b9906084d6635456fcf3f3a01f0d7d5b99a578a", "justinrainbow/json-schema": "~5.2", - "mediawiki/mediawiki-codesniffer": "0.8.1", + "mediawiki/mediawiki-codesniffer": "0.10.1", "monolog/monolog": "~1.22.1", "nikic/php-parser": "2.1.0", "nmred/kafka-php": "0.1.5", diff --git a/includes/Block.php b/includes/Block.php index 2c935df8ec5d..2a04879848cf 100644 --- a/includes/Block.php +++ b/includes/Block.php @@ -485,7 +485,7 @@ class Block { # Periodic purge via commit hooks if ( mt_rand( 0, 9 ) == 0 ) { - Block::purgeExpired(); + self::purgeExpired(); } $row = $this->getDatabaseArray(); @@ -778,12 +778,12 @@ class Block { # It's okay to autoblock. Go ahead and insert/update the block... # Do not add a *new* block if the IP is already blocked. - $ipblock = Block::newFromTarget( $autoblockIP ); + $ipblock = self::newFromTarget( $autoblockIP ); if ( $ipblock ) { # Check if the block is an autoblock and would exceed the user block # if renewed. If so, do nothing, otherwise prolong the block time... if ( $ipblock->mAuto && // @todo Why not compare $ipblock->mExpiry? - $this->mExpiry > Block::getAutoblockExpiry( $ipblock->mTimestamp ) + $this->mExpiry > self::getAutoblockExpiry( $ipblock->mTimestamp ) ) { # Reset block timestamp to now and its expiry to # $wgAutoblockExpiry in the future @@ -810,11 +810,11 @@ class Block { if ( $this->mExpiry == 'infinity' ) { # Original block was indefinite, start an autoblock now - $autoblock->mExpiry = Block::getAutoblockExpiry( $timestamp ); + $autoblock->mExpiry = self::getAutoblockExpiry( $timestamp ); } else { # If the user is already blocked with an expiry date, we don't # want to pile on top of that. - $autoblock->mExpiry = min( $this->mExpiry, Block::getAutoblockExpiry( $timestamp ) ); + $autoblock->mExpiry = min( $this->mExpiry, self::getAutoblockExpiry( $timestamp ) ); } # Insert the block... @@ -870,7 +870,7 @@ class Block { public function updateTimestamp() { if ( $this->mAuto ) { $this->mTimestamp = wfTimestamp(); - $this->mExpiry = Block::getAutoblockExpiry( $this->mTimestamp ); + $this->mExpiry = self::getAutoblockExpiry( $this->mTimestamp ); $dbw = wfGetDB( DB_MASTER ); $dbw->update( 'ipblocks', @@ -1111,8 +1111,8 @@ class Block { */ public static function newFromTarget( $specificTarget, $vagueTarget = null, $fromMaster = false ) { list( $target, $type ) = self::parseTarget( $specificTarget ); - if ( $type == Block::TYPE_ID || $type == Block::TYPE_AUTO ) { - return Block::newFromID( $target ); + if ( $type == self::TYPE_ID || $type == self::TYPE_AUTO ) { + return self::newFromID( $target ); } elseif ( $target === null && $vagueTarget == '' ) { # We're not going to find anything useful here @@ -1122,7 +1122,7 @@ class Block { } elseif ( in_array( $type, - [ Block::TYPE_USER, Block::TYPE_IP, Block::TYPE_RANGE, null ] ) + [ self::TYPE_USER, self::TYPE_IP, self::TYPE_RANGE, null ] ) ) { $block = new Block(); $block->fromMaster( $fromMaster ); @@ -1189,7 +1189,7 @@ class Block { } $selectFields = array_merge( [ 'ipb_range_start', 'ipb_range_end' ], - Block::selectFields() + self::selectFields() ); $rows = $db->select( 'ipblocks', $selectFields, @@ -1350,12 +1350,12 @@ class Block { # off validation checking (which would exclude IP addresses) return [ User::newFromName( IP::sanitizeIP( $target ), false ), - Block::TYPE_IP + self::TYPE_IP ]; } elseif ( IP::isValidBlock( $target ) ) { # Can't create a User from an IP range - return [ IP::sanitizeRange( $target ), Block::TYPE_RANGE ]; + return [ IP::sanitizeRange( $target ), self::TYPE_RANGE ]; } # Consider the possibility that this is not a username at all @@ -1370,11 +1370,11 @@ class Block { # Note that since numbers are valid usernames, a $target of "12345" will be # considered a User. If you want to pass a block ID, prepend a hash "#12345", # since hash characters are not valid in usernames or titles generally. - return [ $userObj, Block::TYPE_USER ]; + return [ $userObj, self::TYPE_USER ]; } elseif ( preg_match( '/^#\d+$/', $target ) ) { # Autoblock reference in the form "#12345" - return [ substr( $target, 1 ), Block::TYPE_AUTO ]; + return [ substr( $target, 1 ), self::TYPE_AUTO ]; } else { # WTF? diff --git a/includes/EditPage.php b/includes/EditPage.php index 973327b0be73..e3b7a10b7b86 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -2783,7 +2783,7 @@ class EditPage { $wgOut->addHTML( $this->editFormTextBeforeContent ); if ( !$this->isCssJsSubpage && $showToolbar && $wgUser->getOption( 'showtoolbar' ) ) { - $wgOut->addHTML( EditPage::getEditToolbar( $this->mTitle ) ); + $wgOut->addHTML( self::getEditToolbar( $this->mTitle ) ); } if ( $this->blankArticle ) { diff --git a/includes/LinkFilter.php b/includes/LinkFilter.php index 2f5055871acf..790e2be4489e 100644 --- a/includes/LinkFilter.php +++ b/includes/LinkFilter.php @@ -50,7 +50,7 @@ class LinkFilter { $text = $content->getNativeData(); - $regex = LinkFilter::makeRegex( $filterEntry ); + $regex = self::makeRegex( $filterEntry ); return preg_match( $regex, $text ); } diff --git a/includes/Linker.php b/includes/Linker.php index f2e4ac4581e1..4aae3ba6284c 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -1328,7 +1328,7 @@ class Linker { Title $title, $text, $wikiId = null, $options = [] ) { if ( $wikiId !== null && !$title->isExternal() ) { - $link = Linker::makeExternalLink( + $link = self::makeExternalLink( WikiMap::getForeignURL( $wikiId, $title->getNamespace() === 0 @@ -1341,7 +1341,7 @@ class Linker { /* escape = */ false // Already escaped ); } else { - $link = Linker::link( $title, $text, [], [], $options ); + $link = self::link( $title, $text, [], [], $options ); } return $link; @@ -2021,7 +2021,7 @@ class Linker { } if ( !$rev->userCan( Revision::DELETED_RESTRICTED, $user ) ) { - return Linker::revDeleteLinkDisabled( $canHide ); // revision was hidden from sysops + return self::revDeleteLinkDisabled( $canHide ); // revision was hidden from sysops } else { if ( $rev->getId() ) { // RevDelete links using revision ID are stable across @@ -2040,7 +2040,7 @@ class Linker { 'ids' => $rev->getTimestamp() ]; } - return Linker::revDeleteLink( $query, + return self::revDeleteLink( $query, $rev->isDeleted( Revision::DELETED_RESTRICTED ), $canHide ); } } diff --git a/includes/MWNamespace.php b/includes/MWNamespace.php index 89cb616a7bfb..97dba26b95ca 100644 --- a/includes/MWNamespace.php +++ b/includes/MWNamespace.php @@ -370,7 +370,7 @@ class MWNamespace { */ public static function getSubjectNamespaces() { return array_filter( - MWNamespace::getValidNamespaces(), + self::getValidNamespaces(), 'MWNamespace::isSubject' ); } @@ -383,7 +383,7 @@ class MWNamespace { */ public static function getTalkNamespaces() { return array_filter( - MWNamespace::getValidNamespaces(), + self::getValidNamespaces(), 'MWNamespace::isTalk' ); } diff --git a/includes/MagicWord.php b/includes/MagicWord.php index ee9591870014..1703179c9e28 100644 --- a/includes/MagicWord.php +++ b/includes/MagicWord.php @@ -664,7 +664,7 @@ class MagicWord { $search = []; $replace = []; foreach ( $magicarr as $id => $replacement ) { - $mw = MagicWord::get( $id ); + $mw = self::get( $id ); $search[] = $mw->getRegex(); $replace[] = $replacement; } diff --git a/includes/MimeMagic.php b/includes/MimeMagic.php index 8670729300cf..a2a44bb86832 100644 --- a/includes/MimeMagic.php +++ b/includes/MimeMagic.php @@ -35,7 +35,7 @@ class MimeMagic extends MimeAnalyzer { $instance = MediaWikiServices::getInstance()->getMimeAnalyzer(); Assert::postcondition( $instance instanceof MimeMagic, - __METHOD__ . ' should return an instance of ' . MimeMagic::class + __METHOD__ . ' should return an instance of ' . self::class ); return $instance; } diff --git a/includes/Preferences.php b/includes/Preferences.php index 008963b5a7f3..7efbef11764b 100644 --- a/includes/Preferences.php +++ b/includes/Preferences.php @@ -1316,7 +1316,7 @@ class Preferences { $formClass = 'PreferencesForm', array $remove = [] ) { - $formDescriptor = Preferences::getPreferences( $user, $context ); + $formDescriptor = self::getPreferences( $user, $context ); if ( count( $remove ) ) { $removeKeys = array_flip( $remove ); $formDescriptor = array_diff_key( $formDescriptor, $removeKeys ); diff --git a/includes/Revision.php b/includes/Revision.php index c6b50f4651b0..537b7c11a69b 100644 --- a/includes/Revision.php +++ b/includes/Revision.php @@ -1002,7 +1002,7 @@ class Revision implements IDBAccessObject { return RecentChange::newFromConds( [ - 'rc_user_text' => $this->getUserText( Revision::RAW ), + 'rc_user_text' => $this->getUserText( self::RAW ), 'rc_timestamp' => $dbr->timestamp( $this->getTimestamp() ), 'rc_this_oldid' => $this->getId() ], @@ -1466,7 +1466,7 @@ class Revision implements IDBAccessObject { ? $this->getPreviousRevisionId( $dbw ) : $this->mParentId, 'rev_sha1' => $this->mSha1 === null - ? Revision::base36Sha1( $this->mText ) + ? self::base36Sha1( $this->mText ) : $this->mSha1, ]; @@ -1555,7 +1555,7 @@ class Revision implements IDBAccessObject { } } - $content = $this->getContent( Revision::RAW ); + $content = $this->getContent( self::RAW ); $prefixedDBkey = $title->getPrefixedDBkey(); $revId = $this->mId; diff --git a/includes/Sanitizer.php b/includes/Sanitizer.php index b08bc6942581..2def06a9dd4d 100644 --- a/includes/Sanitizer.php +++ b/includes/Sanitizer.php @@ -465,7 +465,7 @@ class Sanitizer { extract( self::getRecognizedTagData( $extratags, $removetags ) ); # Remove HTML comments - $text = Sanitizer::removeHTMLcomments( $text ); + $text = self::removeHTMLcomments( $text ); $bits = explode( '<', $text ); $text = str_replace( '>', '>', array_shift( $bits ) ); if ( !MWTidy::isEnabled() ) { @@ -583,12 +583,12 @@ class Sanitizer { call_user_func_array( $processCallback, [ &$params, $args ] ); } - if ( !Sanitizer::validateTag( $params, $t ) ) { + if ( !self::validateTag( $params, $t ) ) { $badtag = true; } # Strip non-approved attributes from the tag - $newparams = Sanitizer::fixTagAttributes( $params, $t ); + $newparams = self::fixTagAttributes( $params, $t ); } if ( !$badtag ) { $rest = str_replace( '>', '>', $rest ); @@ -629,11 +629,11 @@ class Sanitizer { call_user_func_array( $warnCallback, [ 'deprecated-self-close-category' ] ); } } - if ( !Sanitizer::validateTag( $params, $t ) ) { + if ( !self::validateTag( $params, $t ) ) { $badtag = true; } - $newparams = Sanitizer::fixTagAttributes( $params, $t ); + $newparams = self::fixTagAttributes( $params, $t ); if ( !$badtag ) { if ( $brace === '/>' && !isset( $htmlsingleonly[$t] ) ) { # Interpret self-closing tags as empty tags even when @@ -710,7 +710,7 @@ class Sanitizer { * @return bool */ static function validateTag( $params, $element ) { - $params = Sanitizer::decodeTagAttributes( $params ); + $params = self::decodeTagAttributes( $params ); if ( $element == 'meta' || $element == 'link' ) { if ( !isset( $params['itemprop'] ) ) { @@ -746,8 +746,8 @@ class Sanitizer { * @todo Check for unique id attribute :P */ static function validateTagAttributes( $attribs, $element ) { - return Sanitizer::validateAttributes( $attribs, - Sanitizer::attributeWhitelist( $element ) ); + return self::validateAttributes( $attribs, + self::attributeWhitelist( $element ) ); } /** @@ -795,12 +795,12 @@ class Sanitizer { # Strip javascript "expression" from stylesheets. # https://msdn.microsoft.com/en-us/library/ms537634.aspx if ( $attribute == 'style' ) { - $value = Sanitizer::checkCss( $value ); + $value = self::checkCss( $value ); } # Escape HTML id attributes if ( $attribute === 'id' ) { - $value = Sanitizer::escapeId( $value, 'noninitial' ); + $value = self::escapeId( $value, 'noninitial' ); } # Escape HTML id reference lists @@ -809,7 +809,7 @@ class Sanitizer { || $attribute === 'aria-labelledby' || $attribute === 'aria-owns' ) { - $value = Sanitizer::escapeIdReferenceList( $value, 'noninitial' ); + $value = self::escapeIdReferenceList( $value, 'noninitial' ); } // RDFa and microdata properties allow URLs, URIs and/or CURIs. @@ -907,7 +907,7 @@ class Sanitizer { */ public static function normalizeCss( $value ) { // Decode character references like { - $value = Sanitizer::decodeCharReferences( $value ); + $value = self::decodeCharReferences( $value ); // Decode escape sequences and line continuation // See the grammar in the CSS 2 spec, appendix D. @@ -1087,14 +1087,14 @@ class Sanitizer { return ''; } - $decoded = Sanitizer::decodeTagAttributes( $text ); - $stripped = Sanitizer::validateTagAttributes( $decoded, $element ); + $decoded = self::decodeTagAttributes( $text ); + $stripped = self::validateTagAttributes( $decoded, $element ); if ( $sorted ) { ksort( $stripped ); } - return Sanitizer::safeEncodeTagAttributes( $stripped ); + return self::safeEncodeTagAttributes( $stripped ); } /** @@ -1124,7 +1124,7 @@ class Sanitizer { * @return string HTML-encoded text fragment */ static function safeEncodeAttribute( $text ) { - $encValue = Sanitizer::encodeAttribute( $text ); + $encValue = self::encodeAttribute( $text ); # Templates and links may be expanded in later parsing, # creating invalid or dangerous output. Suppress this. @@ -1186,7 +1186,7 @@ class Sanitizer { global $wgExperimentalHtmlIds; $options = (array)$options; - $id = Sanitizer::decodeCharReferences( $id ); + $id = self::decodeCharReferences( $id ); if ( $wgExperimentalHtmlIds && !in_array( 'legacy', $options ) ) { $id = preg_replace( '/[ \t\n\r\f_\'"&#%]+/', '_', $id ); @@ -1238,7 +1238,7 @@ class Sanitizer { # Escape each token as an id foreach ( $references as &$ref ) { - $ref = Sanitizer::escapeId( $ref, $options ); + $ref = self::escapeId( $ref, $options ); } # Merge the array back to a space delimited list string @@ -1275,7 +1275,7 @@ class Sanitizer { * @return string Escaped input */ static function escapeHtmlAllowEntities( $html ) { - $html = Sanitizer::decodeCharReferences( $html ); + $html = self::decodeCharReferences( $html ); # It seems wise to escape ' as well as ", as a matter of course. Can't # hurt. Use ENT_SUBSTITUTE so that incorrectly truncated multibyte characters # don't cause the entire string to disappear. @@ -1317,14 +1317,14 @@ class Sanitizer { foreach ( $pairs as $set ) { $attribute = strtolower( $set[1] ); - $value = Sanitizer::getTagAttributeCallback( $set ); + $value = self::getTagAttributeCallback( $set ); // Normalize whitespace $value = preg_replace( '/[\t\r\n ]+/', ' ', $value ); $value = trim( $value ); // Decode character references - $attribs[$attribute] = Sanitizer::decodeCharReferences( $value ); + $attribs[$attribute] = self::decodeCharReferences( $value ); } return $attribs; } @@ -1340,7 +1340,7 @@ class Sanitizer { $attribs = []; foreach ( $assoc_array as $attribute => $value ) { $encAttribute = htmlspecialchars( $attribute ); - $encValue = Sanitizer::safeEncodeAttribute( $value ); + $encValue = self::safeEncodeAttribute( $value ); $attribs[] = "$encAttribute=\"$encValue\""; } @@ -1427,11 +1427,11 @@ class Sanitizer { static function normalizeCharReferencesCallback( $matches ) { $ret = null; if ( $matches[1] != '' ) { - $ret = Sanitizer::normalizeEntity( $matches[1] ); + $ret = self::normalizeEntity( $matches[1] ); } elseif ( $matches[2] != '' ) { - $ret = Sanitizer::decCharReference( $matches[2] ); + $ret = self::decCharReference( $matches[2] ); } elseif ( $matches[3] != '' ) { - $ret = Sanitizer::hexCharReference( $matches[3] ); + $ret = self::hexCharReference( $matches[3] ); } if ( is_null( $ret ) ) { return htmlspecialchars( $matches[0] ); @@ -1468,7 +1468,7 @@ class Sanitizer { */ static function decCharReference( $codepoint ) { $point = intval( $codepoint ); - if ( Sanitizer::validateCodepoint( $point ) ) { + if ( self::validateCodepoint( $point ) ) { return sprintf( '&#%d;', $point ); } else { return null; @@ -1481,7 +1481,7 @@ class Sanitizer { */ static function hexCharReference( $codepoint ) { $point = hexdec( $codepoint ); - if ( Sanitizer::validateCodepoint( $point ) ) { + if ( self::validateCodepoint( $point ) ) { return sprintf( '&#x%x;', $point ); } else { return null; @@ -1550,11 +1550,11 @@ class Sanitizer { */ static function decodeCharReferencesCallback( $matches ) { if ( $matches[1] != '' ) { - return Sanitizer::decodeEntity( $matches[1] ); + return self::decodeEntity( $matches[1] ); } elseif ( $matches[2] != '' ) { - return Sanitizer::decodeChar( intval( $matches[2] ) ); + return self::decodeChar( intval( $matches[2] ) ); } elseif ( $matches[3] != '' ) { - return Sanitizer::decodeChar( hexdec( $matches[3] ) ); + return self::decodeChar( hexdec( $matches[3] ) ); } # Last case should be an ampersand by itself return $matches[0]; @@ -1568,7 +1568,7 @@ class Sanitizer { * @private */ static function decodeChar( $codepoint ) { - if ( Sanitizer::validateCodepoint( $codepoint ) ) { + if ( self::validateCodepoint( $codepoint ) ) { return UtfNormal\Utils::codepointToUtf8( $codepoint ); } else { return UtfNormal\Constants::UTF8_REPLACEMENT; @@ -1601,7 +1601,7 @@ class Sanitizer { * @return array */ static function attributeWhitelist( $element ) { - $list = Sanitizer::setupAttributeWhitelist(); + $list = self::setupAttributeWhitelist(); return isset( $list[$element] ) ? $list[$element] : []; @@ -1876,7 +1876,7 @@ class Sanitizer { static function cleanUrl( $url ) { # Normalize any HTML entities in input. They will be # re-escaped by makeExternalLink(). - $url = Sanitizer::decodeCharReferences( $url ); + $url = self::decodeCharReferences( $url ); # Escape any control characters introduced by the above step $url = preg_replace_callback( '/[\][<>"\\x00-\\x20\\x7F\|]/', diff --git a/includes/ServiceWiring.php b/includes/ServiceWiring.php index e1244e75900e..d048007c3a99 100644 --- a/includes/ServiceWiring.php +++ b/includes/ServiceWiring.php @@ -287,7 +287,7 @@ return [ return ObjectFactory::constructClassInstance( $conf['class'], [ $conf ] ); }, - 'ParserCache' => function( MediaWikiServices $services ) { + 'ParserCache' => function ( MediaWikiServices $services ) { $config = $services->getMainConfig(); $cache = ObjectCache::getInstance( $config->get( 'ParserCacheType' ) ); wfDebugLog( 'caches', 'parser: ' . get_class( $cache ) ); @@ -298,7 +298,7 @@ return [ ); }, - 'LinkCache' => function( MediaWikiServices $services ) { + 'LinkCache' => function ( MediaWikiServices $services ) { return new LinkCache( $services->getTitleFormatter(), $services->getMainWANObjectCache() diff --git a/includes/Setup.php b/includes/Setup.php index ac00fab74196..3d5bee2a0810 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -687,7 +687,7 @@ $messageMemc = wfGetMessageCacheStorage(); /** * @deprecated since 1.30 */ -$parserMemc = new DeprecatedGlobal( 'parserMemc', function() { +$parserMemc = new DeprecatedGlobal( 'parserMemc', function () { return MediaWikiServices::getInstance()->getParserCache()->getCacheStorage(); }, '1.30' ); diff --git a/includes/Title.php b/includes/Title.php index 083a725d9837..6538538e8ee1 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -272,7 +272,7 @@ class Title implements LinkTarget { } try { - return Title::newFromTextThrow( strval( $text ), $defaultNamespace ); + return self::newFromTextThrow( strval( $text ), $defaultNamespace ); } catch ( MalformedTitleException $ex ) { return null; } @@ -411,7 +411,7 @@ class Title implements LinkTarget { __METHOD__ ); if ( $row !== false ) { - $title = Title::newFromRow( $row ); + $title = self::newFromRow( $row ); } else { $title = null; } @@ -439,7 +439,7 @@ class Title implements LinkTarget { $titles = []; foreach ( $res as $row ) { - $titles[] = Title::newFromRow( $row ); + $titles[] = self::newFromRow( $row ); } return $titles; } @@ -541,7 +541,7 @@ class Title implements LinkTarget { } $t = new Title(); - $t->mDbkeyform = Title::makeName( $ns, $title, $fragment, $interwiki, true ); + $t->mDbkeyform = self::makeName( $ns, $title, $fragment, $interwiki, true ); try { $t->secureAndSplit(); @@ -557,10 +557,10 @@ class Title implements LinkTarget { * @return Title The new object */ public static function newMainPage() { - $title = Title::newFromText( wfMessage( 'mainpage' )->inContentLanguage()->text() ); + $title = self::newFromText( wfMessage( 'mainpage' )->inContentLanguage()->text() ); // Don't give fatal errors if the message is broken if ( !$title ) { - $title = Title::newFromText( 'Main Page' ); + $title = self::newFromText( 'Main Page' ); } return $title; } @@ -933,7 +933,7 @@ class Title implements LinkTarget { */ public function getContentModel( $flags = 0 ) { if ( !$this->mForcedContentModel - && ( !$this->mContentModel || $flags === Title::GAID_FOR_UPDATE ) + && ( !$this->mContentModel || $flags === self::GAID_FOR_UPDATE ) && $this->getArticleID( $flags ) ) { $linkCache = LinkCache::singleton(); @@ -1096,7 +1096,7 @@ class Title implements LinkTarget { if ( $canonicalName ) { $localName = SpecialPageFactory::getLocalNameFor( $canonicalName, $par ); if ( $localName != $this->mDbkeyform ) { - return Title::makeTitle( NS_SPECIAL, $localName ); + return self::makeTitle( NS_SPECIAL, $localName ); } } } @@ -1195,7 +1195,7 @@ class Title implements LinkTarget { * @return bool */ public function isMainPage() { - return $this->equals( Title::newMainPage() ); + return $this->equals( self::newMainPage() ); } /** @@ -1313,7 +1313,7 @@ class Title implements LinkTarget { * @return Title The object for the talk page */ public function getTalkPage() { - return Title::makeTitle( MWNamespace::getTalk( $this->getNamespace() ), $this->getDBkey() ); + return self::makeTitle( MWNamespace::getTalk( $this->getNamespace() ), $this->getDBkey() ); } /** @@ -1328,7 +1328,7 @@ class Title implements LinkTarget { if ( $this->getNamespace() == $subjectNS ) { return $this; } - return Title::makeTitle( $subjectNS, $this->getDBkey() ); + return self::makeTitle( $subjectNS, $this->getDBkey() ); } /** @@ -1388,7 +1388,7 @@ class Title implements LinkTarget { if ( !$this->hasFragment() ) { return ''; } else { - return '#' . Title::escapeFragmentForURL( $this->getFragment() ); + return '#' . self::escapeFragmentForURL( $this->getFragment() ); } } @@ -1535,7 +1535,7 @@ class Title implements LinkTarget { * @since 1.20 */ public function getRootTitle() { - return Title::makeTitle( $this->getNamespace(), $this->getRootText() ); + return self::makeTitle( $this->getNamespace(), $this->getRootText() ); } /** @@ -1575,7 +1575,7 @@ class Title implements LinkTarget { * @since 1.20 */ public function getBaseTitle() { - return Title::makeTitle( $this->getNamespace(), $this->getBaseText() ); + return self::makeTitle( $this->getNamespace(), $this->getBaseText() ); } /** @@ -1611,7 +1611,7 @@ class Title implements LinkTarget { * @since 1.20 */ public function getSubpage( $text ) { - return Title::makeTitleSafe( $this->getNamespace(), $this->getText() . '/' . $text ); + return self::makeTitleSafe( $this->getNamespace(), $this->getText() . '/' . $text ); } /** @@ -2847,7 +2847,7 @@ class Title implements LinkTarget { $page_id = $row->pr_page; $page_ns = $row->page_namespace; $page_title = $row->page_title; - $sources[$page_id] = Title::makeTitle( $page_ns, $page_title ); + $sources[$page_id] = self::makeTitle( $page_ns, $page_title ); # Add groups needed for each restriction type if its not already there # Make sure this restriction type still exists @@ -3329,7 +3329,7 @@ class Title implements LinkTarget { * @return int Int or 0 if the page doesn't exist */ public function getLatestRevID( $flags = 0 ) { - if ( !( $flags & Title::GAID_FOR_UPDATE ) && $this->mLatestID !== false ) { + if ( !( $flags & self::GAID_FOR_UPDATE ) && $this->mLatestID !== false ) { return intval( $this->mLatestID ); } if ( !$this->getArticleID( $flags ) ) { @@ -3489,7 +3489,7 @@ class Title implements LinkTarget { if ( $res->numRows() ) { $linkCache = LinkCache::singleton(); foreach ( $res as $row ) { - $titleObj = Title::makeTitle( $row->page_namespace, $row->page_title ); + $titleObj = self::makeTitle( $row->page_namespace, $row->page_title ); if ( $titleObj ) { $linkCache->addGoodLinkObjFromRow( $titleObj, $row ); $retVal[] = $titleObj; @@ -3557,9 +3557,9 @@ class Title implements LinkTarget { $linkCache = LinkCache::singleton(); foreach ( $res as $row ) { if ( $row->page_id ) { - $titleObj = Title::newFromRow( $row ); + $titleObj = self::newFromRow( $row ); } else { - $titleObj = Title::makeTitle( $row->$blNamespace, $row->$blTitle ); + $titleObj = self::makeTitle( $row->$blNamespace, $row->$blTitle ); $linkCache->addBadLinkObj( $titleObj ); } $retVal[] = $titleObj; @@ -3615,7 +3615,7 @@ class Title implements LinkTarget { $retVal = []; foreach ( $res as $row ) { - $retVal[] = Title::makeTitle( $row->pl_namespace, $row->pl_title ); + $retVal[] = self::makeTitle( $row->pl_namespace, $row->pl_title ); } return $retVal; } @@ -3827,7 +3827,7 @@ class Title implements LinkTarget { } # T16385: we need makeTitleSafe because the new page names may # be longer than 255 characters. - $newSubpage = Title::makeTitleSafe( $newNs, $newPageName ); + $newSubpage = self::makeTitleSafe( $newNs, $newPageName ); $success = $oldSubpage->moveTo( $newSubpage, $auth, $reason, $createRedirect, $changeTags ); if ( $success === true ) { @@ -3989,7 +3989,7 @@ class Title implements LinkTarget { # Circular reference $stack[$parent] = []; } else { - $nt = Title::newFromText( $parent ); + $nt = self::newFromText( $parent ); if ( $nt ) { $stack[$parent] = $nt->getParentCategoryTree( $children + [ $parent => 1 ] ); } diff --git a/includes/WikiMap.php b/includes/WikiMap.php index a03bc19412bc..6a532e5da5f3 100644 --- a/includes/WikiMap.php +++ b/includes/WikiMap.php @@ -115,7 +115,7 @@ class WikiMap { * @return string|int Wiki's name or $wiki_id if the wiki was not found */ public static function getWikiName( $wikiID ) { - $wiki = WikiMap::getWiki( $wikiID ); + $wiki = self::getWiki( $wikiID ); if ( $wiki ) { return $wiki->getDisplayName(); @@ -166,7 +166,7 @@ class WikiMap { * @return string|bool URL or false if the wiki was not found */ public static function getForeignURL( $wikiID, $page, $fragmentId = null ) { - $wiki = WikiMap::getWiki( $wikiID ); + $wiki = self::getWiki( $wikiID ); if ( $wiki ) { return $wiki->getFullUrl( $page, $fragmentId ); diff --git a/includes/Xml.php b/includes/Xml.php index d0164331e138..16a5a9ddecc8 100644 --- a/includes/Xml.php +++ b/includes/Xml.php @@ -225,7 +225,7 @@ class Xml { $selected = isset( $languages[$selected] ) ? $selected : $wgLanguageCode; $options = "\n"; foreach ( $languages as $code => $name ) { - $options .= Xml::option( "$code - $name", $code, $code == $selected ) . "\n"; + $options .= self::option( "$code - $name", $code, $code == $selected ) . "\n"; } $attrs = [ 'id' => 'wpUserLanguage', 'name' => 'wpUserLanguage' ]; @@ -235,8 +235,8 @@ class Xml { $msg = wfMessage( 'yourlanguage' ); } return [ - Xml::label( $msg->text(), $attrs['id'] ), - Xml::tags( 'select', $attrs, $options ) + self::label( $msg->text(), $attrs['id'] ), + self::tags( 'select', $attrs, $options ) ]; } @@ -400,7 +400,7 @@ class Xml { $value = false, $attribs = [] ) { return [ - Xml::label( $label, $id, $attribs ), + self::label( $label, $id, $attribs ), self::input( $name, $size, $value, [ 'id' => $id ] + $attribs ) ]; } @@ -556,11 +556,11 @@ class Xml { $attribs['tabindex'] = $tabindex; } - return Xml::openElement( 'select', $attribs ) + return self::openElement( 'select', $attribs ) . "\n" . $options . "\n" - . Xml::closeElement( 'select' ); + . self::closeElement( 'select' ); } /** @@ -575,15 +575,15 @@ class Xml { * @return string */ public static function fieldset( $legend = false, $content = false, $attribs = [] ) { - $s = Xml::openElement( 'fieldset', $attribs ) . "\n"; + $s = self::openElement( 'fieldset', $attribs ) . "\n"; if ( $legend ) { - $s .= Xml::element( 'legend', null, $legend ) . "\n"; + $s .= self::element( 'legend', null, $legend ) . "\n"; } if ( $content !== false ) { $s .= $content . "\n"; - $s .= Xml::closeElement( 'fieldset' ) . "\n"; + $s .= self::closeElement( 'fieldset' ) . "\n"; } return $s; @@ -644,7 +644,7 @@ class Xml { */ public static function encodeJsCall( $name, $args, $pretty = false ) { foreach ( $args as &$arg ) { - $arg = Xml::encodeJsVar( $arg, $pretty ); + $arg = self::encodeJsVar( $arg, $pretty ); if ( $arg === false ) { return false; } @@ -702,7 +702,7 @@ class Xml { $text . '</html>'; - return Xml::isWellFormed( $html ); + return self::isWellFormed( $html ); } /** @@ -736,25 +736,25 @@ class Xml { foreach ( $fields as $labelmsg => $input ) { $id = "mw-$labelmsg"; - $form .= Xml::openElement( 'tr', [ 'id' => $id ] ); + $form .= self::openElement( 'tr', [ 'id' => $id ] ); // TODO use a <label> here for accessibility purposes - will need // to either not use a table to build the form, or find the ID of // the input somehow. - $form .= Xml::tags( 'td', [ 'class' => 'mw-label' ], wfMessage( $labelmsg )->parse() ); - $form .= Xml::openElement( 'td', [ 'class' => 'mw-input' ] ) - . $input . Xml::closeElement( 'td' ); - $form .= Xml::closeElement( 'tr' ); + $form .= self::tags( 'td', [ 'class' => 'mw-label' ], wfMessage( $labelmsg )->parse() ); + $form .= self::openElement( 'td', [ 'class' => 'mw-input' ] ) + . $input . self::closeElement( 'td' ); + $form .= self::closeElement( 'tr' ); } if ( $submitLabel ) { - $form .= Xml::openElement( 'tr' ); - $form .= Xml::tags( 'td', [], '' ); - $form .= Xml::openElement( 'td', [ 'class' => 'mw-submit' ] ) - . Xml::submitButton( wfMessage( $submitLabel )->text(), $submitAttribs ) - . Xml::closeElement( 'td' ); - $form .= Xml::closeElement( 'tr' ); + $form .= self::openElement( 'tr' ); + $form .= self::tags( 'td', [], '' ); + $form .= self::openElement( 'td', [ 'class' => 'mw-submit' ] ) + . self::submitButton( wfMessage( $submitLabel )->text(), $submitAttribs ) + . self::closeElement( 'td' ); + $form .= self::closeElement( 'tr' ); } $form .= "</tbody></table>"; @@ -770,10 +770,10 @@ class Xml { * @return string */ public static function buildTable( $rows, $attribs = [], $headers = null ) { - $s = Xml::openElement( 'table', $attribs ); + $s = self::openElement( 'table', $attribs ); if ( is_array( $headers ) ) { - $s .= Xml::openElement( 'thead', $attribs ); + $s .= self::openElement( 'thead', $attribs ); foreach ( $headers as $id => $header ) { $attribs = []; @@ -782,9 +782,9 @@ class Xml { $attribs['id'] = $id; } - $s .= Xml::element( 'th', $attribs, $header ); + $s .= self::element( 'th', $attribs, $header ); } - $s .= Xml::closeElement( 'thead' ); + $s .= self::closeElement( 'thead' ); } foreach ( $rows as $id => $row ) { @@ -794,10 +794,10 @@ class Xml { $attribs['id'] = $id; } - $s .= Xml::buildTableRow( $attribs, $row ); + $s .= self::buildTableRow( $attribs, $row ); } - $s .= Xml::closeElement( 'table' ); + $s .= self::closeElement( 'table' ); return $s; } @@ -809,7 +809,7 @@ class Xml { * @return string */ public static function buildTableRow( $attribs, $cells ) { - $s = Xml::openElement( 'tr', $attribs ); + $s = self::openElement( 'tr', $attribs ); foreach ( $cells as $id => $cell ) { $attribs = []; @@ -818,10 +818,10 @@ class Xml { $attribs['id'] = $id; } - $s .= Xml::element( 'td', $attribs, $cell ); + $s .= self::element( 'td', $attribs, $cell ); } - $s .= Xml::closeElement( 'tr' ); + $s .= self::closeElement( 'tr' ); return $s; } diff --git a/includes/actions/Action.php b/includes/actions/Action.php index 88382b694fca..e8d9a3e4029a 100644 --- a/includes/actions/Action.php +++ b/includes/actions/Action.php @@ -151,7 +151,7 @@ abstract class Action implements MessageLocalizer { return 'view'; } - $action = Action::factory( $actionName, $context->getWikiPage(), $context ); + $action = self::factory( $actionName, $context->getWikiPage(), $context ); if ( $action instanceof Action ) { return $action->getName(); } @@ -388,7 +388,7 @@ abstract class Action implements MessageLocalizer { public function addHelpLink( $to, $overrideBaseUrl = false ) { global $wgContLang; $msg = wfMessage( $wgContLang->lc( - Action::getActionName( $this->getContext() ) + self::getActionName( $this->getContext() ) ) . '-helppage' ); if ( !$msg->isDisabled() ) { diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index c0b882824266..034d24360f31 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -548,7 +548,7 @@ abstract class ApiBase extends ContextSource { // Main module has this method overridden // Safety - avoid infinite loop: if ( $this->isMain() ) { - ApiBase::dieDebug( __METHOD__, 'base method was called on main module.' ); + self::dieDebug( __METHOD__, 'base method was called on main module.' ); } return $this->getMain()->lacksSameOriginSecurity(); @@ -620,7 +620,7 @@ abstract class ApiBase extends ContextSource { // Main module has getResult() method overridden // Safety - avoid infinite loop: if ( $this->isMain() ) { - ApiBase::dieDebug( __METHOD__, 'base method was called on main module. ' ); + self::dieDebug( __METHOD__, 'base method was called on main module. ' ); } return $this->getMain()->getResult(); @@ -634,7 +634,7 @@ abstract class ApiBase extends ContextSource { // Main module has getErrorFormatter() method overridden // Safety - avoid infinite loop: if ( $this->isMain() ) { - ApiBase::dieDebug( __METHOD__, 'base method was called on main module. ' ); + self::dieDebug( __METHOD__, 'base method was called on main module. ' ); } return $this->getMain()->getErrorFormatter(); @@ -660,7 +660,7 @@ abstract class ApiBase extends ContextSource { // Main module has getContinuationManager() method overridden // Safety - avoid infinite loop: if ( $this->isMain() ) { - ApiBase::dieDebug( __METHOD__, 'base method was called on main module. ' ); + self::dieDebug( __METHOD__, 'base method was called on main module. ' ); } return $this->getMain()->getContinuationManager(); @@ -674,7 +674,7 @@ abstract class ApiBase extends ContextSource { // Main module has setContinuationManager() method overridden // Safety - avoid infinite loop: if ( $this->isMain() ) { - ApiBase::dieDebug( __METHOD__, 'base method was called on main module. ' ); + self::dieDebug( __METHOD__, 'base method was called on main module. ' ); } $this->getMain()->setContinuationManager( $manager ); @@ -1059,7 +1059,7 @@ abstract class ApiBase extends ContextSource { if ( $type == 'boolean' ) { if ( isset( $default ) && $default !== false ) { // Having a default value of anything other than 'false' is not allowed - ApiBase::dieDebug( + self::dieDebug( __METHOD__, "Boolean param $encParamName's default is set to '$default'. " . 'Boolean parameters must default to false.' @@ -1070,13 +1070,13 @@ abstract class ApiBase extends ContextSource { } elseif ( $type == 'upload' ) { if ( isset( $default ) ) { // Having a default value is not allowed - ApiBase::dieDebug( + self::dieDebug( __METHOD__, "File upload param $encParamName's default is set to " . "'$default'. File upload parameters may not have a default." ); } if ( $multi ) { - ApiBase::dieDebug( __METHOD__, "Multi-values not supported for $encParamName" ); + self::dieDebug( __METHOD__, "Multi-values not supported for $encParamName" ); } $value = $this->getMain()->getUpload( $encParamName ); if ( !$value->exists() ) { @@ -1138,7 +1138,7 @@ abstract class ApiBase extends ContextSource { $allSpecifier = ( is_string( $allowAll ) ? $allowAll : self::ALL_DEFAULT_STRING ); if ( $allowAll && $multi && is_array( $type ) && in_array( $allSpecifier, $type, true ) ) { - ApiBase::dieDebug( + self::dieDebug( __METHOD__, "For param $encParamName, PARAM_ALL collides with a possible value" ); } @@ -1194,13 +1194,13 @@ abstract class ApiBase extends ContextSource { if ( !isset( $paramSettings[self::PARAM_MAX] ) || !isset( $paramSettings[self::PARAM_MAX2] ) ) { - ApiBase::dieDebug( + self::dieDebug( __METHOD__, "MAX1 or MAX2 are not defined for the limit $encParamName" ); } if ( $multi ) { - ApiBase::dieDebug( __METHOD__, "Multi-values not supported for $encParamName" ); + self::dieDebug( __METHOD__, "Multi-values not supported for $encParamName" ); } $min = isset( $paramSettings[self::PARAM_MIN] ) ? $paramSettings[self::PARAM_MIN] : 0; if ( $value == 'max' ) { @@ -1221,7 +1221,7 @@ abstract class ApiBase extends ContextSource { break; case 'boolean': if ( $multi ) { - ApiBase::dieDebug( __METHOD__, "Multi-values not supported for $encParamName" ); + self::dieDebug( __METHOD__, "Multi-values not supported for $encParamName" ); } break; case 'timestamp': @@ -1255,7 +1255,7 @@ abstract class ApiBase extends ContextSource { } break; default: - ApiBase::dieDebug( __METHOD__, "Param $encParamName's type is unknown - $type" ); + self::dieDebug( __METHOD__, "Param $encParamName's type is unknown - $type" ); } } @@ -2077,19 +2077,19 @@ abstract class ApiBase extends ContextSource { * @return Message */ public function getFinalSummary() { - $msg = ApiBase::makeMessage( $this->getSummaryMessage(), $this->getContext(), [ + $msg = self::makeMessage( $this->getSummaryMessage(), $this->getContext(), [ $this->getModulePrefix(), $this->getModuleName(), $this->getModulePath(), ] ); if ( !$msg->exists() ) { wfDeprecated( 'API help "description" messages', '1.30' ); - $msg = ApiBase::makeMessage( $this->getDescriptionMessage(), $this->getContext(), [ + $msg = self::makeMessage( $this->getDescriptionMessage(), $this->getContext(), [ $this->getModulePrefix(), $this->getModuleName(), $this->getModulePath(), ] ); - $msg = ApiBase::makeMessage( 'rawmessage', $this->getContext(), [ + $msg = self::makeMessage( 'rawmessage', $this->getContext(), [ preg_replace( '/\n.*/s', '', $msg->text() ) ] ); } @@ -2116,12 +2116,12 @@ abstract class ApiBase extends ContextSource { $desc = (string)$desc; } - $summary = ApiBase::makeMessage( $this->getSummaryMessage(), $this->getContext(), [ + $summary = self::makeMessage( $this->getSummaryMessage(), $this->getContext(), [ $this->getModulePrefix(), $this->getModuleName(), $this->getModulePath(), ] ); - $extendedDescription = ApiBase::makeMessage( + $extendedDescription = self::makeMessage( $this->getExtendedDescription(), $this->getContext(), [ $this->getModulePrefix(), $this->getModuleName(), @@ -2133,7 +2133,7 @@ abstract class ApiBase extends ContextSource { $msgs = [ $summary, $extendedDescription ]; } else { wfDeprecated( 'API help "description" messages', '1.30' ); - $description = ApiBase::makeMessage( $this->getDescriptionMessage(), $this->getContext(), [ + $description = self::makeMessage( $this->getDescriptionMessage(), $this->getContext(), [ $this->getModulePrefix(), $this->getModuleName(), $this->getModulePath(), @@ -2165,10 +2165,10 @@ abstract class ApiBase extends ContextSource { if ( $this->needsToken() ) { $params['token'] = [ - ApiBase::PARAM_TYPE => 'string', - ApiBase::PARAM_REQUIRED => true, - ApiBase::PARAM_SENSITIVE => true, - ApiBase::PARAM_HELP_MSG => [ + self::PARAM_TYPE => 'string', + self::PARAM_REQUIRED => true, + self::PARAM_SENSITIVE => true, + self::PARAM_HELP_MSG => [ 'api-help-param-token', $this->needsToken(), ], @@ -2205,7 +2205,7 @@ abstract class ApiBase extends ContextSource { } $desc = self::escapeWikiText( $desc ); - $params = $this->getFinalParams( ApiBase::GET_VALUES_FOR_HELP ); + $params = $this->getFinalParams( self::GET_VALUES_FOR_HELP ); $msgs = []; foreach ( $params as $param => $settings ) { if ( !is_array( $settings ) ) { @@ -2224,15 +2224,15 @@ abstract class ApiBase extends ContextSource { $d = implode( ' ', $d ); } - if ( isset( $settings[ApiBase::PARAM_HELP_MSG] ) ) { - $msg = $settings[ApiBase::PARAM_HELP_MSG]; + if ( isset( $settings[self::PARAM_HELP_MSG] ) ) { + $msg = $settings[self::PARAM_HELP_MSG]; } else { $msg = $this->msg( "apihelp-{$path}-param-{$param}" ); if ( !$msg->exists() ) { $msg = $this->msg( 'api-help-fallback-parameter', $d ); } } - $msg = ApiBase::makeMessage( $msg, $this->getContext(), + $msg = self::makeMessage( $msg, $this->getContext(), [ $prefix, $param, $name, $path ] ); if ( !$msg ) { self::dieDebug( __METHOD__, @@ -2240,11 +2240,11 @@ abstract class ApiBase extends ContextSource { } $msgs[$param] = [ $msg ]; - if ( isset( $settings[ApiBase::PARAM_TYPE] ) && - $settings[ApiBase::PARAM_TYPE] === 'submodule' + if ( isset( $settings[self::PARAM_TYPE] ) && + $settings[self::PARAM_TYPE] === 'submodule' ) { - if ( isset( $settings[ApiBase::PARAM_SUBMODULE_MAP] ) ) { - $map = $settings[ApiBase::PARAM_SUBMODULE_MAP]; + if ( isset( $settings[self::PARAM_SUBMODULE_MAP] ) ) { + $map = $settings[self::PARAM_SUBMODULE_MAP]; } else { $prefix = $this->isMain() ? '' : ( $this->getModulePath() . '+' ); $map = []; @@ -2282,29 +2282,29 @@ abstract class ApiBase extends ContextSource { $arr[] = $m->setContext( $this->getContext() ); } $msgs[$param] = array_merge( $msgs[$param], $submodules, $deprecatedSubmodules ); - } elseif ( isset( $settings[ApiBase::PARAM_HELP_MSG_PER_VALUE] ) ) { - if ( !is_array( $settings[ApiBase::PARAM_HELP_MSG_PER_VALUE] ) ) { + } elseif ( isset( $settings[self::PARAM_HELP_MSG_PER_VALUE] ) ) { + if ( !is_array( $settings[self::PARAM_HELP_MSG_PER_VALUE] ) ) { self::dieDebug( __METHOD__, 'ApiBase::PARAM_HELP_MSG_PER_VALUE is not valid' ); } - if ( !is_array( $settings[ApiBase::PARAM_TYPE] ) ) { + if ( !is_array( $settings[self::PARAM_TYPE] ) ) { self::dieDebug( __METHOD__, 'ApiBase::PARAM_HELP_MSG_PER_VALUE may only be used when ' . 'ApiBase::PARAM_TYPE is an array' ); } - $valueMsgs = $settings[ApiBase::PARAM_HELP_MSG_PER_VALUE]; - $deprecatedValues = isset( $settings[ApiBase::PARAM_DEPRECATED_VALUES] ) - ? $settings[ApiBase::PARAM_DEPRECATED_VALUES] + $valueMsgs = $settings[self::PARAM_HELP_MSG_PER_VALUE]; + $deprecatedValues = isset( $settings[self::PARAM_DEPRECATED_VALUES] ) + ? $settings[self::PARAM_DEPRECATED_VALUES] : []; - foreach ( $settings[ApiBase::PARAM_TYPE] as $value ) { + foreach ( $settings[self::PARAM_TYPE] as $value ) { if ( isset( $valueMsgs[$value] ) ) { $msg = $valueMsgs[$value]; } else { $msg = "apihelp-{$path}-paramvalue-{$param}-{$value}"; } - $m = ApiBase::makeMessage( $msg, $this->getContext(), + $m = self::makeMessage( $msg, $this->getContext(), [ $prefix, $param, $name, $path, $value ] ); if ( $m ) { $m = new ApiHelpParamValueMessage( @@ -2321,13 +2321,13 @@ abstract class ApiBase extends ContextSource { } } - if ( isset( $settings[ApiBase::PARAM_HELP_MSG_APPEND] ) ) { - if ( !is_array( $settings[ApiBase::PARAM_HELP_MSG_APPEND] ) ) { + if ( isset( $settings[self::PARAM_HELP_MSG_APPEND] ) ) { + if ( !is_array( $settings[self::PARAM_HELP_MSG_APPEND] ) ) { self::dieDebug( __METHOD__, 'Value for ApiBase::PARAM_HELP_MSG_APPEND is not an array' ); } - foreach ( $settings[ApiBase::PARAM_HELP_MSG_APPEND] as $m ) { - $m = ApiBase::makeMessage( $m, $this->getContext(), + foreach ( $settings[self::PARAM_HELP_MSG_APPEND] as $m ) { + $m = self::makeMessage( $m, $this->getContext(), [ $prefix, $param, $name, $path ] ); if ( $m ) { $msgs[$param][] = $m; diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index 869865e48964..b7d452940d15 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -1829,7 +1829,7 @@ class ApiMain extends ApiBase { ApiBase::PARAM_TYPE => 'submodule', ], 'format' => [ - ApiBase::PARAM_DFLT => ApiMain::API_DEFAULT_FORMAT, + ApiBase::PARAM_DFLT => self::API_DEFAULT_FORMAT, ApiBase::PARAM_TYPE => 'submodule', ], 'maxlag' => [ diff --git a/includes/api/ApiPageSet.php b/includes/api/ApiPageSet.php index 599b3de559ef..cfac761c91ed 100644 --- a/includes/api/ApiPageSet.php +++ b/includes/api/ApiPageSet.php @@ -121,7 +121,7 @@ class ApiPageSet extends ApiBase { public function __construct( ApiBase $dbSource, $flags = 0, $defaultNamespace = NS_MAIN ) { parent::__construct( $dbSource->getMain(), $dbSource->getModuleName() ); $this->mDbSource = $dbSource; - $this->mAllowGenerator = ( $flags & ApiPageSet::DISABLE_GENERATORS ) == 0; + $this->mAllowGenerator = ( $flags & self::DISABLE_GENERATORS ) == 0; $this->mDefaultNamespace = $defaultNamespace; $this->mParams = $this->extractRequestParams(); @@ -166,7 +166,7 @@ class ApiPageSet extends ApiBase { } // Create a temporary pageset to store generator's output, // add any additional fields generator may need, and execute pageset to populate titles/pageids - $tmpPageSet = new ApiPageSet( $dbSource, ApiPageSet::DISABLE_GENERATORS ); + $tmpPageSet = new ApiPageSet( $dbSource, self::DISABLE_GENERATORS ); $generator->setGeneratorMode( $tmpPageSet ); $this->mCacheMode = $generator->getCacheMode( $generator->extractRequestParams() ); diff --git a/includes/api/ApiQueryImageInfo.php b/includes/api/ApiQueryImageInfo.php index b2664dff1efd..bfd5b17b7d0a 100644 --- a/includes/api/ApiQueryImageInfo.php +++ b/includes/api/ApiQueryImageInfo.php @@ -677,7 +677,7 @@ class ApiQueryImageInfo extends ApiQueryBase { ApiBase::PARAM_DFLT => -1, ApiBase::PARAM_HELP_MSG => [ 'apihelp-query+imageinfo-param-urlwidth', - ApiQueryImageInfo::TRANSFORM_LIMIT, + self::TRANSFORM_LIMIT, ], ], 'urlheight' => [ diff --git a/includes/api/ApiQueryInfo.php b/includes/api/ApiQueryInfo.php index 6b8f98c7b9e3..ecdebd4dd96a 100644 --- a/includes/api/ApiQueryInfo.php +++ b/includes/api/ApiQueryInfo.php @@ -128,7 +128,7 @@ class ApiQueryInfo extends ApiQueryBase { * @deprecated since 1.24 */ public static function resetTokenCache() { - ApiQueryInfo::$cachedTokens = []; + self::$cachedTokens = []; } /** @@ -144,11 +144,11 @@ class ApiQueryInfo extends ApiQueryBase { } // The token is always the same, let's exploit that - if ( !isset( ApiQueryInfo::$cachedTokens['edit'] ) ) { - ApiQueryInfo::$cachedTokens['edit'] = $wgUser->getEditToken(); + if ( !isset( self::$cachedTokens['edit'] ) ) { + self::$cachedTokens['edit'] = $wgUser->getEditToken(); } - return ApiQueryInfo::$cachedTokens['edit']; + return self::$cachedTokens['edit']; } /** @@ -161,11 +161,11 @@ class ApiQueryInfo extends ApiQueryBase { } // The token is always the same, let's exploit that - if ( !isset( ApiQueryInfo::$cachedTokens['delete'] ) ) { - ApiQueryInfo::$cachedTokens['delete'] = $wgUser->getEditToken(); + if ( !isset( self::$cachedTokens['delete'] ) ) { + self::$cachedTokens['delete'] = $wgUser->getEditToken(); } - return ApiQueryInfo::$cachedTokens['delete']; + return self::$cachedTokens['delete']; } /** @@ -178,11 +178,11 @@ class ApiQueryInfo extends ApiQueryBase { } // The token is always the same, let's exploit that - if ( !isset( ApiQueryInfo::$cachedTokens['protect'] ) ) { - ApiQueryInfo::$cachedTokens['protect'] = $wgUser->getEditToken(); + if ( !isset( self::$cachedTokens['protect'] ) ) { + self::$cachedTokens['protect'] = $wgUser->getEditToken(); } - return ApiQueryInfo::$cachedTokens['protect']; + return self::$cachedTokens['protect']; } /** @@ -195,11 +195,11 @@ class ApiQueryInfo extends ApiQueryBase { } // The token is always the same, let's exploit that - if ( !isset( ApiQueryInfo::$cachedTokens['move'] ) ) { - ApiQueryInfo::$cachedTokens['move'] = $wgUser->getEditToken(); + if ( !isset( self::$cachedTokens['move'] ) ) { + self::$cachedTokens['move'] = $wgUser->getEditToken(); } - return ApiQueryInfo::$cachedTokens['move']; + return self::$cachedTokens['move']; } /** @@ -212,11 +212,11 @@ class ApiQueryInfo extends ApiQueryBase { } // The token is always the same, let's exploit that - if ( !isset( ApiQueryInfo::$cachedTokens['block'] ) ) { - ApiQueryInfo::$cachedTokens['block'] = $wgUser->getEditToken(); + if ( !isset( self::$cachedTokens['block'] ) ) { + self::$cachedTokens['block'] = $wgUser->getEditToken(); } - return ApiQueryInfo::$cachedTokens['block']; + return self::$cachedTokens['block']; } /** @@ -237,11 +237,11 @@ class ApiQueryInfo extends ApiQueryBase { } // The token is always the same, let's exploit that - if ( !isset( ApiQueryInfo::$cachedTokens['email'] ) ) { - ApiQueryInfo::$cachedTokens['email'] = $wgUser->getEditToken(); + if ( !isset( self::$cachedTokens['email'] ) ) { + self::$cachedTokens['email'] = $wgUser->getEditToken(); } - return ApiQueryInfo::$cachedTokens['email']; + return self::$cachedTokens['email']; } /** @@ -254,11 +254,11 @@ class ApiQueryInfo extends ApiQueryBase { } // The token is always the same, let's exploit that - if ( !isset( ApiQueryInfo::$cachedTokens['import'] ) ) { - ApiQueryInfo::$cachedTokens['import'] = $wgUser->getEditToken(); + if ( !isset( self::$cachedTokens['import'] ) ) { + self::$cachedTokens['import'] = $wgUser->getEditToken(); } - return ApiQueryInfo::$cachedTokens['import']; + return self::$cachedTokens['import']; } /** @@ -271,11 +271,11 @@ class ApiQueryInfo extends ApiQueryBase { } // The token is always the same, let's exploit that - if ( !isset( ApiQueryInfo::$cachedTokens['watch'] ) ) { - ApiQueryInfo::$cachedTokens['watch'] = $wgUser->getEditToken( 'watch' ); + if ( !isset( self::$cachedTokens['watch'] ) ) { + self::$cachedTokens['watch'] = $wgUser->getEditToken( 'watch' ); } - return ApiQueryInfo::$cachedTokens['watch']; + return self::$cachedTokens['watch']; } /** @@ -288,11 +288,11 @@ class ApiQueryInfo extends ApiQueryBase { } // The token is always the same, let's exploit that - if ( !isset( ApiQueryInfo::$cachedTokens['options'] ) ) { - ApiQueryInfo::$cachedTokens['options'] = $wgUser->getEditToken(); + if ( !isset( self::$cachedTokens['options'] ) ) { + self::$cachedTokens['options'] = $wgUser->getEditToken(); } - return ApiQueryInfo::$cachedTokens['options']; + return self::$cachedTokens['options']; } public function execute() { diff --git a/includes/api/ApiResult.php b/includes/api/ApiResult.php index 6734740f77a3..468d8783b4f2 100644 --- a/includes/api/ApiResult.php +++ b/includes/api/ApiResult.php @@ -287,12 +287,12 @@ class ApiResult implements ApiSerializable { * @param int $flags Zero or more OR-ed flags like OVERRIDE | ADD_ON_TOP. */ public static function setValue( array &$arr, $name, $value, $flags = 0 ) { - if ( ( $flags & ApiResult::NO_VALIDATE ) !== ApiResult::NO_VALIDATE ) { + if ( ( $flags & self::NO_VALIDATE ) !== self::NO_VALIDATE ) { $value = self::validateValue( $value ); } if ( $name === null ) { - if ( $flags & ApiResult::ADD_ON_TOP ) { + if ( $flags & self::ADD_ON_TOP ) { array_unshift( $arr, $value ); } else { array_push( $arr, $value ); @@ -301,8 +301,8 @@ class ApiResult implements ApiSerializable { } $exists = isset( $arr[$name] ); - if ( !$exists || ( $flags & ApiResult::OVERRIDE ) ) { - if ( !$exists && ( $flags & ApiResult::ADD_ON_TOP ) ) { + if ( !$exists || ( $flags & self::OVERRIDE ) ) { + if ( !$exists && ( $flags & self::ADD_ON_TOP ) ) { $arr = [ $name => $value ] + $arr; } else { $arr[$name] = $value; @@ -403,13 +403,13 @@ class ApiResult implements ApiSerializable { * @since 1.21 int $flags replaced boolean $override */ public function addValue( $path, $name, $value, $flags = 0 ) { - $arr = &$this->path( $path, ( $flags & ApiResult::ADD_ON_TOP ) ? 'prepend' : 'append' ); + $arr = &$this->path( $path, ( $flags & self::ADD_ON_TOP ) ? 'prepend' : 'append' ); - if ( $this->checkingSize && !( $flags & ApiResult::NO_SIZE_CHECK ) ) { + if ( $this->checkingSize && !( $flags & self::NO_SIZE_CHECK ) ) { // self::size needs the validated value. Then flag // to not re-validate later. $value = self::validateValue( $value ); - $flags |= ApiResult::NO_VALIDATE; + $flags |= self::NO_VALIDATE; $newsize = $this->size + self::size( $value ); if ( $this->maxSize !== false && $newsize > $this->maxSize ) { @@ -459,7 +459,7 @@ class ApiResult implements ApiSerializable { $name = array_pop( $path ); } $ret = self::unsetValue( $this->path( $path, 'dummy' ), $name ); - if ( $this->checkingSize && !( $flags & ApiResult::NO_SIZE_CHECK ) ) { + if ( $this->checkingSize && !( $flags & self::NO_SIZE_CHECK ) ) { $newsize = $this->size - self::size( $ret ); $this->size = max( $newsize, 0 ); } @@ -511,7 +511,7 @@ class ApiResult implements ApiSerializable { public function addParsedLimit( $moduleName, $limit ) { // Add value, allowing overwriting $this->addValue( 'limits', $moduleName, $limit, - ApiResult::OVERRIDE | ApiResult::NO_SIZE_CHECK ); + self::OVERRIDE | self::NO_SIZE_CHECK ); } /**@}*/ @@ -551,7 +551,7 @@ class ApiResult implements ApiSerializable { * @param int $flags Zero or more OR-ed flags like OVERRIDE | ADD_ON_TOP. */ public function addContentField( $path, $name, $flags = 0 ) { - $arr = &$this->path( $path, ( $flags & ApiResult::ADD_ON_TOP ) ? 'prepend' : 'append' ); + $arr = &$this->path( $path, ( $flags & self::ADD_ON_TOP ) ? 'prepend' : 'append' ); self::setContentField( $arr, $name, $flags ); } @@ -1156,7 +1156,7 @@ class ApiResult implements ApiSerializable { $bools = []; foreach ( $vars as $k => $v ) { if ( is_array( $v ) || is_object( $v ) ) { - $vars[$k] = ApiResult::addMetadataToResultVars( (array)$v, is_object( $v ) ); + $vars[$k] = self::addMetadataToResultVars( (array)$v, is_object( $v ) ); } elseif ( is_bool( $v ) ) { // Better here to use real bools even in BC formats $bools[] = $k; @@ -1176,22 +1176,22 @@ class ApiResult implements ApiSerializable { // Get the list of keys we actually care about. Unfortunately, we can't support // certain keys that conflict with ApiResult metadata. $keys = array_diff( array_keys( $vars ), [ - ApiResult::META_TYPE, ApiResult::META_PRESERVE_KEYS, ApiResult::META_KVP_KEY_NAME, - ApiResult::META_INDEXED_TAG_NAME, ApiResult::META_BC_BOOLS + self::META_TYPE, self::META_PRESERVE_KEYS, self::META_KVP_KEY_NAME, + self::META_INDEXED_TAG_NAME, self::META_BC_BOOLS ] ); return [ - ApiResult::META_TYPE => 'kvp', - ApiResult::META_KVP_KEY_NAME => 'key', - ApiResult::META_PRESERVE_KEYS => $keys, - ApiResult::META_BC_BOOLS => $bools, - ApiResult::META_INDEXED_TAG_NAME => 'var', + self::META_TYPE => 'kvp', + self::META_KVP_KEY_NAME => 'key', + self::META_PRESERVE_KEYS => $keys, + self::META_BC_BOOLS => $bools, + self::META_INDEXED_TAG_NAME => 'var', ] + $vars; } else { return [ - ApiResult::META_TYPE => 'array', - ApiResult::META_BC_BOOLS => $bools, - ApiResult::META_INDEXED_TAG_NAME => 'value', + self::META_TYPE => 'array', + self::META_BC_BOOLS => $bools, + self::META_INDEXED_TAG_NAME => 'value', ] + $vars; } } diff --git a/includes/auth/AuthenticationResponse.php b/includes/auth/AuthenticationResponse.php index 6684fb958fcf..956c985069dd 100644 --- a/includes/auth/AuthenticationResponse.php +++ b/includes/auth/AuthenticationResponse.php @@ -133,7 +133,7 @@ class AuthenticationResponse { */ public static function newPass( $username = null ) { $ret = new AuthenticationResponse; - $ret->status = AuthenticationResponse::PASS; + $ret->status = self::PASS; $ret->username = $username; return $ret; } @@ -145,7 +145,7 @@ class AuthenticationResponse { */ public static function newFail( Message $msg ) { $ret = new AuthenticationResponse; - $ret->status = AuthenticationResponse::FAIL; + $ret->status = self::FAIL; $ret->message = $msg; $ret->messageType = 'error'; return $ret; @@ -158,7 +158,7 @@ class AuthenticationResponse { */ public static function newRestart( Message $msg ) { $ret = new AuthenticationResponse; - $ret->status = AuthenticationResponse::RESTART; + $ret->status = self::RESTART; $ret->message = $msg; return $ret; } @@ -169,7 +169,7 @@ class AuthenticationResponse { */ public static function newAbstain() { $ret = new AuthenticationResponse; - $ret->status = AuthenticationResponse::ABSTAIN; + $ret->status = self::ABSTAIN; return $ret; } @@ -189,7 +189,7 @@ class AuthenticationResponse { } $ret = new AuthenticationResponse; - $ret->status = AuthenticationResponse::UI; + $ret->status = self::UI; $ret->neededRequests = $reqs; $ret->message = $msg; $ret->messageType = $msgtype; @@ -209,7 +209,7 @@ class AuthenticationResponse { } $ret = new AuthenticationResponse; - $ret->status = AuthenticationResponse::REDIRECT; + $ret->status = self::REDIRECT; $ret->neededRequests = $reqs; $ret->redirectTarget = $redirectTarget; $ret->redirectApiData = $redirectApiData; diff --git a/includes/cache/MessageCache.php b/includes/cache/MessageCache.php index ad1fffb41bf3..f9f9a08a33d5 100644 --- a/includes/cache/MessageCache.php +++ b/includes/cache/MessageCache.php @@ -816,7 +816,7 @@ class MessageCache { } // Normalise title-case input (with some inlining) - $lckey = MessageCache::normalizeKey( $key ); + $lckey = self::normalizeKey( $key ); Hooks::run( 'MessageCache::get', [ &$lckey ] ); diff --git a/includes/changes/RecentChange.php b/includes/changes/RecentChange.php index e8e35a38391a..5fad8fd9ea5b 100644 --- a/includes/changes/RecentChange.php +++ b/includes/changes/RecentChange.php @@ -130,7 +130,7 @@ class RecentChange { if ( is_array( $type ) ) { $retval = []; foreach ( $type as $t ) { - $retval[] = RecentChange::parseToRCType( $t ); + $retval[] = self::parseToRCType( $t ); } return $retval; @@ -459,7 +459,7 @@ class RecentChange { $change = $change instanceof RecentChange ? $change - : RecentChange::newFromId( $change ); + : self::newFromId( $change ); if ( !$change instanceof RecentChange ) { return null; diff --git a/includes/collation/IcuCollation.php b/includes/collation/IcuCollation.php index e2f82d4781fb..d93362bcaa39 100644 --- a/includes/collation/IcuCollation.php +++ b/includes/collation/IcuCollation.php @@ -535,7 +535,7 @@ class IcuCollation extends Collation { * @return string|bool */ static function getUnicodeVersionForICU() { - $icuVersion = IcuCollation::getICUVersion(); + $icuVersion = self::getICUVersion(); if ( !$icuVersion ) { return false; } diff --git a/includes/content/ContentHandler.php b/includes/content/ContentHandler.php index f85b00d8ed68..8603360ee063 100644 --- a/includes/content/ContentHandler.php +++ b/includes/content/ContentHandler.php @@ -136,7 +136,7 @@ abstract class ContentHandler { $modelId = $title->getContentModel(); } - $handler = ContentHandler::getForModelID( $modelId ); + $handler = self::getForModelID( $modelId ); return $handler->unserializeContent( $text, $format ); } @@ -240,7 +240,7 @@ abstract class ContentHandler { public static function getForTitle( Title $title ) { $modelId = $title->getContentModel(); - return ContentHandler::getForModelID( $modelId ); + return self::getForModelID( $modelId ); } /** @@ -256,7 +256,7 @@ abstract class ContentHandler { public static function getForContent( Content $content ) { $modelId = $content->getModel(); - return ContentHandler::getForModelID( $modelId ); + return self::getForModelID( $modelId ); } /** @@ -293,8 +293,8 @@ abstract class ContentHandler { public static function getForModelID( $modelId ) { global $wgContentHandlers; - if ( isset( ContentHandler::$handlers[$modelId] ) ) { - return ContentHandler::$handlers[$modelId]; + if ( isset( self::$handlers[$modelId] ) ) { + return self::$handlers[$modelId]; } if ( empty( $wgContentHandlers[$modelId] ) ) { @@ -327,9 +327,9 @@ abstract class ContentHandler { wfDebugLog( 'ContentHandler', 'Created handler for ' . $modelId . ': ' . get_class( $handler ) ); - ContentHandler::$handlers[$modelId] = $handler; + self::$handlers[$modelId] = $handler; - return ContentHandler::$handlers[$modelId]; + return self::$handlers[$modelId]; } /** @@ -372,7 +372,7 @@ abstract class ContentHandler { $formats = []; foreach ( $wgContentHandlers as $model => $class ) { - $handler = ContentHandler::getForModelID( $model ); + $handler = self::getForModelID( $model ); $formats = array_merge( $formats, $handler->getSupportedFormats() ); } diff --git a/includes/debug/MWDebug.php b/includes/debug/MWDebug.php index e67a0b35c5fd..012837fdcda2 100644 --- a/includes/debug/MWDebug.php +++ b/includes/debug/MWDebug.php @@ -425,7 +425,7 @@ class MWDebug { $html = ''; if ( self::$enabled ) { - MWDebug::log( 'MWDebug output complete' ); + self::log( 'MWDebug output complete' ); $debugInfo = self::getDebugInfo( $context ); // Cannot use OutputPage::addJsConfigVars because those are already outputted @@ -495,7 +495,7 @@ class MWDebug { } } - MWDebug::log( 'MWDebug output complete' ); + self::log( 'MWDebug output complete' ); $debugInfo = self::getDebugInfo( $context ); ApiResult::setIndexedTagName( $debugInfo, 'debuginfo' ); diff --git a/includes/export/WikiExporter.php b/includes/export/WikiExporter.php index a307468a7132..943aa045f982 100644 --- a/includes/export/WikiExporter.php +++ b/includes/export/WikiExporter.php @@ -91,8 +91,8 @@ class WikiExporter { * @param int $buffer One of WikiExporter::BUFFER or WikiExporter::STREAM * @param int $text One of WikiExporter::TEXT or WikiExporter::STUB */ - function __construct( $db, $history = WikiExporter::CURRENT, - $buffer = WikiExporter::BUFFER, $text = WikiExporter::TEXT ) { + function __construct( $db, $history = self::CURRENT, + $buffer = self::BUFFER, $text = self::TEXT ) { $this->db = $db; $this->history = $history; $this->buffer = $buffer; @@ -272,7 +272,7 @@ class WikiExporter { # Get logging table name for logging.* clause $logging = $this->db->tableName( 'logging' ); - if ( $this->buffer == WikiExporter::STREAM ) { + if ( $this->buffer == self::STREAM ) { $prev = $this->db->bufferResults( false ); } $result = null; // Assuring $result is not undefined, if exception occurs early @@ -284,7 +284,7 @@ class WikiExporter { [ 'ORDER BY' => 'log_id', 'USE INDEX' => [ 'logging' => 'PRIMARY' ] ] ); $this->outputLogStream( $result ); - if ( $this->buffer == WikiExporter::STREAM ) { + if ( $this->buffer == self::STREAM ) { $this->db->bufferResults( $prev ); } } catch ( Exception $e ) { @@ -303,7 +303,7 @@ class WikiExporter { // Putting database back in previous buffer mode try { - if ( $this->buffer == WikiExporter::STREAM ) { + if ( $this->buffer == self::STREAM ) { $this->db->bufferResults( $prev ); } } catch ( Exception $e2 ) { @@ -341,10 +341,10 @@ class WikiExporter { if ( !empty( $this->history['limit'] ) ) { $opts['LIMIT'] = intval( $this->history['limit'] ); } - } elseif ( $this->history & WikiExporter::FULL ) { + } elseif ( $this->history & self::FULL ) { # Full history dumps... # query optimization for history stub dumps - if ( $this->text == WikiExporter::STUB && $orderRevs ) { + if ( $this->text == self::STUB && $orderRevs ) { $tables = [ 'revision', 'page' ]; $opts[] = 'STRAIGHT_JOIN'; $opts['ORDER BY'] = [ 'rev_page ASC', 'rev_id ASC' ]; @@ -353,13 +353,13 @@ class WikiExporter { } else { $join['revision'] = [ 'INNER JOIN', 'page_id=rev_page' ]; } - } elseif ( $this->history & WikiExporter::CURRENT ) { + } elseif ( $this->history & self::CURRENT ) { # Latest revision dumps... if ( $this->list_authors && $cond != '' ) { // List authors, if so desired $this->do_list_authors( $cond ); } $join['revision'] = [ 'INNER JOIN', 'page_id=rev_page AND page_latest=rev_id' ]; - } elseif ( $this->history & WikiExporter::STABLE ) { + } elseif ( $this->history & self::STABLE ) { # "Stable" revision dumps... # Default JOIN, to be overridden... $join['revision'] = [ 'INNER JOIN', 'page_id=rev_page AND page_latest=rev_id' ]; @@ -367,7 +367,7 @@ class WikiExporter { if ( Hooks::run( 'WikiExporter::dumpStableQuery', [ &$tables, &$opts, &$join ] ) ) { throw new MWException( __METHOD__ . " given invalid history dump type." ); } - } elseif ( $this->history & WikiExporter::RANGE ) { + } elseif ( $this->history & self::RANGE ) { # Dump of revisions within a specified range $join['revision'] = [ 'INNER JOIN', 'page_id=rev_page' ]; $opts['ORDER BY'] = [ 'rev_page ASC', 'rev_id ASC' ]; @@ -381,12 +381,12 @@ class WikiExporter { $opts['USE INDEX']['page'] = 'PRIMARY'; } # Build text join options - if ( $this->text != WikiExporter::STUB ) { // 1-pass + if ( $this->text != self::STUB ) { // 1-pass $tables[] = 'text'; $join['text'] = [ 'INNER JOIN', 'rev_text_id=old_id' ]; } - if ( $this->buffer == WikiExporter::STREAM ) { + if ( $this->buffer == self::STREAM ) { $prev = $this->db->bufferResults( false ); } $result = null; // Assuring $result is not undefined, if exception occurs early @@ -399,7 +399,7 @@ class WikiExporter { # Output dump results $this->outputPageStream( $result ); - if ( $this->buffer == WikiExporter::STREAM ) { + if ( $this->buffer == self::STREAM ) { $this->db->bufferResults( $prev ); } } catch ( Exception $e ) { @@ -418,7 +418,7 @@ class WikiExporter { // Putting database back in previous buffer mode try { - if ( $this->buffer == WikiExporter::STREAM ) { + if ( $this->buffer == self::STREAM ) { $this->db->bufferResults( $prev ); } } catch ( Exception $e2 ) { diff --git a/includes/filerepo/ForeignAPIRepo.php b/includes/filerepo/ForeignAPIRepo.php index 43f1d211b38d..56ccc64499af 100644 --- a/includes/filerepo/ForeignAPIRepo.php +++ b/includes/filerepo/ForeignAPIRepo.php @@ -528,7 +528,7 @@ class ForeignAPIRepo extends FileRepo { } $req = MWHttpRequest::factory( $url, $options, __METHOD__ ); - $req->setUserAgent( ForeignAPIRepo::getUserAgent() ); + $req->setUserAgent( self::getUserAgent() ); $status = $req->execute(); if ( $status->isOK() ) { diff --git a/includes/htmlform/HTMLForm.php b/includes/htmlform/HTMLForm.php index 399147b89afe..61d0d8962cbc 100644 --- a/includes/htmlform/HTMLForm.php +++ b/includes/htmlform/HTMLForm.php @@ -285,7 +285,7 @@ class HTMLForm extends ContextSource { return ObjectFactory::constructClassInstance( OOUIHTMLForm::class, $arguments ); default: /** @var HTMLForm $form */ - $form = ObjectFactory::constructClassInstance( HTMLForm::class, $arguments ); + $form = ObjectFactory::constructClassInstance( self::class, $arguments ); $form->setDisplayFormat( $displayFormat ); return $form; } diff --git a/includes/http/Http.php b/includes/http/Http.php index 4f21ce2775c6..c10b312f3128 100644 --- a/includes/http/Http.php +++ b/includes/http/Http.php @@ -106,7 +106,7 @@ class Http { $options['timeout'] = $args[1]; $caller = __METHOD__; } - return Http::request( 'GET', $url, $options, $caller ); + return self::request( 'GET', $url, $options, $caller ); } /** @@ -119,7 +119,7 @@ class Http { * @return string|bool false on error */ public static function post( $url, $options = [], $caller = __METHOD__ ) { - return Http::request( 'POST', $url, $options, $caller ); + return self::request( 'POST', $url, $options, $caller ); } /** diff --git a/includes/import/ImportStreamSource.php b/includes/import/ImportStreamSource.php index 8034400bad23..94a2b937e0ec 100644 --- a/includes/import/ImportStreamSource.php +++ b/includes/import/ImportStreamSource.php @@ -93,7 +93,7 @@ class ImportStreamSource implements ImportSource { } $fname = $upload['tmp_name']; if ( is_uploaded_file( $fname ) ) { - return ImportStreamSource::newFromFile( $fname ); + return self::newFromFile( $fname ); } else { return Status::newFatal( 'importnofile' ); } @@ -178,6 +178,6 @@ class ImportStreamSource implements ImportSource { $url = wfAppendQuery( $link, $params ); # For interwikis, use POST to avoid redirects. - return ImportStreamSource::newFromURL( $url, "POST" ); + return self::newFromURL( $url, "POST" ); } } diff --git a/includes/jobqueue/JobQueue.php b/includes/jobqueue/JobQueue.php index d20a233ee2dd..1f4f179a67a9 100644 --- a/includes/jobqueue/JobQueue.php +++ b/includes/jobqueue/JobQueue.php @@ -378,7 +378,7 @@ abstract class JobQueue { // Flag this job as an old duplicate based on its "root" job... try { if ( $job && $this->isRootJobOldDuplicate( $job ) ) { - JobQueue::incrStats( 'dupe_pops', $this->type ); + self::incrStats( 'dupe_pops', $this->type ); $job = DuplicateJob::newFromJob( $job ); // convert to a no-op } } catch ( Exception $e ) { diff --git a/includes/libs/CSSMin.php b/includes/libs/CSSMin.php index ea0f1b7c740d..d5055629d87d 100644 --- a/includes/libs/CSSMin.php +++ b/includes/libs/CSSMin.php @@ -252,7 +252,7 @@ class CSSMin { // quotation marks (e.g. "foo /* bar"). $comments = []; - $pattern = '/(?!' . CSSMin::EMBED_REGEX . ')(' . CSSMin::COMMENT_REGEX . ')/s'; + $pattern = '/(?!' . self::EMBED_REGEX . ')(' . self::COMMENT_REGEX . ')/s'; $source = preg_replace_callback( $pattern, @@ -355,7 +355,7 @@ class CSSMin { }, $source ); // Re-insert comments - $pattern = '/' . CSSMin::PLACEHOLDER . '(\d+)x/'; + $pattern = '/' . self::PLACEHOLDER . '(\d+)x/'; $source = preg_replace_callback( $pattern, function ( $match ) use ( &$comments ) { return $comments[ $match[1] ]; }, $source ); diff --git a/includes/libs/IP.php b/includes/libs/IP.php index e8b0e6a77084..b22f06d3875e 100644 --- a/includes/libs/IP.php +++ b/includes/libs/IP.php @@ -549,7 +549,7 @@ class IP { */ private static function parseCIDR6( $range ) { # Explode into <expanded IP,range> - $parts = explode( '/', IP::sanitizeIP( $range ), 2 ); + $parts = explode( '/', self::sanitizeIP( $range ), 2 ); if ( count( $parts ) != 2 ) { return [ false, false ]; } @@ -590,7 +590,7 @@ class IP { */ private static function parseRange6( $range ) { # Expand any IPv6 IP - $range = IP::sanitizeIP( $range ); + $range = self::sanitizeIP( $range ); // CIDR notation... if ( strpos( $range, '/' ) !== false ) { list( $network, $bits ) = self::parseCIDR6( $range ); @@ -732,8 +732,8 @@ class IP { public static function getSubnet( $ip ) { $matches = []; $subnet = false; - if ( IP::isIPv6( $ip ) ) { - $parts = IP::parseRange( "$ip/64" ); + if ( self::isIPv6( $ip ) ) { + $parts = self::parseRange( "$ip/64" ); $subnet = $parts[0]; } elseif ( preg_match( '/^(\d+\.\d+\.\d+)\.\d+$/', $ip, $matches ) ) { // IPv4 diff --git a/includes/libs/StringUtils.php b/includes/libs/StringUtils.php index cffb5a39457a..9638706dc22b 100644 --- a/includes/libs/StringUtils.php +++ b/includes/libs/StringUtils.php @@ -276,7 +276,7 @@ class StringUtils { // Replace instances of the separator inside HTML-like tags with the placeholder $replacer = new DoubleReplacer( $separator, $placeholder ); - $cleaned = StringUtils::delimiterReplaceCallback( '<', '>', $replacer->cb(), $text ); + $cleaned = self::delimiterReplaceCallback( '<', '>', $replacer->cb(), $text ); // Explode, then put the replaced separators back in $items = explode( $separator, $cleaned ); @@ -303,7 +303,7 @@ class StringUtils { // Replace instances of the separator inside HTML-like tags with the placeholder $replacer = new DoubleReplacer( $search, $placeholder ); - $cleaned = StringUtils::delimiterReplaceCallback( '<', '>', $replacer->cb(), $text ); + $cleaned = self::delimiterReplaceCallback( '<', '>', $replacer->cb(), $text ); // Explode, then put the replaced separators back in $cleaned = str_replace( $search, $replace, $cleaned ); diff --git a/includes/logging/LogPage.php b/includes/logging/LogPage.php index faca5bc8a17d..ec97b50c24f4 100644 --- a/includes/logging/LogPage.php +++ b/includes/logging/LogPage.php @@ -205,7 +205,7 @@ class LogPage { * @return bool */ public static function isLogType( $type ) { - return in_array( $type, LogPage::validTypes() ); + return in_array( $type, self::validTypes() ); } /** @@ -348,7 +348,7 @@ class LogPage { $this->action = $action; $this->target = $target; $this->comment = $comment; - $this->params = LogPage::makeParamBlob( $params ); + $this->params = self::makeParamBlob( $params ); if ( $doer === null ) { global $wgUser; diff --git a/includes/mail/UserMailer.php b/includes/mail/UserMailer.php index 3858f27566ef..1f8489f7e3d4 100644 --- a/includes/mail/UserMailer.php +++ b/includes/mail/UserMailer.php @@ -175,18 +175,18 @@ class UserMailer { // first send to non-split address list, then to split addresses one by one $status = Status::newGood(); if ( $to ) { - $status->merge( UserMailer::sendInternal( + $status->merge( self::sendInternal( $to, $from, $subject, $body, $options ) ); } foreach ( $splitTo as $newTo ) { - $status->merge( UserMailer::sendInternal( + $status->merge( self::sendInternal( [ $newTo ], $from, $subject, $body, $options ) ); } return $status; } } - return UserMailer::sendInternal( $to, $from, $subject, $body, $options ); + return self::sendInternal( $to, $from, $subject, $body, $options ); } /** diff --git a/includes/media/Exif.php b/includes/media/Exif.php index c355a06be329..cd457f0beca1 100644 --- a/includes/media/Exif.php +++ b/includes/media/Exif.php @@ -118,162 +118,162 @@ class Exif { # TIFF Rev. 6.0 Attribute Information (p22) 'IFD0' => [ # Tags relating to image structure - 'ImageWidth' => Exif::SHORT_OR_LONG, # Image width - 'ImageLength' => Exif::SHORT_OR_LONG, # Image height - 'BitsPerSample' => [ Exif::SHORT, 3 ], # Number of bits per component + 'ImageWidth' => self::SHORT_OR_LONG, # Image width + 'ImageLength' => self::SHORT_OR_LONG, # Image height + 'BitsPerSample' => [ self::SHORT, 3 ], # Number of bits per component # "When a primary image is JPEG compressed, this designation is not" # "necessary and is omitted." (p23) - 'Compression' => Exif::SHORT, # Compression scheme #p23 - 'PhotometricInterpretation' => Exif::SHORT, # Pixel composition #p23 - 'Orientation' => Exif::SHORT, # Orientation of image #p24 - 'SamplesPerPixel' => Exif::SHORT, # Number of components - 'PlanarConfiguration' => Exif::SHORT, # Image data arrangement #p24 - 'YCbCrSubSampling' => [ Exif::SHORT, 2 ], # Subsampling ratio of Y to C #p24 - 'YCbCrPositioning' => Exif::SHORT, # Y and C positioning #p24-25 - 'XResolution' => Exif::RATIONAL, # Image resolution in width direction - 'YResolution' => Exif::RATIONAL, # Image resolution in height direction - 'ResolutionUnit' => Exif::SHORT, # Unit of X and Y resolution #(p26) + 'Compression' => self::SHORT, # Compression scheme #p23 + 'PhotometricInterpretation' => self::SHORT, # Pixel composition #p23 + 'Orientation' => self::SHORT, # Orientation of image #p24 + 'SamplesPerPixel' => self::SHORT, # Number of components + 'PlanarConfiguration' => self::SHORT, # Image data arrangement #p24 + 'YCbCrSubSampling' => [ self::SHORT, 2 ], # Subsampling ratio of Y to C #p24 + 'YCbCrPositioning' => self::SHORT, # Y and C positioning #p24-25 + 'XResolution' => self::RATIONAL, # Image resolution in width direction + 'YResolution' => self::RATIONAL, # Image resolution in height direction + 'ResolutionUnit' => self::SHORT, # Unit of X and Y resolution #(p26) # Tags relating to recording offset - 'StripOffsets' => Exif::SHORT_OR_LONG, # Image data location - 'RowsPerStrip' => Exif::SHORT_OR_LONG, # Number of rows per strip - 'StripByteCounts' => Exif::SHORT_OR_LONG, # Bytes per compressed strip - 'JPEGInterchangeFormat' => Exif::SHORT_OR_LONG, # Offset to JPEG SOI - 'JPEGInterchangeFormatLength' => Exif::SHORT_OR_LONG, # Bytes of JPEG data + 'StripOffsets' => self::SHORT_OR_LONG, # Image data location + 'RowsPerStrip' => self::SHORT_OR_LONG, # Number of rows per strip + 'StripByteCounts' => self::SHORT_OR_LONG, # Bytes per compressed strip + 'JPEGInterchangeFormat' => self::SHORT_OR_LONG, # Offset to JPEG SOI + 'JPEGInterchangeFormatLength' => self::SHORT_OR_LONG, # Bytes of JPEG data # Tags relating to image data characteristics - 'TransferFunction' => Exif::IGNORE, # Transfer function - 'WhitePoint' => [ Exif::RATIONAL, 2 ], # White point chromaticity - 'PrimaryChromaticities' => [ Exif::RATIONAL, 6 ], # Chromaticities of primarities + 'TransferFunction' => self::IGNORE, # Transfer function + 'WhitePoint' => [ self::RATIONAL, 2 ], # White point chromaticity + 'PrimaryChromaticities' => [ self::RATIONAL, 6 ], # Chromaticities of primarities # Color space transformation matrix coefficients #p27 - 'YCbCrCoefficients' => [ Exif::RATIONAL, 3 ], - 'ReferenceBlackWhite' => [ Exif::RATIONAL, 6 ], # Pair of black and white reference values + 'YCbCrCoefficients' => [ self::RATIONAL, 3 ], + 'ReferenceBlackWhite' => [ self::RATIONAL, 6 ], # Pair of black and white reference values # Other tags - 'DateTime' => Exif::ASCII, # File change date and time - 'ImageDescription' => Exif::ASCII, # Image title - 'Make' => Exif::ASCII, # Image input equipment manufacturer - 'Model' => Exif::ASCII, # Image input equipment model - 'Software' => Exif::ASCII, # Software used - 'Artist' => Exif::ASCII, # Person who created the image - 'Copyright' => Exif::ASCII, # Copyright holder + 'DateTime' => self::ASCII, # File change date and time + 'ImageDescription' => self::ASCII, # Image title + 'Make' => self::ASCII, # Image input equipment manufacturer + 'Model' => self::ASCII, # Image input equipment model + 'Software' => self::ASCII, # Software used + 'Artist' => self::ASCII, # Person who created the image + 'Copyright' => self::ASCII, # Copyright holder ], # Exif IFD Attribute Information (p30-31) 'EXIF' => [ # @todo NOTE: Nonexistence of this field is taken to mean nonconformance # to the Exif 2.1 AND 2.2 standards - 'ExifVersion' => Exif::UNDEFINED, # Exif version - 'FlashPixVersion' => Exif::UNDEFINED, # Supported Flashpix version #p32 + 'ExifVersion' => self::UNDEFINED, # Exif version + 'FlashPixVersion' => self::UNDEFINED, # Supported Flashpix version #p32 # Tags relating to Image Data Characteristics - 'ColorSpace' => Exif::SHORT, # Color space information #p32 + 'ColorSpace' => self::SHORT, # Color space information #p32 # Tags relating to image configuration - 'ComponentsConfiguration' => Exif::UNDEFINED, # Meaning of each component #p33 - 'CompressedBitsPerPixel' => Exif::RATIONAL, # Image compression mode - 'PixelYDimension' => Exif::SHORT_OR_LONG, # Valid image height - 'PixelXDimension' => Exif::SHORT_OR_LONG, # Valid image width + 'ComponentsConfiguration' => self::UNDEFINED, # Meaning of each component #p33 + 'CompressedBitsPerPixel' => self::RATIONAL, # Image compression mode + 'PixelYDimension' => self::SHORT_OR_LONG, # Valid image height + 'PixelXDimension' => self::SHORT_OR_LONG, # Valid image width # Tags relating to related user information - 'MakerNote' => Exif::IGNORE, # Manufacturer notes - 'UserComment' => Exif::UNDEFINED, # User comments #p34 + 'MakerNote' => self::IGNORE, # Manufacturer notes + 'UserComment' => self::UNDEFINED, # User comments #p34 # Tags relating to related file information - 'RelatedSoundFile' => Exif::ASCII, # Related audio file + 'RelatedSoundFile' => self::ASCII, # Related audio file # Tags relating to date and time - 'DateTimeOriginal' => Exif::ASCII, # Date and time of original data generation #p36 - 'DateTimeDigitized' => Exif::ASCII, # Date and time of original data generation - 'SubSecTime' => Exif::ASCII, # DateTime subseconds - 'SubSecTimeOriginal' => Exif::ASCII, # DateTimeOriginal subseconds - 'SubSecTimeDigitized' => Exif::ASCII, # DateTimeDigitized subseconds + 'DateTimeOriginal' => self::ASCII, # Date and time of original data generation #p36 + 'DateTimeDigitized' => self::ASCII, # Date and time of original data generation + 'SubSecTime' => self::ASCII, # DateTime subseconds + 'SubSecTimeOriginal' => self::ASCII, # DateTimeOriginal subseconds + 'SubSecTimeDigitized' => self::ASCII, # DateTimeDigitized subseconds # Tags relating to picture-taking conditions (p31) - 'ExposureTime' => Exif::RATIONAL, # Exposure time - 'FNumber' => Exif::RATIONAL, # F Number - 'ExposureProgram' => Exif::SHORT, # Exposure Program #p38 - 'SpectralSensitivity' => Exif::ASCII, # Spectral sensitivity - 'ISOSpeedRatings' => Exif::SHORT, # ISO speed rating - 'OECF' => Exif::IGNORE, + 'ExposureTime' => self::RATIONAL, # Exposure time + 'FNumber' => self::RATIONAL, # F Number + 'ExposureProgram' => self::SHORT, # Exposure Program #p38 + 'SpectralSensitivity' => self::ASCII, # Spectral sensitivity + 'ISOSpeedRatings' => self::SHORT, # ISO speed rating + 'OECF' => self::IGNORE, # Optoelectronic conversion factor. Note: We don't have support for this atm. - 'ShutterSpeedValue' => Exif::SRATIONAL, # Shutter speed - 'ApertureValue' => Exif::RATIONAL, # Aperture - 'BrightnessValue' => Exif::SRATIONAL, # Brightness - 'ExposureBiasValue' => Exif::SRATIONAL, # Exposure bias - 'MaxApertureValue' => Exif::RATIONAL, # Maximum land aperture - 'SubjectDistance' => Exif::RATIONAL, # Subject distance - 'MeteringMode' => Exif::SHORT, # Metering mode #p40 - 'LightSource' => Exif::SHORT, # Light source #p40-41 - 'Flash' => Exif::SHORT, # Flash #p41-42 - 'FocalLength' => Exif::RATIONAL, # Lens focal length - 'SubjectArea' => [ Exif::SHORT, 4 ], # Subject area - 'FlashEnergy' => Exif::RATIONAL, # Flash energy - 'SpatialFrequencyResponse' => Exif::IGNORE, # Spatial frequency response. Not supported atm. - 'FocalPlaneXResolution' => Exif::RATIONAL, # Focal plane X resolution - 'FocalPlaneYResolution' => Exif::RATIONAL, # Focal plane Y resolution - 'FocalPlaneResolutionUnit' => Exif::SHORT, # Focal plane resolution unit #p46 - 'SubjectLocation' => [ Exif::SHORT, 2 ], # Subject location - 'ExposureIndex' => Exif::RATIONAL, # Exposure index - 'SensingMethod' => Exif::SHORT, # Sensing method #p46 - 'FileSource' => Exif::UNDEFINED, # File source #p47 - 'SceneType' => Exif::UNDEFINED, # Scene type #p47 - 'CFAPattern' => Exif::IGNORE, # CFA pattern. not supported atm. - 'CustomRendered' => Exif::SHORT, # Custom image processing #p48 - 'ExposureMode' => Exif::SHORT, # Exposure mode #p48 - 'WhiteBalance' => Exif::SHORT, # White Balance #p49 - 'DigitalZoomRatio' => Exif::RATIONAL, # Digital zoom ration - 'FocalLengthIn35mmFilm' => Exif::SHORT, # Focal length in 35 mm film - 'SceneCaptureType' => Exif::SHORT, # Scene capture type #p49 - 'GainControl' => Exif::SHORT, # Scene control #p49-50 - 'Contrast' => Exif::SHORT, # Contrast #p50 - 'Saturation' => Exif::SHORT, # Saturation #p50 - 'Sharpness' => Exif::SHORT, # Sharpness #p50 - 'DeviceSettingDescription' => Exif::IGNORE, + 'ShutterSpeedValue' => self::SRATIONAL, # Shutter speed + 'ApertureValue' => self::RATIONAL, # Aperture + 'BrightnessValue' => self::SRATIONAL, # Brightness + 'ExposureBiasValue' => self::SRATIONAL, # Exposure bias + 'MaxApertureValue' => self::RATIONAL, # Maximum land aperture + 'SubjectDistance' => self::RATIONAL, # Subject distance + 'MeteringMode' => self::SHORT, # Metering mode #p40 + 'LightSource' => self::SHORT, # Light source #p40-41 + 'Flash' => self::SHORT, # Flash #p41-42 + 'FocalLength' => self::RATIONAL, # Lens focal length + 'SubjectArea' => [ self::SHORT, 4 ], # Subject area + 'FlashEnergy' => self::RATIONAL, # Flash energy + 'SpatialFrequencyResponse' => self::IGNORE, # Spatial frequency response. Not supported atm. + 'FocalPlaneXResolution' => self::RATIONAL, # Focal plane X resolution + 'FocalPlaneYResolution' => self::RATIONAL, # Focal plane Y resolution + 'FocalPlaneResolutionUnit' => self::SHORT, # Focal plane resolution unit #p46 + 'SubjectLocation' => [ self::SHORT, 2 ], # Subject location + 'ExposureIndex' => self::RATIONAL, # Exposure index + 'SensingMethod' => self::SHORT, # Sensing method #p46 + 'FileSource' => self::UNDEFINED, # File source #p47 + 'SceneType' => self::UNDEFINED, # Scene type #p47 + 'CFAPattern' => self::IGNORE, # CFA pattern. not supported atm. + 'CustomRendered' => self::SHORT, # Custom image processing #p48 + 'ExposureMode' => self::SHORT, # Exposure mode #p48 + 'WhiteBalance' => self::SHORT, # White Balance #p49 + 'DigitalZoomRatio' => self::RATIONAL, # Digital zoom ration + 'FocalLengthIn35mmFilm' => self::SHORT, # Focal length in 35 mm film + 'SceneCaptureType' => self::SHORT, # Scene capture type #p49 + 'GainControl' => self::SHORT, # Scene control #p49-50 + 'Contrast' => self::SHORT, # Contrast #p50 + 'Saturation' => self::SHORT, # Saturation #p50 + 'Sharpness' => self::SHORT, # Sharpness #p50 + 'DeviceSettingDescription' => self::IGNORE, # Device settings description. This could maybe be supported. Need to find an # example file that uses this to see if it has stuff of interest in it. - 'SubjectDistanceRange' => Exif::SHORT, # Subject distance range #p51 + 'SubjectDistanceRange' => self::SHORT, # Subject distance range #p51 - 'ImageUniqueID' => Exif::ASCII, # Unique image ID + 'ImageUniqueID' => self::ASCII, # Unique image ID ], # GPS Attribute Information (p52) 'GPS' => [ - 'GPSVersion' => Exif::UNDEFINED, + 'GPSVersion' => self::UNDEFINED, # Should be an array of 4 Exif::BYTE's. However php treats it as an undefined # Note exif standard calls this GPSVersionID, but php doesn't like the id suffix - 'GPSLatitudeRef' => Exif::ASCII, # North or South Latitude #p52-53 - 'GPSLatitude' => [ Exif::RATIONAL, 3 ], # Latitude - 'GPSLongitudeRef' => Exif::ASCII, # East or West Longitude #p53 - 'GPSLongitude' => [ Exif::RATIONAL, 3 ], # Longitude - 'GPSAltitudeRef' => Exif::UNDEFINED, + 'GPSLatitudeRef' => self::ASCII, # North or South Latitude #p52-53 + 'GPSLatitude' => [ self::RATIONAL, 3 ], # Latitude + 'GPSLongitudeRef' => self::ASCII, # East or West Longitude #p53 + 'GPSLongitude' => [ self::RATIONAL, 3 ], # Longitude + 'GPSAltitudeRef' => self::UNDEFINED, # Altitude reference. Note, the exif standard says this should be an EXIF::Byte, # but php seems to disagree. - 'GPSAltitude' => Exif::RATIONAL, # Altitude - 'GPSTimeStamp' => [ Exif::RATIONAL, 3 ], # GPS time (atomic clock) - 'GPSSatellites' => Exif::ASCII, # Satellites used for measurement - 'GPSStatus' => Exif::ASCII, # Receiver status #p54 - 'GPSMeasureMode' => Exif::ASCII, # Measurement mode #p54-55 - 'GPSDOP' => Exif::RATIONAL, # Measurement precision - 'GPSSpeedRef' => Exif::ASCII, # Speed unit #p55 - 'GPSSpeed' => Exif::RATIONAL, # Speed of GPS receiver - 'GPSTrackRef' => Exif::ASCII, # Reference for direction of movement #p55 - 'GPSTrack' => Exif::RATIONAL, # Direction of movement - 'GPSImgDirectionRef' => Exif::ASCII, # Reference for direction of image #p56 - 'GPSImgDirection' => Exif::RATIONAL, # Direction of image - 'GPSMapDatum' => Exif::ASCII, # Geodetic survey data used - 'GPSDestLatitudeRef' => Exif::ASCII, # Reference for latitude of destination #p56 - 'GPSDestLatitude' => [ Exif::RATIONAL, 3 ], # Latitude destination - 'GPSDestLongitudeRef' => Exif::ASCII, # Reference for longitude of destination #p57 - 'GPSDestLongitude' => [ Exif::RATIONAL, 3 ], # Longitude of destination - 'GPSDestBearingRef' => Exif::ASCII, # Reference for bearing of destination #p57 - 'GPSDestBearing' => Exif::RATIONAL, # Bearing of destination - 'GPSDestDistanceRef' => Exif::ASCII, # Reference for distance to destination #p57-58 - 'GPSDestDistance' => Exif::RATIONAL, # Distance to destination - 'GPSProcessingMethod' => Exif::UNDEFINED, # Name of GPS processing method - 'GPSAreaInformation' => Exif::UNDEFINED, # Name of GPS area - 'GPSDateStamp' => Exif::ASCII, # GPS date - 'GPSDifferential' => Exif::SHORT, # GPS differential correction + 'GPSAltitude' => self::RATIONAL, # Altitude + 'GPSTimeStamp' => [ self::RATIONAL, 3 ], # GPS time (atomic clock) + 'GPSSatellites' => self::ASCII, # Satellites used for measurement + 'GPSStatus' => self::ASCII, # Receiver status #p54 + 'GPSMeasureMode' => self::ASCII, # Measurement mode #p54-55 + 'GPSDOP' => self::RATIONAL, # Measurement precision + 'GPSSpeedRef' => self::ASCII, # Speed unit #p55 + 'GPSSpeed' => self::RATIONAL, # Speed of GPS receiver + 'GPSTrackRef' => self::ASCII, # Reference for direction of movement #p55 + 'GPSTrack' => self::RATIONAL, # Direction of movement + 'GPSImgDirectionRef' => self::ASCII, # Reference for direction of image #p56 + 'GPSImgDirection' => self::RATIONAL, # Direction of image + 'GPSMapDatum' => self::ASCII, # Geodetic survey data used + 'GPSDestLatitudeRef' => self::ASCII, # Reference for latitude of destination #p56 + 'GPSDestLatitude' => [ self::RATIONAL, 3 ], # Latitude destination + 'GPSDestLongitudeRef' => self::ASCII, # Reference for longitude of destination #p57 + 'GPSDestLongitude' => [ self::RATIONAL, 3 ], # Longitude of destination + 'GPSDestBearingRef' => self::ASCII, # Reference for bearing of destination #p57 + 'GPSDestBearing' => self::RATIONAL, # Bearing of destination + 'GPSDestDistanceRef' => self::ASCII, # Reference for distance to destination #p57-58 + 'GPSDestDistance' => self::RATIONAL, # Distance to destination + 'GPSProcessingMethod' => self::UNDEFINED, # Name of GPS processing method + 'GPSAreaInformation' => self::UNDEFINED, # Name of GPS area + 'GPSDateStamp' => self::ASCII, # GPS date + 'GPSDifferential' => self::SHORT, # GPS differential correction ], ]; @@ -759,43 +759,43 @@ class Exif { } // Does not work if not typecast switch ( (string)$etype ) { - case (string)Exif::BYTE: + case (string)self::BYTE: $this->debug( $val, __FUNCTION__, $debug ); return $this->isByte( $val ); - case (string)Exif::ASCII: + case (string)self::ASCII: $this->debug( $val, __FUNCTION__, $debug ); return $this->isASCII( $val ); - case (string)Exif::SHORT: + case (string)self::SHORT: $this->debug( $val, __FUNCTION__, $debug ); return $this->isShort( $val ); - case (string)Exif::LONG: + case (string)self::LONG: $this->debug( $val, __FUNCTION__, $debug ); return $this->isLong( $val ); - case (string)Exif::RATIONAL: + case (string)self::RATIONAL: $this->debug( $val, __FUNCTION__, $debug ); return $this->isRational( $val ); - case (string)Exif::SHORT_OR_LONG: + case (string)self::SHORT_OR_LONG: $this->debug( $val, __FUNCTION__, $debug ); return $this->isShort( $val ) || $this->isLong( $val ); - case (string)Exif::UNDEFINED: + case (string)self::UNDEFINED: $this->debug( $val, __FUNCTION__, $debug ); return $this->isUndefined( $val ); - case (string)Exif::SLONG: + case (string)self::SLONG: $this->debug( $val, __FUNCTION__, $debug ); return $this->isSlong( $val ); - case (string)Exif::SRATIONAL: + case (string)self::SRATIONAL: $this->debug( $val, __FUNCTION__, $debug ); return $this->isSrational( $val ); - case (string)Exif::IGNORE: + case (string)self::IGNORE: $this->debug( $val, __FUNCTION__, $debug ); return false; diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php index 20fb9bebca25..91684826cfa7 100644 --- a/includes/page/WikiPage.php +++ b/includes/page/WikiPage.php @@ -2971,7 +2971,7 @@ class WikiPage implements Page, IDBAccessObject { } // Clear caches - WikiPage::onArticleDelete( $this->mTitle ); + self::onArticleDelete( $this->mTitle ); ResourceLoaderWikiModule::invalidateModuleCache( $this->mTitle, $revision, null, wfWikiID() ); diff --git a/includes/pager/IndexPager.php b/includes/pager/IndexPager.php index 0b867ef00e91..6620c4751b3b 100644 --- a/includes/pager/IndexPager.php +++ b/includes/pager/IndexPager.php @@ -737,6 +737,6 @@ abstract class IndexPager extends ContextSource implements Pager { * @return bool */ protected function getDefaultDirections() { - return IndexPager::DIR_ASCENDING; + return self::DIR_ASCENDING; } } diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 5da25465c616..b035b0243d8d 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -227,7 +227,7 @@ class Parser { * @var string Deprecated accessor for the strip marker prefix. * @deprecated since 1.26; use Parser::MARKER_PREFIX instead. */ - public $mUniqPrefix = Parser::MARKER_PREFIX; + public $mUniqPrefix = self::MARKER_PREFIX; /** * @var array Array with the language name of each language link (i.e. the @@ -1295,7 +1295,7 @@ class Parser { if ( !$frame->depth ) { $flag = 0; } else { - $flag = Parser::PTD_FOR_INCLUSION; + $flag = self::PTD_FOR_INCLUSION; } $dom = $this->preprocessToDom( $text, $flag ); $text = $frame->expand( $dom ); diff --git a/includes/parser/ParserOutput.php b/includes/parser/ParserOutput.php index 10ac1925bdc9..cfb0c3ec591b 100644 --- a/includes/parser/ParserOutput.php +++ b/includes/parser/ParserOutput.php @@ -253,7 +253,7 @@ class ParserOutput extends CacheTime { $text = $this->mText; if ( $this->mEditSectionTokens ) { $text = preg_replace_callback( - ParserOutput::EDITSECTION_REGEX, + self::EDITSECTION_REGEX, function ( $m ) { global $wgOut, $wgLang; $editsectionPage = Title::newFromText( htmlspecialchars_decode( $m[1] ) ); @@ -274,7 +274,7 @@ class ParserOutput extends CacheTime { $text ); } else { - $text = preg_replace( ParserOutput::EDITSECTION_REGEX, '', $text ); + $text = preg_replace( self::EDITSECTION_REGEX, '', $text ); } // If you have an old cached version of this class - sorry, you can't disable the TOC diff --git a/includes/resourceloader/ResourceLoader.php b/includes/resourceloader/ResourceLoader.php index 855311667d58..2f292003c176 100644 --- a/includes/resourceloader/ResourceLoader.php +++ b/includes/resourceloader/ResourceLoader.php @@ -178,7 +178,7 @@ class ResourceLoader implements LoggerAwareInterface { * @return string Filtered data, or a comment containing an error message */ public static function filter( $filter, $data, array $options = [] ) { - if ( strpos( $data, ResourceLoader::FILTER_NOMIN ) !== false ) { + if ( strpos( $data, self::FILTER_NOMIN ) !== false ) { return $data; } @@ -1079,7 +1079,7 @@ MESSAGE; // mw.loader.implement will use globalEval if scripts is a string. // Minify manually here, because general response minification is // not effective due it being a string literal, not a function. - if ( !ResourceLoader::inDebugMode() ) { + if ( !self::inDebugMode() ) { $scripts = self::filter( 'minify-js', $scripts ); // T107377 } } else { @@ -1139,7 +1139,7 @@ MESSAGE; } else { if ( count( $states ) ) { $this->errors[] = 'Problematic modules: ' . - FormatJson::encode( $states, ResourceLoader::inDebugMode() ); + FormatJson::encode( $states, self::inDebugMode() ); } } @@ -1214,7 +1214,7 @@ MESSAGE; ]; self::trimArray( $module ); - return Xml::encodeJsCall( 'mw.loader.implement', $module, ResourceLoader::inDebugMode() ); + return Xml::encodeJsCall( 'mw.loader.implement', $module, self::inDebugMode() ); } /** @@ -1228,7 +1228,7 @@ MESSAGE; return Xml::encodeJsCall( 'mw.messages.set', [ (object)$messages ], - ResourceLoader::inDebugMode() + self::inDebugMode() ); } @@ -1285,13 +1285,13 @@ MESSAGE; return Xml::encodeJsCall( 'mw.loader.state', [ $name ], - ResourceLoader::inDebugMode() + self::inDebugMode() ); } else { return Xml::encodeJsCall( 'mw.loader.state', [ $name, $state ], - ResourceLoader::inDebugMode() + self::inDebugMode() ); } } @@ -1317,7 +1317,7 @@ MESSAGE; return Xml::encodeJsCall( "( function ( name, version, dependencies, group, source ) {\n\t$script\n} )", [ $name, $version, $dependencies, $group, $source ], - ResourceLoader::inDebugMode() + self::inDebugMode() ); } @@ -1409,7 +1409,7 @@ MESSAGE; return Xml::encodeJsCall( 'mw.loader.register', [ $name ], - ResourceLoader::inDebugMode() + self::inDebugMode() ); } else { $registration = [ $name, $version, $dependencies, $group, $source, $skip ]; @@ -1417,7 +1417,7 @@ MESSAGE; return Xml::encodeJsCall( 'mw.loader.register', $registration, - ResourceLoader::inDebugMode() + self::inDebugMode() ); } } @@ -1441,13 +1441,13 @@ MESSAGE; return Xml::encodeJsCall( 'mw.loader.addSource', [ $id ], - ResourceLoader::inDebugMode() + self::inDebugMode() ); } else { return Xml::encodeJsCall( 'mw.loader.addSource', [ $id, $loadUrl ], - ResourceLoader::inDebugMode() + self::inDebugMode() ); } } @@ -1494,7 +1494,7 @@ MESSAGE; return Xml::encodeJsCall( 'mw.config.set', [ $configuration ], - ResourceLoader::inDebugMode() + self::inDebugMode() ); } diff --git a/includes/skins/Skin.php b/includes/skins/Skin.php index a8f9d0cbcba1..40905a56dfc2 100644 --- a/includes/skins/Skin.php +++ b/includes/skins/Skin.php @@ -95,7 +95,7 @@ abstract class Skin extends ContextSource { static function normalizeKey( $key ) { global $wgDefaultSkin, $wgFallbackSkin; - $skinNames = Skin::getSkinNames(); + $skinNames = self::getSkinNames(); // Make keys lowercase for case-insensitive matching. $skinNames = array_change_key_case( $skinNames, CASE_LOWER ); diff --git a/includes/specialpage/SpecialPage.php b/includes/specialpage/SpecialPage.php index 67c14d81e267..4c3ca54b3290 100644 --- a/includes/specialpage/SpecialPage.php +++ b/includes/specialpage/SpecialPage.php @@ -383,7 +383,7 @@ class SpecialPage implements MessageLocalizer { return true; } elseif ( $securityStatus === AuthManager::SEC_REAUTH ) { $request = $this->getRequest(); - $title = SpecialPage::getTitleFor( 'Userlogin' ); + $title = self::getTitleFor( 'Userlogin' ); $query = [ 'returnto' => $this->getFullTitle()->getPrefixedDBkey(), 'returntoquery' => wfArrayToCgi( array_diff_key( $request->getQueryValues(), diff --git a/includes/tidy/Balancer.php b/includes/tidy/Balancer.php index b0c12e4c2068..4852ce5211cf 100644 --- a/includes/tidy/Balancer.php +++ b/includes/tidy/Balancer.php @@ -2156,7 +2156,7 @@ class Balancer { if ( $this->allowComments && !( $this->inRCDATA || $this->inRAWTEXT ) && - preg_match( Balancer::VALID_COMMENT_REGEX, $x, $regs, PREG_OFFSET_CAPTURE ) && + preg_match( self::VALID_COMMENT_REGEX, $x, $regs, PREG_OFFSET_CAPTURE ) && // verify EOF condition where necessary ( $regs[4][1] < 0 || !$this->bitsIterator->valid() ) ) { diff --git a/includes/user/BotPassword.php b/includes/user/BotPassword.php index 9a955fb9284e..25625e72c8c9 100644 --- a/includes/user/BotPassword.php +++ b/includes/user/BotPassword.php @@ -411,7 +411,7 @@ class BotPassword implements IDBAccessObject { * @return array|false */ public static function canonicalizeLoginData( $username, $password ) { - $sep = BotPassword::getSeparator(); + $sep = self::getSeparator(); // the strlen check helps minimize the password information obtainable from timing if ( strlen( $password ) >= 32 && strpos( $username, $sep ) !== false ) { // the separator is not valid in new usernames but might appear in legacy ones diff --git a/includes/user/User.php b/includes/user/User.php index 7bf6be508ad1..fa84c94ca755 100644 --- a/includes/user/User.php +++ b/includes/user/User.php @@ -603,7 +603,7 @@ class User implements IDBAccessObject { ] ); - return $id ? User::newFromId( $id ) : null; + return $id ? self::newFromId( $id ) : null; } /** @@ -842,7 +842,7 @@ class User implements IDBAccessObject { global $wgContLang, $wgMaxNameChars; if ( $name == '' - || User::isIP( $name ) + || self::isIP( $name ) || strpos( $name, '/' ) !== false || strlen( $name ) > $wgMaxNameChars || $name != $wgContLang->ucfirst( $name ) @@ -1109,17 +1109,17 @@ class User implements IDBAccessObject { case false: break; case 'valid': - if ( !User::isValidUserName( $name ) ) { + if ( !self::isValidUserName( $name ) ) { $name = false; } break; case 'usable': - if ( !User::isUsableName( $name ) ) { + if ( !self::isUsableName( $name ) ) { $name = false; } break; case 'creatable': - if ( !User::isCreatableName( $name ) ) { + if ( !self::isCreatableName( $name ) ) { $name = false; } break; @@ -1591,7 +1591,7 @@ class User implements IDBAccessObject { // since extensions may change the set of searchable namespaces depending // on user groups/permissions. foreach ( $wgNamespacesToBeSearchedDefault as $nsnum => $val ) { - $defOpt['searchNs' . $nsnum] = (boolean)$val; + $defOpt['searchNs' . $nsnum] = (bool)$val; } $defOpt['skin'] = Skin::normalizeKey( $wgDefaultSkin ); @@ -2212,7 +2212,7 @@ class User implements IDBAccessObject { * @return int The user's ID; 0 if the user is anonymous or nonexistent */ public function getId() { - if ( $this->mId === null && $this->mName !== null && User::isIP( $this->mName ) ) { + if ( $this->mId === null && $this->mName !== null && self::isIP( $this->mName ) ) { // Special case, we know the user is anonymous return 0; } elseif ( !$this->isItemLoaded( 'id' ) ) { @@ -4131,7 +4131,7 @@ class User implements IDBAccessObject { } $dbw->insert( 'user', $fields, __METHOD__, [ 'IGNORE' ] ); if ( $dbw->affectedRows() ) { - $newUser = User::newFromId( $dbw->insertId() ); + $newUser = self::newFromId( $dbw->insertId() ); } else { $newUser = null; } @@ -5036,7 +5036,7 @@ class User implements IDBAccessObject { // Do nothing } elseif ( $wgGroupsAddToSelf[$group] === true ) { // No idea WHY this would be used, but it's there - $groups['add-self'] = User::getAllGroups(); + $groups['add-self'] = self::getAllGroups(); } elseif ( is_array( $wgGroupsAddToSelf[$group] ) ) { $groups['add-self'] = $wgGroupsAddToSelf[$group]; } @@ -5044,7 +5044,7 @@ class User implements IDBAccessObject { if ( empty( $wgGroupsRemoveFromSelf[$group] ) ) { // Do nothing } elseif ( $wgGroupsRemoveFromSelf[$group] === true ) { - $groups['remove-self'] = User::getAllGroups(); + $groups['remove-self'] = self::getAllGroups(); } elseif ( is_array( $wgGroupsRemoveFromSelf[$group] ) ) { $groups['remove-self'] = $wgGroupsRemoveFromSelf[$group]; } @@ -5065,7 +5065,7 @@ class User implements IDBAccessObject { // compatibility with old "userrights lets you change // everything") // Using array_merge to make the groups reindexed - $all = array_merge( User::getAllGroups() ); + $all = array_merge( self::getAllGroups() ); return [ 'add' => $all, 'remove' => $all, @@ -5491,7 +5491,7 @@ class User implements IDBAccessObject { global $wgLang; $groups = []; - foreach ( User::getGroupsWithPermission( $permission ) as $group ) { + foreach ( self::getGroupsWithPermission( $permission ) as $group ) { $groups[] = UserGroupMembership::getLink( $group, RequestContext::getMain(), 'wiki' ); } diff --git a/languages/Language.php b/languages/Language.php index 83dff65aba9c..12f26c3b9fa7 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -208,11 +208,11 @@ class Language { * @return Language */ protected static function newFromCode( $code, $fallback = false ) { - if ( !Language::isValidCode( $code ) ) { + if ( !self::isValidCode( $code ) ) { throw new MWException( "Invalid language code \"$code\"" ); } - if ( !Language::isValidBuiltInCode( $code ) ) { + if ( !self::isValidBuiltInCode( $code ) ) { // It's not possible to customise this code with class files, so // just return a Language object. This is to support uselang= hacks. $lang = new Language; @@ -228,9 +228,9 @@ class Language { } // Keep trying the fallback list until we find an existing class - $fallbacks = Language::getFallbacksFor( $code ); + $fallbacks = self::getFallbacksFor( $code ); foreach ( $fallbacks as $fallbackCode ) { - if ( !Language::isValidBuiltInCode( $fallbackCode ) ) { + if ( !self::isValidBuiltInCode( $fallbackCode ) ) { throw new MWException( "Invalid fallback '$fallbackCode' in fallback sequence for '$code'" ); } @@ -829,7 +829,7 @@ class Language { global $wgExtraLanguageNames, $wgUsePigLatinVariant; // If passed an invalid language code to use, fallback to en - if ( $inLanguage !== null && !Language::isValidCode( $inLanguage ) ) { + if ( $inLanguage !== null && !self::isValidCode( $inLanguage ) ) { $inLanguage = 'en'; } @@ -1192,7 +1192,7 @@ class Language { case 'D': $usedDay = true; $s .= $this->getWeekdayAbbreviation( - Language::dateTimeObjFormat( $dateTimeObj, $ts, $zone, 'w' ) + 1 + self::dateTimeObjFormat( $dateTimeObj, $ts, $zone, 'w' ) + 1 ); break; case 'j': @@ -1223,7 +1223,7 @@ class Language { case 'l': $usedDay = true; $s .= $this->getWeekdayName( - Language::dateTimeObjFormat( $dateTimeObj, $ts, $zone, 'w' ) + 1 + self::dateTimeObjFormat( $dateTimeObj, $ts, $zone, 'w' ) + 1 ); break; case 'F': @@ -1404,36 +1404,36 @@ class Language { case 'O': case 'P': case 'T': - $s .= Language::dateTimeObjFormat( $dateTimeObj, $ts, $zone, $code ); + $s .= self::dateTimeObjFormat( $dateTimeObj, $ts, $zone, $code ); break; case 'w': case 'N': case 'z': $usedDay = true; - $num = Language::dateTimeObjFormat( $dateTimeObj, $ts, $zone, $code ); + $num = self::dateTimeObjFormat( $dateTimeObj, $ts, $zone, $code ); break; case 'W': $usedWeek = true; - $num = Language::dateTimeObjFormat( $dateTimeObj, $ts, $zone, $code ); + $num = self::dateTimeObjFormat( $dateTimeObj, $ts, $zone, $code ); break; case 't': $usedMonth = true; - $num = Language::dateTimeObjFormat( $dateTimeObj, $ts, $zone, $code ); + $num = self::dateTimeObjFormat( $dateTimeObj, $ts, $zone, $code ); break; case 'L': $usedIsLeapYear = true; - $num = Language::dateTimeObjFormat( $dateTimeObj, $ts, $zone, $code ); + $num = self::dateTimeObjFormat( $dateTimeObj, $ts, $zone, $code ); break; case 'o': $usedISOYear = true; - $num = Language::dateTimeObjFormat( $dateTimeObj, $ts, $zone, $code ); + $num = self::dateTimeObjFormat( $dateTimeObj, $ts, $zone, $code ); break; case 'U': $usedSecond = true; // fall through case 'I': case 'Z': - $num = Language::dateTimeObjFormat( $dateTimeObj, $ts, $zone, $code ); + $num = self::dateTimeObjFormat( $dateTimeObj, $ts, $zone, $code ); break; case '\\': # Backslash escaping @@ -1467,7 +1467,7 @@ class Language { $s .= $num; $raw = false; } elseif ( $roman ) { - $s .= Language::romanNumeral( $num ); + $s .= self::romanNumeral( $num ); $roman = false; } elseif ( $hebrewNum ) { $s .= self::hebrewNumeral( $num ); @@ -1509,7 +1509,7 @@ class Language { substr( $ts, 10, 2 ) * 60 - substr( $ts, 12, 2 ); if ( $usedWeek ) { $possibleTtls[] = - ( 7 - Language::dateTimeObjFormat( $dateTimeObj, $ts, $zone, 'N' ) ) * 86400 + + ( 7 - self::dateTimeObjFormat( $dateTimeObj, $ts, $zone, 'N' ) ) * 86400 + $timeRemainingInDay; } elseif ( $usedISOYear ) { // December 28th falls on the last ISO week of the year, every year. @@ -1519,29 +1519,29 @@ class Language { substr( $ts, 0, 4 ) . '1228', $zone ?: new DateTimeZone( 'UTC' ) )->format( 'W' ); - $currentISOWeek = Language::dateTimeObjFormat( $dateTimeObj, $ts, $zone, 'W' ); + $currentISOWeek = self::dateTimeObjFormat( $dateTimeObj, $ts, $zone, 'W' ); $weeksRemaining = $lastWeekOfISOYear - $currentISOWeek; $timeRemainingInWeek = - ( 7 - Language::dateTimeObjFormat( $dateTimeObj, $ts, $zone, 'N' ) ) * 86400 + ( 7 - self::dateTimeObjFormat( $dateTimeObj, $ts, $zone, 'N' ) ) * 86400 + $timeRemainingInDay; $possibleTtls[] = $weeksRemaining * 604800 + $timeRemainingInWeek; } if ( $usedMonth ) { $possibleTtls[] = - ( Language::dateTimeObjFormat( $dateTimeObj, $ts, $zone, 't' ) - + ( self::dateTimeObjFormat( $dateTimeObj, $ts, $zone, 't' ) - substr( $ts, 6, 2 ) ) * 86400 + $timeRemainingInDay; } elseif ( $usedYear ) { $possibleTtls[] = - ( Language::dateTimeObjFormat( $dateTimeObj, $ts, $zone, 'L' ) + 364 - - Language::dateTimeObjFormat( $dateTimeObj, $ts, $zone, 'z' ) ) * 86400 + ( self::dateTimeObjFormat( $dateTimeObj, $ts, $zone, 'L' ) + 364 - + self::dateTimeObjFormat( $dateTimeObj, $ts, $zone, 'z' ) ) * 86400 + $timeRemainingInDay; } elseif ( $usedIsLeapYear ) { $year = substr( $ts, 0, 4 ); $timeRemainingInYear = - ( Language::dateTimeObjFormat( $dateTimeObj, $ts, $zone, 'L' ) + 364 - - Language::dateTimeObjFormat( $dateTimeObj, $ts, $zone, 'z' ) ) * 86400 + ( self::dateTimeObjFormat( $dateTimeObj, $ts, $zone, 'L' ) + 364 - + self::dateTimeObjFormat( $dateTimeObj, $ts, $zone, 'z' ) ) * 86400 + $timeRemainingInDay; $mod = $year % 4; if ( $mod || ( !( $year % 100 ) && $year % 400 ) ) { @@ -3956,7 +3956,7 @@ class Language { * @return string Text, wrapped in LRE...PDF or RLE...PDF or nothing */ public function embedBidi( $text = '' ) { - $dir = Language::strongDirFromContent( $text ); + $dir = self::strongDirFromContent( $text ); if ( $dir === 'ltr' ) { // Wrap in LEFT-TO-RIGHT EMBEDDING ... POP DIRECTIONAL FORMATTING return self::$lre . $text . self::$pdf; @@ -4264,7 +4264,7 @@ class Language { $this->mParentLanguage = null; return null; } - $lang = Language::factory( $code ); + $lang = self::factory( $code ); if ( !$lang->hasVariant( $this->getCode() ) ) { $this->mParentLanguage = null; return null; @@ -4420,7 +4420,7 @@ class Language { * @return array Non-empty array, ending in "en" */ public static function getFallbacksFor( $code ) { - if ( $code === 'en' || !Language::isValidBuiltInCode( $code ) ) { + if ( $code === 'en' || !self::isValidBuiltInCode( $code ) ) { return []; } // For unknown languages, fallbackSequence returns an empty array, @@ -4821,7 +4821,7 @@ class Language { */ public function getCompiledPluralRules() { $pluralRules = self::$dataCache->getItem( strtolower( $this->mCode ), 'compiledPluralRules' ); - $fallbacks = Language::getFallbacksFor( $this->mCode ); + $fallbacks = self::getFallbacksFor( $this->mCode ); if ( !$pluralRules ) { foreach ( $fallbacks as $fallbackCode ) { $pluralRules = self::$dataCache->getItem( strtolower( $fallbackCode ), 'compiledPluralRules' ); @@ -4840,7 +4840,7 @@ class Language { */ public function getPluralRules() { $pluralRules = self::$dataCache->getItem( strtolower( $this->mCode ), 'pluralRules' ); - $fallbacks = Language::getFallbacksFor( $this->mCode ); + $fallbacks = self::getFallbacksFor( $this->mCode ); if ( !$pluralRules ) { foreach ( $fallbacks as $fallbackCode ) { $pluralRules = self::$dataCache->getItem( strtolower( $fallbackCode ), 'pluralRules' ); @@ -4859,7 +4859,7 @@ class Language { */ public function getPluralRuleTypes() { $pluralRuleTypes = self::$dataCache->getItem( strtolower( $this->mCode ), 'pluralRuleTypes' ); - $fallbacks = Language::getFallbacksFor( $this->mCode ); + $fallbacks = self::getFallbacksFor( $this->mCode ); if ( !$pluralRuleTypes ) { foreach ( $fallbacks as $fallbackCode ) { $pluralRuleTypes = self::$dataCache->getItem( strtolower( $fallbackCode ), 'pluralRuleTypes' ); diff --git a/maintenance/Maintenance.php b/maintenance/Maintenance.php index 478a0c41ae88..04565f245068 100644 --- a/maintenance/Maintenance.php +++ b/maintenance/Maintenance.php @@ -344,7 +344,7 @@ abstract class Maintenance { * @return mixed */ protected function getStdin( $len = null ) { - if ( $len == Maintenance::STDIN_ALL ) { + if ( $len == self::STDIN_ALL ) { return file_get_contents( 'php://stdin' ); } $f = fopen( 'php://stdin', 'rt' ); @@ -457,7 +457,7 @@ abstract class Maintenance { * @return int */ public function getDbType() { - return Maintenance::DB_STD; + return self::DB_STD; } /** diff --git a/maintenance/sqlite.inc b/maintenance/sqlite.inc index 117e9cc4b0af..f14856a5b21b 100644 --- a/maintenance/sqlite.inc +++ b/maintenance/sqlite.inc @@ -48,7 +48,7 @@ class Sqlite { * @return bool True if no error or error string in case of errors */ public static function checkSqlSyntax( $files ) { - if ( !Sqlite::isPresent() ) { + if ( !self::isPresent() ) { throw new MWException( "Can't check SQL syntax: SQLite not found" ); } if ( !is_array( $files ) ) { diff --git a/maintenance/userOptions.inc b/maintenance/userOptions.inc index 5d773d14263d..01cf3c3eb1c0 100644 --- a/maintenance/userOptions.inc +++ b/maintenance/userOptions.inc @@ -47,7 +47,7 @@ class UserOptions { */ function __construct( $opts, $args ) { if ( !$this->checkOpts( $opts, $args ) ) { - UserOptions::showUsageAndExit(); + self::showUsageAndExit(); } else { $this->mReady = $this->initializeOpts( $opts, $args ); } diff --git a/phpcs.xml b/phpcs.xml index 8cab639a3b08..d2e4fcc5f04e 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -46,11 +46,8 @@ <arg name="bootstrap" value="vendor/mediawiki/mediawiki-codesniffer/utils/bootstrap-ci.php"/> <arg name="encoding" value="UTF-8"/> <arg name="extensions" value="php,php5,inc,sample"/> - <exclude-pattern>node_modules/</exclude-pattern> - <exclude-pattern>vendor/</exclude-pattern> <exclude-pattern type="relative">^extensions/</exclude-pattern> <exclude-pattern type="relative">^skins/</exclude-pattern> - <exclude-pattern>\.git</exclude-pattern> <exclude-pattern>AdminSettings\.php</exclude-pattern> <exclude-pattern>LocalSettings\.php</exclude-pattern> <exclude-pattern>StartProfiler\.php</exclude-pattern> diff --git a/tests/parser/ParserTestRunner.php b/tests/parser/ParserTestRunner.php index 9255733e7498..8615edcd378f 100644 --- a/tests/parser/ParserTestRunner.php +++ b/tests/parser/ParserTestRunner.php @@ -168,7 +168,7 @@ class ParserTestRunner { global $wgParserTestFiles; // Add core test files - $files = array_map( function( $item ) { + $files = array_map( function ( $item ) { return __DIR__ . "/$item"; }, self::$coreTestFiles ); diff --git a/tests/phpunit/includes/DeprecatedGlobalTest.php b/tests/phpunit/includes/DeprecatedGlobalTest.php index 76a4f515dd2f..802f9b14807a 100644 --- a/tests/phpunit/includes/DeprecatedGlobalTest.php +++ b/tests/phpunit/includes/DeprecatedGlobalTest.php @@ -39,7 +39,7 @@ class DeprecatedGlobalTest extends MediaWikiTestCase { global $wgDummyLazy; $called = false; - $factory = function() use ( &$called ) { + $factory = function () use ( &$called ) { $called = true; return new HashBagOStuff(); }; diff --git a/tests/phpunit/includes/PreferencesTest.php b/tests/phpunit/includes/PreferencesTest.php index ada516d554cf..d78c1e7dc07d 100644 --- a/tests/phpunit/includes/PreferencesTest.php +++ b/tests/phpunit/includes/PreferencesTest.php @@ -131,10 +131,9 @@ class PreferencesTest extends MediaWikiTestCase { ->method( 'getConfig' ) ->willReturn( $configMock ); - $this->setTemporaryHook( 'PreferencesFormPreSave', function( + $this->setTemporaryHook( 'PreferencesFormPreSave', function ( $formData, $form, $user, &$result, $oldUserOptions ) use ( $newOptions, $oldOptions, $userMock ) { - $this->assertSame( $userMock, $user ); foreach ( $newOptions as $option => $value ) { $this->assertSame( $value, $formData[ $option ] ); diff --git a/tests/phpunit/includes/content/WikitextContentTest.php b/tests/phpunit/includes/content/WikitextContentTest.php index b9ce997f233d..d0996e3cfc91 100644 --- a/tests/phpunit/includes/content/WikitextContentTest.php +++ b/tests/phpunit/includes/content/WikitextContentTest.php @@ -103,16 +103,16 @@ more stuff public static function dataGetSection() { return [ - [ WikitextContentTest::$sections, + [ self::$sections, "0", "Intro" ], - [ WikitextContentTest::$sections, + [ self::$sections, "2", "== test == just a test" ], - [ WikitextContentTest::$sections, + [ self::$sections, "8", false ], @@ -138,38 +138,38 @@ just a test" public static function dataReplaceSection() { return [ - [ WikitextContentTest::$sections, + [ self::$sections, "0", "No more", null, - trim( preg_replace( '/^Intro/sm', 'No more', WikitextContentTest::$sections ) ) + trim( preg_replace( '/^Intro/sm', 'No more', self::$sections ) ) ], - [ WikitextContentTest::$sections, + [ self::$sections, "", "No more", null, "No more" ], - [ WikitextContentTest::$sections, + [ self::$sections, "2", "== TEST ==\nmore fun", null, trim( preg_replace( '/^== test ==.*== foo ==/sm', "== TEST ==\nmore fun\n\n== foo ==", - WikitextContentTest::$sections + self::$sections ) ) ], - [ WikitextContentTest::$sections, + [ self::$sections, "8", "No more", null, - WikitextContentTest::$sections + self::$sections ], - [ WikitextContentTest::$sections, + [ self::$sections, "new", "No more", "New", - trim( WikitextContentTest::$sections ) . "\n\n\n== New ==\n\nNo more" + trim( self::$sections ) . "\n\n\n== New ==\n\nNo more" ], ]; } diff --git a/tests/phpunit/includes/page/WikiPageTest.php b/tests/phpunit/includes/page/WikiPageTest.php index 556a34813c8e..3079d8f22789 100644 --- a/tests/phpunit/includes/page/WikiPageTest.php +++ b/tests/phpunit/includes/page/WikiPageTest.php @@ -625,15 +625,15 @@ more stuff return [ [ 'Help:WikiPageTest_testReplaceSection', CONTENT_MODEL_WIKITEXT, - WikiPageTest::$sections, + self::$sections, "0", "No more", null, - trim( preg_replace( '/^Intro/sm', 'No more', WikiPageTest::$sections ) ) + trim( preg_replace( '/^Intro/sm', 'No more', self::$sections ) ) ], [ 'Help:WikiPageTest_testReplaceSection', CONTENT_MODEL_WIKITEXT, - WikiPageTest::$sections, + self::$sections, "", "No more", null, @@ -641,29 +641,29 @@ more stuff ], [ 'Help:WikiPageTest_testReplaceSection', CONTENT_MODEL_WIKITEXT, - WikiPageTest::$sections, + self::$sections, "2", "== TEST ==\nmore fun", null, trim( preg_replace( '/^== test ==.*== foo ==/sm', "== TEST ==\nmore fun\n\n== foo ==", - WikiPageTest::$sections ) ) + self::$sections ) ) ], [ 'Help:WikiPageTest_testReplaceSection', CONTENT_MODEL_WIKITEXT, - WikiPageTest::$sections, + self::$sections, "8", "No more", null, - trim( WikiPageTest::$sections ) + trim( self::$sections ) ], [ 'Help:WikiPageTest_testReplaceSection', CONTENT_MODEL_WIKITEXT, - WikiPageTest::$sections, + self::$sections, "new", "No more", "New", - trim( WikiPageTest::$sections ) . "\n\n== New ==\n\nNo more" + trim( self::$sections ) . "\n\n== New ==\n\nNo more" ], ]; } diff --git a/tests/phpunit/includes/site/TestSites.php b/tests/phpunit/includes/site/TestSites.php index 6597906e51a2..39c34217e8d1 100644 --- a/tests/phpunit/includes/site/TestSites.php +++ b/tests/phpunit/includes/site/TestSites.php @@ -109,6 +109,6 @@ class TestSites { public static function insertIntoDb() { $sitesTable = \MediaWiki\MediaWikiServices::getInstance()->getSiteStore(); $sitesTable->clear(); - $sitesTable->saveSites( TestSites::getSites() ); + $sitesTable->saveSites( self::getSites() ); } } |