diff --git a/includes/AFComputedVariable.php b/includes/AFComputedVariable.php index 9c242538e..a777470b2 100644 --- a/includes/AFComputedVariable.php +++ b/includes/AFComputedVariable.php @@ -23,11 +23,11 @@ class AFComputedVariable { * * * @param string $wikitext - * @param Article $article + * @param WikiPage $article * * @return object */ - public function parseNonEditWikitext( $wikitext, $article ) { + public function parseNonEditWikitext( $wikitext, WikiPage $article ) { static $cache = []; $cacheKey = md5( $wikitext ) . ':' . $article->getTitle()->getPrefixedText(); @@ -93,9 +93,9 @@ class AFComputedVariable { /** * @param int $namespace * @param string $title - * @return Article + * @return WikiPage */ - public static function articleFromTitle( $namespace, $title ) { + public static function pageFromTitle( $namespace, $title ) { if ( isset( self::$articleCache["$namespace:$title"] ) ) { return self::$articleCache["$namespace:$title"]; } @@ -105,20 +105,19 @@ class AFComputedVariable { } $logger = LoggerFactory::getInstance( 'AbuseFilter' ); - $logger->debug( "Creating article object for $namespace:$title in cache" ); + $logger->debug( "Creating wikipage object for $namespace:$title in cache" ); - // TODO: use WikiPage instead! $t = Title::makeTitle( $namespace, $title ); - self::$articleCache["$namespace:$title"] = new Article( $t ); + self::$articleCache["$namespace:$title"] = WikiPage::factory( $t ); return self::$articleCache["$namespace:$title"]; } /** - * @param Article $article + * @param WikiPage $article * @return array */ - public static function getLinksFromDB( $article ) { + public static function getLinksFromDB( WikiPage $article ) { // Stolen from ConfirmEdit, SimpleCaptcha::getLinksFromTracker $id = $article->getId(); if ( !$id ) { @@ -145,7 +144,7 @@ class AFComputedVariable { * @throws MWException * @throws AFPException */ - public function compute( $vars ) { + public function compute( AbuseFilterVariableHolder $vars ) { $parameters = $this->mParameters; $result = null; @@ -201,7 +200,7 @@ class AFComputedVariable { if ( isset( $parameters['article'] ) ) { $article = $parameters['article']; } else { - $article = self::articleFromTitle( + $article = self::pageFromTitle( $parameters['namespace'], $parameters['title'] ); @@ -219,8 +218,8 @@ class AFComputedVariable { // Otherwise fall back to database case 'links-from-wikitext-nonedit': case 'links-from-wikitext-or-database': - // TODO: use Content object instead, if available! In any case, use WikiPage, not Article. - $article = self::articleFromTitle( + // TODO: use Content object instead, if available! + $article = self::pageFromTitle( $parameters['namespace'], $parameters['title'] ); @@ -268,7 +267,7 @@ class AFComputedVariable { if ( isset( $parameters['article'] ) ) { $article = $parameters['article']; } else { - $article = self::articleFromTitle( + $article = self::pageFromTitle( $parameters['namespace'], $parameters['title'] ); @@ -291,8 +290,8 @@ class AFComputedVariable { } // Otherwise fall back to database case 'parse-wikitext-nonedit': - // TODO: use Content object instead, if available! In any case, use WikiPage, not Article. - $article = self::articleFromTitle( $parameters['namespace'], $parameters['title'] ); + // TODO: use Content object instead, if available! + $article = self::pageFromTitle( $parameters['namespace'], $parameters['title'] ); $textVar = $parameters['wikitext-var']; if ( $article->getContentModel() === CONTENT_MODEL_WIKITEXT ) { diff --git a/includes/AbuseFilter.php b/includes/AbuseFilter.php index 6c4efbfcd..e196c692b 100644 --- a/includes/AbuseFilter.php +++ b/includes/AbuseFilter.php @@ -269,7 +269,7 @@ class AbuseFilter { * @param User $user * @return AbuseFilterVariableHolder */ - public static function generateUserVars( $user ) { + public static function generateUserVars( User $user ) { $vars = new AbuseFilterVariableHolder; $vars->setLazyLoadVar( @@ -506,7 +506,7 @@ class AbuseFilter { * @throws Exception */ public static function checkConditions( - $conds, $vars, $ignoreError = true + $conds, AbuseFilterVariableHolder $vars, $ignoreError = true ) { global $wgAbuseFilterParserClass; @@ -545,7 +545,7 @@ class AbuseFilter { * @return bool[] Map of (integer filter ID => bool) */ public static function checkAllFilters( - $vars, + AbuseFilterVariableHolder $vars, $group = 'default', Title $title = null, $mode = 'execute' @@ -648,7 +648,7 @@ class AbuseFilter { */ public static function checkFilter( $row, - $vars, + AbuseFilterVariableHolder $vars, Title $title = null, $prefix = '', $mode = 'execute' @@ -854,7 +854,7 @@ class AbuseFilter { * @param string $prefix * @return array[] */ - public static function loadConsequencesFromDB( $dbr, $filters, $prefix = '' ) { + public static function loadConsequencesFromDB( IDatabase $dbr, $filters, $prefix = '' ) { $actionsByFilter = []; foreach ( $filters as $filter ) { $actionsByFilter[$prefix . $filter] = []; @@ -901,7 +901,12 @@ class AbuseFilter { * an array listing the actions taken. $status->getErrors() etc. will provide * the errors and warnings to be shown to the user to explain the actions. */ - public static function executeFilterActions( $filters, $title, $vars, User $user ) { + public static function executeFilterActions( + $filters, + Title $title, + AbuseFilterVariableHolder $vars, + User $user + ) { global $wgMainCacheType; $actionsByFilter = self::getConsequencesForFilters( $filters ); @@ -1294,7 +1299,12 @@ class AbuseFilter { * @param AbuseFilterVariableHolder $vars * @param string $group The filter's group (as defined in $wgAbuseFilterValidGroups) */ - public static function addLogEntries( $actions_taken, $log_template, $vars, $group = 'default' ) { + public static function addLogEntries( + $actions_taken, + $log_template, + AbuseFilterVariableHolder $vars, + $group = 'default' + ) { $dbw = wfGetDB( DB_MASTER ); $central_log_template = [ @@ -1447,7 +1457,7 @@ class AbuseFilter { * * @return int|null */ - public static function storeVarDump( $vars, $global = false ) { + public static function storeVarDump( AbuseFilterVariableHolder $vars, $global = false ) { global $wgCompressRevisions; // Get all variables yet set and compute old and new wikitext if not yet done @@ -1579,8 +1589,15 @@ class AbuseFilter { * or null if no action was taken. The message is given as an array * containing the message key followed by any message parameters. */ - public static function takeConsequenceAction( $action, $parameters, $title, - $vars, $rule_desc, $rule_number, User $user ) { + public static function takeConsequenceAction( + $action, + $parameters, + Title $title, + AbuseFilterVariableHolder $vars, + $rule_desc, + $rule_number, + User $user + ) { global $wgAbuseFilterCustomActionsHandlers, $wgRequest; $message = null; @@ -1808,7 +1825,7 @@ class AbuseFilter { * @param bool $global * @return bool */ - public static function isThrottled( $throttleId, $types, $title, $rateCount, + public static function isThrottled( $throttleId, $types, Title $title, $rateCount, $ratePeriod, $global = false ) { $stash = ObjectCache::getMainStashInstance(); @@ -1846,7 +1863,7 @@ class AbuseFilter { * @param Title $title * @return int|string */ - public static function throttleIdentifier( $type, $title ) { + public static function throttleIdentifier( $type, Title $title ) { global $wgUser, $wgRequest; switch ( $type ) { @@ -1887,7 +1904,7 @@ class AbuseFilter { * @param bool $global * @return string */ - public static function throttleKey( $throttleId, $type, $title, $global = false ) { + public static function throttleKey( $throttleId, $type, Title $title, $global = false ) { $types = explode( ',', $type ); $identifiers = []; @@ -1929,7 +1946,7 @@ class AbuseFilter { * @param User $user * @return string */ - public static function autoPromoteBlockKey( $user ) { + public static function autoPromoteBlockKey( User $user ) { $cache = MediaWikiServices::getInstance()->getMainWANObjectCache(); return $cache->makeKey( 'abusefilter', 'block-autopromote', $user->getId() ); @@ -2294,7 +2311,13 @@ class AbuseFilter { * @param array $actions * @return Status */ - public static function saveFilter( $page, $filter, $request, $newRow, $actions ) { + public static function saveFilter( + AbuseFilterViewEdit $page, + $filter, + $request, + $newRow, + $actions + ) { $validationStatus = Status::newGood(); // Check the syntax @@ -2420,7 +2443,7 @@ class AbuseFilter { $filter, $actions, $wasGlobal, - $page + AbuseFilterViewEdit $page ) { $user = $page->getUser(); $dbw = wfGetDB( DB_MASTER ); @@ -2824,7 +2847,7 @@ class AbuseFilter { * @param Page|null $page * @return AbuseFilterVariableHolder */ - public static function getEditVars( $title, Page $page = null ) { + public static function getEditVars( Title $title = null, Page $page = null ) { $vars = new AbuseFilterVariableHolder; // NOTE: $page may end up remaining null, e.g. if $title points to a special page. @@ -3116,8 +3139,9 @@ class AbuseFilter { * @return string|null the content of the revision as some kind of string, * or an empty string if it can not be found */ - public static function revisionToString( $revision, $audience = Revision::FOR_THIS_USER ) { - if ( !$revision instanceof Revision ) { + public static function revisionToString( Revision $revision = null, + $audience = Revision::FOR_THIS_USER ) { + if ( !$revision ) { return ''; } diff --git a/includes/AbuseFilterHooks.php b/includes/AbuseFilterHooks.php index 20c07e4a4..06017dbe7 100644 --- a/includes/AbuseFilterHooks.php +++ b/includes/AbuseFilterHooks.php @@ -230,8 +230,8 @@ class AbuseFilterHooks { * @param int $baseRevId */ public static function onPageContentSaveComplete( - WikiPage $wikiPage, $user, $content, $summary, $minoredit, $watchthis, $sectionanchor, - $flags, $revision, $status, $baseRevId + WikiPage $wikiPage, User $user, $content, $summary, $minoredit, $watchthis, $sectionanchor, + $flags, Revision $revision, Status $status, $baseRevId ) { if ( !self::$successful_action_vars || !$revision ) { self::$successful_action_vars = false; @@ -300,7 +300,7 @@ class AbuseFilterHooks { * @param User $user * @param array &$promote */ - public static function onGetAutoPromoteGroups( $user, &$promote ) { + public static function onGetAutoPromoteGroups( User $user, &$promote ) { if ( $promote ) { $key = AbuseFilter::autoPromoteBlockKey( $user ); $blocked = (bool)ObjectCache::getInstance( 'hash' )->getWithSetCallback( @@ -351,7 +351,8 @@ class AbuseFilterHooks { * @param Status $status * @return bool */ - public static function onArticleDelete( $article, $user, $reason, &$error, $status ) { + public static function onArticleDelete( WikiPage $article, User $user, $reason, &$error, + Status $status ) { $vars = new AbuseFilterVariableHolder; $vars->addHolders( @@ -373,7 +374,7 @@ class AbuseFilterHooks { /** * @param RecentChange $recentChange */ - public static function onRecentChangeSave( $recentChange ) { + public static function onRecentChangeSave( RecentChange $recentChange ) { $title = Title::makeTitle( $recentChange->getAttribute( 'rc_namespace' ), $recentChange->getAttribute( 'rc_title' ) @@ -659,7 +660,7 @@ class AbuseFilterHooks { * Updater callback to create the AbuseFilter user after the user tables have been updated. * @param DatabaseUpdater $updater */ - public static function createAbuseFilterUser( $updater ) { + public static function createAbuseFilterUser( DatabaseUpdater $updater ) { $username = wfMessage( 'abusefilter-blocker' )->inContentLanguage()->text(); $user = User::newFromName( $username ); @@ -677,7 +678,7 @@ class AbuseFilterHooks { * @param array &$tools * @param SpecialPage $sp for context */ - public static function onContributionsToolLinks( $id, $nt, array &$tools, SpecialPage $sp ) { + public static function onContributionsToolLinks( $id, Title $nt, array &$tools, SpecialPage $sp ) { $username = $nt->getText(); if ( $sp->getUser()->isAllowed( 'abusefilter-log' ) && !IP::isValidRange( $username ) ) { $linkRenderer = $sp->getLinkRenderer(); diff --git a/includes/Views/AbuseFilterView.php b/includes/Views/AbuseFilterView.php index 9b0193357..2e2a22520 100644 --- a/includes/Views/AbuseFilterView.php +++ b/includes/Views/AbuseFilterView.php @@ -14,7 +14,7 @@ abstract class AbuseFilterView extends ContextSource { * @param SpecialAbuseFilter $page * @param array $params */ - public function __construct( $page, $params ) { + public function __construct( SpecialAbuseFilter $page, $params ) { $this->mPage = $page; $this->mParams = $params; $this->setContext( $this->mPage->getContext() ); diff --git a/includes/Views/AbuseFilterViewEdit.php b/includes/Views/AbuseFilterViewEdit.php index 866a2fdbb..2e9160fb5 100644 --- a/includes/Views/AbuseFilterViewEdit.php +++ b/includes/Views/AbuseFilterViewEdit.php @@ -6,7 +6,7 @@ class AbuseFilterViewEdit extends AbuseFilterView { * @param SpecialAbuseFilter $page * @param array $params */ - public function __construct( $page, $params ) { + public function __construct( SpecialAbuseFilter $page, $params ) { parent::__construct( $page, $params ); $this->mFilter = $page->mFilter; $this->mHistoryID = $page->mHistoryID; diff --git a/includes/Views/AbuseFilterViewHistory.php b/includes/Views/AbuseFilterViewHistory.php index 66a14a562..454ced764 100644 --- a/includes/Views/AbuseFilterViewHistory.php +++ b/includes/Views/AbuseFilterViewHistory.php @@ -5,7 +5,7 @@ class AbuseFilterViewHistory extends AbuseFilterView { * @param SpecialAbuseFilter $page * @param array $params */ - public function __construct( $page, $params ) { + public function __construct( SpecialAbuseFilter $page, $params ) { parent::__construct( $page, $params ); $this->mFilter = $page->mFilter; } diff --git a/includes/api/ApiQueryAbuseFilters.php b/includes/api/ApiQueryAbuseFilters.php index cafe20d10..d4357744b 100644 --- a/includes/api/ApiQueryAbuseFilters.php +++ b/includes/api/ApiQueryAbuseFilters.php @@ -34,7 +34,7 @@ class ApiQueryAbuseFilters extends ApiQueryBase { * @param ApiQuery $query * @param string $moduleName */ - public function __construct( $query, $moduleName ) { + public function __construct( ApiQuery $query, $moduleName ) { parent::__construct( $query, $moduleName, 'abf' ); } diff --git a/includes/api/ApiQueryAbuseLog.php b/includes/api/ApiQueryAbuseLog.php index c7f87751d..5ddc8ccb6 100644 --- a/includes/api/ApiQueryAbuseLog.php +++ b/includes/api/ApiQueryAbuseLog.php @@ -34,7 +34,7 @@ class ApiQueryAbuseLog extends ApiQueryBase { * @param ApiQuery $query * @param string $moduleName */ - public function __construct( $query, $moduleName ) { + public function __construct( ApiQuery $query, $moduleName ) { parent::__construct( $query, $moduleName, 'afl' ); } diff --git a/includes/pagers/AbuseFilterExaminePager.php b/includes/pagers/AbuseFilterExaminePager.php index 02b13755c..9a305a2a5 100644 --- a/includes/pagers/AbuseFilterExaminePager.php +++ b/includes/pagers/AbuseFilterExaminePager.php @@ -7,7 +7,7 @@ class AbuseFilterExaminePager extends ReverseChronologicalPager { * @param AbuseFilterViewExamine $page * @param AbuseFilterChangesList $changesList */ - public function __construct( $page, $changesList ) { + public function __construct( AbuseFilterViewExamine $page, AbuseFilterChangesList $changesList ) { parent::__construct(); $this->mChangesList = $changesList; $this->mPage = $page; diff --git a/includes/pagers/AbuseFilterHistoryPager.php b/includes/pagers/AbuseFilterHistoryPager.php index 265c97f1a..af14aa6ba 100644 --- a/includes/pagers/AbuseFilterHistoryPager.php +++ b/includes/pagers/AbuseFilterHistoryPager.php @@ -12,7 +12,8 @@ class AbuseFilterHistoryPager extends TablePager { * @param string $user User name * @param LinkRenderer $linkRenderer */ - public function __construct( $filter, $page, $user, $linkRenderer ) { + public function __construct( $filter, AbuseFilterViewHistory $page, $user, + LinkRenderer $linkRenderer ) { $this->mFilter = $filter; $this->mPage = $page; $this->mUser = $user; diff --git a/includes/pagers/AbuseFilterPager.php b/includes/pagers/AbuseFilterPager.php index 2092b8508..5f960c71b 100644 --- a/includes/pagers/AbuseFilterPager.php +++ b/includes/pagers/AbuseFilterPager.php @@ -20,7 +20,8 @@ class AbuseFilterPager extends TablePager { * @param LinkRenderer $linkRenderer * @param array $query */ - public function __construct( $page, $conds, $linkRenderer, $query ) { + public function __construct( AbuseFilterViewList $page, $conds, LinkRenderer $linkRenderer, + $query ) { $this->mPage = $page; $this->mConds = $conds; $this->linkRenderer = $linkRenderer; diff --git a/includes/pagers/AbuseLogPager.php b/includes/pagers/AbuseLogPager.php index 5c4f1a669..2c56cad9e 100644 --- a/includes/pagers/AbuseLogPager.php +++ b/includes/pagers/AbuseLogPager.php @@ -17,7 +17,7 @@ class AbuseLogPager extends ReverseChronologicalPager { * @param SpecialAbuseLog $form * @param array $conds */ - public function __construct( $form, $conds = [] ) { + public function __construct( SpecialAbuseLog $form, $conds = [] ) { $this->mForm = $form; $this->mConds = $conds; parent::__construct(); diff --git a/includes/pagers/GlobalAbuseFilterPager.php b/includes/pagers/GlobalAbuseFilterPager.php index 7db965e4b..983e912eb 100644 --- a/includes/pagers/GlobalAbuseFilterPager.php +++ b/includes/pagers/GlobalAbuseFilterPager.php @@ -11,7 +11,7 @@ class GlobalAbuseFilterPager extends AbuseFilterPager { * @param array $conds * @param LinkRenderer $linkRenderer */ - public function __construct( $page, $conds, $linkRenderer ) { + public function __construct( AbuseFilterViewList $page, $conds, LinkRenderer $linkRenderer ) { parent::__construct( $page, $conds, $linkRenderer, [ '', 'LIKE' ] ); $this->mDb = wfGetDB( DB_REPLICA, [], $this->getConfig()->get( 'AbuseFilterCentralDB' ) ); diff --git a/includes/parser/AFPParserState.php b/includes/parser/AFPParserState.php index 453948d18..ee345d942 100644 --- a/includes/parser/AFPParserState.php +++ b/includes/parser/AFPParserState.php @@ -7,7 +7,7 @@ class AFPParserState { * @param AFPToken $token * @param int $pos */ - public function __construct( $token, $pos ) { + public function __construct( AFPToken $token, $pos ) { $this->token = $token; $this->pos = $pos; } diff --git a/includes/special/SpecialAbuseLog.php b/includes/special/SpecialAbuseLog.php index ab2e2cbc2..f8d2d2d99 100644 --- a/includes/special/SpecialAbuseLog.php +++ b/includes/special/SpecialAbuseLog.php @@ -843,7 +843,7 @@ class SpecialAbuseLog extends SpecialPage { * @param User $user The user who accessed the private details * @return void */ - public static function addLogEntry( $logID, $reason, $user ) { + public static function addLogEntry( $logID, $reason, User $user ) { $target = self::getTitleFor( 'AbuseLog', $logID ); $logEntry = new ManualLogEntry( 'abusefilterprivatedetails', 'access' );