From a063e33ee8f7a56514aa07d94ace88430cbce5a9 Mon Sep 17 00:00:00 2001 From: Umherirrender Date: Thu, 15 Jun 2017 16:23:34 +0200 Subject: [PATCH] Use short array syntax Done by phpcbf over composer fix Change-Id: I53fd1fc8d056b9b60194d2d630852cfca37aadea --- AbuseFilter.hooks.php | 168 ++++----- includes/AFComputedVariable.php | 42 +-- includes/AbuseFilter.class.php | 350 +++++++++---------- includes/AbuseFilterVariableHolder.php | 22 +- includes/AbuseLogHitFormatter.php | 2 +- includes/parser/AFPData.php | 14 +- includes/parser/AFPTreeParser.php | 6 +- includes/parser/AFPUserVisibleException.php | 2 +- includes/parser/AbuseFilterCachingParser.php | 10 +- includes/parser/AbuseFilterParser.php | 140 ++++---- includes/parser/AbuseFilterTokenizer.php | 32 +- maintenance/addMissingLoggingEntries.php | 24 +- maintenance/purgeOldLogIPData.php | 10 +- phpcs.xml | 4 +- special/SpecialAbuseFilter.php | 4 +- special/SpecialAbuseLog.php | 112 +++--- tests/phpunit/parserTest.php | 24 +- 17 files changed, 482 insertions(+), 484 deletions(-) diff --git a/AbuseFilter.hooks.php b/AbuseFilter.hooks.php index 71750975f..7fb0d5c99 100644 --- a/AbuseFilter.hooks.php +++ b/AbuseFilter.hooks.php @@ -197,21 +197,21 @@ class AbuseFilterHooks { $code = ( $actionsTaken === [ 'warn' ] ) ? 'abusefilter-warning' : 'abusefilter-disallowed'; ApiResult::setIndexedTagName( $params, 'param' ); - return array( + return [ 'code' => $code, - 'message' => array( + 'message' => [ 'key' => $key, 'params' => $params, - ), - 'abusefilter' => array( + ], + 'abusefilter' => [ 'id' => $filter, 'description' => $filterDescription, 'actions' => $actionsTaken, - ), + ], // For backwards-compatibility 'info' => 'Hit AbuseFilter: ' . $filterDescription, 'warning' => $warning->parse(), - ); + ]; } /** @@ -259,8 +259,8 @@ class AbuseFilterHooks { if ( count( $log_ids ) ) { $dbw->update( 'abuse_filter_log', - array( 'afl_rev_id' => $revision->getId() ), - array( 'afl_id' => $log_ids ), + [ 'afl_rev_id' => $revision->getId() ], + [ 'afl_id' => $log_ids ], __METHOD__ ); } @@ -271,11 +271,11 @@ class AbuseFilterHooks { if ( count( $log_ids ) ) { global $wgAbuseFilterCentralDB; - $fdb = wfGetDB( DB_MASTER, array(), $wgAbuseFilterCentralDB ); + $fdb = wfGetDB( DB_MASTER, [], $wgAbuseFilterCentralDB ); $fdb->update( 'abuse_filter_log', - array( 'afl_rev_id' => $revision->getId() ), - array( 'afl_id' => $log_ids, 'afl_wiki' => wfWikiId() ), + [ 'afl_rev_id' => $revision->getId() ], + [ 'afl_id' => $log_ids, 'afl_wiki' => wfWikiId() ], __METHOD__ ); } @@ -318,7 +318,7 @@ class AbuseFilterHooks { ); if ( $blocked ) { - $promote = array(); + $promote = []; } } @@ -465,9 +465,9 @@ class AbuseFilterHooks { ); $action = $recentChange->mAttribs['rc_log_type'] ? $recentChange->mAttribs['rc_log_type'] : 'edit'; - $actionID = implode( '-', array( + $actionID = implode( '-', [ $title->getPrefixedText(), $recentChange->mAttribs['rc_user_text'], $action - ) ); + ] ); if ( isset( AbuseFilter::$tagsToSet[$actionID] ) ) { $recentChange->addTags( AbuseFilter::$tagsToSet[$actionID] ); @@ -487,17 +487,17 @@ class AbuseFilterHooks { # This is a pretty awful hack. $dbr = wfGetDB( DB_SLAVE ); - $where = array( 'afa_consequence' => 'tag', 'af_deleted' => false ); + $where = [ 'afa_consequence' => 'tag', 'af_deleted' => false ]; if ( $enabled ) { $where['af_enabled'] = true; } $res = $dbr->select( - array( 'abuse_filter_action', 'abuse_filter' ), + [ 'abuse_filter_action', 'abuse_filter' ], 'afa_parameters', $where, __METHOD__, - array(), - array( 'abuse_filter' => array( 'INNER JOIN', 'afa_filter=af_id' ) ) + [], + [ 'abuse_filter' => [ 'INNER JOIN', 'afa_filter=af_id' ] ] ); foreach ( $res as $row ) { @@ -507,15 +507,15 @@ class AbuseFilterHooks { } if ( $wgAbuseFilterCentralDB && !$wgAbuseFilterIsCentral ) { - $dbr = wfGetDB( DB_SLAVE, array(), $wgAbuseFilterCentralDB ); + $dbr = wfGetDB( DB_SLAVE, [], $wgAbuseFilterCentralDB ); $where['af_global'] = 1; $res = $dbr->select( - array( 'abuse_filter_action', 'abuse_filter' ), + [ 'abuse_filter_action', 'abuse_filter' ], 'afa_parameters', $where, __METHOD__, - array(), - array( 'abuse_filter' => array( 'INNER JOIN', 'afa_filter=af_id' ) ) + [], + [ 'abuse_filter' => [ 'INNER JOIN', 'afa_filter=af_id' ] ] ); foreach ( $res as $row ) { @@ -554,58 +554,58 @@ class AbuseFilterHooks { if ( $updater->getDB()->getType() == 'mysql' || $updater->getDB()->getType() == 'sqlite' ) { if ( $updater->getDB()->getType() == 'mysql' ) { - $updater->addExtensionUpdate( array( 'addTable', 'abuse_filter', - "$dir/abusefilter.tables.sql", true ) ); - $updater->addExtensionUpdate( array( 'addTable', 'abuse_filter_history', - "$dir/db_patches/patch-abuse_filter_history.sql", true ) ); + $updater->addExtensionUpdate( [ 'addTable', 'abuse_filter', + "$dir/abusefilter.tables.sql", true ] ); + $updater->addExtensionUpdate( [ 'addTable', 'abuse_filter_history', + "$dir/db_patches/patch-abuse_filter_history.sql", true ] ); } else { - $updater->addExtensionUpdate( array( 'addTable', 'abuse_filter', - "$dir/abusefilter.tables.sqlite.sql", true ) ); - $updater->addExtensionUpdate( array( 'addTable', 'abuse_filter_history', - "$dir/db_patches/patch-abuse_filter_history.sqlite.sql", true ) ); + $updater->addExtensionUpdate( [ 'addTable', 'abuse_filter', + "$dir/abusefilter.tables.sqlite.sql", true ] ); + $updater->addExtensionUpdate( [ 'addTable', 'abuse_filter_history', + "$dir/db_patches/patch-abuse_filter_history.sqlite.sql", true ] ); } - $updater->addExtensionUpdate( array( + $updater->addExtensionUpdate( [ 'addField', 'abuse_filter_history', 'afh_changed_fields', "$dir/db_patches/patch-afh_changed_fields.sql", true - ) ); - $updater->addExtensionUpdate( array( 'addField', 'abuse_filter', 'af_deleted', - "$dir/db_patches/patch-af_deleted.sql", true ) ); - $updater->addExtensionUpdate( array( 'addField', 'abuse_filter', 'af_actions', - "$dir/db_patches/patch-af_actions.sql", true ) ); - $updater->addExtensionUpdate( array( 'addField', 'abuse_filter', 'af_global', - "$dir/db_patches/patch-global_filters.sql", true ) ); - $updater->addExtensionUpdate( array( 'addField', 'abuse_filter_log', 'afl_rev_id', - "$dir/db_patches/patch-afl_action_id.sql", true ) ); + ] ); + $updater->addExtensionUpdate( [ 'addField', 'abuse_filter', 'af_deleted', + "$dir/db_patches/patch-af_deleted.sql", true ] ); + $updater->addExtensionUpdate( [ 'addField', 'abuse_filter', 'af_actions', + "$dir/db_patches/patch-af_actions.sql", true ] ); + $updater->addExtensionUpdate( [ 'addField', 'abuse_filter', 'af_global', + "$dir/db_patches/patch-global_filters.sql", true ] ); + $updater->addExtensionUpdate( [ 'addField', 'abuse_filter_log', 'afl_rev_id', + "$dir/db_patches/patch-afl_action_id.sql", true ] ); if ( $updater->getDB()->getType() == 'mysql' ) { - $updater->addExtensionUpdate( array( 'addIndex', 'abuse_filter_log', - 'filter_timestamp', "$dir/db_patches/patch-fix-indexes.sql", true ) ); + $updater->addExtensionUpdate( [ 'addIndex', 'abuse_filter_log', + 'filter_timestamp', "$dir/db_patches/patch-fix-indexes.sql", true ] ); } else { - $updater->addExtensionUpdate( array( + $updater->addExtensionUpdate( [ 'addIndex', 'abuse_filter_log', 'afl_filter_timestamp', "$dir/db_patches/patch-fix-indexes.sqlite.sql", true - ) ); + ] ); } - $updater->addExtensionUpdate( array( 'addField', 'abuse_filter', - 'af_group', "$dir/db_patches/patch-af_group.sql", true ) ); + $updater->addExtensionUpdate( [ 'addField', 'abuse_filter', + 'af_group', "$dir/db_patches/patch-af_group.sql", true ] ); if ( $updater->getDB()->getType() == 'mysql' ) { - $updater->addExtensionUpdate( array( + $updater->addExtensionUpdate( [ 'addIndex', 'abuse_filter_log', 'wiki_timestamp', "$dir/db_patches/patch-global_logging_wiki-index.sql", true - ) ); + ] ); } else { - $updater->addExtensionUpdate( array( + $updater->addExtensionUpdate( [ 'addIndex', 'abuse_filter_log', 'afl_wiki_timestamp', "$dir/db_patches/patch-global_logging_wiki-index.sqlite.sql", true - ) ); + ] ); } if ( $updater->getDB()->getType() == 'mysql' ) { - $updater->addExtensionUpdate( array( + $updater->addExtensionUpdate( [ 'modifyField', 'abuse_filter_log', 'afl_namespace', "$dir/db_patches/patch-afl-namespace_int.sql", true - ) ); + ] ); } else { /* $updater->addExtensionUpdate( array( @@ -625,33 +625,33 @@ class AbuseFilterHooks { */ } } elseif ( $updater->getDB()->getType() == 'postgres' ) { - $updater->addExtensionUpdate( array( - 'addTable', 'abuse_filter', "$dir/abusefilter.tables.pg.sql", true ) ); - $updater->addExtensionUpdate( array( + $updater->addExtensionUpdate( [ + 'addTable', 'abuse_filter', "$dir/abusefilter.tables.pg.sql", true ] ); + $updater->addExtensionUpdate( [ 'addTable', 'abuse_filter_history', "$dir/db_patches/patch-abuse_filter_history.pg.sql", true - ) ); - $updater->addExtensionUpdate( array( - 'addPgField', 'abuse_filter', 'af_actions', "TEXT NOT NULL DEFAULT ''" ) ); - $updater->addExtensionUpdate( array( - 'addPgField', 'abuse_filter', 'af_deleted', 'SMALLINT NOT NULL DEFAULT 0' ) ); - $updater->addExtensionUpdate( array( - 'addPgField', 'abuse_filter', 'af_global', 'SMALLINT NOT NULL DEFAULT 0' ) ); - $updater->addExtensionUpdate( array( - 'addPgField', 'abuse_filter_log', 'afl_wiki', 'TEXT' ) ); - $updater->addExtensionUpdate( array( - 'addPgField', 'abuse_filter_log', 'afl_deleted', 'SMALLINT' ) ); - $updater->addExtensionUpdate( array( - 'changeField', 'abuse_filter_log', 'afl_filter', 'TEXT', '' ) ); - $updater->addExtensionUpdate( array( - 'addPgExtIndex', 'abuse_filter_log', 'abuse_filter_log_ip', "(afl_ip)" ) ); - $updater->addExtensionUpdate( array( - 'addPgExtIndex', 'abuse_filter_log', 'abuse_filter_log_wiki', "(afl_wiki)" ) ); - $updater->addExtensionUpdate( array( - 'changeField', 'abuse_filter_log', 'afl_namespace', "INTEGER" ) ); + ] ); + $updater->addExtensionUpdate( [ + 'addPgField', 'abuse_filter', 'af_actions', "TEXT NOT NULL DEFAULT ''" ] ); + $updater->addExtensionUpdate( [ + 'addPgField', 'abuse_filter', 'af_deleted', 'SMALLINT NOT NULL DEFAULT 0' ] ); + $updater->addExtensionUpdate( [ + 'addPgField', 'abuse_filter', 'af_global', 'SMALLINT NOT NULL DEFAULT 0' ] ); + $updater->addExtensionUpdate( [ + 'addPgField', 'abuse_filter_log', 'afl_wiki', 'TEXT' ] ); + $updater->addExtensionUpdate( [ + 'addPgField', 'abuse_filter_log', 'afl_deleted', 'SMALLINT' ] ); + $updater->addExtensionUpdate( [ + 'changeField', 'abuse_filter_log', 'afl_filter', 'TEXT', '' ] ); + $updater->addExtensionUpdate( [ + 'addPgExtIndex', 'abuse_filter_log', 'abuse_filter_log_ip', "(afl_ip)" ] ); + $updater->addExtensionUpdate( [ + 'addPgExtIndex', 'abuse_filter_log', 'abuse_filter_log_wiki', "(afl_wiki)" ] ); + $updater->addExtensionUpdate( [ + 'changeField', 'abuse_filter_log', 'afl_namespace', "INTEGER" ] ); } - $updater->addExtensionUpdate( array( array( __CLASS__, 'createAbuseFilterUser' ) ) ); + $updater->addExtensionUpdate( [ [ __CLASS__, 'createAbuseFilterUser' ] ] ); return true; } @@ -666,7 +666,7 @@ class AbuseFilterHooks { if ( $user && !$updater->updateRowExists( 'create abusefilter-blocker-user' ) ) { if ( method_exists( 'User', 'newSystemUser' ) ) { - $user = User::newSystemUser( $username, array( 'steal' => true ) ); + $user = User::newSystemUser( $username, [ 'steal' => true ] ); } else { if ( !$user->getId() ) { $user->addToDatabase(); @@ -706,9 +706,9 @@ class AbuseFilterHooks { $tools[] = $linkRenderer->makeLink( SpecialPage::getTitleFor( 'AbuseLog' ), $context->msg( 'abusefilter-log-linkoncontribs' )->text(), - array( 'title' => $context->msg( 'abusefilter-log-linkoncontribs-text', - $nt->getText() )->parse() ), - array( 'wpSearchUser' => $nt->getText() ) + [ 'title' => $context->msg( 'abusefilter-log-linkoncontribs-text', + $nt->getText() )->parse() ], + [ 'wpSearchUser' => $nt->getText() ] ); } @@ -868,10 +868,10 @@ class AbuseFilterHooks { } if ( AbuseFilterViewExamine::$examineType !== null ) { - $vars['abuseFilterExamine'] = array( + $vars['abuseFilterExamine'] = [ 'type' => AbuseFilterViewExamine::$examineType, 'id' => AbuseFilterViewExamine::$examineId, - ); + ]; } return true; @@ -884,9 +884,9 @@ class AbuseFilterHooks { * @return bool */ public static function onUserMergeAccountFields( array &$updateFields ) { - $updateFields[] = array( 'abuse_filter', 'af_user', 'af_user_text' ); - $updateFields[] = array( 'abuse_filter_log', 'afl_user', 'afl_user_text' ); - $updateFields[] = array( 'abuse_filter_history', 'afh_user', 'afh_user_text' ); + $updateFields[] = [ 'abuse_filter', 'af_user', 'af_user_text' ]; + $updateFields[] = [ 'abuse_filter_log', 'afl_user', 'afl_user_text' ]; + $updateFields[] = [ 'abuse_filter_history', 'afh_user', 'afh_user_text' ]; return true; } diff --git a/includes/AFComputedVariable.php b/includes/AFComputedVariable.php index 3b8ce731a..1bcfced84 100644 --- a/includes/AFComputedVariable.php +++ b/includes/AFComputedVariable.php @@ -2,8 +2,8 @@ class AFComputedVariable { public $mMethod, $mParameters; - public static $userCache = array(); - public static $articleCache = array(); + public static $userCache = []; + public static $articleCache = []; /** * @param $method @@ -24,7 +24,7 @@ class AFComputedVariable { * @return object */ function parseNonEditWikitext( $wikitext, $article ) { - static $cache = array(); + static $cache = []; $cacheKey = md5( $wikitext ) . ':' . $article->getTitle()->getPrefixedText(); @@ -33,7 +33,7 @@ class AFComputedVariable { } global $wgParser; - $edit = (object)array(); + $edit = (object)[]; $options = new ParserOptions; $options->setTidy( true ); $edit->output = $wgParser->parse( $wikitext, $article->getTitle(), $options ); @@ -63,7 +63,7 @@ class AFComputedVariable { } if ( count( self::$userCache ) > 1000 ) { - self::$userCache = array(); + self::$userCache = []; } if ( $user instanceof User ) { @@ -96,7 +96,7 @@ class AFComputedVariable { } if ( count( self::$articleCache ) > 1000 ) { - self::$articleCache = array(); + self::$articleCache = []; } wfDebug( "Creating article object for $namespace:$title in cache\n" ); @@ -116,17 +116,17 @@ class AFComputedVariable { // Stolen from ConfirmEdit $id = $article->getId(); if ( !$id ) { - return array(); + return []; } $dbr = wfGetDB( DB_SLAVE ); $res = $dbr->select( 'externallinks', - array( 'el_to' ), - array( 'el_from' => $id ), + [ 'el_to' ], + [ 'el_from' => $id ], __METHOD__ ); - $links = array(); + $links = []; foreach ( $res as $row ) { $links[] = $row->el_to; } @@ -144,7 +144,7 @@ class AFComputedVariable { $result = null; if ( !Hooks::run( 'AbuseFilter-interceptVariable', - array( $this->mMethod, $vars, $parameters, &$result ) ) ) { + [ $this->mMethod, $vars, $parameters, &$result ] ) ) { return $result instanceof AFPData ? $result : AFPData::newFromPHPVar( $result ); } @@ -163,7 +163,7 @@ class AFComputedVariable { $diff = $vars->getVar( $parameters['diff-var'] )->toString(); $line_prefix = $parameters['line-prefix']; $diff_lines = explode( "\n", $diff ); - $interest_lines = array(); + $interest_lines = []; foreach ( $diff_lines as $line ) { if ( substr( $line, 0, 1 ) === $line_prefix ) { $interest_lines[] = substr( $line, strlen( $line_prefix ) ); @@ -218,7 +218,7 @@ class AFComputedVariable { // TODO: Get links from Content object. But we don't have the content object. // And for non-text content, $wikitext is usually not going to be a valid // serialization, but rather some dummy text for filtering. - $links = array(); + $links = []; } $result = $links; @@ -321,7 +321,7 @@ class AFComputedVariable { $title = Title::makeTitle( $parameters['namespace'], $parameters['title'] ); $rights = $title->getRestrictions( $action ); - $rights = count( $rights ) ? $rights : array(); + $rights = count( $rights ) ? $rights : []; $result = $rights; break; case 'simple-user-accessor': @@ -338,7 +338,7 @@ class AFComputedVariable { throw new MWException( "Invalid username $user" ); } - $result = call_user_func( array( $obj, $method ) ); + $result = call_user_func( [ $obj, $method ] ); break; case 'user-age': $user = $parameters['user']; @@ -381,7 +381,7 @@ class AFComputedVariable { break; default: if ( Hooks::run( 'AbuseFilter-computeVariable', - array( $this->mMethod, $vars, $parameters, &$result ) ) ) { + [ $this->mMethod, $vars, $parameters, &$result ] ) ) { throw new AFPException( 'Unknown variable compute type ' . $this->mMethod ); } } @@ -396,7 +396,7 @@ class AFComputedVariable { */ public static function getLastPageAuthors( Title $title ) { if ( !$title->exists() ) { - return array(); + return []; } $cache = ObjectCache::getMainWANInstance(); @@ -411,17 +411,17 @@ class AFComputedVariable { $revAuthors = $dbr->selectFieldValues( 'revision', 'rev_user_text', - array( 'rev_page' => $title->getArticleID() ), + [ 'rev_page' => $title->getArticleID() ], __METHOD__, // Some pages have < 10 authors but many revisions (e.g. bot pages) - array( 'ORDER BY' => 'rev_timestamp DESC', + [ 'ORDER BY' => 'rev_timestamp DESC', 'LIMIT' => 100, // Force index per T116557 'USE INDEX' => 'page_timestamp', - ) + ] ); // Get the last 10 distinct authors within this set of edits - $users = array(); + $users = []; foreach ( $revAuthors as $author ) { $users[$author] = 1; if ( count( $users ) >= 10 ) { diff --git a/includes/AbuseFilter.class.php b/includes/AbuseFilter.class.php index c531e96ad..fd0d8bba8 100644 --- a/includes/AbuseFilter.class.php +++ b/includes/AbuseFilter.class.php @@ -16,9 +16,9 @@ class AbuseFilter { private static $filterCache = []; public static $condCount = 0; - public static $tagsToSet = array(); // FIXME: avoid global state here + public static $tagsToSet = []; // FIXME: avoid global state here - public static $history_mappings = array( + public static $history_mappings = [ 'af_pattern' => 'afh_pattern', 'af_user' => 'afh_user', 'af_user_text' => 'afh_user_text', @@ -28,31 +28,31 @@ class AbuseFilter { 'af_deleted' => 'afh_deleted', 'af_id' => 'afh_filter', 'af_group' => 'afh_group', - ); - public static $builderValues = array( - 'op-arithmetic' => array( + ]; + public static $builderValues = [ + 'op-arithmetic' => [ '+' => 'addition', '-' => 'subtraction', '*' => 'multiplication', '/' => 'divide', '%' => 'modulo', '**' => 'pow' - ), - 'op-comparison' => array( + ], + 'op-comparison' => [ '==' => 'equal', '!=' => 'notequal', '<' => 'lt', '>' => 'gt', '<=' => 'lte', '>=' => 'gte' - ), - 'op-bool' => array( + ], + 'op-bool' => [ '!' => 'not', '&' => 'and', '|' => 'or', '^' => 'xor' - ), - 'misc' => array( + ], + 'misc' => [ 'in' => 'in', 'contains' => 'contains', 'like' => 'like', @@ -61,8 +61,8 @@ class AbuseFilter { 'irlike' => 'irlike', 'cond ? iftrue : iffalse' => 'tern', 'if cond then iftrue elseiffalse end' => 'cond', - ), - 'funcs' => array( + ], + 'funcs' => [ 'length(string)' => 'length', 'lcase(string)' => 'lcase', 'ucase(string)' => 'ucase', @@ -81,8 +81,8 @@ class AbuseFilter { 'str_replace(subject, search, replace)' => 'str_replace', 'rescape(string)' => 'rescape', 'set_var(var,value)' => 'set_var', - ), - 'vars' => array( + ], + 'vars' => [ 'timestamp' => 'timestamp', 'accountname' => 'accountname', 'action' => 'action', @@ -142,8 +142,8 @@ class AbuseFilter { 'file_width' => 'file-width', 'file_height' => 'file-height', 'file_bits_per_channel' => 'file-bits-per-channel', - ), - ); + ], + ]; public static $editboxName = null; @@ -152,27 +152,27 @@ class AbuseFilter { * @param $pageType */ public static function addNavigationLinks( IContextSource $context, $pageType ) { - $linkDefs = array( + $linkDefs = [ 'home' => 'Special:AbuseFilter', 'recentchanges' => 'Special:AbuseFilter/history', 'examine' => 'Special:AbuseFilter/examine', 'log' => 'Special:AbuseLog', - ); + ]; if ( $context->getUser()->isAllowed( 'abusefilter-modify' ) ) { - $linkDefs = array_merge( $linkDefs, array( + $linkDefs = array_merge( $linkDefs, [ 'test' => 'Special:AbuseFilter/test', 'tools' => 'Special:AbuseFilter/tools', 'import' => 'Special:AbuseFilter/import', - ) ); + ] ); } // Save some translator work - $msgOverrides = array( + $msgOverrides = [ 'recentchanges' => 'abusefilter-filter-log', - ); + ]; - $links = array(); + $links = []; $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer(); foreach ( $linkDefs as $name => $page ) { @@ -198,7 +198,7 @@ class AbuseFilter { $linkStr = $context->msg( 'parentheses', $context->getLanguage()->pipeList( $links ) )->text(); $linkStr = $context->msg( 'abusefilter-topnav' )->parse() . " $linkStr"; - $linkStr = Xml::tags( 'div', array( 'class' => 'mw-abusefilter-navigation' ), $linkStr ); + $linkStr = Xml::tags( 'div', [ 'class' => 'mw-abusefilter-navigation' ], $linkStr ); $context->getOutput()->setSubtitle( $linkStr ); } @@ -214,7 +214,7 @@ class AbuseFilter { $vars->setLazyLoadVar( 'user_editcount', 'simple-user-accessor', - array( 'user' => $user, 'method' => 'getEditCount' ) + [ 'user' => $user, 'method' => 'getEditCount' ] ); $vars->setVar( 'user_name', $user->getName() ); @@ -222,34 +222,34 @@ class AbuseFilter { $vars->setLazyLoadVar( 'user_emailconfirm', 'simple-user-accessor', - array( 'user' => $user, 'method' => 'getEmailAuthenticationTimestamp' ) + [ 'user' => $user, 'method' => 'getEmailAuthenticationTimestamp' ] ); $vars->setLazyLoadVar( 'user_age', 'user-age', - array( 'user' => $user, 'asof' => wfTimestampNow() ) + [ 'user' => $user, 'asof' => wfTimestampNow() ] ); $vars->setLazyLoadVar( 'user_groups', 'simple-user-accessor', - array( 'user' => $user, 'method' => 'getEffectiveGroups' ) + [ 'user' => $user, 'method' => 'getEffectiveGroups' ] ); $vars->setLazyLoadVar( 'user_rights', 'simple-user-accessor', - array( 'user' => $user, 'method' => 'getRights' ) + [ 'user' => $user, 'method' => 'getRights' ] ); $vars->setLazyLoadVar( 'user_blocked', 'simple-user-accessor', - array( 'user' => $user, 'method' => 'isBlocked' ) + [ 'user' => $user, 'method' => 'isBlocked' ] ); - Hooks::run( 'AbuseFilter-generateUserVars', array( $vars, $user ) ); + Hooks::run( 'AbuseFilter-generateUserVars', [ $vars, $user ] ); return $vars; } @@ -269,7 +269,7 @@ class AbuseFilter { if ( !$wgDisableCounters ) { $realValues['vars']['article_views'] = 'article-views'; } - Hooks::run( 'AbuseFilter-builder', array( &$realValues ) ); + Hooks::run( 'AbuseFilter-builder', [ &$realValues ] ); return $realValues; } @@ -285,7 +285,7 @@ class AbuseFilter { if ( !$wgAbuseFilterCentralDB ) { return false; } - $dbr = wfGetDB( DB_SLAVE, array(), $wgAbuseFilterCentralDB ); + $dbr = wfGetDB( DB_SLAVE, [], $wgAbuseFilterCentralDB ); $filter = $globalIndex; } else { $dbr = wfGetDB( DB_SLAVE ); @@ -296,7 +296,7 @@ class AbuseFilter { $hidden = $dbr->selectField( 'abuse_filter', 'af_hidden', - array( 'af_id' => $filter ), + [ 'af_id' => $filter ], __METHOD__ ); @@ -354,26 +354,26 @@ class AbuseFilter { global $wgRestrictionTypes; foreach ( $wgRestrictionTypes as $action ) { $vars->setLazyLoadVar( "{$prefix}_restrictions_$action", 'get-page-restrictions', - array( 'title' => $title->getText(), + [ 'title' => $title->getText(), 'namespace' => $title->getNamespace(), 'action' => $action - ) + ] ); } $vars->setLazyLoadVar( "{$prefix}_recent_contributors", 'load-recent-authors', - array( + [ 'title' => $title->getText(), 'namespace' => $title->getNamespace() - ) ); + ] ); $vars->setLazyLoadVar( "{$prefix}_first_contributor", 'load-first-author', - array( + [ 'title' => $title->getText(), 'namespace' => $title->getNamespace() - ) ); + ] ); - Hooks::run( 'AbuseFilter-generateTitleVars', array( $vars, $title, $prefix ) ); + Hooks::run( 'AbuseFilter-generateTitleVars', [ $vars, $title, $prefix ] ); return $vars; } @@ -396,7 +396,7 @@ class AbuseFilter { * @param array $vars * @return string */ - public static function evaluateExpression( $expr, $vars = array() ) { + public static function evaluateExpression( $expr, $vars = [] ) { global $wgAbuseFilterParserClass; if ( self::checkSyntax( $expr ) !== true ) { @@ -457,17 +457,17 @@ class AbuseFilter { global $wgAbuseFilterCentralDB, $wgAbuseFilterIsCentral; // Fetch from the database. - $filter_matched = array(); + $filter_matched = []; $dbr = wfGetDB( DB_SLAVE ); $res = $dbr->select( 'abuse_filter', '*', - array( + [ 'af_enabled' => 1, 'af_deleted' => 0, 'af_group' => $group, - ), + ], __METHOD__ ); @@ -487,25 +487,25 @@ class AbuseFilter { global $wgAbuseFilterCentralDB; $fdb = wfGetLB( $wgAbuseFilterCentralDB )->getConnectionRef( - DB_SLAVE, array(), $wgAbuseFilterCentralDB + DB_SLAVE, [], $wgAbuseFilterCentralDB ); return iterator_to_array( $fdb->select( 'abuse_filter', '*', - array( + [ 'af_enabled' => 1, 'af_deleted' => 0, 'af_global' => 1, 'af_group' => $group, - ), + ], $fname ) ); }, - array( - 'checkKeys' => array( $globalRulesKey ), + [ + 'checkKeys' => [ $globalRulesKey ], 'lockTSE' => 300 - ) + ] ); foreach ( $res as $row ) { @@ -628,7 +628,7 @@ class AbuseFilter { $curConds = $stash->get( $condsKey ); if ( !$curCount ) { - return array( 0, 0 ); + return [ 0, 0 ]; } $timeProfile = ( $curTotal / $curCount ) * 1000; // 1000 ms in a sec @@ -637,7 +637,7 @@ class AbuseFilter { $condProfile = ( $curConds / $curCount ); $condProfile = round( $condProfile, 0 ); - return array( $timeProfile, $condProfile ); + return [ $timeProfile, $condProfile ]; } /** @@ -660,8 +660,8 @@ class AbuseFilter { * @return array */ public static function getConsequencesForFilters( $filters ) { - $globalFilters = array(); - $localFilters = array(); + $globalFilters = []; + $localFilters = []; foreach ( $filters as $filter ) { $globalIndex = self::decodeGlobalName( $filter ); @@ -677,14 +677,14 @@ class AbuseFilter { // Load local filter info $dbr = wfGetDB( DB_SLAVE ); // Retrieve the consequences. - $consequences = array(); + $consequences = []; if ( count( $localFilters ) ) { $consequences = self::loadConsequencesFromDB( $dbr, $localFilters ); } if ( count( $globalFilters ) ) { - $fdb = wfGetDB( DB_SLAVE, array(), $wgAbuseFilterCentralDB ); + $fdb = wfGetDB( DB_SLAVE, [], $wgAbuseFilterCentralDB ); $consequences = $consequences + self::loadConsequencesFromDB( $fdb, $globalFilters, 'global-' ); } @@ -698,18 +698,18 @@ class AbuseFilter { * @return array */ public static function loadConsequencesFromDB( $dbr, $filters, $prefix = '' ) { - $actionsByFilter = array(); + $actionsByFilter = []; foreach ( $filters as $filter ) { - $actionsByFilter[$prefix . $filter] = array(); + $actionsByFilter[$prefix . $filter] = []; } $res = $dbr->select( - array( 'abuse_filter_action', 'abuse_filter' ), + [ 'abuse_filter_action', 'abuse_filter' ], '*', - array( 'af_id' => $filters ), + [ 'af_id' => $filters ], __METHOD__, - array(), - array( 'abuse_filter_action' => array( 'LEFT JOIN', 'afa_filter=af_id' ) ) + [], + [ 'abuse_filter_action' => [ 'LEFT JOIN', 'afa_filter=af_id' ] ] ); // Categorise consequences by filter. @@ -723,10 +723,10 @@ class AbuseFilter { // We probably got a NULL, as it's a LEFT JOIN. // Don't add it. } else { - $actionsByFilter[$prefix . $row->afa_filter][$row->afa_consequence] = array( + $actionsByFilter[$prefix . $row->afa_filter][$row->afa_consequence] = [ 'action' => $row->afa_consequence, 'parameters' => explode( "\n", $row->afa_parameters ) - ); + ]; } } @@ -748,9 +748,9 @@ class AbuseFilter { global $wgMainCacheType; $actionsByFilter = self::getConsequencesForFilters( $filters ); - $actionsTaken = array_fill_keys( $filters, array() ); + $actionsTaken = array_fill_keys( $filters, [] ); - $messages = array(); + $messages = []; global $wgOut, $wgAbuseFilterDisallowGlobalLocalBlocks, $wgAbuseFilterRestrictions; foreach ( $actionsByFilter as $filter => $actions ) { @@ -805,7 +805,7 @@ class AbuseFilter { } else { $msg = 'abusefilter-warning'; } - $messages[] = array( $msg, $parsed_public_comments, $filter ); + $messages[] = [ $msg, $parsed_public_comments, $filter ]; $actionsTaken[$filter][] = 'warn'; @@ -861,7 +861,7 @@ class AbuseFilter { $status = Status::newGood( $actionsTaken ); foreach ( $messages as $msg ) { - call_user_func_array( array( $status, 'fatal' ), $msg ); + call_user_func_array( [ $status, 'fatal' ], $msg ); } return $status; @@ -897,7 +897,7 @@ class AbuseFilter { $statsd = MediaWikiServices::getInstance()->getStatsdDataFactory(); // Add vars from extensions - Hooks::run( 'AbuseFilter-filterAction', array( &$vars, $title ) ); + Hooks::run( 'AbuseFilter-filterAction', [ &$vars, $title ] ); $vars->setVar( 'context', 'filter' ); $vars->setVar( 'timestamp', time() ); @@ -956,14 +956,14 @@ class AbuseFilter { $user = $user->isSafeToLoad() ? $user : new User; // Create a template - $log_template = array( + $log_template = [ 'afl_user' => $user->getId(), 'afl_user_text' => $user->getName(), 'afl_timestamp' => wfGetDB( DB_SLAVE )->timestamp( wfTimestampNow() ), 'afl_namespace' => $title->getNamespace(), 'afl_title' => $title->getDBkey(), 'afl_ip' => $wgRequest->getIP() - ); + ]; // Hack to avoid revealing IPs of people creating accounts if ( !$user->getId() && ( $action == 'createaccount' || $action == 'autocreateaccount' ) ) { @@ -1004,7 +1004,7 @@ class AbuseFilter { $id = $globalIndex; $lb = wfGetLB( $wgAbuseFilterCentralDB ); - $dbr = $lb->getConnectionRef( DB_SLAVE, array(), $wgAbuseFilterCentralDB ); + $dbr = $lb->getConnectionRef( DB_SLAVE, [], $wgAbuseFilterCentralDB ); } else { // Local wiki filter $dbr = wfGetDB( DB_SLAVE ); @@ -1059,14 +1059,14 @@ class AbuseFilter { ) { $dbw = wfGetDB( DB_MASTER ); - $central_log_template = array( + $central_log_template = [ 'afl_wiki' => wfWikiID(), - ); + ]; - $log_rows = array(); - $central_log_rows = array(); - $logged_local_filters = array(); - $logged_global_filters = array(); + $log_rows = []; + $central_log_rows = []; + $logged_local_filters = []; + $logged_global_filters = []; foreach ( $actions_taken as $filter => $actions ) { $globalIndex = self::decodeGlobalName( $filter ); @@ -1112,7 +1112,7 @@ class AbuseFilter { // Increment trigger counter $stash->incr( self::filterMatchesKey() ); - $local_log_ids = array(); + $local_log_ids = []; global $wgAbuseFilterNotifications, $wgAbuseFilterNotificationsPrivate; foreach ( $log_rows as $data ) { $data['afl_var_dump'] = $var_dump; @@ -1129,12 +1129,12 @@ class AbuseFilter { // Set action target $entry->setTarget( Title::makeTitle( $data['afl_namespace'], $data['afl_title'] ) ); // Additional info - $entry->setParameters( array( + $entry->setParameters( [ 'action' => $data['afl_action'], 'filter' => $data['afl_filter'], 'actions' => $data['afl_actions'], 'log' => $data['afl_id'], - ) ); + ] ); // Send data to CheckUser if installed and we // aren't already sending a notification to recentchanges @@ -1162,15 +1162,15 @@ class AbuseFilter { $dbw->onTransactionPreCommitOrIdle( function () use ( $dbw, $logged_local_filters, $method ) { $dbw->update( 'abuse_filter', - array( 'af_hit_count=af_hit_count+1' ), - array( 'af_id' => $logged_local_filters ), + [ 'af_hit_count=af_hit_count+1' ], + [ 'af_id' => $logged_local_filters ], $method ); } ); } - $global_log_ids = array(); + $global_log_ids = []; // Global stuff if ( count( $logged_global_filters ) ) { @@ -1182,7 +1182,7 @@ class AbuseFilter { } global $wgAbuseFilterCentralDB; - $fdb = wfGetDB( DB_MASTER, array(), $wgAbuseFilterCentralDB ); + $fdb = wfGetDB( DB_MASTER, [], $wgAbuseFilterCentralDB ); foreach ( $central_log_rows as $row ) { $fdb->insert( 'abuse_filter_log', $row, __METHOD__ ); @@ -1192,8 +1192,8 @@ class AbuseFilter { $fdb->onTransactionPreCommitOrIdle( function () use ( $fdb, $logged_global_filters, $method ) { $fdb->update( 'abuse_filter', - array( 'af_hit_count=af_hit_count+1' ), - array( 'af_id' => $logged_global_filters ), + [ 'af_hit_count=af_hit_count+1' ], + [ 'af_id' => $logged_global_filters ], $method ); } @@ -1224,11 +1224,11 @@ class AbuseFilter { // Get all variables yet set and compute old and new wikitext if not yet done // as those are needed for the diff view on top of the abuse log pages - $vars = $vars->dumpAllVars( array( 'old_wikitext', 'new_wikitext' ) ); + $vars = $vars->dumpAllVars( [ 'old_wikitext', 'new_wikitext' ] ); // Vars is an array with native PHP data types (non-objects) now $text = serialize( $vars ); - $flags = array( 'nativeDataArray' ); + $flags = [ 'nativeDataArray' ]; if ( $wgCompressRevisions ) { if ( function_exists( 'gzdeflate' ) ) { @@ -1255,17 +1255,17 @@ class AbuseFilter { // Store to text table if ( $global ) { - $dbw = wfGetDB( DB_MASTER, array(), $wgAbuseFilterCentralDB ); + $dbw = wfGetDB( DB_MASTER, [], $wgAbuseFilterCentralDB ); } else { $dbw = wfGetDB( DB_MASTER ); } $old_id = $dbw->nextSequenceValue( 'text_old_id_seq' ); $dbw->insert( 'text', - array( + [ 'old_id' => $old_id, 'old_text' => $text, 'old_flags' => implode( ',', $flags ), - ), __METHOD__ + ], __METHOD__ ); return $dbw->insertId(); @@ -1301,8 +1301,8 @@ class AbuseFilter { $text_row = $dbr->selectRow( 'text', - array( 'old_text', 'old_flags' ), - array( 'old_id' => $text_id ), + [ 'old_text', 'old_flags' ], + [ 'old_id' => $text_id ], __METHOD__ ); @@ -1360,14 +1360,14 @@ class AbuseFilter { switch ( $action ) { case 'disallow': if ( strlen( $parameters[0] ) ) { - $message = array( $parameters[0], $rule_desc, $rule_number ); + $message = [ $parameters[0], $rule_desc, $rule_number ]; } else { // Generic message. - $message = array( + $message = [ 'abusefilter-disallowed', $rule_desc, $rule_number - ); + ]; } break; @@ -1382,37 +1382,37 @@ class AbuseFilter { } self::doAbuseFilterBlock( - array( + [ 'desc' => $rule_desc, 'number' => $rule_number - ), + ], $wgUser->getName(), $expiry, true ); - $message = array( + $message = [ 'abusefilter-blocked-display', $rule_desc, $rule_number - ); + ]; break; case 'rangeblock': self::doAbuseFilterBlock( - array( + [ 'desc' => $rule_desc, 'number' => $rule_number - ), + ], IP::sanitizeRange( $wgRequest->getIP() . '/16' ), '1 week', false ); - $message = array( + $message = [ 'abusefilter-blocked-display', $rule_desc, $rule_number - ); + ]; break; case 'degroup': global $wgUser; @@ -1424,11 +1424,11 @@ class AbuseFilter { $wgUser->removeGroup( $group ); } - $message = array( + $message = [ 'abusefilter-degrouped', $rule_desc, $rule_number - ); + ]; // Don't log it if there aren't any groups being removed! if ( !count( $groups ) ) { @@ -1445,10 +1445,10 @@ class AbuseFilter { $rule_desc, $rule_number )->inContentLanguage()->text(), - array( + [ implode( ', ', $groups ), '' - ), + ], self::getFilterUser() ); } @@ -1462,11 +1462,11 @@ class AbuseFilter { self::autoPromoteBlockKey( $wgUser ), true, $blockPeriod ); - $message = array( + $message = [ 'abusefilter-autopromote-blocked', $rule_desc, $rule_number - ); + ]; } break; @@ -1478,10 +1478,10 @@ class AbuseFilter { // Mark with a tag on recentchanges. global $wgUser; - $actionID = implode( '-', array( + $actionID = implode( '-', [ $title->getPrefixedText(), $wgUser->getName(), $vars->getVar( 'ACTION' )->toString() - ) ); + ] ); self::bufferTagsToSetByAction( [ $actionID => $parameters ] ); break; @@ -1500,7 +1500,7 @@ class AbuseFilter { ); } if ( isset( $msg ) ) { - $message = array( $msg ); + $message = [ $msg ]; } } else { wfDebugLog( 'AbuseFilter', "Unrecognised action $action" ); @@ -1551,11 +1551,11 @@ class AbuseFilter { if ( $success ) { // Log it only if the block was successful - $logParams = array(); + $logParams = []; $logParams['5::duration'] = ( $block->mExpiry === 'infinity' ) ? 'indefinite' : $expiry; - $flags = array( 'nocreate' ); + $flags = [ 'nocreate' ]; if ( !$block->isAutoblocking() && !IP::isIPAddress( $target ) ) { // Conditionally added same as SpecialBlock $flags[] = 'noautoblock'; @@ -1567,8 +1567,8 @@ class AbuseFilter { $logEntry->setComment( $reason ); $logEntry->setPerformer( $filterUser ); $logEntry->setParameters( $logParams ); - $blockIds = array_merge( array( $success['id'] ), $success['autoIds'] ); - $logEntry->setRelations( array( 'ipb_id' => $blockIds ) ); + $blockIds = array_merge( [ $success['id'] ], $success['autoIds'] ); + $logEntry->setRelations( [ 'ipb_id' => $blockIds ] ); $logEntry->publish( $logEntry->insert() ); } } @@ -1661,7 +1661,7 @@ class AbuseFilter { public static function throttleKey( $throttleId, $type, $title, $global = false ) { $types = explode( ',', $type ); - $identifiers = array(); + $identifiers = []; foreach ( $types as $subtype ) { $identifiers[] = self::throttleIdentifier( $subtype, $title ); @@ -1798,8 +1798,8 @@ class AbuseFilter { __METHOD__, function ( IDatabase $dbw, $fname ) use ( $filter ) { $dbw->update( 'abuse_filter', - array( 'af_throttled' => 1 ), - array( 'af_id' => $filter ), + [ 'af_throttled' => 1 ], + [ 'af_id' => $filter ], $fname ); } @@ -1847,7 +1847,7 @@ class AbuseFilter { public static function getFilterUser() { $username = wfMessage( 'abusefilter-blocker' )->inContentLanguage()->text(); if ( method_exists( 'User', 'newSystemUser' ) ) { - $user = User::newSystemUser( $username, array( 'steal' => true ) ); + $user = User::newSystemUser( $username, [ 'steal' => true ] ); } else { $user = User::newFromName( $username ); $user->load(); @@ -1892,13 +1892,13 @@ class AbuseFilter { $canEdit = true ) { global $wgOut; - $textareaAttrib = array( 'dir' => 'ltr' ); # Rules are in English + $textareaAttrib = [ 'dir' => 'ltr' ]; # Rules are in English if ( !$canEdit ) { $textareaAttrib['readonly'] = 'readonly'; } global $wgUser; - $noTestAttrib = array(); + $noTestAttrib = []; if ( !$wgUser->isAllowed( 'abusefilter-modify' ) ) { $noTestAttrib['disabled'] = 'disabled'; $addResultDiv = false; @@ -1922,7 +1922,7 @@ class AbuseFilter { $builder .= Xml::openElement( 'optgroup', - array( 'label' => wfMessage( "abusefilter-edit-builder-group-$group" )->text() ) + [ 'label' => wfMessage( "abusefilter-edit-builder-group-$group" )->text() ] ) . "\n"; foreach ( $values as $content => $name ) { @@ -1939,22 +1939,22 @@ class AbuseFilter { $rules .= Xml::tags( 'select', - array( 'id' => 'wpFilterBuilder', ), + [ 'id' => 'wpFilterBuilder', ], $builder ) . ' '; // Add syntax checking $rules .= Xml::element( 'input', - array( + [ 'type' => 'button', 'value' => wfMessage( 'abusefilter-edit-check' )->text(), 'id' => 'mw-abusefilter-syntaxcheck' - ) + $noTestAttrib ); + ] + $noTestAttrib ); } if ( $addResultDiv ) { $rules .= Xml::element( 'div', - array( 'id' => 'mw-abusefilter-syntaxresult', 'style' => 'display: none;' ), + [ 'id' => 'mw-abusefilter-syntaxresult', 'style' => 'display: none;' ], ' ' ); } @@ -1975,7 +1975,7 @@ class AbuseFilter { * @return array */ static function compareVersions( $version_1, $version_2 ) { - $compareFields = array( + $compareFields = [ 'af_public_comments', 'af_pattern', 'af_comments', @@ -1984,8 +1984,8 @@ class AbuseFilter { 'af_hidden', 'af_global', 'af_group', - ); - $differences = array(); + ]; + $differences = []; list( $row1, $actions1 ) = $version_1; list( $row2, $actions2 ) = $version_2; @@ -2043,17 +2043,17 @@ class AbuseFilter { # Process actions $actions_raw = unserialize( $row->afh_actions ); - $actions_output = array(); + $actions_output = []; if ( is_array( $actions_raw ) ) { foreach ( $actions_raw as $action => $parameters ) { - $actions_output[$action] = array( + $actions_output[$action] = [ 'action' => $action, 'parameters' => $parameters - ); + ]; } } - return array( $af_row, $actions_output ); + return [ $af_row, $actions_output ]; } /** @@ -2141,11 +2141,11 @@ class AbuseFilter { $vars->setVar( 'SUMMARY', $row->rc_comment ); $vars->setLazyLoadVar( 'new_wikitext', 'revision-text-by-id', - array( 'revid' => $row->rc_this_oldid ) ); + [ 'revid' => $row->rc_this_oldid ] ); if ( $row->rc_last_oldid ) { $vars->setLazyLoadVar( 'old_wikitext', 'revision-text-by-id', - array( 'revid' => $row->rc_last_oldid ) ); + [ 'revid' => $row->rc_last_oldid ] ); } else { $vars->setVar( 'old_wikitext', '' ); } @@ -2198,67 +2198,67 @@ class AbuseFilter { } $vars->setLazyLoadVar( 'edit_diff', 'diff', - array( 'oldtext-var' => 'old_wikitext', 'newtext-var' => 'new_wikitext' ) ); + [ 'oldtext-var' => 'old_wikitext', 'newtext-var' => 'new_wikitext' ] ); $vars->setLazyLoadVar( 'edit_diff_pst', 'diff', - array( 'oldtext-var' => 'old_wikitext', 'newtext-var' => 'new_pst' ) ); - $vars->setLazyLoadVar( 'new_size', 'length', array( 'length-var' => 'new_wikitext' ) ); - $vars->setLazyLoadVar( 'old_size', 'length', array( 'length-var' => 'old_wikitext' ) ); + [ 'oldtext-var' => 'old_wikitext', 'newtext-var' => 'new_pst' ] ); + $vars->setLazyLoadVar( 'new_size', 'length', [ 'length-var' => 'new_wikitext' ] ); + $vars->setLazyLoadVar( 'old_size', 'length', [ 'length-var' => 'old_wikitext' ] ); $vars->setLazyLoadVar( 'edit_delta', 'subtract', - array( 'val1-var' => 'new_size', 'val2-var' => 'old_size' ) ); + [ 'val1-var' => 'new_size', 'val2-var' => 'old_size' ] ); // Some more specific/useful details about the changes. $vars->setLazyLoadVar( 'added_lines', 'diff-split', - array( 'diff-var' => 'edit_diff', 'line-prefix' => '+' ) ); + [ 'diff-var' => 'edit_diff', 'line-prefix' => '+' ] ); $vars->setLazyLoadVar( 'removed_lines', 'diff-split', - array( 'diff-var' => 'edit_diff', 'line-prefix' => '-' ) ); + [ 'diff-var' => 'edit_diff', 'line-prefix' => '-' ] ); $vars->setLazyLoadVar( 'added_lines_pst', 'diff-split', - array( 'diff-var' => 'edit_diff_pst', 'line-prefix' => '+' ) ); + [ 'diff-var' => 'edit_diff_pst', 'line-prefix' => '+' ] ); // Links $vars->setLazyLoadVar( 'added_links', 'link-diff-added', - array( 'oldlink-var' => 'old_links', 'newlink-var' => 'all_links' ) ); + [ 'oldlink-var' => 'old_links', 'newlink-var' => 'all_links' ] ); $vars->setLazyLoadVar( 'removed_links', 'link-diff-removed', - array( 'oldlink-var' => 'old_links', 'newlink-var' => 'all_links' ) ); + [ 'oldlink-var' => 'old_links', 'newlink-var' => 'all_links' ] ); $vars->setLazyLoadVar( 'new_text', 'strip-html', - array( 'html-var' => 'new_html' ) ); + [ 'html-var' => 'new_html' ] ); $vars->setLazyLoadVar( 'old_text', 'strip-html', - array( 'html-var' => 'old_html' ) ); + [ 'html-var' => 'old_html' ] ); if ( $title instanceof Title ) { $vars->setLazyLoadVar( 'all_links', 'links-from-wikitext', - array( + [ 'namespace' => $title->getNamespace(), 'title' => $title->getText(), 'text-var' => 'new_wikitext', 'article' => $page - ) ); + ] ); $vars->setLazyLoadVar( 'old_links', 'links-from-wikitext-or-database', - array( + [ 'namespace' => $title->getNamespace(), 'title' => $title->getText(), 'text-var' => 'old_wikitext' - ) ); + ] ); $vars->setLazyLoadVar( 'new_pst', 'parse-wikitext', - array( + [ 'namespace' => $title->getNamespace(), 'title' => $title->getText(), 'wikitext-var' => 'new_wikitext', 'article' => $page, 'pst' => true, - ) ); + ] ); $vars->setLazyLoadVar( 'new_html', 'parse-wikitext', - array( + [ 'namespace' => $title->getNamespace(), 'title' => $title->getText(), 'wikitext-var' => 'new_wikitext', 'article' => $page - ) ); + ] ); $vars->setLazyLoadVar( 'old_html', 'parse-wikitext-nonedit', - array( + [ 'namespace' => $title->getNamespace(), 'title' => $title->getText(), 'wikitext-var' => 'old_wikitext' - ) ); + ] ); } return $vars; @@ -2284,7 +2284,7 @@ class AbuseFilter { $variableMessageMappings = $variableMessageMappings['vars']; $output .= - Xml::openElement( 'table', array( 'class' => 'mw-abuselog-details' ) ) . + Xml::openElement( 'table', [ 'class' => 'mw-abuselog-details' ] ) . Xml::openElement( 'tbody' ) . "\n"; @@ -2314,14 +2314,14 @@ class AbuseFilter { if ( is_null( $value ) ) { $value = ''; } - $value = Xml::element( 'div', array( 'class' => 'mw-abuselog-var-value' ), $value, false ); + $value = Xml::element( 'div', [ 'class' => 'mw-abuselog-var-value' ], $value, false ); $trow = - Xml::tags( 'td', array( 'class' => 'mw-abuselog-var' ), $keyDisplay ) . - Xml::tags( 'td', array( 'class' => 'mw-abuselog-var-value' ), $value ); + Xml::tags( 'td', [ 'class' => 'mw-abuselog-var' ], $keyDisplay ) . + Xml::tags( 'td', [ 'class' => 'mw-abuselog-var-value' ], $value ); $output .= Xml::tags( 'tr', - array( 'class' => "mw-abuselog-details-$key mw-abuselog-value" ), $trow + [ 'class' => "mw-abuselog-details-$key mw-abuselog-value" ], $trow ) . "\n"; } @@ -2389,7 +2389,7 @@ class AbuseFilter { /** @var $wgLang Language */ global $wgLang; $flags = array_filter( explode( ',', $value ) ); - $flags_display = array(); + $flags_display = []; foreach ( $flags as $flag ) { $flags_display[] = wfMessage( "abusefilter-history-$flag" )->text(); } @@ -2408,12 +2408,12 @@ class AbuseFilter { return ''; } - $fdb = wfGetDB( DB_SLAVE, array(), $wgAbuseFilterCentralDB ); + $fdb = wfGetDB( DB_SLAVE, [], $wgAbuseFilterCentralDB ); return $fdb->selectField( 'abuse_filter', 'af_public_comments', - array( 'af_id' => $filterID ), + [ 'af_id' => $filterID ], __METHOD__ ); } @@ -2479,7 +2479,7 @@ class AbuseFilter { static function contentToString( Content $content ) { $text = null; - if ( Hooks::run( 'AbuseFilter-contentToString', array( $content, &$text ) ) ) { + if ( Hooks::run( 'AbuseFilter-contentToString', [ $content, &$text ] ) ) { $text = $content instanceof TextContent ? $content->getNativeData() : $content->getTextForSearchIndex(); @@ -2503,18 +2503,18 @@ class AbuseFilter { * @return integer|bool */ public static function getFirstFilterChange( $filterID ) { - static $firstChanges = array(); + static $firstChanges = []; if ( !isset( $firstChanges[$filterID] ) ) { $dbr = wfGetDB( DB_SLAVE ); $row = $dbr->selectRow( 'abuse_filter_history', 'afh_id', - array( + [ 'afh_filter' => $filterID, - ), + ], __METHOD__, - array( 'ORDER BY' => 'afh_timestamp ASC' ) + [ 'ORDER BY' => 'afh_timestamp ASC' ] ); $firstChanges[$filterID] = $row->afh_id; } diff --git a/includes/AbuseFilterVariableHolder.php b/includes/AbuseFilterVariableHolder.php index 41fbba542..8a1a1ee4e 100644 --- a/includes/AbuseFilterVariableHolder.php +++ b/includes/AbuseFilterVariableHolder.php @@ -1,9 +1,9 @@ mVars ); - $exported = array(); - $coreVariables = array(); + $exported = []; + $coreVariables = []; if ( !$includeUserVars ) { // Compile a list of all variables set by the extension to be able @@ -152,14 +152,14 @@ class AbuseFilterVariableHolder { $coreVariables = array_keys( $coreVariables['vars'] ); // Title vars can have several prefixes - $prefixes = array( 'ARTICLE', 'MOVED_FROM', 'MOVED_TO' ); - $titleVars = array( + $prefixes = [ 'ARTICLE', 'MOVED_FROM', 'MOVED_TO' ]; + $titleVars = [ '_ARTICLEID', '_NAMESPACE', '_TEXT', '_PREFIXEDTEXT', '_recent_contributors' - ); + ]; foreach ( $wgRestrictionTypes as $action ) { $titleVars[] = "_restrictions_$action"; } @@ -202,7 +202,7 @@ class AbuseFilterVariableHolder { * cross-wiki or used for offline analysis. */ function computeDBVars() { - static $dbTypes = array( + static $dbTypes = [ 'links-from-wikitext-or-database', 'load-recent-authors', 'get-page-restrictions', @@ -212,7 +212,7 @@ class AbuseFilterVariableHolder { 'user-rights', 'revision-text-by-id', 'revision-text-by-timestamp' - ); + ]; foreach ( $this->mVars as $name => $value ) { if ( $value instanceof AFComputedVariable && diff --git a/includes/AbuseLogHitFormatter.php b/includes/AbuseLogHitFormatter.php index d97208843..4daf0e57f 100644 --- a/includes/AbuseLogHitFormatter.php +++ b/includes/AbuseLogHitFormatter.php @@ -42,7 +42,7 @@ class AbuseLogHitFormatter extends LogFormatter { $actions_taken = $this->msg( 'abusefilter-log-noactions' ); } else { $actions = explode( ',', $actions_taken ); - $displayActions = array(); + $displayActions = []; foreach ( $actions as $action ) { $displayActions[] = AbuseFilter::getActionDisplay( $action ); diff --git a/includes/parser/AFPData.php b/includes/parser/AFPData.php index 824c776d2..7a9f8158b 100644 --- a/includes/parser/AFPData.php +++ b/includes/parser/AFPData.php @@ -11,7 +11,7 @@ class AFPData { // Translation table mapping shell-style wildcards to PCRE equivalents. // Derived from - private static $wildcardMap = array( + private static $wildcardMap = [ '\*' => '.*', '\+' => '\+', '\-' => '\-', @@ -21,7 +21,7 @@ class AFPData { '\[\!' => '[^', '\\' => '\\\\', '\]' => ']', - ); + ]; public $type; public $data; @@ -50,7 +50,7 @@ class AFPData { } elseif ( is_bool( $var ) ) { return new AFPData( self::DBOOL, $var ); } elseif ( is_array( $var ) ) { - $result = array(); + $result = []; foreach ( $var as $item ) { $result[] = self::newFromPHPVar( $item ); } @@ -118,7 +118,7 @@ class AFPData { return new AFPData( self::DSTRING, strval( $orig->data ) ); } if ( $target == self::DLIST ) { - return new AFPData( self::DLIST, array( $orig ) ); + return new AFPData( self::DLIST, [ $orig ] ); } } @@ -236,7 +236,7 @@ class AFPData { throw new AFPUserVisibleException( 'regexfailure', $pos, - array( 'unspecified error in preg_match()', $pattern ) + [ 'unspecified error in preg_match()', $pattern ] ); } @@ -348,7 +348,7 @@ class AFPData { } if ( $op != '*' && $b == 0 ) { - throw new AFPUserVisibleException( 'dividebyzero', $pos, array( $a ) ); + throw new AFPUserVisibleException( 'dividebyzero', $pos, [ $a ] ); } if ( $op == '*' ) { @@ -413,7 +413,7 @@ class AFPData { return $this->toInt(); case self::DLIST: $input = $this->toList(); - $output = array(); + $output = []; foreach ( $input as $item ) { $output[] = $item->toNative(); } diff --git a/includes/parser/AFPTreeParser.php b/includes/parser/AFPTreeParser.php index d59cbb609..345adcb86 100644 --- a/includes/parser/AFPTreeParser.php +++ b/includes/parser/AFPTreeParser.php @@ -27,7 +27,7 @@ class AFPTreeParser { } public function resetState() { - $this->mTokens = array(); + $this->mTokens = []; $this->mPos = 0; } @@ -516,7 +516,7 @@ class AFPTreeParser { ); } - $args = array(); + $args = []; do { $args[] = $this->doLevelSemicolon(); } while ( $this->mCur->type == AFPToken::TCOMMA ); @@ -568,7 +568,7 @@ class AFPTreeParser { /** @noinspection PhpMissingBreakStatementInspection */ case AFPToken::TSQUAREBRACKET: if ( $this->mCur->value == '[' ) { - $list = array(); + $list = []; while ( true ) { $this->move(); if ( $this->mCur->type == AFPToken::TSQUAREBRACKET && $this->mCur->value == ']' ) { diff --git a/includes/parser/AFPUserVisibleException.php b/includes/parser/AFPUserVisibleException.php index 624ddef62..45eea7451 100644 --- a/includes/parser/AFPUserVisibleException.php +++ b/includes/parser/AFPUserVisibleException.php @@ -34,7 +34,7 @@ class AFPUserVisibleException extends AFPException { // abusefilter-exception-notlist return wfMessage( 'abusefilter-exception-' . $this->mExceptionID, - array_merge( array( $this->mPosition ), $this->mParams ) + array_merge( [ $this->mPosition ], $this->mParams ) ); } } diff --git a/includes/parser/AbuseFilterCachingParser.php b/includes/parser/AbuseFilterCachingParser.php index f0971d626..0c5ba69e0 100644 --- a/includes/parser/AbuseFilterCachingParser.php +++ b/includes/parser/AbuseFilterCachingParser.php @@ -126,7 +126,7 @@ class AbuseFilterCachingParser extends AbuseFilterParser { } if ( count( self::$funcCache ) > 1000 ) { - self::$funcCache = array(); + self::$funcCache = []; } return $result; @@ -136,7 +136,7 @@ class AbuseFilterCachingParser extends AbuseFilterParser { $list = $this->evalNode( $list ); if ( $list->type != AFPData::DLIST ) { - throw new AFPUserVisibleException( 'notlist', $node->position, array() ); + throw new AFPUserVisibleException( 'notlist', $node->position, [] ); } $offset = $this->evalNode( $offset )->toInt(); @@ -236,7 +236,7 @@ class AbuseFilterCachingParser extends AbuseFilterParser { $list = $this->mVars->getVar( $varName ); if ( $list->type != AFPData::DLIST ) { - throw new AFPUserVisibleException( 'notlist', $node->position, array() ); + throw new AFPUserVisibleException( 'notlist', $node->position, [] ); } $offset = $this->evalNode( $offset )->toInt(); @@ -244,7 +244,7 @@ class AbuseFilterCachingParser extends AbuseFilterParser { $list = $list->toList(); if ( count( $list ) <= $offset ) { throw new AFPUserVisibleException( 'outofbounds', $node->position, - array( $offset, count( $list ) ) ); + [ $offset, count( $list ) ] ); } $list[$offset] = $this->evalNode( $value ); @@ -256,7 +256,7 @@ class AbuseFilterCachingParser extends AbuseFilterParser { $list = $this->mVars->getVar( $varName ); if ( $list->type != AFPData::DLIST ) { - throw new AFPUserVisibleException( 'notlist', $node->position, array() ); + throw new AFPUserVisibleException( 'notlist', $node->position, [] ); } $list = $list->toList(); diff --git a/includes/parser/AbuseFilterParser.php b/includes/parser/AbuseFilterParser.php index 79747d3ae..4f1534e4a 100644 --- a/includes/parser/AbuseFilterParser.php +++ b/includes/parser/AbuseFilterParser.php @@ -9,7 +9,7 @@ class AbuseFilterParser { public $mVars; // length,lcase,ucase,ccnorm,rmdoubles,specialratio,rmspecials,norm,count - public static $mFunctions = array( + public static $mFunctions = [ 'lcase' => 'funcLc', 'ucase' => 'funcUc', 'length' => 'funcLen', @@ -34,14 +34,14 @@ class AbuseFilterParser { 'rescape' => 'funcStrRegexEscape', 'set' => 'funcSetVar', 'set_var' => 'funcSetVar', - ); + ]; // Functions that affect parser state, and shouldn't be cached. - public static $ActiveFunctions = array( + public static $ActiveFunctions = [ 'funcSetVar', - ); + ]; - public static $mKeywords = array( + public static $mKeywords = [ 'in' => 'keywordIn', 'like' => 'keywordLike', 'matches' => 'keywordLike', @@ -49,9 +49,9 @@ class AbuseFilterParser { 'rlike' => 'keywordRegex', 'irlike' => 'keywordRegexInsensitive', 'regex' => 'keywordRegex' - ); + ]; - public static $funcCache = array(); + public static $funcCache = []; /** * Create a new instance @@ -67,7 +67,7 @@ class AbuseFilterParser { public function resetState() { $this->mCode = ''; - $this->mTokens = array(); + $this->mTokens = []; $this->mVars = new AbuseFilterVariableHolder; $this->mPos = 0; $this->mShortCircuit = false; @@ -86,7 +86,7 @@ class AbuseFilterParser { } catch ( AFPUserVisibleException $excep ) { $this->mAllowShort = $origAS; - return array( $excep->getMessageObj()->text(), $excep->mPosition ); + return [ $excep->getMessageObj()->text(), $excep->mPosition ]; } $this->mAllowShort = $origAS; @@ -161,7 +161,7 @@ class AbuseFilterParser { } } if ( !( $this->mCur->type == AFPToken::TBRACE && $this->mCur->value == ')' ) ) { - throw new AFPUserVisibleException( 'expectednotfound', $this->mCur->pos, array( ')' ) ); + throw new AFPUserVisibleException( 'expectednotfound', $this->mCur->pos, [ ')' ] ); } } @@ -226,7 +226,7 @@ class AbuseFilterParser { if ( $this->mCur->type != AFPToken::TNONE ) { throw new AFPUserVisibleException( 'unexpectedatend', - $this->mCur->pos, array( $this->mCur->type ) + $this->mCur->pos, [ $this->mCur->type ] ); } } @@ -266,12 +266,12 @@ class AbuseFilterParser { if ( !$this->mVars->varIsSet( $varname ) ) { throw new AFPUserVisibleException( 'unrecognisedvar', $this->mCur->pos, - array( $varname ) + [ $varname ] ); } $list = $this->mVars->getVar( $varname ); if ( $list->type != AFPData::DLIST ) { - throw new AFPUserVisibleException( 'notlist', $this->mCur->pos, array() ); + throw new AFPUserVisibleException( 'notlist', $this->mCur->pos, [] ); } $list = $list->toList(); $this->move(); @@ -285,11 +285,11 @@ class AbuseFilterParser { $idx = $idx->toInt(); if ( !( $this->mCur->type == AFPToken::TSQUAREBRACKET && $this->mCur->value == ']' ) ) { throw new AFPUserVisibleException( 'expectednotfound', $this->mCur->pos, - array( ']', $this->mCur->type, $this->mCur->value ) ); + [ ']', $this->mCur->type, $this->mCur->value ] ); } if ( count( $list ) <= $idx ) { throw new AFPUserVisibleException( 'outofbounds', $this->mCur->pos, - array( $idx, count( $result->data ) ) ); + [ $idx, count( $result->data ) ] ); } } $this->move(); @@ -326,11 +326,11 @@ class AbuseFilterParser { if ( !( $this->mCur->type == AFPToken::TKEYWORD && $this->mCur->value == 'then' ) ) { throw new AFPUserVisibleException( 'expectednotfound', $this->mCur->pos, - array( + [ 'then', $this->mCur->type, $this->mCur->value - ) + ] ); } $this->move(); @@ -352,11 +352,11 @@ class AbuseFilterParser { if ( !( $this->mCur->type == AFPToken::TKEYWORD && $this->mCur->value == 'else' ) ) { throw new AFPUserVisibleException( 'expectednotfound', $this->mCur->pos, - array( + [ 'else', $this->mCur->type, $this->mCur->value - ) + ] ); } $this->move(); @@ -373,11 +373,11 @@ class AbuseFilterParser { if ( !( $this->mCur->type == AFPToken::TKEYWORD && $this->mCur->value == 'end' ) ) { throw new AFPUserVisibleException( 'expectednotfound', $this->mCur->pos, - array( + [ 'end', $this->mCur->type, $this->mCur->value - ) + ] ); } $this->move(); @@ -408,11 +408,11 @@ class AbuseFilterParser { if ( !( $this->mCur->type == AFPToken::TOP && $this->mCur->value == ':' ) ) { throw new AFPUserVisibleException( 'expectednotfound', $this->mCur->pos, - array( + [ ':', $this->mCur->type, $this->mCur->value - ) + ] ); } $this->move(); @@ -440,7 +440,7 @@ class AbuseFilterParser { */ protected function doLevelBoolOps( &$result ) { $this->doLevelCompares( $result ); - $ops = array( '&', '|', '^' ); + $ops = [ '&', '|', '^' ]; while ( $this->mCur->type == AFPToken::TOP && in_array( $this->mCur->value, $ops ) ) { $op = $this->mCur->value; $this->move(); @@ -469,7 +469,7 @@ class AbuseFilterParser { */ protected function doLevelCompares( &$result ) { $this->doLevelSumRels( $result ); - $ops = array( '==', '===', '!=', '!==', '<', '>', '<=', '>=', '=' ); + $ops = [ '==', '===', '!=', '!==', '<', '>', '<=', '>=', '=' ]; while ( $this->mCur->type == AFPToken::TOP && in_array( $this->mCur->value, $ops ) ) { $op = $this->mCur->value; $this->move(); @@ -488,7 +488,7 @@ class AbuseFilterParser { */ protected function doLevelSumRels( &$result ) { $this->doLevelMulRels( $result ); - $ops = array( '+', '-' ); + $ops = [ '+', '-' ]; while ( $this->mCur->type == AFPToken::TOP && in_array( $this->mCur->value, $ops ) ) { $op = $this->mCur->value; $this->move(); @@ -511,7 +511,7 @@ class AbuseFilterParser { */ protected function doLevelMulRels( &$result ) { $this->doLevelPow( $result ); - $ops = array( '*', '/', '%' ); + $ops = [ '*', '/', '%' ]; while ( $this->mCur->type == AFPToken::TOP && in_array( $this->mCur->value, $ops ) ) { $op = $this->mCur->value; $this->move(); @@ -611,17 +611,17 @@ class AbuseFilterParser { $this->doLevelSemicolon( $idx ); if ( !( $this->mCur->type == AFPToken::TSQUAREBRACKET && $this->mCur->value == ']' ) ) { throw new AFPUserVisibleException( 'expectednotfound', $this->mCur->pos, - array( ']', $this->mCur->type, $this->mCur->value ) ); + [ ']', $this->mCur->type, $this->mCur->value ] ); } $idx = $idx->toInt(); if ( $result->type == AFPData::DLIST ) { if ( count( $result->data ) <= $idx ) { throw new AFPUserVisibleException( 'outofbounds', $this->mCur->pos, - array( $idx, count( $result->data ) ) ); + [ $idx, count( $result->data ) ] ); } $result = $result->data[$idx]; } else { - throw new AFPUserVisibleException( 'notlist', $this->mCur->pos, array() ); + throw new AFPUserVisibleException( 'notlist', $this->mCur->pos, [] ); } $this->move(); } @@ -642,7 +642,7 @@ class AbuseFilterParser { throw new AFPUserVisibleException( 'expectednotfound', $this->mCur->pos, - array( ')', $this->mCur->type, $this->mCur->value ) + [ ')', $this->mCur->type, $this->mCur->value ] ); } $this->move(); @@ -662,11 +662,11 @@ class AbuseFilterParser { if ( $this->mCur->type != AFPToken::TBRACE || $this->mCur->value != '(' ) { throw new AFPUserVisibleException( 'expectednotfound', $this->mCur->pos, - array( + [ '(', $this->mCur->type, $this->mCur->value - ) + ] ); } @@ -678,7 +678,7 @@ class AbuseFilterParser { } wfProfileIn( __METHOD__ . '-loadargs' ); - $args = array(); + $args = []; do { $r = new AFPData(); $this->doLevelSemicolon( $r ); @@ -688,11 +688,11 @@ class AbuseFilterParser { if ( $this->mCur->type != AFPToken::TBRACE || $this->mCur->value != ')' ) { throw new AFPUserVisibleException( 'expectednotfound', $this->mCur->pos, - array( + [ ')', $this->mCur->type, $this->mCur->value - ) + ] ); } $this->move(); @@ -713,7 +713,7 @@ class AbuseFilterParser { } if ( count( self::$funcCache ) > 1000 ) { - self::$funcCache = array(); + self::$funcCache = []; } wfProfileOut( __METHOD__ . "-$func" ); @@ -757,7 +757,7 @@ class AbuseFilterParser { throw new AFPUserVisibleException( 'unrecognisedkeyword', $this->mCur->pos, - array( $tok ) + [ $tok ] ); } break; @@ -769,7 +769,7 @@ class AbuseFilterParser { } case AFPToken::TSQUAREBRACKET: if ( $this->mCur->value == '[' ) { - $list = array(); + $list = []; while ( true ) { $this->move(); if ( $this->mCur->type == AFPToken::TSQUAREBRACKET && $this->mCur->value == ']' ) { @@ -785,7 +785,7 @@ class AbuseFilterParser { throw new AFPUserVisibleException( 'expectednotfound', $this->mCur->pos, - array( ', or ]', $this->mCur->type, $this->mCur->value ) + [ ', or ]', $this->mCur->type, $this->mCur->value ] ); } } @@ -796,10 +796,10 @@ class AbuseFilterParser { throw new AFPUserVisibleException( 'unexpectedtoken', $this->mCur->pos, - array( + [ $this->mCur->type, $this->mCur->value - ) + ] ); } $this->move(); @@ -822,7 +822,7 @@ class AbuseFilterParser { throw new AFPUserVisibleException( 'unrecognisedvar', $this->mCur->pos, - array( $var ) + [ $var ] ); } else { return $this->mVars->getVar( $var ); @@ -837,7 +837,7 @@ class AbuseFilterParser { protected function setUserVariable( $name, $value ) { $builderValues = AbuseFilter::getBuilderValues(); if ( array_key_exists( $name, $builderValues['vars'] ) ) { - throw new AFPUserVisibleException( 'overridebuiltin', $this->mCur->pos, array( $name ) ); + throw new AFPUserVisibleException( 'overridebuiltin', $this->mCur->pos, [ $name ] ); } $this->mVars->setVar( $name, $value ); } @@ -855,7 +855,7 @@ class AbuseFilterParser { throw new AFPUserVisibleException( 'notenoughargs', $this->mCur->pos, - array( 'lc', 2, count( $args ) ) + [ 'lc', 2, count( $args ) ] ); } $s = $args[0]->toString(); @@ -874,7 +874,7 @@ class AbuseFilterParser { throw new AFPUserVisibleException( 'notenoughargs', $this->mCur->pos, - array( 'uc', 2, count( $args ) ) + [ 'uc', 2, count( $args ) ] ); } $s = $args[0]->toString(); @@ -892,7 +892,7 @@ class AbuseFilterParser { throw new AFPUserVisibleException( 'notenoughargs', $this->mCur->pos, - array( 'len', 2, count( $args ) ) + [ 'len', 2, count( $args ) ] ); } if ( $args[0]->type == AFPData::DLIST ) { @@ -914,7 +914,7 @@ class AbuseFilterParser { throw new AFPUserVisibleException( 'notenoughargs', $this->mCur->pos, - array( 'simplenorm', 2, count( $args ) ) + [ 'simplenorm', 2, count( $args ) ] ); } $s = $args[0]->toString(); @@ -935,7 +935,7 @@ class AbuseFilterParser { throw new AFPUserVisibleException( 'notenoughargs', $this->mCur->pos, - array( 'specialratio', 1, count( $args ) ) + [ 'specialratio', 1, count( $args ) ] ); } $s = $args[0]->toString(); @@ -961,7 +961,7 @@ class AbuseFilterParser { throw new AFPUserVisibleException( 'notenoughargs', $this->mCur->pos, - array( 'count', 1, count( $args ) ) + [ 'count', 1, count( $args ) ] ); } @@ -997,7 +997,7 @@ class AbuseFilterParser { throw new AFPUserVisibleException( 'notenoughargs', $this->mCur->pos, - array( 'rcount', 1, count( $args ) ) + [ 'rcount', 1, count( $args ) ] ); } @@ -1018,7 +1018,7 @@ class AbuseFilterParser { throw new AFPUserVisibleException( 'regexfailure', $this->mCur->pos, - array( 'unspecified error in preg_match_all()', $needle ) + [ 'unspecified error in preg_match_all()', $needle ] ); } } @@ -1036,7 +1036,7 @@ class AbuseFilterParser { throw new AFPUserVisibleException( 'notenoughargs', $this->mCur->pos, - array( 'ip_in_range', 2, count( $args ) ) + [ 'ip_in_range', 2, count( $args ) ] ); } @@ -1058,7 +1058,7 @@ class AbuseFilterParser { throw new AFPUserVisibleException( 'notenoughargs', $this->mCur->pos, - array( 'ccnorm', 1, count( $args ) ) + [ 'ccnorm', 1, count( $args ) ] ); } $s = $args[0]->toString(); @@ -1079,14 +1079,14 @@ class AbuseFilterParser { throw new AFPUserVisibleException( 'notenoughargs', $this->mCur->pos, - array( 'contains_any', 2, count( $args ) ) + [ 'contains_any', 2, count( $args ) ] ); } $s = array_shift( $args ); $s = $s->toString(); - $searchStrings = array(); + $searchStrings = []; foreach ( $args as $arg ) { $searchStrings[] = $arg->toString(); @@ -1139,7 +1139,7 @@ class AbuseFilterParser { 'AbuseFilter', "Can't compute normalized string (ccnorm) as the AntiSpoof Extension isn't installed." ); - $replacementArray = new ReplacementArray( array() ); + $replacementArray = new ReplacementArray( [] ); } } @@ -1180,7 +1180,7 @@ class AbuseFilterParser { throw new AFPUserVisibleException( 'notenoughargs', $this->mCur->pos, - array( 'rmspecials', 1, count( $args ) ) + [ 'rmspecials', 1, count( $args ) ] ); } $s = $args[0]->toString(); @@ -1200,7 +1200,7 @@ class AbuseFilterParser { throw new AFPUserVisibleException( 'notenoughargs', $this->mCur->pos, - array( 'rmwhitespace', 1, count( $args ) ) + [ 'rmwhitespace', 1, count( $args ) ] ); } $s = $args[0]->toString(); @@ -1220,7 +1220,7 @@ class AbuseFilterParser { throw new AFPUserVisibleException( 'notenoughargs', $this->mCur->pos, - array( 'rmdoubles', 1, count( $args ) ) + [ 'rmdoubles', 1, count( $args ) ] ); } $s = $args[0]->toString(); @@ -1240,7 +1240,7 @@ class AbuseFilterParser { throw new AFPUserVisibleException( 'notenoughargs', $this->mCur->pos, - array( 'norm', 1, count( $args ) ) + [ 'norm', 1, count( $args ) ] ); } $s = $args[0]->toString(); @@ -1263,7 +1263,7 @@ class AbuseFilterParser { throw new AFPUserVisibleException( 'notenoughargs', $this->mCur->pos, - array( 'substr', 2, count( $args ) ) + [ 'substr', 2, count( $args ) ] ); } @@ -1291,7 +1291,7 @@ class AbuseFilterParser { throw new AFPUserVisibleException( 'notenoughargs', $this->mCur->pos, - array( 'strpos', 2, count( $args ) ) + [ 'strpos', 2, count( $args ) ] ); } @@ -1328,7 +1328,7 @@ class AbuseFilterParser { throw new AFPUserVisibleException( 'notenoughargs', $this->mCur->pos, - array( 'str_replace', 3, count( $args ) ) + [ 'str_replace', 3, count( $args ) ] ); } @@ -1347,7 +1347,7 @@ class AbuseFilterParser { protected function funcStrRegexEscape( $args ) { if ( count( $args ) < 1 ) { throw new AFPUserVisibleException( 'notenoughargs', $this->mCur->pos, - array( 'rescape', 1, count( $args ) ) ); + [ 'rescape', 1, count( $args ) ] ); } $string = $args[0]->toString(); @@ -1367,7 +1367,7 @@ class AbuseFilterParser { throw new AFPUserVisibleException( 'notenoughargs', $this->mCur->pos, - array( 'set_var', 2, count( $args ) ) + [ 'set_var', 2, count( $args ) ] ); } @@ -1386,7 +1386,7 @@ class AbuseFilterParser { */ protected function castString( $args ) { if ( count( $args ) < 1 ) { - throw new AFPUserVisibleException( 'noparams', $this->mCur->pos, array( __METHOD__ ) ); + throw new AFPUserVisibleException( 'noparams', $this->mCur->pos, [ __METHOD__ ] ); } $val = $args[0]; @@ -1400,7 +1400,7 @@ class AbuseFilterParser { */ protected function castInt( $args ) { if ( count( $args ) < 1 ) { - throw new AFPUserVisibleException( 'noparams', $this->mCur->pos, array( __METHOD__ ) ); + throw new AFPUserVisibleException( 'noparams', $this->mCur->pos, [ __METHOD__ ] ); } $val = $args[0]; @@ -1414,7 +1414,7 @@ class AbuseFilterParser { */ protected function castFloat( $args ) { if ( count( $args ) < 1 ) { - throw new AFPUserVisibleException( 'noparams', $this->mCur->pos, array( __METHOD__ ) ); + throw new AFPUserVisibleException( 'noparams', $this->mCur->pos, [ __METHOD__ ] ); } $val = $args[0]; @@ -1428,7 +1428,7 @@ class AbuseFilterParser { */ protected function castBool( $args ) { if ( count( $args ) < 1 ) { - throw new AFPUserVisibleException( 'noparams', $this->mCur->pos, array( __METHOD__ ) ); + throw new AFPUserVisibleException( 'noparams', $this->mCur->pos, [ __METHOD__ ] ); } $val = $args[0]; diff --git a/includes/parser/AbuseFilterTokenizer.php b/includes/parser/AbuseFilterTokenizer.php index 1a01422b0..ee8fdb63c 100644 --- a/includes/parser/AbuseFilterTokenizer.php +++ b/includes/parser/AbuseFilterTokenizer.php @@ -18,7 +18,7 @@ class AbuseFilterTokenizer { // Order is important. The punctuation-matching regex requires that // ** comes before *, etc. They are sorted to make it easy to spot // such errors. - public static $operators = array( + public static $operators = [ '!==', '!=', '!', // Inequality '**', '*', // Multiplication/exponentiation '/', '+', '-', '%', // Other arithmetic @@ -28,34 +28,34 @@ class AbuseFilterTokenizer { '<=', '<', // Less than '>=', '>', // Greater than '===', '==', '=', // Equality - ); + ]; - public static $punctuation = array( + public static $punctuation = [ ',' => AFPToken::TCOMMA, '(' => AFPToken::TBRACE, ')' => AFPToken::TBRACE, '[' => AFPToken::TSQUAREBRACKET, ']' => AFPToken::TSQUAREBRACKET, ';' => AFPToken::TSTATEMENTSEPARATOR, - ); + ]; - public static $bases = array( + public static $bases = [ 'b' => 2, 'x' => 16, 'o' => 8 - ); + ]; - public static $baseCharsRe = array( + public static $baseCharsRe = [ 2 => '/^[01]+$/', 8 => '/^[0-8]+$/', 16 => '/^[0-9A-Fa-f]+$/', 10 => '/^[0-9.]+$/', - ); + ]; - public static $keywords = array( + public static $keywords = [ 'in', 'like', 'true', 'false', 'null', 'contains', 'matches', 'rlike', 'irlike', 'regex', 'if', 'then', 'else', 'end', - ); + ]; /** * @param string $code @@ -86,13 +86,13 @@ class AbuseFilterTokenizer { } $stats->increment( 'AbuseFilter.tokenizerCache.miss' ); - $tokens = array(); + $tokens = []; $curPos = 0; do { $prevPos = $curPos; $token = self::nextToken( $code, $curPos ); - $tokens[ $token->pos ] = array( $token, $curPos ); + $tokens[ $token->pos ] = [ $token, $curPos ]; } while ( $curPos !== $prevPos ); $tokenizerCache->set( $cacheKey, $tokens, 60 * 60 * 24 ); @@ -108,7 +108,7 @@ class AbuseFilterTokenizer { * @throws AFPUserVisibleException */ protected static function nextToken( $code, &$offset ) { - $matches = array(); + $matches = []; $start = $offset; // Read past comments @@ -135,7 +135,7 @@ class AbuseFilterTokenizer { return self::readStringLiteral( $code, $offset, $start ); } - $matches = array(); + $matches = []; // Operators if ( preg_match( self::OPERATOR_RE, $code, $matches, 0, $offset ) ) { @@ -182,7 +182,7 @@ class AbuseFilterTokenizer { } throw new AFPUserVisibleException( - 'unrecognisedtoken', $start, array( substr( $code, $start ) ) ); + 'unrecognisedtoken', $start, [ substr( $code, $start ) ] ); } /** @@ -249,7 +249,7 @@ class AbuseFilterTokenizer { $offset++; } } - throw new AFPUserVisibleException( 'unclosedstring', $offset, array() ); + throw new AFPUserVisibleException( 'unclosedstring', $offset, [] ); } } diff --git a/maintenance/addMissingLoggingEntries.php b/maintenance/addMissingLoggingEntries.php index 3c8391de9..1711d593d 100644 --- a/maintenance/addMissingLoggingEntries.php +++ b/maintenance/addMissingLoggingEntries.php @@ -17,21 +17,21 @@ class AddMissingLoggingEntries extends Maintenance { } public function execute() { - $logParams = array(); - $afhRows = array(); + $logParams = []; + $afhRows = []; // Find all entries in abuse_filter_history without logging entry of same timestamp $afhResult = wfGetDB( DB_SLAVE, 'vslow' )->select( - array( 'abuse_filter_history', 'logging' ), - array( 'afh_id', 'afh_filter', 'afh_timestamp', 'afh_user', 'afh_deleted', 'afh_user_text' ), - array( 'log_id IS NULL' ), + [ 'abuse_filter_history', 'logging' ], + [ 'afh_id', 'afh_filter', 'afh_timestamp', 'afh_user', 'afh_deleted', 'afh_user_text' ], + [ 'log_id IS NULL' ], __METHOD__, - array(), - array( 'logging' => array( + [], + [ 'logging' => [ 'LEFT JOIN', 'afh_timestamp = log_timestamp AND ' . 'SUBSTRING_INDEX(log_params, \'\n\', 1) = afh_id AND log_type = \'abusefilter\'' - ) ) + ] ] ); // Because the timestamp matches aren't exact (sometimes a couple of @@ -48,8 +48,8 @@ class AddMissingLoggingEntries extends Maintenance { $logResult = wfGetDB( DB_SLAVE )->select( 'logging', - array( 'log_params' ), - array( 'log_type' => 'abusefilter', 'log_params' => $logParams ), + [ 'log_params' ], + [ 'log_type' => 'abusefilter', 'log_params' => $logParams ], __METHOD__ ); @@ -72,7 +72,7 @@ class AddMissingLoggingEntries extends Maintenance { } $dbw->insert( 'logging', - array( + [ 'log_type' => 'abusefilter', 'log_action' => 'modify', 'log_timestamp' => $row->afh_timestamp, @@ -83,7 +83,7 @@ class AddMissingLoggingEntries extends Maintenance { 'log_deleted' => $row->afh_deleted, 'log_user_text' => $row->afh_user_text, 'log_comment' => '' - ), + ], __METHOD__ ); $count++; diff --git a/maintenance/purgeOldLogIPData.php b/maintenance/purgeOldLogIPData.php index c2e310c51..ad1dbdce1 100644 --- a/maintenance/purgeOldLogIPData.php +++ b/maintenance/purgeOldLogIPData.php @@ -28,19 +28,19 @@ class PurgeOldLogIPData extends Maintenance { $ids = $dbw->selectFieldValues( 'abuse_filter_log', 'afl_id', - array( + [ 'afl_ip <> ""', "afl_timestamp < " . $dbw->addQuotes( $dbw->timestamp( $cutoffUnix ) ) - ), + ], __METHOD__, - array( 'LIMIT' => $this->mBatchSize ) + [ 'LIMIT' => $this->mBatchSize ] ); if ( $ids ) { $dbw->update( 'abuse_filter_log', - array( 'afl_ip' => '' ), - array( 'afl_id' => $ids ), + [ 'afl_ip' => '' ], + [ 'afl_id' => $ids ], __METHOD__ ); $count += $dbw->affectedRows(); diff --git a/phpcs.xml b/phpcs.xml index 365683ffd..edb827cf6 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,8 +1,6 @@ - - - + AbuseFilter.alias.php diff --git a/special/SpecialAbuseFilter.php b/special/SpecialAbuseFilter.php index 762dc46e8..04d581910 100644 --- a/special/SpecialAbuseFilter.php +++ b/special/SpecialAbuseFilter.php @@ -31,12 +31,12 @@ class SpecialAbuseFilter extends SpecialPage { $changedFilter = intval( $request->getVal( 'changedfilter' ) ); $changeId = intval( $request->getVal( 'changeid' ) ); $out->wrapWikiMsg( '

$1

', - array( + [ 'abusefilter-edit-done', $changedFilter, $changeId, $this->getLanguage()->formatNum( $changedFilter ) - ) + ] ); } diff --git a/special/SpecialAbuseLog.php b/special/SpecialAbuseLog.php index 3708ee428..853424b39 100644 --- a/special/SpecialAbuseLog.php +++ b/special/SpecialAbuseLog.php @@ -42,7 +42,7 @@ class SpecialAbuseLog extends SpecialPage { // Are we allowed? $errors = $this->getPageTitle()->getUserPermissionsErrors( - 'abusefilter-log', $this->getUser(), true, array( 'ns-specialprotected' ) ); + 'abusefilter-log', $this->getUser(), true, [ 'ns-specialprotected' ] ); if ( count( $errors ) ) { // Go away. $out->showPermissionsErrorPage( $errors, 'abusefilter-log' ); @@ -100,37 +100,37 @@ class SpecialAbuseLog extends SpecialPage { function searchForm() { global $wgAbuseFilterIsCentral; - $formDescriptor = array( - 'SearchUser' => array( + $formDescriptor = [ + 'SearchUser' => [ 'label-message' => 'abusefilter-log-search-user', 'type' => 'user', 'default' => $this->mSearchUser, 'size' => 45, - ), - 'SearchTitle' => array( + ], + 'SearchTitle' => [ 'label-message' => 'abusefilter-log-search-title', 'type' => 'title', 'default' => $this->mSearchTitle, 'size' => 45, - ) - ); + ] + ]; if ( self::canSeeDetails() ) { - $formDescriptor['SearchFilter'] = array( + $formDescriptor['SearchFilter'] = [ 'label-message' => 'abusefilter-log-search-filter', 'type' => 'text', 'default' => $this->mSearchFilter, 'size' => 45, - ); + ]; } if ( $wgAbuseFilterIsCentral ) { // Add free form input for wiki name. Would be nice to generate // a select with unique names in the db at some point. - $formDescriptor['SearchWiki'] = array( + $formDescriptor['SearchWiki'] = [ 'label-message' => 'abusefilter-log-search-wiki', 'type' => 'text', 'default' => $this->mSearchWiki, 'size' => 45, - ); + ]; } $htmlForm = HTMLForm::factory( 'table', $formDescriptor, $this->getContext() ); @@ -155,40 +155,40 @@ class SpecialAbuseLog extends SpecialPage { $dbr = wfGetDB( DB_SLAVE ); $row = $dbr->selectRow( - array( 'abuse_filter_log', 'abuse_filter' ), + [ 'abuse_filter_log', 'abuse_filter' ], '*', - array( 'afl_id' => $id ), + [ 'afl_id' => $id ], __METHOD__, - array(), - array( 'abuse_filter' => array( 'LEFT JOIN', 'af_id=afl_filter' ) ) + [], + [ 'abuse_filter' => [ 'LEFT JOIN', 'af_id=afl_filter' ] ] ); if ( !$row ) { return; } - $formInfo = array( - 'logid' => array( + $formInfo = [ + 'logid' => [ 'type' => 'info', 'default' => $id, 'label-message' => 'abusefilter-log-hide-id', - ), - 'reason' => array( + ], + 'reason' => [ 'type' => 'text', 'label-message' => 'abusefilter-log-hide-reason', - ), - 'hidden' => array( + ], + 'hidden' => [ 'type' => 'toggle', 'default' => $row->afl_deleted, 'label-message' => 'abusefilter-log-hide-hidden', - ), - ); + ], + ]; $form = new HTMLForm( $formInfo, $this->getContext() ); $form->setTitle( $this->getPageTitle() ); $form->setWrapperLegend( $this->msg( 'abusefilter-log-hide-legend' )->text() ); $form->addHiddenField( 'hide', $id ); - $form->setSubmitCallback( array( $this, 'saveHideForm' ) ); + $form->setSubmitCallback( [ $this, 'saveHideForm' ] ); $form->show(); } @@ -203,8 +203,8 @@ class SpecialAbuseLog extends SpecialPage { $dbw->update( 'abuse_filter_log', - array( 'afl_deleted' => $fields['hidden'] ), - array( 'afl_id' => $logid ), + [ 'afl_deleted' => $fields['hidden'] ], + [ 'afl_id' => $logid ], __METHOD__ ); @@ -222,7 +222,7 @@ class SpecialAbuseLog extends SpecialPage { $out = $this->getOutput(); // Generate conditions list. - $conds = array(); + $conds = []; if ( $this->mSearchUser ) { $user = User::newFromName( $this->mSearchUser ); @@ -281,7 +281,7 @@ class SpecialAbuseLog extends SpecialPage { $result = $pager->getResult(); if ( $result && $result->numRows() !== 0 ) { $out->addHTML( $pager->getNavigationBar() . - Xml::tags( 'ul', array( 'class' => 'plainlinks' ), $pager->getBody() ) . + Xml::tags( 'ul', [ 'class' => 'plainlinks' ], $pager->getBody() ) . $pager->getNavigationBar() ); } else { $out->addWikiMsg( 'abusefilter-log-noresults' ); @@ -298,12 +298,12 @@ class SpecialAbuseLog extends SpecialPage { $dbr = wfGetDB( DB_SLAVE ); $row = $dbr->selectRow( - array( 'abuse_filter_log', 'abuse_filter' ), + [ 'abuse_filter_log', 'abuse_filter' ], '*', - array( 'afl_id' => $id ), + [ 'afl_id' => $id ], __METHOD__, - array(), - array( 'abuse_filter' => array( 'LEFT JOIN', 'af_id=afl_filter' ) ) + [], + [ 'abuse_filter' => [ 'LEFT JOIN', 'af_id=afl_filter' ] ] ); if ( !$row ) { @@ -376,10 +376,10 @@ class SpecialAbuseLog extends SpecialPage { $output .= Xml::element( 'h3', null, $this->msg( 'abusefilter-log-details-private' )->text() ); $output .= Xml::openElement( 'table', - array( + [ 'class' => 'wikitable mw-abuselog-private', 'style' => 'width: 80%;' - ) + ] ) . Xml::openElement( 'tbody' ); $output .= $header; @@ -388,7 +388,7 @@ class SpecialAbuseLog extends SpecialPage { $output .= Xml::tags( 'tr', null, Xml::element( 'td', - array( 'style' => 'width: 30%;' ), + [ 'style' => 'width: 30%;' ], $this->msg( 'abusefilter-log-details-ip' )->text() ) . Xml::element( 'td', null, $row->afl_ip ) @@ -451,7 +451,7 @@ class SpecialAbuseLog extends SpecialPage { $user = $this->getUser(); $lang = $this->getLanguage(); - $actionLinks = array(); + $actionLinks = []; $title = Title::makeTitle( $row->afl_namespace, $row->afl_title ); @@ -470,8 +470,8 @@ class SpecialAbuseLog extends SpecialPage { $diffLink = $linkRenderer->makeKnownLink( $title, new HtmlArmor( $this->msg( 'abusefilter-log-diff' )->parse() ), - array(), - array( 'diff' => 'prev', 'oldid' => $row->afl_rev_id ) ); + [], + [ 'diff' => 'prev', 'oldid' => $row->afl_rev_id ] ); } } else { $pageLink = WikiMap::makeForeignLink( $row->afl_wiki, $row->afl_title ); @@ -479,7 +479,7 @@ class SpecialAbuseLog extends SpecialPage { if ( $row->afl_rev_id ) { $diffUrl = WikiMap::getForeignURL( $row->afl_wiki, $row->afl_title ); $diffUrl = wfAppendQuery( $diffUrl, - array( 'diff' => 'prev', 'oldid' => $row->afl_rev_id ) ); + [ 'diff' => 'prev', 'oldid' => $row->afl_rev_id ] ); $diffLink = Linker::makeExternalLink( $diffUrl, $this->msg( 'abusefilter-log-diff' )->parse() ); @@ -501,7 +501,7 @@ class SpecialAbuseLog extends SpecialPage { $actions_taken = $this->msg( 'abusefilter-log-noactions' )->text(); } else { $actions = explode( ',', $actions_taken ); - $displayActions = array(); + $displayActions = []; foreach ( $actions as $action ) { $displayActions[] = AbuseFilter::getActionDisplay( $action ); @@ -545,8 +545,8 @@ class SpecialAbuseLog extends SpecialPage { $hideLink = $linkRenderer->makeKnownLink( $this->getPageTitle(), $this->msg( 'abusefilter-log-hidelink' )->text(), - array(), - array( 'hide' => $row->afl_id ) + [], + [ 'hide' => $row->afl_id ] ); $actionLinks[] = $hideLink; @@ -604,14 +604,14 @@ class SpecialAbuseLog extends SpecialPage { } if ( $isListItem ) { - return Xml::tags( 'li', isset( $class ) ? array( 'class' => $class ) : null, $description ); + return Xml::tags( 'li', isset( $class ) ? [ 'class' => $class ] : null, $description ); } else { - return Xml::tags( 'span', isset( $class ) ? array( 'class' => $class ) : null, $description ); + return Xml::tags( 'span', isset( $class ) ? [ 'class' => $class ] : null, $description ); } } protected static function getUserLinks( $userId, $userName ) { - static $cache = array(); + static $cache = []; if ( !isset( $cache[$userName][$userId] ) ) { $cache[$userName][$userId] = Linker::userLink( $userId, $userName ) . @@ -627,11 +627,11 @@ class SpecialAbuseLog extends SpecialPage { */ public static function getNotDeletedCond( $db ) { $deletedZeroCond = $db->makeList( - array( 'afl_deleted' => 0 ), LIST_AND ); + [ 'afl_deleted' => 0 ], LIST_AND ); $deletedNullCond = $db->makeList( - array( 'afl_deleted' => null ), LIST_AND ); + [ 'afl_deleted' => null ], LIST_AND ); $notDeletedCond = $db->makeList( - array( $deletedZeroCond, $deletedNullCond ), LIST_OR ); + [ $deletedZeroCond, $deletedNullCond ], LIST_OR ); return $notDeletedCond; } @@ -676,7 +676,7 @@ class AbuseLogPager extends ReverseChronologicalPager { * @param array $conds * @param bool $details */ - function __construct( $form, $conds = array(), $details = false ) { + function __construct( $form, $conds = [], $details = false ) { $this->mForm = $form; $this->mConds = $conds; parent::__construct(); @@ -689,18 +689,18 @@ class AbuseLogPager extends ReverseChronologicalPager { function getQueryInfo() { $conds = $this->mConds; - $info = array( - 'tables' => array( 'abuse_filter_log', 'abuse_filter' ), + $info = [ + 'tables' => [ 'abuse_filter_log', 'abuse_filter' ], 'fields' => '*', 'conds' => $conds, 'join_conds' => - array( 'abuse_filter' => - array( + [ 'abuse_filter' => + [ 'LEFT JOIN', 'af_id=afl_filter', - ), - ), - ); + ], + ], + ]; if ( !$this->mForm->canSeeHidden() ) { $db = $this->mDb; diff --git a/tests/phpunit/parserTest.php b/tests/phpunit/parserTest.php index cd6c96ced..b253e8584 100644 --- a/tests/phpunit/parserTest.php +++ b/tests/phpunit/parserTest.php @@ -70,7 +70,7 @@ class AbuseFilterParserTest extends MediaWikiTestCase { * @return array */ public function readTests() { - $tests = array(); + $tests = []; $testPath = __DIR__ . "/../parserTests"; $testFiles = glob( $testPath . "/*.t" ); @@ -81,11 +81,11 @@ class AbuseFilterParserTest extends MediaWikiTestCase { $rule = trim( file_get_contents( $testFile ) ); $result = trim( file_get_contents( $resultFile ) ) == 'MATCH'; - $tests[] = array( + $tests[] = [ basename( $testName ), $rule, $result - ); + ]; } return $tests; @@ -132,14 +132,14 @@ class AbuseFilterParserTest extends MediaWikiTestCase { * @return array */ public function condCountCases() { - return array( - array( '(((a == b)))', 1 ), - array( 'contains_any(a, b, c)', 1 ), - array( 'a == b == c', 2 ), - array( 'a in b + c in d + e in f', 3 ), - array( 'true', 0 ), - array( 'a == a | c == d', 1 ), - array( 'a == b & c == d', 1 ), - ); + return [ + [ '(((a == b)))', 1 ], + [ 'contains_any(a, b, c)', 1 ], + [ 'a == b == c', 2 ], + [ 'a in b + c in d + e in f', 3 ], + [ 'true', 0 ], + [ 'a == a | c == d', 1 ], + [ 'a == b & c == d', 1 ], + ]; } }