From 6e9b4f0e9ce4ccd6089c18b205065ef7fa077484 Mon Sep 17 00:00:00 2001
From: Kunal Mehta ' . implode( ' ',
array_filter(
- array(
+ [
$actiontext,
- Linker::formatComment( $comment ) ) ) ) . "$1
', "yourtext" );
$this->showTextbox2();
- $wgOut->addReturnTo( $this->getContextTitle(), array( 'action' => 'edit' ) );
+ $wgOut->addReturnTo( $this->getContextTitle(), [ 'action' => 'edit' ] );
}
/**
@@ -4106,7 +4106,7 @@ HTML
*/
private function makeSafe( $invalue ) {
// Armor existing references for reversibility.
- $invalue = strtr( $invalue, array( "" => "" ) );
+ $invalue = strtr( $invalue, [ "" => "" ] );
$bytesleft = 0;
$result = "";
@@ -4172,6 +4172,6 @@ HTML
}
}
// reverse the transform that we made for reversibility reasons.
- return strtr( $result, array( "" => "" ) );
+ return strtr( $result, [ "" => "" ] );
}
}
diff --git a/includes/EventRelayerGroup.php b/includes/EventRelayerGroup.php
index 3af756dccb..9dfac795a6 100644
--- a/includes/EventRelayerGroup.php
+++ b/includes/EventRelayerGroup.php
@@ -7,10 +7,10 @@
*/
class EventRelayerGroup {
/** @var array[] */
- protected $configByChannel = array();
+ protected $configByChannel = [];
/** @var EventRelayer[] */
- protected $relayers = array();
+ protected $relayers = [];
/** @var EventRelayerGroup */
protected static $instance = null;
diff --git a/includes/Fallback.php b/includes/Fallback.php
index 8e7f4b7e27..4c19dca267 100644
--- a/includes/Fallback.php
+++ b/includes/Fallback.php
@@ -138,7 +138,7 @@ class Fallback {
public static function mb_strpos( $haystack, $needle, $offset = 0, $encoding = '' ) {
$needle = preg_quote( $needle, '/' );
- $ar = array();
+ $ar = [];
preg_match( '/' . $needle . '/u', $haystack, $ar, PREG_OFFSET_CAPTURE, $offset );
if ( isset( $ar[0][1] ) ) {
@@ -159,7 +159,7 @@ class Fallback {
public static function mb_strrpos( $haystack, $needle, $offset = 0, $encoding = '' ) {
$needle = preg_quote( $needle, '/' );
- $ar = array();
+ $ar = [];
preg_match_all( '/' . $needle . '/u', $haystack, $ar, PREG_OFFSET_CAPTURE, $offset );
if ( isset( $ar[0] ) && count( $ar[0] ) > 0 &&
diff --git a/includes/FauxRequest.php b/includes/FauxRequest.php
index f049d2ece0..c2108f207a 100644
--- a/includes/FauxRequest.php
+++ b/includes/FauxRequest.php
@@ -33,7 +33,7 @@ use MediaWiki\Session\SessionManager;
class FauxRequest extends WebRequest {
private $wasPosted = false;
private $requestUrl;
- protected $cookies = array();
+ protected $cookies = [];
/**
* @param array $data Array of *non*-urlencoded key => value pairs, the
@@ -44,7 +44,7 @@ class FauxRequest extends WebRequest {
* @param string $protocol 'http' or 'https'
* @throws MWException
*/
- public function __construct( $data = array(), $wasPosted = false,
+ public function __construct( $data = [], $wasPosted = false,
$session = null, $protocol = 'http'
) {
$this->requestTime = microtime( true );
@@ -98,7 +98,7 @@ class FauxRequest extends WebRequest {
*/
public function getQueryValues() {
if ( $this->wasPosted ) {
- return array();
+ return [];
} else {
return $this->data;
}
@@ -131,7 +131,7 @@ class FauxRequest extends WebRequest {
* @param string|null $prefix Cookie prefix. Defaults to $wgCookiePrefix
*/
public function setCookie( $key, $value, $prefix = null ) {
- $this->setCookies( array( $key => $value ), $prefix );
+ $this->setCookies( [ $key => $value ], $prefix );
}
/**
@@ -177,7 +177,7 @@ class FauxRequest extends WebRequest {
* @param string $val
*/
public function setHeader( $name, $val ) {
- $this->setHeaders( array( $name => $val ) );
+ $this->setHeaders( [ $name => $val ] );
}
/**
@@ -229,7 +229,7 @@ class FauxRequest extends WebRequest {
* @param array $extWhitelist
* @return bool
*/
- public function checkUrlExtension( $extWhitelist = array() ) {
+ public function checkUrlExtension( $extWhitelist = [] ) {
return true;
}
diff --git a/includes/Feed.php b/includes/Feed.php
index 2133dae48c..8bfe1c7ef9 100644
--- a/includes/Feed.php
+++ b/includes/Feed.php
@@ -248,12 +248,12 @@ abstract class ChannelFeed extends FeedItem {
global $wgRequest;
$ctype = $wgRequest->getVal( 'ctype', 'application/xml' );
- $allowedctypes = array(
+ $allowedctypes = [
'application/xml',
'text/xml',
'application/rss+xml',
'application/atom+xml'
- );
+ ];
return ( in_array( $ctype, $allowedctypes ) ? $ctype : 'application/xml' );
}
diff --git a/includes/FeedUtils.php b/includes/FeedUtils.php
index b058975b73..d7dbd2292e 100644
--- a/includes/FeedUtils.php
+++ b/includes/FeedUtils.php
@@ -111,9 +111,9 @@ class FeedUtils {
// log entries
$completeText = '
' . $link . '
'; } @@ -398,7 +398,7 @@ class FileDeleteForm { * @return string */ private function getAction() { - $q = array(); + $q = []; $q['action'] = 'delete'; if ( $this->oldimage ) { diff --git a/includes/ForkController.php b/includes/ForkController.php index 4a021ee1e5..2725753498 100644 --- a/includes/ForkController.php +++ b/includes/ForkController.php @@ -30,11 +30,11 @@ * @ingroup Maintenance */ class ForkController { - protected $children = array(), $childNumber = 0; + protected $children = [], $childNumber = 0; protected $termReceived = false; protected $flags = 0, $procsToStart = 0; - protected static $restartableSignals = array( + protected static $restartableSignals = [ SIGFPE, SIGILL, SIGSEGV, @@ -44,7 +44,7 @@ class ForkController { SIGPIPE, SIGXCPU, SIGXFSZ, - ); + ]; /** * Pass this flag to __construct() to cause the class to automatically restart @@ -73,7 +73,7 @@ class ForkController { */ public function start() { // Trap SIGTERM - pcntl_signal( SIGTERM, array( $this, 'handleTermSignal' ), false ); + pcntl_signal( SIGTERM, [ $this, 'handleTermSignal' ], false ); do { // Start child processes diff --git a/includes/FormOptions.php b/includes/FormOptions.php index c91c336762..5e5e8d4011 100644 --- a/includes/FormOptions.php +++ b/includes/FormOptions.php @@ -64,7 +64,7 @@ class FormOptions implements ArrayAccess { * consumeValue() or consumeValues() * - 'type' - one of the type constants (but never AUTO) */ - protected $options = array(); + protected $options = []; # Setting up @@ -76,7 +76,7 @@ class FormOptions implements ArrayAccess { * @param int $type One of the type constants (optional, defaults to AUTO) */ public function add( $name, $default, $type = self::AUTO ) { - $option = array(); + $option = []; $option['default'] = $default; $option['value'] = null; $option['consumed'] = false; @@ -228,7 +228,7 @@ class FormOptions implements ArrayAccess { * @return array Array of option values, or the default values if they are null */ public function consumeValues( $names ) { - $out = array(); + $out = []; foreach ( $names as $name ) { $this->validateName( $name, true ); @@ -278,7 +278,7 @@ class FormOptions implements ArrayAccess { * @return array */ public function getUnconsumedValues( $all = false ) { - $values = array(); + $values = []; foreach ( $this->options as $name => $data ) { if ( !$data['consumed'] ) { @@ -296,7 +296,7 @@ class FormOptions implements ArrayAccess { * @return array */ public function getChangedValues() { - $values = array(); + $values = []; foreach ( $this->options as $name => $data ) { if ( $data['value'] !== null ) { @@ -312,7 +312,7 @@ class FormOptions implements ArrayAccess { * @return array */ public function getAllValues() { - $values = array(); + $values = []; foreach ( $this->options as $name => $data ) { $values[$name] = $this->getValueReal( $data ); diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index a1ea9360cf..ac1dd6d049 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -293,13 +293,13 @@ function wfAppendToArrayIfNotDefault( $key, $value, $default, &$changed ) { */ function wfMergeErrorArrays( /*...*/ ) { $args = func_get_args(); - $out = array(); + $out = []; foreach ( $args as $errors ) { foreach ( $errors as $params ) { $originalParams = $params; if ( $params[0] instanceof MessageSpecifier ) { $msg = $params[0]; - $params = array_merge( array( $msg->getKey() ), $msg->getParams() ); + $params = array_merge( [ $msg->getKey() ], $msg->getParams() ); } # @todo FIXME: Sometimes get nested arrays for $params, # which leads to E_NOTICEs @@ -342,7 +342,7 @@ function wfArrayInsertAfter( array $array, array $insert, $after ) { * @return array */ function wfObjectToArray( $objOrArray, $recursive = true ) { - $array = array(); + $array = []; if ( is_object( $objOrArray ) ) { $objOrArray = get_object_vars( $objOrArray ); } @@ -429,7 +429,7 @@ function wfUrlencode( $s ) { } if ( is_null( $needle ) ) { - $needle = array( '%3B', '%40', '%24', '%21', '%2A', '%28', '%29', '%2C', '%2F', '%7E' ); + $needle = [ '%3B', '%40', '%24', '%21', '%2A', '%28', '%29', '%2C', '%2F', '%7E' ]; if ( !isset( $_SERVER['SERVER_SOFTWARE'] ) || ( strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS/7' ) === false ) ) { @@ -440,7 +440,7 @@ function wfUrlencode( $s ) { $s = urlencode( $s ); $s = str_ireplace( $needle, - array( ';', '@', '$', '!', '*', '(', ')', ',', '/', '~', ':' ), + [ ';', '@', '$', '!', '*', '(', ')', ',', '/', '~', ':' ], $s ); @@ -507,7 +507,7 @@ function wfCgiToArray( $query ) { $query = substr( $query, 1 ); } $bits = explode( '&', $query ); - $ret = array(); + $ret = []; foreach ( $bits as $bit ) { if ( $bit === '' ) { continue; @@ -527,7 +527,7 @@ function wfCgiToArray( $query ) { $temp = $value; foreach ( $keys as $k ) { $k = substr( $k, 0, -1 ); - $temp = array( $k => $temp ); + $temp = [ $k => $temp ]; } if ( isset( $ret[$key] ) ) { $ret[$key] = array_merge( $ret[$key], $temp ); @@ -806,7 +806,7 @@ function wfUrlProtocols( $includeProtocolRelative = true ) { // Support old-style $wgUrlProtocols strings, for backwards compatibility // with LocalSettings files from 1.5 if ( is_array( $wgUrlProtocols ) ) { - $protocols = array(); + $protocols = []; foreach ( $wgUrlProtocols as $protocol ) { // Filter out '//' if !$includeProtocolRelative if ( $includeProtocolRelative || $protocol !== '//' ) { @@ -988,9 +988,9 @@ function wfMakeUrlIndexes( $url ) { } if ( $prot == '' ) { - return array( "http:$index", "https:$index" ); + return [ "http:$index", "https:$index" ]; } else { - return array( $index ); + return [ $index ]; } } @@ -1034,7 +1034,7 @@ function wfMatchesDomainList( $url, $domains ) { * - false: same as 'private' * @param array $context Additional logging context data */ -function wfDebug( $text, $dest = 'all', array $context = array() ) { +function wfDebug( $text, $dest = 'all', array $context = [] ) { global $wgDebugRawPage, $wgDebugLogPrefix; global $wgDebugTimestamps, $wgRequestTime; @@ -1128,7 +1128,7 @@ function wfDebugMem( $exact = false ) { * @param array $context Additional logging context data */ function wfDebugLog( - $logGroup, $text, $dest = 'all', array $context = array() + $logGroup, $text, $dest = 'all', array $context = [] ) { $text = trim( $text ); @@ -1145,7 +1145,7 @@ function wfDebugLog( * @param string $text Database error message. * @param array $context Additional logging context data */ -function wfLogDBError( $text, array $context = array() ) { +function wfLogDBError( $text, array $context = [] ) { $logger = LoggerFactory::getInstance( 'wfLogDBError' ); $logger->error( trim( $text ), $context ); } @@ -1207,7 +1207,7 @@ function wfLogWarning( $msg, $callerOffset = 1, $level = E_USER_WARNING ) { * @throws MWException * @deprecated since 1.25 Use \MediaWiki\Logger\LegacyLogger::emit or UDPTransport */ -function wfErrorLog( $text, $file, array $context = array() ) { +function wfErrorLog( $text, $file, array $context = [] ) { wfDeprecated( __METHOD__, '1.25' ); $logger = LoggerFactory::getInstance( 'wfErrorLog' ); $context['destination'] = $file; @@ -1256,7 +1256,7 @@ function wfLogProfilingData() { return; } - $ctx = array( 'elapsed' => $request->getElapsedTime() ); + $ctx = [ 'elapsed' => $request->getElapsedTime() ]; if ( !empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { $ctx['forwarded_for'] = $_SERVER['HTTP_X_FORWARDED_FOR']; } @@ -1466,7 +1466,7 @@ function wfMsgReplaceArgs( $message, $args ) { if ( is_array( $args[0] ) ) { $args = array_values( $args[0] ); } - $replacementKeys = array(); + $replacementKeys = []; foreach ( $args as $n => $param ) { $replacementKeys['$' . ( $n + 1 )] = $param; } @@ -1527,7 +1527,7 @@ function wfReportTime() { global $wgRequestTime, $wgShowHostnames; $responseTime = round( ( microtime( true ) - $wgRequestTime ) * 1000 ); - $reportVars = array( 'wgBackendResponseTime' => $responseTime ); + $reportVars = [ 'wgBackendResponseTime' => $responseTime ]; if ( $wgShowHostnames ) { $reportVars['wgHostname'] = wfHostname(); } @@ -1554,7 +1554,7 @@ function wfDebugBacktrace( $limit = 0 ) { } } if ( $disabled ) { - return array(); + return []; } if ( $limit && version_compare( PHP_VERSION, '5.4.0', '>=' ) ) { @@ -1675,7 +1675,7 @@ function wfClientAcceptsGzip( $force = false ) { $result = false; if ( isset( $_SERVER['HTTP_ACCEPT_ENCODING'] ) ) { # @todo FIXME: We may want to blacklist some broken browsers - $m = array(); + $m = []; if ( preg_match( '/\bgzip(?:;(q)=([0-9]+(?:\.[0-9]+)))?\b/', $_SERVER['HTTP_ACCEPT_ENCODING'], @@ -1706,7 +1706,7 @@ function wfClientAcceptsGzip( $force = false ) { function wfEscapeWikiText( $text ) { static $repl = null, $repl2 = null; if ( $repl === null ) { - $repl = array( + $repl = [ '"' => '"', '&' => '&', "'" => ''', '<' => '<', '=' => '=', '>' => '>', '[' => '[', ']' => ']', '{' => '{', '|' => '|', '}' => '}', ';' => ';', @@ -1719,10 +1719,10 @@ function wfEscapeWikiText( $text ) { "\n\t" => "\n ", "\r\t" => "\r ", // "\n\t\n" is treated like "\n\n" "\n----" => "\n----", "\r----" => "\r----", '__' => '__', '://' => '://', - ); + ]; // We have to catch everything "\s" matches in PCRE - foreach ( array( 'ISBN', 'RFC', 'PMID' ) as $magic ) { + foreach ( [ 'ISBN', 'RFC', 'PMID' ] as $magic ) { $repl["$magic "] = "$magic "; $repl["$magic\t"] = "$magic "; $repl["$magic\r"] = "$magic "; @@ -1732,7 +1732,7 @@ function wfEscapeWikiText( $text ) { // And handle protocols that don't use "://" global $wgUrlProtocols; - $repl2 = array(); + $repl2 = []; foreach ( $wgUrlProtocols as $prot ) { if ( substr( $prot, -1 ) === ':' ) { $repl2[] = preg_quote( substr( $prot, 0, -1 ), '/' ); @@ -1912,17 +1912,17 @@ function wfClearOutputBuffers() { function wfAcceptToPrefs( $accept, $def = '*/*' ) { # No arg means accept anything (per HTTP spec) if ( !$accept ) { - return array( $def => 1.0 ); + return [ $def => 1.0 ]; } - $prefs = array(); + $prefs = []; $parts = explode( ',', $accept ); foreach ( $parts as $part ) { # @todo FIXME: Doesn't deal with params like 'text/html; level=1' $values = explode( ';', trim( $part ) ); - $match = array(); + $match = []; if ( count( $values ) == 1 ) { $prefs[$values[0]] = 1.0; } elseif ( preg_match( '/q\s*=\s*(\d*\.\d+)/', $values[1], $match ) ) { @@ -1974,7 +1974,7 @@ function mimeTypeMatch( $type, $avail ) { * XXX: generalize to negotiate other stuff */ function wfNegotiateType( $cprefs, $sprefs ) { - $combine = array(); + $combine = []; foreach ( array_keys( $sprefs ) as $type ) { $parts = explode( '/', $type ); @@ -2164,7 +2164,7 @@ function wfTempDir() { return $wgTmpDirectory; } - $tmpDir = array_map( "getenv", array( 'TMPDIR', 'TMP', 'TEMP' ) ); + $tmpDir = array_map( "getenv", [ 'TMPDIR', 'TMP', 'TEMP' ] ); $tmpDir[] = sys_get_temp_dir(); $tmpDir[] = ini_get( 'upload_tmp_dir' ); @@ -2201,7 +2201,7 @@ function wfMkdirParents( $dir, $mode = null, $caller = null ) { return true; } - $dir = str_replace( array( '\\', '/' ), DIRECTORY_SEPARATOR, $dir ); + $dir = str_replace( [ '\\', '/' ], DIRECTORY_SEPARATOR, $dir ); if ( is_null( $mode ) ) { $mode = $wgDirectoryMode; @@ -2349,7 +2349,7 @@ function wfEscapeShellArg( /*...*/ ) { } // Double the backslashes before the end of the string, because // we will soon add a quote - $m = array(); + $m = []; if ( preg_match( '/^(.*?)(\\\\+)$/', $arg, $m ) ) { $arg = $m[1] . str_replace( '\\', '\\\\', $m[2] ); } @@ -2404,8 +2404,8 @@ function wfShellExecDisabled() { * * @return string Collected stdout as a string */ -function wfShellExec( $cmd, &$retval = null, $environ = array(), - $limits = array(), $options = array() +function wfShellExec( $cmd, &$retval = null, $environ = [], + $limits = [], $options = [] ) { global $IP, $wgMaxShellMemory, $wgMaxShellFileSize, $wgMaxShellTime, $wgMaxShellWallClockTime, $wgShellCgroup; @@ -2478,12 +2478,12 @@ function wfShellExec( $cmd, &$retval = null, $environ = array(), } wfDebug( "wfShellExec: $cmd\n" ); - $desc = array( - 0 => array( 'file', 'php://stdin', 'r' ), - 1 => array( 'pipe', 'w' ), - 2 => array( 'file', 'php://stderr', 'w' ) ); + $desc = [ + 0 => [ 'file', 'php://stdin', 'r' ], + 1 => [ 'pipe', 'w' ], + 2 => [ 'file', 'php://stderr', 'w' ] ]; if ( $useLogPipe ) { - $desc[3] = array( 'pipe', 'w' ); + $desc[3] = [ 'pipe', 'w' ]; } $pipes = null; $scoped = Profiler::instance()->scopedProfileIn( __FUNCTION__ . '-' . $profileMethod ); @@ -2494,7 +2494,7 @@ function wfShellExec( $cmd, &$retval = null, $environ = array(), return ''; } $outBuffer = $logBuffer = ''; - $emptyArray = array(); + $emptyArray = []; $status = false; $logMsg = false; @@ -2515,7 +2515,7 @@ function wfShellExec( $cmd, &$retval = null, $environ = array(), // Build a table mapping resource IDs to pipe FDs to work around a // PHP 5.3 issue in which stream_select() does not preserve array keys //{$link}
\n" ); } @@ -2707,7 +2707,7 @@ class OutputPage extends ContextSource { // Our XML declaration is output by Html::htmlHeader. // http://www.whatwg.org/html/semantics.html#attr-meta-http-equiv-content-type // http://www.whatwg.org/html/semantics.html#charset - $ret .= Html::element( 'meta', array( 'charset' => 'UTF-8' ) ) . "\n"; + $ret .= Html::element( 'meta', [ 'charset' => 'UTF-8' ] ) . "\n"; } $ret .= Html::element( 'title', null, $this->getHTMLTitle() ) . "\n"; @@ -2728,7 +2728,7 @@ class OutputPage extends ContextSource { $ret .= "$closeHead\n"; } - $bodyClasses = array(); + $bodyClasses = []; $bodyClasses[] = 'mediawiki'; # Classes for LTR/RTL directionality support @@ -2745,14 +2745,14 @@ class OutputPage extends ContextSource { $bodyClasses[] = 'action-' . Sanitizer::escapeClass( Action::getActionName( $this->getContext() ) ); - $bodyAttrs = array(); + $bodyAttrs = []; // While the implode() is not strictly needed, it's used for backwards compatibility // (this used to be built as a string and hooks likely still expect that). $bodyAttrs['class'] = implode( ' ', $bodyClasses ); // Allow skins and extensions to add body attributes they need $sk->addToBodyAttributes( $this, $bodyAttrs ); - Hooks::run( 'OutputPageBodyAttributes', array( $this, $sk, &$bodyAttrs ) ); + Hooks::run( 'OutputPageBodyAttributes', [ $this, $sk, &$bodyAttrs ] ); $ret .= Html::openElement( 'body', $bodyAttrs ) . "\n"; @@ -2784,15 +2784,15 @@ class OutputPage extends ContextSource { * @param array $extraQuery [optional] Array with extra query parameters for the request * @return array A list of HTML strings and array of client loader preset states */ - public function makeResourceLoaderLink( $modules, $only, array $extraQuery = array() ) { + public function makeResourceLoaderLink( $modules, $only, array $extraQuery = [] ) { $modules = (array)$modules; - $links = array( + $links = [ // List of html strings - 'html' => array(), + 'html' => [], // Associative array of module names and their states - 'states' => array(), - ); + 'states' => [], + ]; if ( !count( $modules ) ) { return $links; @@ -2820,7 +2820,7 @@ class OutputPage extends ContextSource { } // Create keyed-by-source and then keyed-by-group list of module objects from modules list - $sortedModules = array(); + $sortedModules = []; $resourceLoader = $this->getResourceLoader(); foreach ( $modules as $name ) { $module = $resourceLoader->getModule( $name ); @@ -2851,7 +2851,7 @@ class OutputPage extends ContextSource { // Create a fake request based on the one we are about to make so modules return // correct timestamp and emptiness data $query = ResourceLoader::makeLoaderQuery( - array(), // modules; not determined yet + [], // modules; not determined yet $this->getLanguage()->getCode(), $this->getSkin()->getSkinName(), $user, @@ -2922,14 +2922,14 @@ class OutputPage extends ContextSource { } else { if ( $context->getRaw() || $isRaw ) { // Startup module can't load itself, needs to use ', diff --git a/includes/libs/ArrayUtils.php b/includes/libs/ArrayUtils.php index f93402108a..fb35801130 100644 --- a/includes/libs/ArrayUtils.php +++ b/includes/libs/ArrayUtils.php @@ -47,7 +47,7 @@ class ArrayUtils { * function was introduced. */ public static function consistentHashSort( &$array, $key, $separator = "\000" ) { - $hashes = array(); + $hashes = []; foreach ( $array as $elt ) { $hashes[$elt] = md5( $elt . $separator . $key ); } @@ -158,11 +158,11 @@ class ArrayUtils { public static function arrayDiffAssocRecursive( $array1 ) { $arrays = func_get_args(); array_shift( $arrays ); - $ret = array(); + $ret = []; foreach ( $array1 as $key => $value ) { if ( is_array( $value ) ) { - $args = array( $value ); + $args = [ $value ]; foreach ( $arrays as $array ) { if ( isset( $array[$key] ) ) { $args[] = $array[$key]; diff --git a/includes/libs/BufferingStatsdDataFactory.php b/includes/libs/BufferingStatsdDataFactory.php index a0020dabb3..9c18b10f10 100644 --- a/includes/libs/BufferingStatsdDataFactory.php +++ b/includes/libs/BufferingStatsdDataFactory.php @@ -33,7 +33,7 @@ use Liuggio\StatsdClient\Factory\StatsdDataFactory; * @since 1.25 */ class BufferingStatsdDataFactory extends StatsdDataFactory { - protected $buffer = array(); + protected $buffer = []; public function __construct( $prefix ) { parent::__construct(); @@ -54,7 +54,7 @@ class BufferingStatsdDataFactory extends StatsdDataFactory { $key = preg_replace( '/[:.]+/', '.', $key ); $key = preg_replace( '/[^a-z0-9.]+/i', '_', $key ); $key = trim( $key, '_.' ); - return str_replace( array( '._', '_.' ), '.', $key ); + return str_replace( [ '._', '_.' ], '.', $key ); } public function produceStatsdData( diff --git a/includes/libs/CSSMin.php b/includes/libs/CSSMin.php index 246de75c99..5f4dda9703 100644 --- a/includes/libs/CSSMin.php +++ b/includes/libs/CSSMin.php @@ -45,7 +45,7 @@ class CSSMin { /* Protected Static Members */ /** @var array List of common image files extensions and MIME-types */ - protected static $mimeTypes = array( + protected static $mimeTypes = [ 'gif' => 'image/gif', 'jpe' => 'image/jpeg', 'jpeg' => 'image/jpeg', @@ -55,7 +55,7 @@ class CSSMin { 'tiff' => 'image/tiff', 'xbm' => 'image/x-xbitmap', 'svg' => 'image/svg+xml', - ); + ]; /* Static Methods */ @@ -73,7 +73,7 @@ class CSSMin { */ public static function getLocalFileReferences( $source, $path = null ) { if ( $path === null ) { - return array(); + return []; } $files = self::getAllLocalFileReferences( $source, $path ); @@ -97,7 +97,7 @@ class CSSMin { public static function getAllLocalFileReferences( $source, $path ) { $stripped = preg_replace( '/' . self::COMMENT_REGEX . '/s', '', $source ); $path = rtrim( $path, '/' ) . '/'; - $files = array(); + $files = []; $rFlags = PREG_OFFSET_CAPTURE | PREG_SET_ORDER; if ( preg_match_all( '/' . self::URL_REGEX . '/', $stripped, $matches, $rFlags ) ) { @@ -192,7 +192,7 @@ class CSSMin { if ( strstr( $value, "\0" ) ) { throw new Exception( "Invalid character in CSS string" ); } - $value = strtr( $value, array( '\\' => '\\\\', '"' => '\\"' ) ); + $value = strtr( $value, [ '\\' => '\\\\', '"' => '\\"' ] ); $value = preg_replace_callback( '/[\x01-\x1f\x7f-\x9f]/', function ( $match ) { return '\\' . base_convert( ord( $match[0] ), 10, 16 ) . ' '; }, $value ); @@ -239,7 +239,7 @@ class CSSMin { if ( preg_match( '!^[\w\d:@/~.%+;,?&=-]+$!', $url ) ) { return "url($url)"; } else { - return 'url("' . strtr( $url, array( '\\' => '\\\\', '"' => '\\"' ) ) . '")'; + return 'url("' . strtr( $url, [ '\\' => '\\\\', '"' => '\\"' ] ) . '")'; } } @@ -277,7 +277,7 @@ class CSSMin { // Replace all comments by a placeholder so they will not interfere with the remapping. // Warning: This will also catch on anything looking like the start of a comment between // quotation marks (e.g. "foo /* bar"). - $comments = array(); + $comments = []; $pattern = '/(?!' . CSSMin::EMBED_REGEX . ')(' . CSSMin::COMMENT_REGEX . ')/s'; @@ -332,7 +332,7 @@ class CSSMin { if ( $embedData ) { // Remember the occurring MIME types to avoid fallbacks when embedding some files. - $mimeTypes = array(); + $mimeTypes = []; $ruleWithEmbedded = preg_replace_callback( $pattern, @@ -361,7 +361,7 @@ class CSSMin { ); // Are all referenced images SVGs? - $needsEmbedFallback = $mimeTypes !== array( 'image/svg+xml' => true ); + $needsEmbedFallback = $mimeTypes !== [ 'image/svg+xml' => true ]; } if ( !$embedData || $ruleWithEmbedded === $ruleWithRemapped ) { @@ -483,9 +483,9 @@ class CSSMin { public static function minify( $css ) { return trim( str_replace( - array( '; ', ': ', ' {', '{ ', ', ', '} ', ';}' ), - array( ';', ':', '{', '{', ',', '}', '}' ), - preg_replace( array( '/\s+/', '/\/\*.*?\*\//s' ), array( ' ', '' ), $css ) + [ '; ', ': ', ' {', '{ ', ', ', '} ', ';}' ], + [ ';', ':', '{', '{', ',', '}', '}' ], + preg_replace( [ '/\s+/', '/\/\*.*?\*\//s' ], [ ' ', '' ], $css ) ) ); } diff --git a/includes/libs/Cookie.php b/includes/libs/Cookie.php index 0fe944443f..cc236e289c 100644 --- a/includes/libs/Cookie.php +++ b/includes/libs/Cookie.php @@ -208,7 +208,7 @@ class Cookie { } class CookieJar { - private $cookie = array(); + private $cookie = []; /** * Set a cookie in the cookie jar. Make sure only one cookie per-name exists. @@ -237,7 +237,7 @@ class CookieJar { * @return string */ public function serializeToHttpRequest( $path, $domain ) { - $cookies = array(); + $cookies = []; foreach ( $this->cookie as $c ) { $serialized = $c->serializeToHttpRequest( $path, $domain ); @@ -268,7 +268,7 @@ class CookieJar { if ( count( $bit ) >= 1 ) { list( $name, $value ) = explode( '=', array_shift( $bit ), 2 ); - $attr = array(); + $attr = []; foreach ( $bit as $piece ) { $parts = explode( '=', $piece ); diff --git a/includes/libs/GenericArrayObject.php b/includes/libs/GenericArrayObject.php index 93ae83b272..dec55c9540 100644 --- a/includes/libs/GenericArrayObject.php +++ b/includes/libs/GenericArrayObject.php @@ -77,7 +77,7 @@ abstract class GenericArrayObject extends ArrayObject { * @param string $iterator_class */ public function __construct( $input = null, $flags = 0, $iterator_class = 'ArrayIterator' ) { - parent::__construct( array(), $flags, $iterator_class ); + parent::__construct( [], $flags, $iterator_class ); if ( !is_null( $input ) ) { foreach ( $input as $offset => $value ) { @@ -198,10 +198,10 @@ abstract class GenericArrayObject extends ArrayObject { * @return array */ protected function getSerializationData() { - return array( + return [ 'data' => $this->getArrayCopy(), 'index' => $this->indexOffset, - ); + ]; } /** diff --git a/includes/libs/HashRing.php b/includes/libs/HashRing.php index e7a10997cc..70ce31d713 100644 --- a/includes/libs/HashRing.php +++ b/includes/libs/HashRing.php @@ -28,14 +28,14 @@ */ class HashRing { /** @var Array (location => weight) */ - protected $sourceMap = array(); + protected $sourceMap = []; /** @var Array (location => (start, end)) */ - protected $ring = array(); + protected $ring = []; /** @var Array (location => (start, end)) */ protected $liveRing; /** @var Array (location => UNIX timestamp) */ - protected $ejectionExpiries = array(); + protected $ejectionExpiries = []; /** @var integer UNIX timestamp */ protected $ejectionNextExpiry = INF; @@ -53,7 +53,7 @@ class HashRing { } $this->sourceMap = $map; // Sort the locations based on the hash of their names - $hashes = array(); + $hashes = []; foreach ( $map as $location => $weight ) { $hashes[$location] = sha1( $location ); } @@ -62,7 +62,7 @@ class HashRing { } ); // Fit the map to weight-proportionate one with a space of size RING_SIZE $sum = array_sum( $map ); - $standardMap = array(); + $standardMap = []; foreach ( $map as $location => $weight ) { $standardMap[$location] = (int)floor( $weight / $sum * self::RING_SIZE ); } @@ -70,7 +70,7 @@ class HashRing { $index = 0; foreach ( $standardMap as $location => $weight ) { // Location covers half-closed interval [$index,$index + $weight) - $this->ring[$location] = array( $index, $index + $weight ); + $this->ring[$location] = [ $index, $index + $weight ]; $index += $weight; } // Make sure the last location covers what is left @@ -98,7 +98,7 @@ class HashRing { * @return array List of locations */ public function getLocations( $item, $limit ) { - $locations = array(); + $locations = []; $primaryLocation = null; $spot = hexdec( substr( sha1( $item ), 0, 7 ) ); // first 28 bits foreach ( $this->ring as $location => $range ) { @@ -190,7 +190,7 @@ class HashRing { $this->ejectionNextExpiry = min( $this->ejectionExpiries ); } else { // common case; avoid recalculating ring $this->liveRing = clone $this; - $this->liveRing->ejectionExpiries = array(); + $this->liveRing->ejectionExpiries = []; $this->liveRing->ejectionNextExpiry = INF; $this->liveRing->liveRing = null; diff --git a/includes/libs/HttpStatus.php b/includes/libs/HttpStatus.php index 3d7dee7da1..72fc333869 100644 --- a/includes/libs/HttpStatus.php +++ b/includes/libs/HttpStatus.php @@ -32,7 +32,7 @@ class HttpStatus { * @return string|null Message, or null if $code is not known */ public static function getMessage( $code ) { - static $statusMessage = array( + static $statusMessage = [ 100 => 'Continue', 101 => 'Switching Protocols', 102 => 'Processing', @@ -83,7 +83,7 @@ class HttpStatus { 505 => 'HTTP Version Not Supported', 507 => 'Insufficient Storage', 511 => 'Network Authentication Required', - ); + ]; return isset( $statusMessage[$code] ) ? $statusMessage[$code] : null; } diff --git a/includes/libs/IEContentAnalyzer.php b/includes/libs/IEContentAnalyzer.php index c31a35278a..0d1e527ba6 100644 --- a/includes/libs/IEContentAnalyzer.php +++ b/includes/libs/IEContentAnalyzer.php @@ -28,35 +28,35 @@ class IEContentAnalyzer { /** * Relevant data taken from the type table in IE 5 */ - protected $baseTypeTable = array( - 'ambiguous' /*1*/ => array( + protected $baseTypeTable = [ + 'ambiguous' /*1*/ => [ 'text/plain', 'application/octet-stream', 'application/x-netcdf', // [sic] - ), - 'text' /*3*/ => array( + ], + 'text' /*3*/ => [ 'text/richtext', 'image/x-bitmap', 'application/postscript', 'application/base64', 'application/macbinhex40', 'application/x-cdf', 'text/scriptlet' - ), - 'binary' /*4*/ => array( + ], + 'binary' /*4*/ => [ 'application/pdf', 'audio/x-aiff', 'audio/basic', 'audio/wav', 'image/gif', 'image/pjpeg', 'image/jpeg', 'image/tiff', 'image/x-png', 'image/png', 'image/bmp', 'image/x-jg', 'image/x-art', 'image/x-emf', 'image/x-wmf', 'video/avi', 'video/x-msvideo', 'video/mpeg', 'application/x-compressed', 'application/x-zip-compressed', 'application/x-gzip-compressed', 'application/java', 'application/x-msdownload' - ), - 'html' /*5*/ => array( 'text/html' ), - ); + ], + 'html' /*5*/ => [ 'text/html' ], + ]; /** * Changes to the type table in later versions of IE */ - protected $addedTypes = array( - 'ie07' => array( - 'text' => array( 'text/xml', 'application/xml' ) - ), - ); + protected $addedTypes = [ + 'ie07' => [ + 'text' => [ 'text/xml', 'application/xml' ] + ], + ]; /** * An approximation of the "Content Type" values in HKEY_CLASSES_ROOT in a @@ -64,7 +64,7 @@ class IEContentAnalyzer { * * Used for extension to MIME type mapping if detection fails. */ - protected $registry = array( + protected $registry = [ '.323' => 'text/h323', '.3g2' => 'video/3gpp2', '.3gp' => 'video/3gpp', @@ -297,19 +297,19 @@ class IEContentAnalyzer { '.xml' => 'text/xml', '.xps' => 'application/vnd.ms-xpsdocument', '.xsl' => 'text/xml', - ); + ]; /** * IE versions which have been analysed to bring you this class, and for * which some substantive difference exists. These will appear as keys * in the return value of getRealMimesFromData(). The names are chosen to sort correctly. */ - protected $versions = array( 'ie05', 'ie06', 'ie07', 'ie07.strict', 'ie07.nohtml' ); + protected $versions = [ 'ie05', 'ie06', 'ie07', 'ie07.strict', 'ie07.nohtml' ]; /** * Type table with versions expanded */ - protected $typeTable = array(); + protected $typeTable = []; /** constructor */ function __construct() { @@ -337,7 +337,7 @@ class IEContentAnalyzer { */ public function getRealMimesFromData( $fileName, $chunk, $proposed ) { $types = $this->getMimesFromData( $fileName, $chunk, $proposed ); - $types = array_map( array( $this, 'translateMimeType' ), $types ); + $types = array_map( [ $this, 'translateMimeType' ], $types ); return $types; } @@ -348,7 +348,7 @@ class IEContentAnalyzer { * @return string */ public function translateMimeType( $type ) { - static $table = array( + static $table = [ 'image/pjpeg' => 'image/jpeg', 'image/x-png' => 'image/png', 'image/x-wmf' => 'application/x-msmetafile', @@ -357,7 +357,7 @@ class IEContentAnalyzer { 'application/x-compressed' => 'application/x-compress', 'application/x-gzip-compressed' => 'application/x-gzip', 'audio/mid' => 'audio/midi', - ); + ]; if ( isset( $table[$type] ) ) { $type = $table[$type]; } @@ -374,7 +374,7 @@ class IEContentAnalyzer { * @return Array: map of IE version to detected MIME type */ public function getMimesFromData( $fileName, $chunk, $proposed ) { - $types = array(); + $types = []; foreach ( $this->versions as $version ) { $types[$version] = $this->getMimeTypeForVersion( $version, $fileName, $chunk, $proposed ); } @@ -685,16 +685,16 @@ class IEContentAnalyzer { * @return array */ protected function sampleData( $version, $chunk ) { - $found = array(); - $counters = array( + $found = []; + $counters = [ 'ctrl' => 0, 'high' => 0, 'low' => 0, 'lf' => 0, 'cr' => 0, 'ff' => 0 - ); - $htmlTags = array( + ]; + $htmlTags = [ 'html', 'head', 'title', @@ -705,7 +705,7 @@ class IEContentAnalyzer { 'img', 'plaintext', 'table' - ); + ]; $rdfUrl = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'; $rdfPurl = 'http://purl.org/rss/1.0/'; $xbmMagic1 = '#define'; @@ -828,7 +828,7 @@ class IEContentAnalyzer { $found['binhex'] = true; } } - return array( 'found' => $found, 'counters' => $counters ); + return [ 'found' => $found, 'counters' => $counters ]; } /** diff --git a/includes/libs/IEUrlExtension.php b/includes/libs/IEUrlExtension.php index 216d9b7860..16163fb304 100644 --- a/includes/libs/IEUrlExtension.php +++ b/includes/libs/IEUrlExtension.php @@ -59,7 +59,7 @@ class IEUrlExtension { * @param array $extWhitelist Extensions which are allowed, assumed harmless. * @return bool */ - public static function areServerVarsBad( $vars, $extWhitelist = array() ) { + public static function areServerVarsBad( $vars, $extWhitelist = [] ) { // Check QUERY_STRING or REQUEST_URI if ( isset( $vars['SERVER_SOFTWARE'] ) && isset( $vars['REQUEST_URI'] ) @@ -97,7 +97,7 @@ class IEUrlExtension { * URL, and which should be allowed. * @return bool */ - public static function isUrlExtensionBad( $urlPart, $extWhitelist = array() ) { + public static function isUrlExtensionBad( $urlPart, $extWhitelist = [] ) { if ( strval( $urlPart ) === '' ) { return false; } @@ -108,7 +108,7 @@ class IEUrlExtension { return false; } - if ( in_array( $extension, array( 'php', 'php5' ) ) ) { + if ( in_array( $extension, [ 'php', 'php5' ] ) ) { // Script extension, OK return false; } @@ -137,7 +137,7 @@ class IEUrlExtension { * @param $extWhitelist array * @return bool|string */ - public static function fixUrlForIE6( $url, $extWhitelist = array() ) { + public static function fixUrlForIE6( $url, $extWhitelist = [] ) { $questionPos = strpos( $url, '?' ); if ( $questionPos === false ) { $beforeQuery = $url . '?'; @@ -256,10 +256,10 @@ class IEUrlExtension { * */ public static function haveUndecodedRequestUri( $serverSoftware ) { - static $whitelist = array( + static $whitelist = [ 'Apache', 'Zeus', - 'LiteSpeed' ); + 'LiteSpeed' ]; if ( preg_match( '/^(.*?)($|\/| )/', $serverSoftware, $m ) ) { return in_array( $m[1], $whitelist ); } else { diff --git a/includes/libs/MapCacheLRU.php b/includes/libs/MapCacheLRU.php index a49eb0106c..2370ed3a8a 100644 --- a/includes/libs/MapCacheLRU.php +++ b/includes/libs/MapCacheLRU.php @@ -33,7 +33,7 @@ use Wikimedia\Assert\Assert; */ class MapCacheLRU { /** @var array */ - protected $cache = array(); // (key => value) + protected $cache = []; // (key => value) protected $maxCacheKeys; // integer; max entries @@ -110,7 +110,7 @@ class MapCacheLRU { */ public function clear( $keys = null ) { if ( $keys === null ) { - $this->cache = array(); + $this->cache = []; } else { foreach ( (array)$keys as $key ) { unset( $this->cache[$key] ); diff --git a/includes/libs/MappedIterator.php b/includes/libs/MappedIterator.php index 7fdde8a81a..73ffb14747 100644 --- a/includes/libs/MappedIterator.php +++ b/includes/libs/MappedIterator.php @@ -32,7 +32,7 @@ class MappedIterator extends FilterIterator { /** @var callable */ protected $aCallback; /** @var array */ - protected $cache = array(); + protected $cache = []; protected $rewound = false; // boolean; whether rewind() has been called @@ -51,7 +51,7 @@ class MappedIterator extends FilterIterator { * @param array $options Options map (includes "accept") (since 1.22) * @throws UnexpectedValueException */ - public function __construct( $iter, $vCallback, array $options = array() ) { + public function __construct( $iter, $vCallback, array $options = [] ) { if ( is_array( $iter ) ) { $baseIterator = new ArrayIterator( $iter ); } elseif ( $iter instanceof Iterator ) { @@ -65,13 +65,13 @@ class MappedIterator extends FilterIterator { } public function next() { - $this->cache = array(); + $this->cache = []; parent::next(); } public function rewind() { $this->rewound = true; - $this->cache = array(); + $this->cache = []; parent::rewind(); } diff --git a/includes/libs/MemoizedCallable.php b/includes/libs/MemoizedCallable.php index 14de6b9034..39faf3d08f 100644 --- a/includes/libs/MemoizedCallable.php +++ b/includes/libs/MemoizedCallable.php @@ -102,7 +102,7 @@ class MemoizedCallable { * @param array $args Parameters for memoized function or method. * @return mixed The memoized callable's return value. */ - public function invokeArgs( Array $args = array() ) { + public function invokeArgs( Array $args = [] ) { foreach ( $args as $arg ) { if ( $arg !== null && !is_scalar( $arg ) ) { throw new InvalidArgumentException( @@ -144,7 +144,7 @@ class MemoizedCallable { * @param array $args * @param int $ttl */ - public static function call( $callable, Array $args = array(), $ttl = 3600 ) { + public static function call( $callable, Array $args = [], $ttl = 3600 ) { $instance = new self( $callable, $ttl ); return $instance->invokeArgs( $args ); } diff --git a/includes/libs/MultiHttpClient.php b/includes/libs/MultiHttpClient.php index 6ad77411dc..4e19025bbc 100644 --- a/includes/libs/MultiHttpClient.php +++ b/includes/libs/MultiHttpClient.php @@ -75,9 +75,9 @@ class MultiHttpClient { throw new Exception( "Cannot find CA bundle: " . $this->caBundlePath ); } } - static $opts = array( + static $opts = [ 'connTimeout', 'reqTimeout', 'usePipelining', 'maxConnsPerHost', 'proxy', 'userAgent' - ); + ]; foreach ( $opts as $key ) { if ( isset( $options[$key] ) ) { $this->$key = $options[$key]; @@ -104,8 +104,8 @@ class MultiHttpClient { * - reqTimeout : post-connection timeout per request (seconds) * @return array Response array for request */ - final public function run( array $req, array $opts = array() ) { - $req = $this->runMulti( array( $req ), $opts ); + final public function run( array $req, array $opts = [] ) { + $req = $this->runMulti( [ $req ], $opts ); return $req[0]['response']; } @@ -135,19 +135,19 @@ class MultiHttpClient { * @return array $reqs With response array populated for each * @throws Exception */ - public function runMulti( array $reqs, array $opts = array() ) { + public function runMulti( array $reqs, array $opts = [] ) { $chm = $this->getCurlMulti(); // Normalize $reqs and add all of the required cURL handles... - $handles = array(); + $handles = []; foreach ( $reqs as $index => &$req ) { - $req['response'] = array( + $req['response'] = [ 'code' => 0, 'reason' => '', - 'headers' => array(), + 'headers' => [], 'body' => '', 'error' => '' - ); + ]; if ( isset( $req[0] ) ) { $req['method'] = $req[0]; // short-form unset( $req[0] ); @@ -161,8 +161,8 @@ class MultiHttpClient { } elseif ( !isset( $req['url'] ) ) { throw new Exception( "Request has no 'url' field set." ); } - $req['query'] = isset( $req['query'] ) ? $req['query'] : array(); - $headers = array(); // normalized headers + $req['query'] = isset( $req['query'] ) ? $req['query'] : []; + $headers = []; // normalized headers if ( isset( $req['headers'] ) ) { foreach ( $req['headers'] as $name => $value ) { $headers[strtolower( $name )] = $value; @@ -194,7 +194,7 @@ class MultiHttpClient { // @TODO: use a per-host rolling handle window (e.g. CURLMOPT_MAX_HOST_CONNECTIONS) $batches = array_chunk( $indexes, $this->maxConnsPerHost ); - $infos = array(); + $infos = []; foreach ( $batches as $batch ) { // Attach all cURL handles for this batch @@ -272,7 +272,7 @@ class MultiHttpClient { * @return resource * @throws Exception */ - protected function getCurlHandle( array &$req, array $opts = array() ) { + protected function getCurlHandle( array &$req, array $opts = [] ) { $ch = curl_init(); curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, @@ -292,8 +292,8 @@ class MultiHttpClient { $url = $req['url']; // PHP_QUERY_RFC3986 is PHP 5.4+ only $query = str_replace( - array( '+', '%7E' ), - array( '%20', '~' ), + [ '+', '%7E' ], + [ '%20', '~' ], http_build_query( $req['query'], '', '&' ) ); if ( $query != '' ) { @@ -363,7 +363,7 @@ class MultiHttpClient { $req['headers']['user-agent'] = $this->userAgent; } - $headers = array(); + $headers = []; foreach ( $req['headers'] as $name => $value ) { if ( strpos( $name, ': ' ) ) { throw new Exception( "Headers cannot have ':' in the name." ); @@ -375,7 +375,7 @@ class MultiHttpClient { curl_setopt( $ch, CURLOPT_HEADERFUNCTION, function ( $ch, $header ) use ( &$req ) { $length = strlen( $header ); - $matches = array(); + $matches = []; if ( preg_match( "/^(HTTP\/1\.[01]) (\d{3}) (.*)/", $header, $matches ) ) { $req['response']['code'] = (int)$matches[2]; $req['response']['reason'] = trim( $matches[3] ); diff --git a/includes/libs/ObjectFactory.php b/includes/libs/ObjectFactory.php index 2ffc1d3be8..c96a8a1643 100644 --- a/includes/libs/ObjectFactory.php +++ b/includes/libs/ObjectFactory.php @@ -57,7 +57,7 @@ class ObjectFactory { * constructor is non-public or non-existent */ public static function getObjectFromSpec( $spec ) { - $args = isset( $spec['args'] ) ? $spec['args'] : array(); + $args = isset( $spec['args'] ) ? $spec['args'] : []; $expandArgs = !isset( $spec['closure_expansion'] ) || $spec['closure_expansion'] === true; @@ -86,7 +86,7 @@ class ObjectFactory { if ( $expandArgs ) { $margs = static::expandClosures( $margs ); } - call_user_func_array( array( $obj, $method ), $margs ); + call_user_func_array( [ $obj, $method ], $margs ); } } diff --git a/includes/libs/ProcessCacheLRU.php b/includes/libs/ProcessCacheLRU.php index eec31cee56..5a933914c6 100644 --- a/includes/libs/ProcessCacheLRU.php +++ b/includes/libs/ProcessCacheLRU.php @@ -28,10 +28,10 @@ use Wikimedia\Assert\Assert; */ class ProcessCacheLRU { /** @var Array */ - protected $cache = array(); // (key => prop => value) + protected $cache = []; // (key => prop => value) /** @var Array */ - protected $cacheTimes = array(); // (key => prop => UNIX timestamp) + protected $cacheTimes = []; // (key => prop => UNIX timestamp) protected $maxCacheKeys; // integer; max entries @@ -109,8 +109,8 @@ class ProcessCacheLRU { */ public function clear( $keys = null ) { if ( $keys === null ) { - $this->cache = array(); - $this->cacheTimes = array(); + $this->cache = []; + $this->cacheTimes = []; } else { foreach ( (array)$keys as $key ) { unset( $this->cache[$key] ); diff --git a/includes/libs/ReplacementArray.php b/includes/libs/ReplacementArray.php index 02762f36d1..4512a4b13d 100644 --- a/includes/libs/ReplacementArray.php +++ b/includes/libs/ReplacementArray.php @@ -37,7 +37,7 @@ class ReplacementArray { * @return array */ public function __sleep() { - return array( 'data' ); + return [ 'data' ]; } /** diff --git a/includes/libs/RiffExtractor.php b/includes/libs/RiffExtractor.php index f987c59d21..3a8b55e21c 100644 --- a/includes/libs/RiffExtractor.php +++ b/includes/libs/RiffExtractor.php @@ -49,11 +49,11 @@ class RiffExtractor { } // Create basic info structure - $info = array( + $info = [ 'fileSize' => self::extractUInt32( $fileSize ), 'fourCC' => $fourCC, - 'chunks' => array(), - ); + 'chunks' => [], + ]; $numberOfChunks = 0; // Find out the chunks @@ -72,11 +72,11 @@ class RiffExtractor { $intChunkSize = self::extractUInt32( $chunkSize ); // Add chunk info to the info structure - $info['chunks'][] = array( + $info['chunks'][] = [ 'fourCC' => $chunkFourCC, 'start' => $chunkStart, 'size' => $intChunkSize - ); + ]; // Uneven chunks have padding bytes $padding = $intChunkSize % 2; diff --git a/includes/libs/SamplingStatsdClient.php b/includes/libs/SamplingStatsdClient.php index f77b211637..2e780c9728 100644 --- a/includes/libs/SamplingStatsdClient.php +++ b/includes/libs/SamplingStatsdClient.php @@ -61,7 +61,7 @@ class SamplingStatsdClient extends StatsdClient { */ public function send( $data, $sampleRate = 1 ) { if ( !is_array( $data ) ) { - $data = array( $data ); + $data = [ $data ]; } if ( !$data ) { return; @@ -111,7 +111,7 @@ class SamplingStatsdClient extends StatsdClient { * @throws LogicException */ protected function sampleData( $data ) { - $newData = array(); + $newData = []; $mt_rand_max = mt_getrandmax(); foreach ( $data as $item ) { $samplingRate = $item->getSampleRate(); diff --git a/includes/libs/ScopedCallback.php b/includes/libs/ScopedCallback.php index 1ec9eaa627..96075aad66 100644 --- a/includes/libs/ScopedCallback.php +++ b/includes/libs/ScopedCallback.php @@ -36,7 +36,7 @@ class ScopedCallback { * @param array $params Callback arguments (since 1.25) * @throws Exception */ - public function __construct( $callback, array $params = array() ) { + public function __construct( $callback, array $params = [] ) { if ( $callback !== null && !is_callable( $callback ) ) { throw new InvalidArgumentException( "Provided callback is not valid." ); } diff --git a/includes/libs/StatusValue.php b/includes/libs/StatusValue.php index 35de084b5f..b4206a21fc 100644 --- a/includes/libs/StatusValue.php +++ b/includes/libs/StatusValue.php @@ -43,12 +43,12 @@ class StatusValue { /** @var bool */ protected $ok = true; /** @var array */ - protected $errors = array(); + protected $errors = []; /** @var mixed */ public $value; /** @var array Map of (key => bool) to indicate success of each part of batch operations */ - public $success = array(); + public $success = []; /** @var int Counter for batch operations */ public $successCount = 0; /** @var int Counter for batch operations */ @@ -63,7 +63,7 @@ class StatusValue { public static function newFatal( $message /*, parameters...*/ ) { $params = func_get_args(); $result = new static(); - call_user_func_array( array( &$result, 'fatal' ), $params ); + call_user_func_array( [ &$result, 'fatal' ], $params ); return $result; } @@ -142,11 +142,11 @@ class StatusValue { * @param string|MessageSpecifier $message Message key or object */ public function warning( $message /*, parameters... */ ) { - $this->errors[] = array( + $this->errors[] = [ 'type' => 'warning', 'message' => $message, 'params' => array_slice( func_get_args(), 1 ) - ); + ]; } /** @@ -156,11 +156,11 @@ class StatusValue { * @param string|MessageSpecifier $message Message key or object */ public function error( $message /*, parameters... */ ) { - $this->errors[] = array( + $this->errors[] = [ 'type' => 'error', 'message' => $message, 'params' => array_slice( func_get_args(), 1 ) - ); + ]; } /** @@ -170,11 +170,11 @@ class StatusValue { * @param string|MessageSpecifier $message Message key or object */ public function fatal( $message /*, parameters... */ ) { - $this->errors[] = array( + $this->errors[] = [ 'type' => 'error', 'message' => $message, 'params' => array_slice( func_get_args(), 1 ) - ); + ]; $this->ok = false; } @@ -203,7 +203,7 @@ class StatusValue { * @return array */ public function getErrorsByType( $type ) { - $result = array(); + $result = []; foreach ( $this->errors as $error ) { if ( $error['type'] === $type ) { $result[] = $error; @@ -298,7 +298,7 @@ class StatusValue { $params = $error['params']; } else { $key = $error['message']; - $params = array(); + $params = []; } $out .= sprintf( "| %4d | %-25.25s | %-40.40s |\n", diff --git a/includes/libs/StringUtils.php b/includes/libs/StringUtils.php index c56ed07a88..d2226b6daa 100644 --- a/includes/libs/StringUtils.php +++ b/includes/libs/StringUtils.php @@ -75,7 +75,7 @@ class StringUtils { if ( $regexes === null ) { $cont = "[\x80-\xbf]"; $after = "(?!$cont)"; // "(?:[^\x80-\xbf]|$)" would work here - $regexes = array( + $regexes = [ // Continuation byte at the start "/^$cont/", @@ -97,7 +97,7 @@ class StringUtils { "/\xf0(?![\x90-\xbf]$cont{2}$after)/", "/[\xf1-\xf3](?!$cont{3}$after)/S", "/\xf4(?![\x80-\x8f]$cont{2}$after)/", - ); + ]; } foreach ( $regexes as $regex ) { @@ -176,7 +176,7 @@ class StringUtils { $encEnd = preg_quote( $endDelim, '!' ); $strcmp = strpos( $flags, 'i' ) === false ? 'strcmp' : 'strcasecmp'; $endLength = strlen( $endDelim ); - $m = array(); + $m = []; while ( $inputPos < strlen( $subject ) && preg_match( "!($encStart)|($encEnd)!S$flags", $subject, $m, PREG_OFFSET_CAPTURE, $inputPos ) @@ -219,10 +219,10 @@ class StringUtils { } elseif ( $tokenType == 'end' ) { if ( $foundStart ) { # Found match - $output .= call_user_func( $callback, array( + $output .= call_user_func( $callback, [ substr( $subject, $outputPos, $tokenOffset + $tokenLength - $outputPos ), substr( $subject, $contentPos, $tokenOffset - $contentPos ) - ) ); + ] ); $foundStart = false; } else { # Non-matching end, write it out diff --git a/includes/libs/Timing.php b/includes/libs/Timing.php index 00ceda3e78..62baaf1e93 100644 --- a/includes/libs/Timing.php +++ b/includes/libs/Timing.php @@ -45,12 +45,12 @@ use Psr\Log\NullLogger; class Timing implements LoggerAwareInterface { /** @var array[] */ - private $entries = array(); + private $entries = []; /** @var LoggerInterface */ protected $logger; - public function __construct( array $params = array() ) { + public function __construct( array $params = [] ) { $this->clearMarks(); $this->setLogger( isset( $params['logger'] ) ? $params['logger'] : new NullLogger() ); } @@ -73,12 +73,12 @@ class Timing implements LoggerAwareInterface { * @return array The mark that has been created. */ public function mark( $markName ) { - $this->entries[$markName] = array( + $this->entries[$markName] = [ 'name' => $markName, 'entryType' => 'mark', 'startTime' => microtime( true ), 'duration' => 0, - ); + ]; return $this->entries[$markName]; } @@ -90,16 +90,16 @@ class Timing implements LoggerAwareInterface { if ( $markName !== null ) { unset( $this->entries[$markName] ); } else { - $this->entries = array( - 'requestStart' => array( + $this->entries = [ + 'requestStart' => [ 'name' => 'requestStart', 'entryType' => 'mark', 'startTime' => isset( $_SERVER['REQUEST_TIME_FLOAT'] ) ? $_SERVER['REQUEST_TIME_FLOAT'] : $_SERVER['REQUEST_TIME'], 'duration' => 0, - ), - ); + ], + ]; } } @@ -142,12 +142,12 @@ class Timing implements LoggerAwareInterface { $endTime = microtime( true ); } - $this->entries[$measureName] = array( + $this->entries[$measureName] = [ 'name' => $measureName, 'entryType' => 'measure', 'startTime' => $startTime, 'duration' => $endTime - $startTime, - ); + ]; return $this->entries[$measureName]; } @@ -176,7 +176,7 @@ class Timing implements LoggerAwareInterface { */ public function getEntriesByType( $entryType ) { $this->sortEntries(); - $entries = array(); + $entries = []; foreach ( $this->entries as $entry ) { if ( $entry['entryType'] === $entryType ) { $entries[] = $entry; diff --git a/includes/libs/Xhprof.php b/includes/libs/Xhprof.php index d2cd0e4ea8..d0f067f6e1 100644 --- a/includes/libs/Xhprof.php +++ b/includes/libs/Xhprof.php @@ -70,20 +70,20 @@ class Xhprof { * * @param array $config */ - public function __construct( array $config = array() ) { + public function __construct( array $config = [] ) { $this->config = array_merge( - array( + [ 'flags' => 0, - 'exclude' => array(), + 'exclude' => [], 'include' => null, 'sort' => 'wt', - ), + ], $config ); - xhprof_enable( $this->config['flags'], array( + xhprof_enable( $this->config['flags'], [ 'ignored_functions' => $this->config['exclude'] - ) ); + ] ); } /** @@ -182,7 +182,7 @@ class Xhprof { $want = array_fill_keys( $this->config['include'], true ); $want['main()'] = true; - $keep = array(); + $keep = []; foreach ( $data as $key => $stats ) { list( $parent, $child ) = self::splitKey( $key ); if ( isset( $want[$parent] ) || isset( $want[$child] ) ) { @@ -223,14 +223,14 @@ class Xhprof { $hasMu = isset( $main['mu'] ); $hasAlloc = isset( $main['alloc'] ); - $this->inclusive = array(); + $this->inclusive = []; foreach ( $this->hieraData as $key => $stats ) { list( $parent, $child ) = self::splitKey( $key ); if ( !isset( $this->inclusive[$child] ) ) { - $this->inclusive[$child] = array( + $this->inclusive[$child] = [ 'ct' => 0, 'wt' => new RunningStat(), - ); + ]; if ( $hasCpu ) { $this->inclusive[$child]['cpu'] = new RunningStat(); } @@ -272,14 +272,14 @@ class Xhprof { $percent = ( isset( $main[$name] ) && $main[$name] ) ? 100 * $total / $main[$name] : 0; - $this->inclusive[$func][$name] = array( + $this->inclusive[$func][$name] = [ 'total' => $total, 'min' => $value->min, 'mean' => $value->m1, 'max' => $value->max, 'variance' => $value->m2, 'percent' => $percent, - ); + ]; } } } @@ -319,8 +319,8 @@ class Xhprof { $this->complete[$func][$stat]['exclusive'] = $value['total']; } // Add sapce for call tree information to be filled in later - $this->complete[$func]['calls'] = array(); - $this->complete[$func]['subcalls'] = array(); + $this->complete[$func]['calls'] = []; + $this->complete[$func]['subcalls'] = []; } foreach ( $this->hieraData as $key => $stats ) { @@ -367,7 +367,7 @@ class Xhprof { if ( isset( $edges[$function]['calls'] ) ) { return array_keys( $edges[$function]['calls'] ); } else { - return array(); + return []; } } @@ -383,7 +383,7 @@ class Xhprof { if ( isset( $edges[$function]['subcalls'] ) ) { return array_keys( $edges[$function]['subcalls'] ); } else { - return array(); + return []; } } @@ -396,9 +396,9 @@ class Xhprof { public function getCriticalPath( $metric = 'wt' ) { $this->stop(); $func = 'main()'; - $path = array( + $path = [ $func => $this->hieraData[$func], - ); + ]; while ( $func ) { $callees = $this->getCallees( $func ); $maxCallee = null; diff --git a/includes/libs/XmlTypeCheck.php b/includes/libs/XmlTypeCheck.php index 34afb68914..b3ea08da9c 100644 --- a/includes/libs/XmlTypeCheck.php +++ b/includes/libs/XmlTypeCheck.php @@ -56,12 +56,12 @@ class XmlTypeCheck { * data to the top string of the stack, then pop off the string and process it when the * element is closed. */ - protected $elementData = array(); + protected $elementData = []; /** * A stack of element names and attributes, as we process them. */ - protected $elementDataContext = array(); + protected $elementDataContext = []; /** * Current depth of the data stack. @@ -71,9 +71,9 @@ class XmlTypeCheck { /** * Additional parsing options */ - private $parserOptions = array( + private $parserOptions = [ 'processing_instruction_handler' => '', - ); + ]; /** * @param string $input a filename or string containing the XML element @@ -87,7 +87,7 @@ class XmlTypeCheck { * @param array $options list of additional parsing options: * processing_instruction_handler: Callback for xml_set_processing_instruction_handler */ - function __construct( $input, $filterCallback = null, $isFile = true, $options = array() ) { + function __construct( $input, $filterCallback = null, $isFile = true, $options = [] ) { $this->filterCallback = $filterCallback; $this->parserOptions = array_merge( $this->parserOptions, $options ); $this->validateFromInput( $input, $isFile ); @@ -165,7 +165,7 @@ class XmlTypeCheck { } private function readNext( XMLReader $reader ) { - set_error_handler( array( $this, 'XmlErrorHandler' ) ); + set_error_handler( [ $this, 'XmlErrorHandler' ] ); $ret = $reader->read(); restore_error_handler(); return $ret; @@ -258,7 +258,7 @@ class XmlTypeCheck { * @return array of attributes */ private function getAttributesArray( XMLReader $r ) { - $attrs = array(); + $attrs = []; while ( $r->moveToNextAttribute() ) { if ( $r->namespaceURI === 'http://www.w3.org/2000/xmlns/' ) { // XMLReader treats xmlns attributes as normal @@ -290,7 +290,7 @@ class XmlTypeCheck { * @param $attribs */ private function elementOpen( $name, $attribs ) { - $this->elementDataContext[] = array( $name, $attribs ); + $this->elementDataContext[] = [ $name, $attribs ]; $this->elementData[] = ''; $this->stackDepth++; } diff --git a/includes/libs/composer/ComposerInstalled.php b/includes/libs/composer/ComposerInstalled.php index 5f87b54b1d..9f15078c64 100644 --- a/includes/libs/composer/ComposerInstalled.php +++ b/includes/libs/composer/ComposerInstalled.php @@ -21,15 +21,15 @@ class ComposerInstalled { * @return array */ public function getInstalledDependencies() { - $deps = array(); + $deps = []; foreach ( $this->contents as $installed ) { - $deps[$installed['name']] = array( + $deps[$installed['name']] = [ 'version' => ComposerJson::normalizeVersion( $installed['version'] ), 'type' => $installed['type'], - 'licenses' => isset( $installed['license'] ) ? $installed['license'] : array(), - 'authors' => isset( $installed['authors'] ) ? $installed['authors'] : array(), + 'licenses' => isset( $installed['license'] ) ? $installed['license'] : [], + 'authors' => isset( $installed['authors'] ) ? $installed['authors'] : [], 'description' => isset( $installed['description'] ) ? $installed['description']: '', - ); + ]; } ksort( $deps ); diff --git a/includes/libs/composer/ComposerJson.php b/includes/libs/composer/ComposerJson.php index bb55ac6380..311508f7c0 100644 --- a/includes/libs/composer/ComposerJson.php +++ b/includes/libs/composer/ComposerJson.php @@ -26,7 +26,7 @@ class ComposerJson { * @return array */ public function getRequiredDependencies() { - $deps = array(); + $deps = []; if ( isset( $this->contents['require'] ) ) { foreach ( $this->contents['require'] as $package => $version ) { if ( $package !== "php" && strpos( $package, 'ext-' ) !== 0 ) { diff --git a/includes/libs/composer/ComposerLock.php b/includes/libs/composer/ComposerLock.php index 22c33191d7..e93127c167 100644 --- a/includes/libs/composer/ComposerLock.php +++ b/includes/libs/composer/ComposerLock.php @@ -25,15 +25,15 @@ class ComposerLock { * @return array */ public function getInstalledDependencies() { - $deps = array(); + $deps = []; foreach ( $this->contents['packages'] as $installed ) { - $deps[$installed['name']] = array( + $deps[$installed['name']] = [ 'version' => ComposerJson::normalizeVersion( $installed['version'] ), 'type' => $installed['type'], - 'licenses' => isset( $installed['license'] ) ? $installed['license'] : array(), - 'authors' => isset( $installed['authors'] ) ? $installed['authors'] : array(), + 'licenses' => isset( $installed['license'] ) ? $installed['license'] : [], + 'authors' => isset( $installed['authors'] ) ? $installed['authors'] : [], 'description' => isset( $installed['description'] ) ? $installed['description']: '', - ); + ]; } return $deps; diff --git a/includes/libs/eventrelayer/EventRelayer.php b/includes/libs/eventrelayer/EventRelayer.php index f95ba3f0e9..c385c38dfb 100644 --- a/includes/libs/eventrelayer/EventRelayer.php +++ b/includes/libs/eventrelayer/EventRelayer.php @@ -35,7 +35,7 @@ abstract class EventRelayer { * @return bool Success */ final public function notify( $channel, $event ) { - return $this->doNotify( $channel, array( $event ) ); + return $this->doNotify( $channel, [ $event ] ); } /** diff --git a/includes/libs/eventrelayer/EventRelayerMCRD.php b/includes/libs/eventrelayer/EventRelayerMCRD.php index 1e8b2a4058..4bcdf123ab 100644 --- a/includes/libs/eventrelayer/EventRelayerMCRD.php +++ b/includes/libs/eventrelayer/EventRelayerMCRD.php @@ -38,7 +38,7 @@ class EventRelayerMCRD extends EventRelayer { $this->baseUrl = $params['mcrdConfig']['url']; - $httpConfig = isset( $params['httpConfig'] ) ? $params['httpConfig'] : array(); + $httpConfig = isset( $params['httpConfig'] ) ? $params['httpConfig'] : []; if ( !isset( $httpConfig['connTimeout'] ) ) { $httpConfig['connTimeout'] = 1; } @@ -54,12 +54,12 @@ class EventRelayerMCRD extends EventRelayer { return true; } - $response = $this->http->run( array( + $response = $this->http->run( [ 'url' => "{$this->baseUrl}/relayer/api/v1.0/" . rawurlencode( $channel ), 'method' => 'POST', - 'body' => json_encode( array( 'events' => $events ) ), - 'headers' => array( 'content-type' => 'application/json' ) - ) ); + 'body' => json_encode( [ 'events' => $events ] ), + 'headers' => [ 'content-type' => 'application/json' ] + ] ); return $response['code'] == 201; } diff --git a/includes/libs/objectcache/APCBagOStuff.php b/includes/libs/objectcache/APCBagOStuff.php index c7f9c574da..8f70fc7a77 100644 --- a/includes/libs/objectcache/APCBagOStuff.php +++ b/includes/libs/objectcache/APCBagOStuff.php @@ -51,7 +51,7 @@ class APCBagOStuff extends BagOStuff { * * @param array $params */ - public function __construct( array $params = array() ) { + public function __construct( array $params = [] ) { parent::__construct( $params ); if ( isset( $params['nativeSerialize'] ) ) { diff --git a/includes/libs/objectcache/BagOStuff.php b/includes/libs/objectcache/BagOStuff.php index a7e8a4780b..1aed28036a 100644 --- a/includes/libs/objectcache/BagOStuff.php +++ b/includes/libs/objectcache/BagOStuff.php @@ -44,7 +44,7 @@ use Psr\Log\NullLogger; */ abstract class BagOStuff implements IExpiringStore, LoggerAwareInterface { /** @var array[] Lock tracking */ - protected $locks = array(); + protected $locks = []; /** @var integer */ protected $lastError = self::ERR_NONE; @@ -71,7 +71,7 @@ abstract class BagOStuff implements IExpiringStore, LoggerAwareInterface { const WRITE_SYNC = 1; // synchronously write to all locations for replicated stores const WRITE_CACHE_ONLY = 2; // Only change state of the in-memory cache - public function __construct( array $params = array() ) { + public function __construct( array $params = [] ) { if ( isset( $params['logger'] ) ) { $this->setLogger( $params['logger'] ); } else { @@ -351,7 +351,7 @@ abstract class BagOStuff implements IExpiringStore, LoggerAwareInterface { } if ( $locked ) { - $this->locks[$key] = array( 'class' => $rclass, 'depth' => 1 ); + $this->locks[$key] = [ 'class' => $rclass, 'depth' => 1 ]; } return $locked; @@ -430,7 +430,7 @@ abstract class BagOStuff implements IExpiringStore, LoggerAwareInterface { * @return array */ public function getMulti( array $keys, $flags = 0 ) { - $res = array(); + $res = []; foreach ( $keys as $key ) { $val = $this->get( $key ); if ( $val !== false ) { @@ -577,9 +577,9 @@ abstract class BagOStuff implements IExpiringStore, LoggerAwareInterface { */ protected function debug( $text ) { if ( $this->debugMode ) { - $this->logger->debug( "{class} debug: $text", array( + $this->logger->debug( "{class} debug: $text", [ 'class' => get_class( $this ), - ) ); + ] ); } } diff --git a/includes/libs/objectcache/CachedBagOStuff.php b/includes/libs/objectcache/CachedBagOStuff.php index fc156187fe..c71b16e502 100644 --- a/includes/libs/objectcache/CachedBagOStuff.php +++ b/includes/libs/objectcache/CachedBagOStuff.php @@ -43,7 +43,7 @@ class CachedBagOStuff extends HashBagOStuff { * @param BagOStuff $backend Permanent backend to use * @param array $params Parameters for HashBagOStuff */ - function __construct( BagOStuff $backend, $params = array() ) { + function __construct( BagOStuff $backend, $params = [] ) { $this->backend = $backend; parent::__construct( $params ); } diff --git a/includes/libs/objectcache/HashBagOStuff.php b/includes/libs/objectcache/HashBagOStuff.php index 7b85d92580..6e7fb0cae0 100644 --- a/includes/libs/objectcache/HashBagOStuff.php +++ b/includes/libs/objectcache/HashBagOStuff.php @@ -31,7 +31,7 @@ use Wikimedia\Assert\Assert; */ class HashBagOStuff extends BagOStuff { /** @var mixed[] */ - protected $bag = array(); + protected $bag = []; /** @var integer Max entries allowed */ protected $maxCacheKeys; @@ -42,7 +42,7 @@ class HashBagOStuff extends BagOStuff { * @param array $params Additional parameters include: * - maxKeys : only allow this many keys (using oldest-first eviction) */ - function __construct( $params = array() ) { + function __construct( $params = [] ) { parent::__construct( $params ); $this->maxCacheKeys = isset( $params['maxKeys'] ) ? $params['maxKeys'] : INF; @@ -80,10 +80,10 @@ class HashBagOStuff extends BagOStuff { public function set( $key, $value, $exptime = 0, $flags = 0 ) { // Refresh key position for maxCacheKeys eviction unset( $this->bag[$key] ); - $this->bag[$key] = array( + $this->bag[$key] = [ self::KEY_VAL => $value, self::KEY_EXP => $this->convertExpiry( $exptime ) - ); + ]; if ( count( $this->bag ) > $this->maxCacheKeys ) { reset( $this->bag ); @@ -101,6 +101,6 @@ class HashBagOStuff extends BagOStuff { } public function clear() { - $this->bag = array(); + $this->bag = []; } } diff --git a/includes/libs/objectcache/MultiWriteBagOStuff.php b/includes/libs/objectcache/MultiWriteBagOStuff.php index 73bdabd1c2..ec588cee00 100644 --- a/includes/libs/objectcache/MultiWriteBagOStuff.php +++ b/includes/libs/objectcache/MultiWriteBagOStuff.php @@ -72,7 +72,7 @@ class MultiWriteBagOStuff extends BagOStuff { ); } - $this->caches = array(); + $this->caches = []; foreach ( $params['caches'] as $cacheInfo ) { if ( $cacheInfo instanceof BagOStuff ) { $this->caches[] = $cacheInfo; @@ -82,7 +82,7 @@ class MultiWriteBagOStuff extends BagOStuff { // Callers intenting this to be for ObjectFactory::getObjectFromSpec // should have set "args" per the docs above. Doings so avoids extra // (likely harmless) params (factory/class/calls) ending up in "args". - $cacheInfo['args'] = array( $cacheInfo ); + $cacheInfo['args'] = [ $cacheInfo ]; } $this->caches[] = ObjectFactory::getObjectFromSpec( $cacheInfo ); } @@ -194,7 +194,7 @@ class MultiWriteBagOStuff extends BagOStuff { if ( $i == 0 || !$asyncWrites ) { // First store or in sync mode: write now and get result - if ( !call_user_func_array( array( $cache, $method ), $args ) ) { + if ( !call_user_func_array( [ $cache, $method ], $args ) ) { $ret = false; } } else { @@ -203,7 +203,7 @@ class MultiWriteBagOStuff extends BagOStuff { call_user_func( $this->asyncHandler, function () use ( $cache, $method, $args, $logger ) { - if ( !call_user_func_array( array( $cache, $method ), $args ) ) { + if ( !call_user_func_array( [ $cache, $method ], $args ) ) { $logger->warning( "Async $method op failed" ); } } diff --git a/includes/libs/objectcache/WANObjectCache.php b/includes/libs/objectcache/WANObjectCache.php index 4aa868efce..e43d37b8ca 100644 --- a/includes/libs/objectcache/WANObjectCache.php +++ b/includes/libs/objectcache/WANObjectCache.php @@ -145,7 +145,7 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { $this->cache = $params['cache']; $this->pool = $params['pool']; $this->relayer = $params['relayer']; - $this->procCache = new HashBagOStuff( array( 'maxKeys' => self::MAX_PC_KEYS ) ); + $this->procCache = new HashBagOStuff( [ 'maxKeys' => self::MAX_PC_KEYS ] ); $this->setLogger( isset( $params['logger'] ) ? $params['logger'] : new NullLogger() ); } @@ -159,11 +159,11 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { * @return WANObjectCache */ public static function newEmpty() { - return new self( array( + return new self( [ 'cache' => new EmptyBagOStuff(), 'pool' => 'empty', - 'relayer' => new EventRelayerNull( array() ) - ) ); + 'relayer' => new EventRelayerNull( [] ) + ] ); } /** @@ -205,9 +205,9 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { * @param array $checkKeys List of "check" keys * @return mixed Value of cache key or false on failure */ - final public function get( $key, &$curTTL = null, array $checkKeys = array() ) { - $curTTLs = array(); - $values = $this->getMulti( array( $key ), $curTTLs, $checkKeys ); + final public function get( $key, &$curTTL = null, array $checkKeys = [] ) { + $curTTLs = []; + $values = $this->getMulti( [ $key ], $curTTLs, $checkKeys ); $curTTL = isset( $curTTLs[$key] ) ? $curTTLs[$key] : null; return isset( $values[$key] ) ? $values[$key] : false; @@ -225,17 +225,17 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { * @return array Map of (key => value) for keys that exist */ final public function getMulti( - array $keys, &$curTTLs = array(), array $checkKeys = array() + array $keys, &$curTTLs = [], array $checkKeys = [] ) { - $result = array(); - $curTTLs = array(); + $result = []; + $curTTLs = []; $vPrefixLen = strlen( self::VALUE_KEY_PREFIX ); $valueKeys = self::prefixCacheKeys( $keys, self::VALUE_KEY_PREFIX ); - $checkKeysForAll = array(); - $checkKeysByKey = array(); - $checkKeysFlat = array(); + $checkKeysForAll = []; + $checkKeysByKey = []; + $checkKeysFlat = []; foreach ( $checkKeys as $i => $keys ) { $prefixed = self::prefixCacheKeys( (array)$keys, self::TIME_KEY_PREFIX ); $checkKeysFlat = array_merge( $checkKeysFlat, $prefixed ); @@ -256,7 +256,7 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { // Collect timestamps from all "check" keys $purgeValuesForAll = $this->processCheckKeys( $checkKeysForAll, $wrappedValues, $now ); - $purgeValuesByKey = array(); + $purgeValuesByKey = []; foreach ( $checkKeysByKey as $cacheKey => $checks ) { $purgeValuesByKey[$cacheKey] = $this->processCheckKeys( $checks, $wrappedValues, $now ); @@ -304,7 +304,7 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { * @return array List of purge value arrays */ private function processCheckKeys( array $timeKeys, array $wrappedValues, $now ) { - $purgeValues = array(); + $purgeValues = []; foreach ( $timeKeys as $timeKey ) { $purge = isset( $wrappedValues[$timeKey] ) ? self::parsePurgeValue( $wrappedValues[$timeKey] ) @@ -370,7 +370,7 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { * Default: WANObjectCache::TSE_NONE * @return bool Success */ - final public function set( $key, $value, $ttl = 0, array $opts = array() ) { + final public function set( $key, $value, $ttl = 0, array $opts = [] ) { $lockTSE = isset( $opts['lockTSE'] ) ? $opts['lockTSE'] : self::TSE_NONE; $age = isset( $opts['since'] ) ? max( 0, microtime( true ) - $opts['since'] ) : 0; $lag = isset( $opts['lag'] ) ? $opts['lag'] : 0; @@ -382,7 +382,7 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { return true; // no-op the write for being unsafe } - $wrapExtra = array(); // additional wrapped value fields + $wrapExtra = []; // additional wrapped value fields // Check if there's a risk of writing stale data after the purge tombstone expired if ( $lag === false || ( $lag + $age ) > self::MAX_READ_LAG ) { // Case A: read lag with "lockTSE"; save but record value as stale @@ -762,7 +762,7 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { * Default: WANObjectCache::TTL_UNCACHEABLE. * @return mixed Value to use for the key */ - final public function getWithSetCallback( $key, $ttl, $callback, array $opts = array() ) { + final public function getWithSetCallback( $key, $ttl, $callback, array $opts = [] ) { $pcTTL = isset( $opts['pcTTL'] ) ? $opts['pcTTL'] : self::TTL_UNCACHEABLE; // Try the process cache if enabled @@ -794,7 +794,7 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { protected function doGetWithSetCallback( $key, $ttl, $callback, array $opts ) { $lowTTL = isset( $opts['lowTTL'] ) ? $opts['lowTTL'] : min( self::LOW_TTL, $ttl ); $lockTSE = isset( $opts['lockTSE'] ) ? $opts['lockTSE'] : self::TSE_NONE; - $checkKeys = isset( $opts['checkKeys'] ) ? $opts['checkKeys'] : array(); + $checkKeys = isset( $opts['checkKeys'] ) ? $opts['checkKeys'] : []; // Get the current key value $curTTL = null; @@ -841,8 +841,8 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { } // Generate the new value from the callback... - $setOpts = array(); - $value = call_user_func_array( $callback, array( $cValue, &$ttl, &$setOpts ) ); + $setOpts = []; + $value = call_user_func_array( $callback, [ $cValue, &$ttl, &$setOpts ] ); // When delete() is called, writes are write-holed by the tombstone, // so use a special stash key to pass the new value around threads. if ( $useMutex && $value !== false && $ttl >= 0 ) { @@ -870,7 +870,7 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { * @since 1.27 */ public function makeKey() { - return call_user_func_array( array( $this->cache, __FUNCTION__ ), func_get_args() ); + return call_user_func_array( [ $this->cache, __FUNCTION__ ], func_get_args() ); } /** @@ -880,7 +880,7 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { * @since 1.27 */ public function makeGlobalKey() { - return call_user_func_array( array( $this->cache, __FUNCTION__ ), func_get_args() ); + return call_user_func_array( [ $this->cache, __FUNCTION__ ], func_get_args() ); } /** @@ -929,13 +929,13 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { * @return bool Success */ protected function relayPurge( $key, $ttl, $holdoff ) { - $event = $this->cache->modifySimpleRelayEvent( array( + $event = $this->cache->modifySimpleRelayEvent( [ 'cmd' => 'set', 'key' => $key, 'val' => 'PURGED:$UNIXTIME$:' . (int)$holdoff, 'ttl' => max( $ttl, 1 ), 'sbt' => true, // substitute $UNIXTIME$ with actual microtime - ) ); + ] ); $ok = $this->relayer->notify( "{$this->pool}:purge", $event ); if ( !$ok ) { @@ -952,10 +952,10 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { * @return bool Success */ protected function relayDelete( $key ) { - $event = $this->cache->modifySimpleRelayEvent( array( + $event = $this->cache->modifySimpleRelayEvent( [ 'cmd' => 'delete', 'key' => $key, - ) ); + ] ); $ok = $this->relayer->notify( "{$this->pool}:purge", $event ); if ( !$ok ) { @@ -997,12 +997,12 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { * @return array */ protected function wrap( $value, $ttl ) { - return array( + return [ self::FLD_VERSION => self::VERSION, self::FLD_VALUE => $value, self::FLD_TTL => $ttl, self::FLD_TIME => microtime( true ) - ); + ]; } /** @@ -1018,14 +1018,14 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { if ( $purge !== false ) { // Purged values should always have a negative current $ttl $curTTL = min( $purge[self::FLD_TIME] - $now, self::TINY_NEGATIVE ); - return array( false, $curTTL ); + return [ false, $curTTL ]; } if ( !is_array( $wrapped ) // not found || !isset( $wrapped[self::FLD_VERSION] ) // wrong format || $wrapped[self::FLD_VERSION] !== self::VERSION // wrong version ) { - return array( false, null ); + return [ false, null ]; } $flags = isset( $wrapped[self::FLD_FLAGS] ) ? $wrapped[self::FLD_FLAGS] : 0; @@ -1042,7 +1042,7 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { $curTTL = INF; } - return array( $wrapped[self::FLD_VALUE], $curTTL ); + return [ $wrapped[self::FLD_VALUE], $curTTL ]; } /** @@ -1051,7 +1051,7 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { * @return string[] */ protected static function prefixCacheKeys( array $keys, $prefix ) { - $res = array(); + $res = []; foreach ( $keys as $key ) { $res[] = $prefix . $key; } @@ -1078,10 +1078,10 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { // Back-compat with old purge values without holdoff $segments[2] = self::HOLDOFF_TTL; } - return array( + return [ self::FLD_TIME => (float)$segments[1], self::FLD_HOLDOFF => (int)$segments[2], - ); + ]; } /** diff --git a/includes/libs/objectcache/WinCacheBagOStuff.php b/includes/libs/objectcache/WinCacheBagOStuff.php index 8b0161090c..3d72abe84f 100644 --- a/includes/libs/objectcache/WinCacheBagOStuff.php +++ b/includes/libs/objectcache/WinCacheBagOStuff.php @@ -51,7 +51,7 @@ class WinCacheBagOStuff extends BagOStuff { /* wincache_ucache_set returns an empty array on success if $value was an array, bool otherwise */ - return ( is_array( $result ) && $result === array() ) || $result; + return ( is_array( $result ) && $result === [] ) || $result; } protected function cas( $casToken, $key, $value, $exptime = 0 ) { diff --git a/includes/libs/replacers/RegexlikeReplacer.php b/includes/libs/replacers/RegexlikeReplacer.php index 2b1fa74023..9874f524c2 100644 --- a/includes/libs/replacers/RegexlikeReplacer.php +++ b/includes/libs/replacers/RegexlikeReplacer.php @@ -36,7 +36,7 @@ class RegexlikeReplacer extends Replacer { * @return string */ public function replace( array $matches ) { - $pairs = array(); + $pairs = []; foreach ( $matches as $i => $match ) { $pairs["\$$i"] = $match; } diff --git a/includes/libs/replacers/Replacer.php b/includes/libs/replacers/Replacer.php index f4850bf6ad..3b978357ed 100644 --- a/includes/libs/replacers/Replacer.php +++ b/includes/libs/replacers/Replacer.php @@ -27,7 +27,7 @@ abstract class Replacer { * @return array */ public function cb() { - return array( &$this, 'replace' ); + return [ &$this, 'replace' ]; } /** diff --git a/includes/libs/virtualrest/ParsoidVirtualRESTService.php b/includes/libs/virtualrest/ParsoidVirtualRESTService.php index 5be4aeab41..da47d35651 100644 --- a/includes/libs/virtualrest/ParsoidVirtualRESTService.php +++ b/includes/libs/virtualrest/ParsoidVirtualRESTService.php @@ -53,14 +53,14 @@ class ParsoidVirtualRESTService extends VirtualRESTService { unset( $params['URL'] ); } // set up defaults and merge them with the given params - $mparams = array_merge( array( + $mparams = array_merge( [ 'name' => 'parsoid', 'url' => 'http://localhost:8000/', 'prefix' => 'localhost', 'domain' => 'localhost', 'forwardCookies' => false, 'HTTPProxy' => null, - ), $params ); + ], $params ); // Ensure that the url parameter has a trailing slash. $mparams['url'] = preg_replace( '#/?$#', @@ -79,7 +79,7 @@ class ParsoidVirtualRESTService extends VirtualRESTService { } public function onRequests( array $reqs, Closure $idGeneratorFunc ) { - $result = array(); + $result = []; foreach ( $reqs as $key => $req ) { $parts = explode( '/', $req['url'] ); diff --git a/includes/libs/virtualrest/RestbaseVirtualRESTService.php b/includes/libs/virtualrest/RestbaseVirtualRESTService.php index 81442adc42..d2dd89f809 100644 --- a/includes/libs/virtualrest/RestbaseVirtualRESTService.php +++ b/includes/libs/virtualrest/RestbaseVirtualRESTService.php @@ -47,7 +47,7 @@ class RestbaseVirtualRESTService extends VirtualRESTService { */ public function __construct( array $params ) { // set up defaults and merge them with the given params - $mparams = array_merge( array( + $mparams = array_merge( [ 'name' => 'restbase', 'url' => 'http://localhost:7231/', 'domain' => 'localhost', @@ -55,7 +55,7 @@ class RestbaseVirtualRESTService extends VirtualRESTService { 'forwardCookies' => false, 'HTTPProxy' => null, 'parsoidCompat' => false - ), $params ); + ], $params ); // Ensure that the url parameter has a trailing slash. $mparams['url'] = preg_replace( '#/?$#', @@ -79,7 +79,7 @@ class RestbaseVirtualRESTService extends VirtualRESTService { return $this->onParsoidRequests( $reqs, $idGenFunc ); } - $result = array(); + $result = []; foreach ( $reqs as $key => $req ) { // replace /local/ with the current domain $req['url'] = preg_replace( '#^local/#', $this->params['domain'] . '/', $req['url'] ); @@ -107,7 +107,7 @@ class RestbaseVirtualRESTService extends VirtualRESTService { */ public function onParsoidRequests( array $reqs, Closure $idGeneratorFunc ) { - $result = array(); + $result = []; foreach ( $reqs as $key => $req ) { $parts = explode( '/', $req['url'] ); if ( $parts[1] === 'v3' ) { diff --git a/includes/libs/virtualrest/SwiftVirtualRESTService.php b/includes/libs/virtualrest/SwiftVirtualRESTService.php index 88b0e1f14a..679d51c5ac 100644 --- a/includes/libs/virtualrest/SwiftVirtualRESTService.php +++ b/includes/libs/virtualrest/SwiftVirtualRESTService.php @@ -46,9 +46,9 @@ class SwiftVirtualRESTService extends VirtualRESTService { */ public function __construct( array $params ) { // set up defaults and merge them with the given params - $mparams = array_merge( array( + $mparams = array_merge( [ 'name' => 'swift' - ), $params ); + ], $params ); parent::__construct( $mparams ); } @@ -74,10 +74,10 @@ class SwiftVirtualRESTService extends VirtualRESTService { $this->authSessionTimestamp = 0; list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $req['response']; if ( $rcode >= 200 && $rcode <= 299 ) { // OK - $this->authCreds = array( + $this->authCreds = [ 'auth_token' => $rhdrs['x-auth-token'], 'storage_url' => $rhdrs['x-storage-url'] - ); + ]; $this->authSessionTimestamp = time(); return true; } elseif ( $rcode === 403 ) { @@ -94,7 +94,7 @@ class SwiftVirtualRESTService extends VirtualRESTService { } public function onRequests( array $reqs, Closure $idGeneratorFunc ) { - $result = array(); + $result = []; $firstReq = reset( $reqs ); if ( $firstReq && count( $reqs ) == 1 && isset( $firstReq['isAuth'] ) ) { // This was an authentication request for work requests... @@ -105,29 +105,29 @@ class SwiftVirtualRESTService extends VirtualRESTService { if ( $needsAuth === true ) { // These are work requests and we don't have any token to use. // Replace the work requests with an authentication request. - $result = array( - $idGeneratorFunc() => array( + $result = [ + $idGeneratorFunc() => [ 'method' => 'GET', 'url' => $this->params['swiftAuthUrl'] . "/v1.0", - 'headers' => array( + 'headers' => [ 'x-auth-user' => $this->params['swiftUser'], - 'x-auth-key' => $this->params['swiftKey'] ), + 'x-auth-key' => $this->params['swiftKey'] ], 'isAuth' => true, 'chain' => $reqs - ) - ); + ] + ]; } elseif ( $needsAuth !== false ) { // These are work requests and authentication has previously failed. // It is most efficient to just give failed pseudo responses back for // the original work requests. foreach ( $reqs as $key => $req ) { - $req['response'] = array( + $req['response'] = [ 'code' => $this->authCachedStatus, 'reason' => $this->authCachedReason, - 'headers' => array(), + 'headers' => [], 'body' => '', 'error' => '' - ); + ]; $result[$key] = $req; } } else { @@ -151,7 +151,7 @@ class SwiftVirtualRESTService extends VirtualRESTService { public function onResponses( array $reqs, Closure $idGeneratorFunc ) { $firstReq = reset( $reqs ); if ( $firstReq && count( $reqs ) == 1 && isset( $firstReq['isAuth'] ) ) { - $result = array(); + $result = []; // This was an authentication request for work requests... if ( $this->applyAuthResponse( $firstReq ) ) { // If it succeeded, we can subsitute the work requests back. @@ -161,13 +161,13 @@ class SwiftVirtualRESTService extends VirtualRESTService { // If it failed, it is most efficient to just give failing // pseudo-responses back for the actual work requests. foreach ( $firstReq['chain'] as $key => $req ) { - $req['response'] = array( + $req['response'] = [ 'code' => $this->authCachedStatus, 'reason' => $this->authCachedReason, - 'headers' => array(), + 'headers' => [], 'body' => '', 'error' => '' - ); + ]; $result[$key] = $req; } } diff --git a/includes/libs/virtualrest/VirtualRESTService.php b/includes/libs/virtualrest/VirtualRESTService.php index 01a4ea6edf..ccb14db020 100644 --- a/includes/libs/virtualrest/VirtualRESTService.php +++ b/includes/libs/virtualrest/VirtualRESTService.php @@ -35,7 +35,7 @@ */ abstract class VirtualRESTService { /** @var array Key/value map */ - protected $params = array(); + protected $params = []; /** * @param array $params Key/value map @@ -78,7 +78,7 @@ abstract class VirtualRESTService { * @return array Modified HTTP request array map */ public function onRequests( array $reqs, Closure $idGeneratorFunc ) { - $result = array(); + $result = []; foreach ( $reqs as $key => $req ) { // The default encoding treats the URL as a REST style path that uses // forward slash as a hierarchical delimiter (and never otherwise). diff --git a/includes/libs/virtualrest/VirtualRESTServiceClient.php b/includes/libs/virtualrest/VirtualRESTServiceClient.php index 519da4313c..c64fe34af7 100644 --- a/includes/libs/virtualrest/VirtualRESTServiceClient.php +++ b/includes/libs/virtualrest/VirtualRESTServiceClient.php @@ -47,7 +47,7 @@ class VirtualRESTServiceClient { /** @var MultiHttpClient */ protected $http; /** @var Array Map of (prefix => VirtualRESTService) */ - protected $instances = array(); + protected $instances = []; const VALID_MOUNT_REGEX = '#^/[0-9a-z]+/([0-9a-z]+/)*$#'; @@ -103,7 +103,7 @@ class VirtualRESTServiceClient { return ( $al < $bl ) ? 1 : -1; // largest prefix first }; - $matches = array(); // matching prefixes (mount points) + $matches = []; // matching prefixes (mount points) foreach ( $this->instances as $prefix => $service ) { if ( strpos( $path, $prefix ) === 0 ) { $matches[] = $prefix; @@ -113,8 +113,8 @@ class VirtualRESTServiceClient { // Return the most specific prefix and corresponding service return isset( $matches[0] ) - ? array( $matches[0], $this->instances[$matches[0]] ) - : array( null, null ); + ? [ $matches[0], $this->instances[$matches[0]] ] + : [ null, null ]; } /** @@ -134,7 +134,7 @@ class VirtualRESTServiceClient { * @return array Response array for request */ public function run( array $req ) { - $responses = $this->runMulti( array( $req ) ); + $responses = $this->runMulti( [ $req ] ); return $responses[0]; } @@ -166,17 +166,17 @@ class VirtualRESTServiceClient { $req['url'] = $req[1]; // short-form unset( $req[1] ); } - $req['chain'] = array(); // chain or list of replaced requests + $req['chain'] = []; // chain or list of replaced requests } unset( $req ); // don't assign over this by accident $curUniqueId = 0; - $armoredIndexMap = array(); // (original index => new index) + $armoredIndexMap = []; // (original index => new index) - $doneReqs = array(); // (index => request) - $executeReqs = array(); // (index => request) - $replaceReqsByService = array(); // (prefix => index => request) - $origPending = array(); // (index => 1) for original requests + $doneReqs = []; // (index => request) + $executeReqs = []; // (index => request) + $replaceReqsByService = []; // (prefix => index => request) + $origPending = []; // (index => 1) for original requests foreach ( $reqs as $origIndex => $req ) { // Re-index keys to consecutive integers (they will be swapped back later) @@ -210,12 +210,12 @@ class VirtualRESTServiceClient { } // Track requests executed this round that have a prefix/service. // Note that this also includes requests where 'response' was forced. - $checkReqIndexesByPrefix = array(); + $checkReqIndexesByPrefix = []; // Resolve the virtual URLs valid and qualified HTTP(S) URLs // and add any required authentication headers for the backend. // Services can also replace requests with new ones, either to // defer the original or to set a proxy response to the original. - $newReplaceReqsByService = array(); + $newReplaceReqsByService = []; foreach ( $replaceReqsByService as $prefix => $servReqs ) { $service = $this->instances[$prefix]; foreach ( $service->onRequests( $servReqs, $idFunc ) as $index => $req ) { @@ -245,13 +245,13 @@ class VirtualRESTServiceClient { $doneReqs[$index] = $ranReq; unset( $origPending[$index] ); } - $executeReqs = array(); + $executeReqs = []; // Services can also replace requests with new ones, either to // defer the original or to set a proxy response to the original. // Any replacement requests executed above will need to be replaced // with new requests (eventually the original). The responses can be // forced by setting 'response' rather than actually be sent over the wire. - $newReplaceReqsByService = array(); + $newReplaceReqsByService = []; foreach ( $checkReqIndexesByPrefix as $prefix => $servReqIndexes ) { $service = $this->instances[$prefix]; // $doneReqs actually has the requests (with 'response' set) @@ -278,7 +278,7 @@ class VirtualRESTServiceClient { $replaceReqsByService = $newReplaceReqsByService; } while ( count( $origPending ) ); - $responses = array(); + $responses = []; // Update $reqs to include 'response' and normalized request 'headers'. // This maintains the original order of $reqs. foreach ( $reqs as $origIndex => $req ) { diff --git a/includes/logging/BlockLogFormatter.php b/includes/logging/BlockLogFormatter.php index 72fcc3a5df..aa90d1d369 100644 --- a/includes/logging/BlockLogFormatter.php +++ b/includes/logging/BlockLogFormatter.php @@ -83,9 +83,9 @@ class BlockLogFormatter extends LogFormatter { $title = $this->entry->getTarget(); // Preload user page for non-autoblocks if ( substr( $title->getText(), 0, 1 ) !== '#' ) { - return array( $title->getTalkPage() ); + return [ $title->getTalkPage() ]; } - return array(); + return []; } public function getActionLinks() { @@ -99,7 +99,7 @@ class BlockLogFormatter extends LogFormatter { // Show unblock/change block link $title = $this->entry->getTarget(); - $links = array( + $links = [ Linker::linkKnown( SpecialPage::getTitleFor( 'Unblock', $title->getDBkey() ), $this->msg( 'unblocklink' )->escaped() @@ -108,7 +108,7 @@ class BlockLogFormatter extends LogFormatter { SpecialPage::getTitleFor( 'Block', $title->getDBkey() ), $this->msg( 'change-blocklink' )->escaped() ) - ); + ]; return $this->msg( 'parentheses' )->rawParams( $this->context->getLanguage()->pipeList( $links ) )->escaped(); @@ -146,7 +146,7 @@ class BlockLogFormatter extends LogFormatter { * @return string */ public static function formatBlockFlag( $flag, $lang ) { - static $messages = array(); + static $messages = []; if ( !isset( $messages[$flag] ) ) { $messages[$flag] = htmlspecialchars( $flag ); // Fallback @@ -173,13 +173,13 @@ class BlockLogFormatter extends LogFormatter { $entry = $this->entry; $params = $entry->getParameters(); - static $map = array( + static $map = [ // While this looks wrong to be starting at 5 rather than 4, it's // because getMessageParameters uses $4 for its own purposes. '5::duration', '6:array:flags', '6::flags' => '6:array:flags', - ); + ]; foreach ( $map as $index => $key ) { if ( isset( $params[$index] ) ) { $params[$key] = $params[$index]; @@ -190,14 +190,14 @@ class BlockLogFormatter extends LogFormatter { $subtype = $entry->getSubtype(); if ( $subtype === 'block' || $subtype === 'reblock' ) { // Defaults for old log entries missing some fields - $params += array( + $params += [ '5::duration' => 'infinite', - '6:array:flags' => array(), - ); + '6:array:flags' => [], + ]; if ( !is_array( $params['6:array:flags'] ) ) { $params['6:array:flags'] = $params['6:array:flags'] === '' - ? array() + ? [] : explode( ',', $params['6:array:flags'] ); } diff --git a/includes/logging/ContentModelLogFormatter.php b/includes/logging/ContentModelLogFormatter.php index 982fcc308c..f130740a8d 100644 --- a/includes/logging/ContentModelLogFormatter.php +++ b/includes/logging/ContentModelLogFormatter.php @@ -21,12 +21,12 @@ class ContentModelLogFormatter extends LogFormatter { $revert = Linker::linkKnown( SpecialPage::getTitleFor( 'ChangeContentModel' ), $this->msg( 'logentry-contentmodel-change-revertlink' )->escaped(), - array(), - array( + [], + [ 'pagetitle' => $this->entry->getTarget()->getPrefixedText(), 'model' => $params[3], 'reason' => $this->msg( 'logentry-contentmodel-change-revert' )->inContentLanguage()->text(), - ) + ] ); return $this->msg( 'parentheses' )->rawParams( $revert )->escaped(); diff --git a/includes/logging/DeleteLogFormatter.php b/includes/logging/DeleteLogFormatter.php index f0598aa749..3b470ecd8f 100644 --- a/includes/logging/DeleteLogFormatter.php +++ b/includes/logging/DeleteLogFormatter.php @@ -31,7 +31,7 @@ class DeleteLogFormatter extends LogFormatter { protected function getMessageKey() { $key = parent::getMessageKey(); - if ( in_array( $this->entry->getSubtype(), array( 'event', 'revision' ) ) ) { + if ( in_array( $this->entry->getSubtype(), [ 'event', 'revision' ] ) ) { if ( count( $this->getMessageParameters() ) < 5 ) { return "$key-legacy"; } @@ -47,7 +47,7 @@ class DeleteLogFormatter extends LogFormatter { $params = parent::getMessageParameters(); $subtype = $this->entry->getSubtype(); - if ( in_array( $subtype, array( 'event', 'revision' ) ) ) { + if ( in_array( $subtype, [ 'event', 'revision' ] ) ) { // $params[3] here is 'revision' or 'archive' for page revisions, 'oldimage' or // 'filearchive' for file versions, or a comma-separated list of log_ids for log // entries. $subtype here is 'revision' for page revisions and file @@ -63,7 +63,7 @@ class DeleteLogFormatter extends LogFormatter { $old = $this->parseBitField( $params[$paramStart + 1] ); $new = $this->parseBitField( $params[$paramStart + 2] ); list( $hid, $unhid, $extra ) = RevisionDeleter::getChanges( $new, $old ); - $changes = array(); + $changes = []; // messages used: revdelete-content-hid, revdelete-summary-hid, revdelete-uname-hid foreach ( $hid as $v ) { $changes[] = $this->msg( "$v-hid" )->plain(); @@ -125,8 +125,8 @@ class DeleteLogFormatter extends LogFormatter { $revert = Linker::linkKnown( SpecialPage::getTitleFor( 'Undelete' ), $this->msg( $message )->escaped(), - array(), - array( 'target' => $this->entry->getTarget()->getPrefixedDBkey() ) + [], + [ 'target' => $this->entry->getTarget()->getPrefixedDBkey() ] ); return $this->msg( 'parentheses' )->rawParams( $revert )->escaped(); @@ -144,7 +144,7 @@ class DeleteLogFormatter extends LogFormatter { ? $params[4] : explode( ',', $params[4] ); - $links = array(); + $links = []; // If there's only one item, we can show a diff link if ( count( $ids ) == 1 ) { @@ -153,23 +153,23 @@ class DeleteLogFormatter extends LogFormatter { $links[] = Linker::linkKnown( $this->entry->getTarget(), $this->msg( 'diff' )->escaped(), - array(), - array( + [], + [ 'diff' => intval( $ids[0] ), 'unhide' => 1 - ) + ] ); // Deleted revision diffs... } elseif ( $key == 'artimestamp' || $key == 'archive' ) { $links[] = Linker::linkKnown( SpecialPage::getTitleFor( 'Undelete' ), $this->msg( 'diff' )->escaped(), - array(), - array( + [], + [ 'target' => $this->entry->getTarget()->getPrefixedDBkey(), 'diff' => 'prev', 'timestamp' => $ids[0] - ) + ] ); } } @@ -178,12 +178,12 @@ class DeleteLogFormatter extends LogFormatter { $links[] = Linker::linkKnown( SpecialPage::getTitleFor( 'Revisiondelete' ), $this->msg( 'revdel-restore' )->escaped(), - array(), - array( + [], + [ 'target' => $this->entry->getTarget()->getPrefixedText(), 'type' => $key, 'ids' => implode( ',', $ids ), - ) + ] ); return $this->msg( 'parentheses' )->rawParams( @@ -203,12 +203,12 @@ class DeleteLogFormatter extends LogFormatter { $revert = Linker::linkKnown( SpecialPage::getTitleFor( 'Revisiondelete' ), $this->msg( 'revdel-restore' )->escaped(), - array(), - array( + [], + [ 'target' => $this->entry->getTarget()->getPrefixedText(), 'type' => 'logging', 'ids' => $query - ) + ] ); return $this->msg( 'parentheses' )->rawParams( $revert )->escaped(); @@ -219,16 +219,16 @@ class DeleteLogFormatter extends LogFormatter { protected function getParametersForApi() { $entry = $this->entry; - $params = array(); + $params = []; $subtype = $this->entry->getSubtype(); - if ( in_array( $subtype, array( 'event', 'revision' ) ) ) { + if ( in_array( $subtype, [ 'event', 'revision' ] ) ) { $rawParams = $entry->getParameters(); if ( $subtype === 'event' ) { array_unshift( $rawParams, 'logging' ); } - static $map = array( + static $map = [ '4::type', '5::ids', '6::ofield', @@ -236,7 +236,7 @@ class DeleteLogFormatter extends LogFormatter { '4::ids' => '5::ids', '5::ofield' => '6::ofield', '6::nfield' => '7::nfield', - ); + ]; foreach ( $map as $index => $key ) { if ( isset( $rawParams[$index] ) ) { $rawParams[$key] = $rawParams[$index]; @@ -250,19 +250,19 @@ class DeleteLogFormatter extends LogFormatter { $rawParams['5::ids'] = explode( ',', $rawParams['5::ids'] ); } - $params = array( + $params = [ '::type' => $rawParams['4::type'], ':array:ids' => $rawParams['5::ids'], - ':assoc:old' => array( 'bitmask' => $old ), - ':assoc:new' => array( 'bitmask' => $new ), - ); + ':assoc:old' => [ 'bitmask' => $old ], + ':assoc:new' => [ 'bitmask' => $new ], + ]; - static $fields = array( + static $fields = [ Revision::DELETED_TEXT => 'content', Revision::DELETED_COMMENT => 'comment', Revision::DELETED_USER => 'user', Revision::DELETED_RESTRICTED => 'restricted', - ); + ]; foreach ( $fields as $bit => $key ) { $params[':assoc:old'][$key] = (bool)( $old & $bit ); $params[':assoc:new'][$key] = (bool)( $new & $bit ); diff --git a/includes/logging/LogEntry.php b/includes/logging/LogEntry.php index ddcb6365ec..e76aa29476 100644 --- a/includes/logging/LogEntry.php +++ b/includes/logging/LogEntry.php @@ -168,27 +168,27 @@ class DatabaseLogEntry extends LogEntryBase { * @return array */ public static function getSelectQueryData() { - $tables = array( 'logging', 'user' ); - $fields = array( + $tables = [ 'logging', 'user' ]; + $fields = [ 'log_id', 'log_type', 'log_action', 'log_timestamp', 'log_user', 'log_user_text', 'log_namespace', 'log_title', // unused log_page 'log_comment', 'log_params', 'log_deleted', 'user_id', 'user_name', 'user_editcount', - ); + ]; - $joins = array( + $joins = [ // IPs don't have an entry in user table - 'user' => array( 'LEFT JOIN', 'log_user=user_id' ), - ); + 'user' => [ 'LEFT JOIN', 'log_user=user_id' ], + ]; - return array( + return [ 'tables' => $tables, 'fields' => $fields, - 'conds' => array(), - 'options' => array(), + 'conds' => [], + 'options' => [], 'join_conds' => $joins, - ); + ]; } /** @@ -399,10 +399,10 @@ class ManualLogEntry extends LogEntryBase { protected $subtype; /** @var array Parameters for log entry */ - protected $parameters = array(); + protected $parameters = []; /** @var array */ - protected $relations = array(); + protected $relations = []; /** @var User Performer of the action for the log entry */ protected $performer; @@ -582,7 +582,7 @@ class ManualLogEntry extends LogEntryBase { $relations['associated_rev_id'] = $revId; } - $data = array( + $data = [ 'log_id' => $id, 'log_type' => $this->getType(), 'log_action' => $this->getSubtype(), @@ -594,7 +594,7 @@ class ManualLogEntry extends LogEntryBase { 'log_page' => $this->getTarget()->getArticleID(), 'log_comment' => $comment, 'log_params' => LogEntryBase::makeParamBlob( $params ), - ); + ]; if ( isset( $this->deleted ) ) { $data['log_deleted'] = $this->deleted; } @@ -602,22 +602,22 @@ class ManualLogEntry extends LogEntryBase { $dbw->insert( 'logging', $data, __METHOD__ ); $this->id = !is_null( $id ) ? $id : $dbw->insertId(); - $rows = array(); + $rows = []; foreach ( $relations as $tag => $values ) { if ( !strlen( $tag ) ) { throw new MWException( "Got empty log search tag." ); } if ( !is_array( $values ) ) { - $values = array( $values ); + $values = [ $values ]; } foreach ( $values as $value ) { - $rows[] = array( + $rows[] = [ 'ls_field' => $tag, 'ls_value' => $value, 'ls_log_id' => $this->id - ); + ]; } } if ( count( $rows ) ) { diff --git a/includes/logging/LogEventsList.php b/includes/logging/LogEventsList.php index e93030f07b..c96c0dbf0c 100644 --- a/includes/logging/LogEventsList.php +++ b/includes/logging/LogEventsList.php @@ -75,7 +75,7 @@ class LogEventsList extends ContextSource { * @param array $filter * @param string $tagFilter Tag to select by default */ - public function showOptions( $types = array(), $user = '', $page = '', $pattern = '', $year = 0, + public function showOptions( $types = [], $user = '', $page = '', $pattern = '', $year = 0, $month = 0, $filter = null, $tagFilter = '' ) { global $wgScript, $wgMiserMode; @@ -83,7 +83,7 @@ class LogEventsList extends ContextSource { $title = SpecialPage::getTitleFor( 'Log' ); // For B/C, we take strings, but make sure they are converted... - $types = ( $types === '' ) ? array() : (array)$types; + $types = ( $types === '' ) ? [] : (array)$types; $tagSelector = ChangeTags::buildTagFilterSelector( $tagFilter ); @@ -120,7 +120,7 @@ class LogEventsList extends ContextSource { $html = Xml::fieldset( $this->msg( 'log' )->text(), $html ); // Form wrapping - $html = Xml::tags( 'form', array( 'action' => $wgScript, 'method' => 'get' ), $html ); + $html = Xml::tags( 'form', [ 'action' => $wgScript, 'method' => 'get' ], $html ); $this->getOutput()->addHTML( $html ); } @@ -131,9 +131,9 @@ class LogEventsList extends ContextSource { */ private function getFilterLinks( $filter ) { // show/hide links - $messages = array( $this->msg( 'show' )->escaped(), $this->msg( 'hide' )->escaped() ); + $messages = [ $this->msg( 'show' )->escaped(), $this->msg( 'hide' )->escaped() ]; // Option value -> message mapping - $links = array(); + $links = []; $hiddens = ''; // keep track for "go" button foreach ( $filter as $type => $val ) { // Should the below assignment be outside the foreach? @@ -147,7 +147,7 @@ class LogEventsList extends ContextSource { $link = Linker::linkKnown( $this->getTitle(), $messages[$hideVal], - array(), + [], $query ); @@ -193,7 +193,7 @@ class LogEventsList extends ContextSource { * @since 1.19 */ public function getTypeSelector() { - $typesByName = array(); // Temporary array + $typesByName = []; // Temporary array // First pass to load the log names foreach ( LogPage::validTypes() as $type ) { $page = new LogPage( $type ); @@ -209,7 +209,7 @@ class LogEventsList extends ContextSource { // Always put "All public logs" on top $public = $typesByName['']; unset( $typesByName[''] ); - $typesByName = array( '' => $public ) + $typesByName; + $typesByName = [ '' => $public ] + $typesByName; $select = new XmlSelect( 'type' ); foreach ( $typesByName as $type => $name ) { @@ -230,7 +230,7 @@ class LogEventsList extends ContextSource { 'mw-log-user', 15, $user, - array( 'class' => 'mw-autocomplete-user' ) + [ 'class' => 'mw-autocomplete-user' ] ); return '' . $label . ''; @@ -279,7 +279,7 @@ class LogEventsList extends ContextSource { } else { // Allow extensions to add their own extra inputs $input = ''; - Hooks::run( 'LogEventsListGetExtraInputs', array( $types[0], $this, &$input ) ); + Hooks::run( 'LogEventsListGetExtraInputs', [ $types[0], $this, &$input ] ); return $input; } } @@ -337,11 +337,11 @@ class LogEventsList extends ContextSource { $this->getContext() ); $classes = array_merge( - array( 'mw-logline-' . $entry->getType() ), + [ 'mw-logline-' . $entry->getType() ], $newClasses ); - return Html::rawElement( 'li', array( 'class' => $classes ), + return Html::rawElement( 'li', [ 'class' => $classes ], "$del $time $action $comment $revert $tagDisplay" ) . "\n"; } @@ -362,7 +362,7 @@ class LogEventsList extends ContextSource { return Xml::check( 'showhiderevisions', false, - array( 'name' => 'ids[' . $row->log_id . ']' ) + [ 'name' => 'ids[' . $row->log_id . ']' ] ); } @@ -384,12 +384,12 @@ class LogEventsList extends ContextSource { if ( $canHide && $this->flags & self::USE_CHECKBOXES && !$canViewThisSuppressedEntry ) { // If event was hidden from sysops if ( !self::userCan( $row, LogPage::DELETED_RESTRICTED, $user ) ) { - $del = Xml::check( 'deleterevisions', false, array( 'disabled' => 'disabled' ) ); + $del = Xml::check( 'deleterevisions', false, [ 'disabled' => 'disabled' ] ); } else { $del = Xml::check( 'showhiderevisions', false, - array( 'name' => 'ids[' . $row->log_id . ']' ) + [ 'name' => 'ids[' . $row->log_id . ']' ] ); } } else { @@ -397,11 +397,11 @@ class LogEventsList extends ContextSource { if ( !self::userCan( $row, LogPage::DELETED_RESTRICTED, $user ) ) { $del = Linker::revDeleteLinkDisabled( $canHide ); } else { - $query = array( + $query = [ 'target' => SpecialPage::getTitleFor( 'Log', $row->log_type )->getPrefixedDBkey(), 'type' => 'logging', 'ids' => $row->log_id, - ); + ]; $del = Linker::revDeleteLink( $query, $entryIsSuppressed, @@ -466,13 +466,13 @@ class LogEventsList extends ContextSource { $user = $wgUser; } if ( $bitfield & LogPage::DELETED_RESTRICTED ) { - $permissions = array( 'suppressrevision', 'viewsuppressed' ); + $permissions = [ 'suppressrevision', 'viewsuppressed' ]; } else { - $permissions = array( 'deletedhistory' ); + $permissions = [ 'deletedhistory' ]; } $permissionlist = implode( ', ', $permissions ); wfDebug( "Checking for $permissionlist due to $field match on $bitfield\n" ); - return call_user_func_array( array( $user, 'isAllowedAny' ), $permissions ); + return call_user_func_array( [ $user, 'isAllowedAny' ], $permissions ); } return true; } @@ -510,18 +510,18 @@ class LogEventsList extends ContextSource { * @return int Number of total log items (not limited by $lim) */ public static function showLogExtract( - &$out, $types = array(), $page = '', $user = '', $param = array() + &$out, $types = [], $page = '', $user = '', $param = [] ) { - $defaultParameters = array( + $defaultParameters = [ 'lim' => 25, - 'conds' => array(), + 'conds' => [], 'showIfEmpty' => true, - 'msgKey' => array( '' ), + 'msgKey' => [ '' ], 'wrap' => "$1", 'flags' => 0, 'useRequestParams' => false, 'useMaster' => false, - ); + ]; # The + operator appends elements of remaining keys from the right # handed array to the left handed, whereas duplicated keys are NOT overwritten. $param += $defaultParameters; @@ -534,7 +534,7 @@ class LogEventsList extends ContextSource { $flags = $param['flags']; $useRequestParams = $param['useRequestParams']; if ( !is_array( $msgKey ) ) { - $msgKey = array( $msgKey ); + $msgKey = [ $msgKey ]; } if ( $out instanceof OutputPage ) { @@ -575,11 +575,11 @@ class LogEventsList extends ContextSource { $dir = $context->getLanguage()->getDir(); $lang = $context->getLanguage()->getHtmlCode(); - $s = Xml::openElement( 'div', array( + $s = Xml::openElement( 'div', [ 'class' => "mw-warning-with-logexcerpt mw-content-$dir", 'dir' => $dir, 'lang' => $lang, - ) ); + ] ); if ( count( $msgKey ) == 1 ) { $s .= $context->msg( $msgKey[0] )->parseAsBlock(); @@ -593,12 +593,12 @@ class LogEventsList extends ContextSource { $logBody . $loglist->endLogEventsList(); } elseif ( $showIfEmpty ) { - $s = Html::rawElement( 'div', array( 'class' => 'mw-warning-logempty' ), + $s = Html::rawElement( 'div', [ 'class' => 'mw-warning-logempty' ], $context->msg( 'logempty' )->parse() ); } if ( $numRows > $pager->mLimit ) { # Show "Full log" link - $urlParam = array(); + $urlParam = []; if ( $page instanceof Title ) { $urlParam['page'] = $page->getPrefixedDBkey(); } elseif ( $page != '' ) { @@ -610,7 +610,7 @@ class LogEventsList extends ContextSource { } if ( !is_array( $types ) ) { # Make it an array, if it isn't - $types = array( $types ); + $types = [ $types ]; } # If there is exactly one log type, we can link to Special:Log?type=foo @@ -621,7 +621,7 @@ class LogEventsList extends ContextSource { $s .= Linker::link( SpecialPage::getTitleFor( 'Log' ), $context->msg( 'log-fulllog' )->escaped(), - array(), + [], $urlParam ); } @@ -635,7 +635,7 @@ class LogEventsList extends ContextSource { } /* hook can return false, if we don't want the message to be emitted (Wikia BugId:7093) */ - if ( Hooks::run( 'LogEventsListShowLogExtract', array( &$s, $types, $page, $user, $param ) ) ) { + if ( Hooks::run( 'LogEventsListShowLogExtract', [ &$s, $types, $page, $user, $param ] ) ) { // $out can be either an OutputPage object or a String-by-reference if ( $out instanceof OutputPage ) { $out->addHTML( $s ); @@ -664,7 +664,7 @@ class LogEventsList extends ContextSource { } // Reset the array, clears extra "where" clauses when $par is used - $hiddenLogs = array(); + $hiddenLogs = []; // Don't show private logs to unprivileged users foreach ( $wgLogRestrictions as $logType => $right ) { diff --git a/includes/logging/LogFormatter.php b/includes/logging/LogFormatter.php index b99cb410af..a64fee1e50 100644 --- a/includes/logging/LogFormatter.php +++ b/includes/logging/LogFormatter.php @@ -462,7 +462,7 @@ class LogFormatter { */ protected function extractParameters() { $entry = $this->entry; - $params = array(); + $params = []; if ( $entry->isLegacy() ) { foreach ( $entry->getParameters() as $index => $value ) { @@ -608,9 +608,9 @@ class LogFormatter { * @throws MWException * @return string */ - protected function makePageLink( Title $title = null, $parameters = array(), $html = null ) { + protected function makePageLink( Title $title = null, $parameters = [], $html = null ) { if ( !$this->plaintext ) { - $link = Linker::link( $title, $html, array(), $parameters ); + $link = Linker::link( $title, $html, [], $parameters ); } else { if ( !$title instanceof Title ) { throw new MWException( "Expected title, got null" ); @@ -671,7 +671,7 @@ class LogFormatter { } $content = $this->msg( $message )->escaped(); - $attribs = array( 'class' => 'history-deleted' ); + $attribs = [ 'class' => 'history-deleted' ]; return Html::rawElement( 'span', $attribs, $content ); } @@ -685,7 +685,7 @@ class LogFormatter { if ( $this->plaintext ) { return $content; } - $attribs = array( 'class' => 'history-deleted' ); + $attribs = [ 'class' => 'history-deleted' ]; return Html::rawElement( 'span', $attribs, $content ); } @@ -726,7 +726,7 @@ class LogFormatter { * @return array Array of titles that should be preloaded with LinkBatch */ public function getPreloadTitles() { - return array(); + return []; } /** @@ -763,7 +763,7 @@ class LogFormatter { * @return array */ public function formatParametersForApi() { - $logParams = array(); + $logParams = []; foreach ( $this->getParametersForApi() as $key => $value ) { $vals = explode( ':', $key, 3 ); if ( count( $vals ) !== 3 ) { @@ -820,7 +820,7 @@ class LogFormatter { if ( $type === 'msg-content' ) { $msg->inContentLanguage(); } - $value = array(); + $value = []; $value["{$name}_key"] = $msg->getKey(); if ( $msg->getParams() ) { $value["{$name}_params"] = $msg->getParams(); @@ -832,7 +832,7 @@ class LogFormatter { case 'title-link': $title = Title::newFromText( $value ); if ( $title ) { - $value = array(); + $value = []; ApiQueryBase::addTitleInfo( $value, $title, "{$name}_" ); } return $value; @@ -850,7 +850,7 @@ class LogFormatter { break; } - return array( $name => $value ); + return [ $name => $value ]; } } @@ -946,8 +946,8 @@ class LegacyLogFormatter extends LogFormatter { $params = $this->entry->getParameters(); - Hooks::run( 'LogLine', array( $type, $subtype, $title, $params, - &$this->comment, &$this->revert, $this->entry->getTimestamp() ) ); + Hooks::run( 'LogLine', [ $type, $subtype, $title, $params, + &$this->comment, &$this->revert, $this->entry->getTimestamp() ] ); return $this->revert; } diff --git a/includes/logging/LogPage.php b/includes/logging/LogPage.php index 6b70ceca4d..daaff07a1e 100644 --- a/includes/logging/LogPage.php +++ b/includes/logging/LogPage.php @@ -97,7 +97,7 @@ class LogPage { // @todo FIXME private/protected/public property? $this->timestamp = $now = wfTimestampNow(); - $data = array( + $data = [ 'log_id' => $log_id, 'log_type' => $this->type, 'log_action' => $this->action, @@ -109,7 +109,7 @@ class LogPage { 'log_page' => $this->target->getArticleID(), 'log_comment' => $this->comment, 'log_params' => $this->params - ); + ]; $dbw->insert( 'logging', $data, __METHOD__ ); $newId = !is_null( $log_id ) ? $log_id : $dbw->insertId(); @@ -225,7 +225,7 @@ class LogPage { * @return string HTML */ public static function actionText( $type, $action, $title = null, $skin = null, - $params = array(), $filterWikilinks = false + $params = [], $filterWikilinks = false ) { global $wgLang, $wgContLang, $wgLogActions; @@ -331,11 +331,11 @@ class LogPage { * * @return int The log_id of the inserted log entry */ - public function addEntry( $action, $target, $comment, $params = array(), $doer = null ) { + public function addEntry( $action, $target, $comment, $params = [], $doer = null ) { global $wgContLang; if ( !is_array( $params ) ) { - $params = array( $params ); + $params = [ $params ]; } if ( $comment === null ) { @@ -394,14 +394,14 @@ class LogPage { return false; // nothing } - $data = array(); + $data = []; foreach ( $values as $value ) { - $data[] = array( + $data[] = [ 'ls_field' => $field, 'ls_value' => $value, 'ls_log_id' => $logid - ); + ]; } $dbw = wfGetDB( DB_MASTER ); @@ -428,7 +428,7 @@ class LogPage { */ public static function extractParams( $blob ) { if ( $blob === '' ) { - return array(); + return []; } else { return explode( "\n", $blob ); } diff --git a/includes/logging/LogPager.php b/includes/logging/LogPager.php index 3583599bd0..11ae5d636a 100644 --- a/includes/logging/LogPager.php +++ b/includes/logging/LogPager.php @@ -28,7 +28,7 @@ */ class LogPager extends ReverseChronologicalPager { /** @var array Log types */ - private $types = array(); + private $types = []; /** @var string Events limited to those by performer when set */ private $performer = ''; @@ -58,8 +58,8 @@ class LogPager extends ReverseChronologicalPager { * @param int|bool $month The month to start from. Default: false * @param string $tagFilter Tag */ - public function __construct( $list, $types = array(), $performer = '', $title = '', $pattern = '', - $conds = array(), $year = false, $month = false, $tagFilter = '' ) { + public function __construct( $list, $types = [], $performer = '', $title = '', $pattern = '', + $conds = [], $year = false, $month = false, $tagFilter = '' ) { parent::__construct( $list->getContext() ); $this->mConds = $conds; @@ -87,7 +87,7 @@ class LogPager extends ReverseChronologicalPager { // Call ONLY after calling $this->limitType() already! public function getFilterParams() { global $wgFilterLogTypes; - $filters = array(); + $filters = []; if ( count( $this->types ) ) { return $filters; } @@ -117,7 +117,7 @@ class LogPager extends ReverseChronologicalPager { $user = $this->getUser(); // If $types is not an array, make it an array - $types = ( $types === '' ) ? array() : (array)$types; + $types = ( $types === '' ) ? [] : (array)$types; // Don't even show header for private logs; don't recognize it... $needReindex = false; foreach ( $types as $type ) { @@ -125,7 +125,7 @@ class LogPager extends ReverseChronologicalPager { && !$user->isAllowed( $wgLogRestrictions[$type] ) ) { $needReindex = true; - $types = array_diff( $types, array( $type ) ); + $types = array_diff( $types, [ $type ] ); } } if ( $needReindex ) { @@ -208,7 +208,7 @@ class LogPager extends ReverseChronologicalPager { $db = $this->mDb; $doUserRightsLogLike = false; - if ( $this->types == array( 'rights' ) ) { + if ( $this->types == [ 'rights' ] ) { $parts = explode( $wgUserrightsInterwikiDelimiter, $title->getDBKey() ); if ( count( $parts ) == 2 ) { list( $name, $database ) = array_map( 'trim', $parts ); @@ -233,7 +233,7 @@ class LogPager extends ReverseChronologicalPager { */ $this->mConds['log_namespace'] = $ns; if ( $doUserRightsLogLike ) { - $params = array( $name . $wgUserrightsInterwikiDelimiter ); + $params = [ $name . $wgUserrightsInterwikiDelimiter ]; foreach ( explode( '*', $database ) as $databasepart ) { $params[] = $databasepart; $params[] = $db->anyString(); @@ -270,7 +270,7 @@ class LogPager extends ReverseChronologicalPager { $options = $basic['options']; $joins = $basic['join_conds']; - $index = array(); + $index = []; # Add log_search table if there are conditions on it. # This filters the results to only include log rows that have # log_search records with the specified ls_field and ls_value values. @@ -291,15 +291,15 @@ class LogPager extends ReverseChronologicalPager { $options['USE INDEX'] = $index; } # Don't show duplicate rows when using log_search - $joins['log_search'] = array( 'INNER JOIN', 'ls_log_id=log_id' ); + $joins['log_search'] = [ 'INNER JOIN', 'ls_log_id=log_id' ]; - $info = array( + $info = [ 'tables' => $tables, 'fields' => $fields, 'conds' => array_merge( $conds, $this->mConds ), 'options' => $options, 'join_conds' => $joins, - ); + ]; # Add ChangeTags filter query ChangeTags::modifyDisplayQuery( $info['tables'], $info['fields'], $info['conds'], $info['join_conds'], $info['options'], $this->mTagFilter ); diff --git a/includes/logging/MergeLogFormatter.php b/includes/logging/MergeLogFormatter.php index 36e383b069..b0edd4c07f 100644 --- a/includes/logging/MergeLogFormatter.php +++ b/includes/logging/MergeLogFormatter.php @@ -31,12 +31,12 @@ class MergeLogFormatter extends LogFormatter { public function getPreloadTitles() { $params = $this->extractParameters(); - return array( Title::newFromText( $params[3] ) ); + return [ Title::newFromText( $params[3] ) ]; } protected function getMessageParameters() { $params = parent::getMessageParameters(); - $oldname = $this->makePageLink( $this->entry->getTarget(), array( 'redirect' => 'no' ) ); + $oldname = $this->makePageLink( $this->entry->getTarget(), [ 'redirect' => 'no' ] ); $newname = $this->makePageLink( Title::newFromText( $params[3] ) ); $params[2] = Message::rawParam( $oldname ); $params[3] = Message::rawParam( $newname ); @@ -57,13 +57,13 @@ class MergeLogFormatter extends LogFormatter { $revert = Linker::linkKnown( SpecialPage::getTitleFor( 'MergeHistory' ), $this->msg( 'revertmerge' )->escaped(), - array(), - array( + [], + [ 'target' => $params[3], 'dest' => $this->entry->getTarget()->getPrefixedDBkey(), 'mergepoint' => $params[4], 'submitted' => 1 // show the revisions immediately - ) + ] ); return $this->msg( 'parentheses' )->rawParams( $revert )->escaped(); @@ -73,12 +73,12 @@ class MergeLogFormatter extends LogFormatter { $entry = $this->entry; $params = $entry->getParameters(); - static $map = array( + static $map = [ '4:title:dest', '5:timestamp:mergepoint', '4::dest' => '4:title:dest', '5::mergepoint' => '5:timestamp:mergepoint', - ); + ]; foreach ( $map as $index => $key ) { if ( isset( $params[$index] ) ) { $params[$key] = $params[$index]; diff --git a/includes/logging/MoveLogFormatter.php b/includes/logging/MoveLogFormatter.php index 7f5e9efab7..afbf8e95e6 100644 --- a/includes/logging/MoveLogFormatter.php +++ b/includes/logging/MoveLogFormatter.php @@ -32,7 +32,7 @@ class MoveLogFormatter extends LogFormatter { public function getPreloadTitles() { $params = $this->extractParameters(); - return array( Title::newFromText( $params[3] ) ); + return [ Title::newFromText( $params[3] ) ]; } protected function getMessageKey() { @@ -48,7 +48,7 @@ class MoveLogFormatter extends LogFormatter { protected function getMessageParameters() { $params = parent::getMessageParameters(); - $oldname = $this->makePageLink( $this->entry->getTarget(), array( 'redirect' => 'no' ) ); + $oldname = $this->makePageLink( $this->entry->getTarget(), [ 'redirect' => 'no' ] ); $newname = $this->makePageLink( Title::newFromText( $params[3] ) ); $params[2] = Message::rawParam( $oldname ); $params[3] = Message::rawParam( $newname ); @@ -74,13 +74,13 @@ class MoveLogFormatter extends LogFormatter { $revert = Linker::linkKnown( SpecialPage::getTitleFor( 'Movepage' ), $this->msg( 'revertmove' )->escaped(), - array(), - array( + [], + [ 'wpOldTitle' => $destTitle->getPrefixedDBkey(), 'wpNewTitle' => $this->entry->getTarget()->getPrefixedDBkey(), 'wpReason' => $this->msg( 'revertmove' )->inContentLanguage()->text(), 'wpMovetalk' => 0 - ) + ] ); return $this->msg( 'parentheses' )->rawParams( $revert )->escaped(); @@ -90,12 +90,12 @@ class MoveLogFormatter extends LogFormatter { $entry = $this->entry; $params = $entry->getParameters(); - static $map = array( + static $map = [ '4:title:target', '5:bool:suppressredirect', '4::target' => '4:title:target', '5::noredir' => '5:bool:suppressredirect', - ); + ]; foreach ( $map as $index => $key ) { if ( isset( $params[$index] ) ) { $params[$key] = $params[$index]; diff --git a/includes/logging/NewUsersLogFormatter.php b/includes/logging/NewUsersLogFormatter.php index b7068a08a0..382e4adb5c 100644 --- a/includes/logging/NewUsersLogFormatter.php +++ b/includes/logging/NewUsersLogFormatter.php @@ -60,9 +60,9 @@ class NewUsersLogFormatter extends LogFormatter { $subtype = $this->entry->getSubtype(); if ( $subtype === 'create2' || $subtype === 'byemail' ) { // add the user talk to LinkBatch for the userLink - return array( Title::makeTitle( NS_USER_TALK, $this->entry->getTarget()->getText() ) ); + return [ Title::makeTitle( NS_USER_TALK, $this->entry->getTarget()->getText() ) ]; } - return array(); + return []; } } diff --git a/includes/logging/PatrolLog.php b/includes/logging/PatrolLog.php index 4f2a565de3..510c71150d 100644 --- a/includes/logging/PatrolLog.php +++ b/includes/logging/PatrolLog.php @@ -76,10 +76,10 @@ class PatrolLog { * @return array */ private static function buildParams( $change, $auto ) { - return array( + return [ '4::curid' => $change->getAttribute( 'rc_this_oldid' ), '5::previd' => $change->getAttribute( 'rc_last_oldid' ), '6::auto' => (int)$auto - ); + ]; } } diff --git a/includes/logging/PatrolLogFormatter.php b/includes/logging/PatrolLogFormatter.php index 7fe0143ffb..0d007b3308 100644 --- a/includes/logging/PatrolLogFormatter.php +++ b/includes/logging/PatrolLogFormatter.php @@ -49,11 +49,11 @@ class PatrolLogFormatter extends LogFormatter { if ( $this->plaintext ) { $revlink = $revision; } elseif ( $target->exists() ) { - $query = array( + $query = [ 'oldid' => $oldid, 'diff' => 'prev' - ); - $revlink = Linker::link( $target, htmlspecialchars( $revision ), array(), $query ); + ]; + $revlink = Linker::link( $target, htmlspecialchars( $revision ), [], $query ); } else { $revlink = htmlspecialchars( $revision ); } @@ -67,14 +67,14 @@ class PatrolLogFormatter extends LogFormatter { $entry = $this->entry; $params = $entry->getParameters(); - static $map = array( + static $map = [ '4:number:curid', '5:number:previd', '6:bool:auto', '4::curid' => '4:number:curid', '5::previd' => '5:number:previd', '6::auto' => '6:bool:auto', - ); + ]; foreach ( $map as $index => $key ) { if ( isset( $params[$index] ) ) { $params[$key] = $params[$index]; diff --git a/includes/logging/ProtectLogFormatter.php b/includes/logging/ProtectLogFormatter.php index bd04f15e60..0458297190 100644 --- a/includes/logging/ProtectLogFormatter.php +++ b/includes/logging/ProtectLogFormatter.php @@ -32,9 +32,9 @@ class ProtectLogFormatter extends LogFormatter { $subtype = $this->entry->getSubtype(); if ( $subtype === 'move_prot' ) { $params = $this->extractParameters(); - return array( Title::newFromText( $params[3] ) ); + return [ Title::newFromText( $params[3] ) ]; } - return array(); + return []; } protected function getMessageKey() { @@ -69,7 +69,7 @@ class ProtectLogFormatter extends LogFormatter { unset( $params[4] ); } } elseif ( $subtype === 'move_prot' ) { - $oldname = $this->makePageLink( Title::newFromText( $params[3] ), array( 'redirect' => 'no' ) ); + $oldname = $this->makePageLink( Title::newFromText( $params[3] ), [ 'redirect' => 'no' ] ); $params[3] = Message::rawParam( $oldname ); } @@ -86,24 +86,24 @@ class ProtectLogFormatter extends LogFormatter { // Show history link for all changes after the protection $title = $this->entry->getTarget(); - $links = array( + $links = [ Linker::link( $title, $this->msg( 'hist' )->escaped(), - array(), - array( + [], + [ 'action' => 'history', 'offset' => $this->entry->getTimestamp(), - ) + ] ) - ); + ]; // Show change protection link if ( $this->context->getUser()->isAllowed( 'protect' ) ) { $links[] = Linker::linkKnown( $title, $this->msg( 'protect_change' )->escaped(), - array(), - array( 'action' => 'protect' ) + [], + [ 'action' => 'protect' ] ); } @@ -116,18 +116,18 @@ class ProtectLogFormatter extends LogFormatter { $subtype = $this->entry->getSubtype(); $params = $entry->getParameters(); - $map = array(); + $map = []; if ( $subtype === 'protect' || $subtype === 'modify' ) { - $map = array( + $map = [ '4::description', '5:bool:cascade', 'details' => ':array:details', - ); + ]; } elseif ( $subtype === 'move_prot' ) { - $map = array( + $map = [ '4:title:oldtitle', '4::oldtitle' => '4:title:oldtitle', - ); + ]; } foreach ( $map as $index => $key ) { if ( isset( $params[$index] ) ) { diff --git a/includes/logging/RightsLogFormatter.php b/includes/logging/RightsLogFormatter.php index 79ffe867a4..eebccddbcd 100644 --- a/includes/logging/RightsLogFormatter.php +++ b/includes/logging/RightsLogFormatter.php @@ -29,7 +29,7 @@ * @since 1.21 */ class RightsLogFormatter extends LogFormatter { - protected function makePageLink( Title $title = null, $parameters = array(), $html = null ) { + protected function makePageLink( Title $title = null, $parameters = [], $html = null ) { global $wgContLang, $wgUserrightsInterwikiDelimiter; if ( !$this->plaintext ) { @@ -103,12 +103,12 @@ class RightsLogFormatter extends LogFormatter { $entry = $this->entry; $params = $entry->getParameters(); - static $map = array( + static $map = [ '4:array:oldgroups', '5:array:newgroups', '4::oldgroups' => '4:array:oldgroups', '5::newgroups' => '5:array:newgroups', - ); + ]; foreach ( $map as $index => $key ) { if ( isset( $params[$index] ) ) { $params[$key] = $params[$index]; @@ -141,7 +141,7 @@ class RightsLogFormatter extends LogFormatter { private function makeGroupArray( $group ) { // Migrate old group params from string to array if ( $group === '' ) { - $group = array(); + $group = []; } elseif ( is_string( $group ) ) { $group = array_map( 'trim', explode( ',', $group ) ); } diff --git a/includes/logging/UploadLogFormatter.php b/includes/logging/UploadLogFormatter.php index 52961dc4aa..6c5367172f 100644 --- a/includes/logging/UploadLogFormatter.php +++ b/includes/logging/UploadLogFormatter.php @@ -33,9 +33,9 @@ class UploadLogFormatter extends LogFormatter { $entry = $this->entry; $params = $entry->getParameters(); - static $map = array( + static $map = [ 'img_timestamp' => ':timestamp:img_timestamp', - ); + ]; foreach ( $map as $index => $key ) { if ( isset( $params[$index] ) ) { $params[$key] = $params[$index]; diff --git a/includes/mail/EmailNotification.php b/includes/mail/EmailNotification.php index 9bda12cb4d..30907e636c 100644 --- a/includes/mail/EmailNotification.php +++ b/includes/mail/EmailNotification.php @@ -59,7 +59,7 @@ class EmailNotification { protected $subject, $body, $replyto, $from; protected $timestamp, $summary, $minorEdit, $oldid, $composed_common, $pageStatus; - protected $mailTargets = array(); + protected $mailTargets = []; /** * @var Title @@ -86,21 +86,21 @@ class EmailNotification { global $wgEnotifWatchlist, $wgShowUpdatedMarker; if ( !$wgEnotifWatchlist && !$wgShowUpdatedMarker ) { - return array(); + return []; } $dbw = wfGetDB( DB_MASTER ); - $res = $dbw->select( array( 'watchlist' ), - array( 'wl_user' ), - array( + $res = $dbw->select( [ 'watchlist' ], + [ 'wl_user' ], + [ 'wl_user != ' . intval( $editor->getID() ), 'wl_namespace' => $linkTarget->getNamespace(), 'wl_title' => $linkTarget->getDBkey(), 'wl_notificationtimestamp IS NULL', - ), __METHOD__ + ], __METHOD__ ); - $watchers = array(); + $watchers = []; foreach ( $res as $row ) { $watchers[] = intval( $row->wl_user ); } @@ -111,13 +111,13 @@ class EmailNotification { $dbw->onTransactionIdle( function () use ( $dbw, $timestamp, $watchers, $linkTarget, $fname ) { $dbw->update( 'watchlist', - array( /* SET */ + [ /* SET */ 'wl_notificationtimestamp' => $dbw->timestamp( $timestamp ) - ), array( /* WHERE */ + ], [ /* WHERE */ 'wl_user' => $watchers, 'wl_namespace' => $linkTarget->getNamespace(), 'wl_title' => $linkTarget->getDBkey(), - ), $fname + ], $fname ); } ); @@ -173,7 +173,7 @@ class EmailNotification { if ( $sendEmail ) { JobQueueGroup::singleton()->lazyPush( new EnotifNotifyJob( $title, - array( + [ 'editor' => $editor->getName(), 'editorID' => $editor->getID(), 'timestamp' => $timestamp, @@ -182,7 +182,7 @@ class EmailNotification { 'oldid' => $oldid, 'watchers' => $watchers, 'pageStatus' => $pageStatus - ) + ] ) ); } } @@ -225,9 +225,9 @@ class EmailNotification { $this->composed_common = false; $this->pageStatus = $pageStatus; - $formattedPageStatus = array( 'deleted', 'created', 'moved', 'restored', 'changed' ); + $formattedPageStatus = [ 'deleted', 'created', 'moved', 'restored', 'changed' ]; - Hooks::run( 'UpdateUserMailerFormattedPageStatus', array( &$formattedPageStatus ) ); + Hooks::run( 'UpdateUserMailerFormattedPageStatus', [ &$formattedPageStatus ] ); if ( !in_array( $this->pageStatus, $formattedPageStatus ) ) { throw new MWException( 'Not a valid page status!' ); } @@ -256,7 +256,7 @@ class EmailNotification { && !in_array( $watchingUser->getName(), $wgUsersNotifiedOnAllChanges ) && !( $wgBlockDisablesLogin && $watchingUser->isBlocked() ) ) { - if ( Hooks::run( 'SendWatchlistEmailNotification', array( $watchingUser, $title, $this ) ) ) { + if ( Hooks::run( 'SendWatchlistEmailNotification', [ $watchingUser, $title, $this ] ) ) { $this->compose( $watchingUser, self::WATCHLIST ); } } @@ -300,7 +300,7 @@ class EmailNotification { ) { if ( !$targetUser->isEmailConfirmed() ) { wfDebug( __METHOD__ . ": talk page owner doesn't have validated email\n" ); - } elseif ( !Hooks::run( 'AbortTalkPageEmailNotification', array( $targetUser, $title ) ) ) { + } elseif ( !Hooks::run( 'AbortTalkPageEmailNotification', [ $targetUser, $title ] ) ) { wfDebug( __METHOD__ . ": talk page update notification is aborted for this user\n" ); } else { wfDebug( __METHOD__ . ": sending talk page update notification\n" ); @@ -327,22 +327,22 @@ class EmailNotification { # named variables when composing your notification emails while # simply editing the Meta pages - $keys = array(); - $postTransformKeys = array(); + $keys = []; + $postTransformKeys = []; $pageTitleUrl = $this->title->getCanonicalURL(); $pageTitle = $this->title->getPrefixedText(); if ( $this->oldid ) { // Always show a link to the diff which triggered the mail. See bug 32210. $keys['$NEWPAGE'] = "\n\n" . wfMessage( 'enotif_lastdiff', - $this->title->getCanonicalURL( array( 'diff' => 'next', 'oldid' => $this->oldid ) ) ) + $this->title->getCanonicalURL( [ 'diff' => 'next', 'oldid' => $this->oldid ] ) ) ->inContentLanguage()->text(); if ( !$wgEnotifImpersonal ) { // For personal mail, also show a link to the diff of all changes // since last visited. $keys['$NEWPAGE'] .= "\n\n" . wfMessage( 'enotif_lastvisited', - $this->title->getCanonicalURL( array( 'diff' => '0', 'oldid' => $this->oldid ) ) ) + $this->title->getCanonicalURL( [ 'diff' => '0', 'oldid' => $this->oldid ] ) ) ->inContentLanguage()->text(); } $keys['$OLDID'] = $this->oldid; @@ -479,24 +479,24 @@ class EmailNotification { # expressed in terms of individual local time of the notification # recipient, i.e. watching user $body = str_replace( - array( '$WATCHINGUSERNAME', + [ '$WATCHINGUSERNAME', '$PAGEEDITDATE', - '$PAGEEDITTIME' ), - array( $wgEnotifUseRealName && $watchingUser->getRealName() !== '' + '$PAGEEDITTIME' ], + [ $wgEnotifUseRealName && $watchingUser->getRealName() !== '' ? $watchingUser->getRealName() : $watchingUser->getName(), $wgContLang->userDate( $this->timestamp, $watchingUser ), - $wgContLang->userTime( $this->timestamp, $watchingUser ) ), + $wgContLang->userTime( $this->timestamp, $watchingUser ) ], $this->body ); - $headers = array(); + $headers = []; if ( $source === self::WATCHLIST ) { $headers['List-Help'] = 'https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Watchlist'; } - return UserMailer::send( $to, $this->from, $this->subject, $body, array( + return UserMailer::send( $to, $this->from, $this->subject, $body, [ 'replyTo' => $this->replyto, 'headers' => $headers, - ) ); + ] ); } /** @@ -513,17 +513,17 @@ class EmailNotification { } $body = str_replace( - array( '$WATCHINGUSERNAME', + [ '$WATCHINGUSERNAME', '$PAGEEDITDATE', - '$PAGEEDITTIME' ), - array( wfMessage( 'enotif_impersonal_salutation' )->inContentLanguage()->text(), + '$PAGEEDITTIME' ], + [ wfMessage( 'enotif_impersonal_salutation' )->inContentLanguage()->text(), $wgContLang->date( $this->timestamp, false, false ), - $wgContLang->time( $this->timestamp, false, false ) ), + $wgContLang->time( $this->timestamp, false, false ) ], $this->body ); - return UserMailer::send( $addresses, $this->from, $this->subject, $body, array( + return UserMailer::send( $addresses, $this->from, $this->subject, $body, [ 'replyTo' => $this->replyto, - ) ); + ] ); } } diff --git a/includes/mail/UserMailer.php b/includes/mail/UserMailer.php index b5a09bde82..983f42c636 100644 --- a/includes/mail/UserMailer.php +++ b/includes/mail/UserMailer.php @@ -65,7 +65,7 @@ class UserMailer { * @return string */ static function arrayToHeaderString( $headers, $endl = PHP_EOL ) { - $strings = array(); + $strings = []; foreach ( $headers as $name => $value ) { // Prevent header injection by stripping newlines from value $value = self::sanitizeHeaderValue( $value ); @@ -114,20 +114,20 @@ class UserMailer { * @throws Exception * @return Status */ - public static function send( $to, $from, $subject, $body, $options = array() ) { + public static function send( $to, $from, $subject, $body, $options = [] ) { global $wgAllowHTMLEmail; $contentType = 'text/plain; charset=UTF-8'; if ( !is_array( $options ) ) { // Old calling style wfDeprecated( __METHOD__ . ' with $replyto as 5th parameter', '1.26' ); - $options = array( 'replyTo' => $options ); + $options = [ 'replyTo' => $options ]; if ( func_num_args() === 6 ) { $options['contentType'] = func_get_arg( 5 ); } } if ( !is_array( $to ) ) { - $to = array( $to ); + $to = [ $to ]; } // mail body must have some content @@ -176,7 +176,7 @@ class UserMailer { // target differently to split up the address list if ( count( $to ) > 1 ) { $oldTo = $to; - Hooks::run( 'UserMailerSplitTo', array( &$to ) ); + Hooks::run( 'UserMailerSplitTo', [ &$to ] ); if ( $oldTo != $to ) { $splitTo = array_diff( $oldTo, $to ); $to = array_diff( $oldTo, $splitTo ); // ignore new addresses added in the hook @@ -188,7 +188,7 @@ class UserMailer { } foreach ( $splitTo as $newTo ) { $status->merge( UserMailer::sendInternal( - array( $newTo ), $from, $subject, $body, $options ) ); + [ $newTo ], $from, $subject, $body, $options ) ); } return $status; } @@ -218,7 +218,7 @@ class UserMailer { MailAddress $from, $subject, $body, - $options = array() + $options = [] ) { global $wgSMTP, $wgEnotifMaxRecips, $wgAdditionalMailParams; $mime = null; @@ -226,11 +226,11 @@ class UserMailer { $replyto = isset( $options['replyTo'] ) ? $options['replyTo'] : null; $contentType = isset( $options['contentType'] ) ? $options['contentType'] : 'text/plain; charset=UTF-8'; - $headers = isset( $options['headers'] ) ? $options['headers'] : array(); + $headers = isset( $options['headers'] ) ? $options['headers'] : []; // Allow transformation of content, such as encrypting/signing $error = false; - if ( !Hooks::run( 'UserMailerTransformContent', array( $to, $from, &$body, &$error ) ) ) { + if ( !Hooks::run( 'UserMailerTransformContent', [ $to, $from, &$body, &$error ] ) ) { if ( $error ) { return Status::newFatal( 'php-mail-error', $error ); } else { @@ -272,7 +272,7 @@ class UserMailer { $extraParams = $wgAdditionalMailParams; // Hook to generate custom VERP address for 'Return-Path' - Hooks::run( 'UserMailerChangeReturnPath', array( $to, &$returnPath ) ); + Hooks::run( 'UserMailerChangeReturnPath', [ $to, &$returnPath ] ); // Add the envelope sender address using the -f command line option when PHP mail() is used. // Will default to the $from->address when the UserMailerChangeReturnPath hook fails and the // generated VERP address when the hook runs effectively. @@ -310,11 +310,11 @@ class UserMailer { $body['text'] = str_replace( "\n", "\r\n", $body['text'] ); $body['html'] = str_replace( "\n", "\r\n", $body['html'] ); } - $mime = new Mail_mime( array( + $mime = new Mail_mime( [ 'eol' => $endl, 'text_charset' => 'UTF-8', 'html_charset' => 'UTF-8' - ) ); + ] ); $mime->setTXTBody( $body['text'] ); $mime->setHTMLBody( $body['html'] ); $body = $mime->get(); // must call get() before headers() @@ -334,7 +334,7 @@ class UserMailer { // allow transformation of MIME-encoded message if ( !Hooks::run( 'UserMailerTransformMessage', - array( $to, $from, &$subject, &$headers, &$body, &$error ) ) + [ $to, $from, &$subject, &$headers, &$body, &$error ] ) ) { if ( $error ) { return Status::newFatal( 'php-mail-error', $error ); @@ -343,7 +343,7 @@ class UserMailer { } } - $ret = Hooks::run( 'AlternateUserMailer', array( $headers, $to, $from, $subject, $body ) ); + $ret = Hooks::run( 'AlternateUserMailer', [ $headers, $to, $from, $subject, $body ] ); if ( $ret === false ) { // the hook implementation will return false to skip regular mail sending return Status::newGood(); @@ -455,7 +455,7 @@ class UserMailer { * @return string */ public static function sanitizeHeaderValue( $val ) { - return strtr( $val, array( "\r" => '', "\n" => '' ) ); + return strtr( $val, [ "\r" => '', "\n" => '' ] ); } /** @@ -499,7 +499,7 @@ class UserMailer { } $out = "=?$charset?Q?"; $out .= preg_replace_callback( "/([$replace])/", - array( __CLASS__, 'quotedPrintableCallback' ), $string ); + [ __CLASS__, 'quotedPrintableCallback' ], $string ); $out .= '?='; return $out; } diff --git a/includes/media/BMP.php b/includes/media/BMP.php index 52f9518f79..64f12f71e4 100644 --- a/includes/media/BMP.php +++ b/includes/media/BMP.php @@ -45,7 +45,7 @@ class BmpHandler extends BitmapHandler { * @return array */ function getThumbType( $text, $mime, $params = null ) { - return array( 'png', 'image/png' ); + return [ 'png', 'image/png' ]; } /** @@ -75,6 +75,6 @@ class BmpHandler extends BitmapHandler { return false; } - return array( $w[1], $h[1] ); + return [ $w[1], $h[1] ]; } } diff --git a/includes/media/Bitmap.php b/includes/media/Bitmap.php index c2b82d8605..b470e064c8 100644 --- a/includes/media/Bitmap.php +++ b/includes/media/Bitmap.php @@ -117,37 +117,37 @@ class BitmapHandler extends TransformationalImageHandler { global $wgSharpenReductionThreshold, $wgSharpenParameter, $wgMaxAnimatedGifArea, $wgImageMagickTempDir, $wgImageMagickConvertCommand, $wgMaxInterlacingAreas; - $quality = array(); - $sharpen = array(); + $quality = []; + $sharpen = []; $scene = false; - $animation_pre = array(); - $animation_post = array(); - $decoderHint = array(); + $animation_pre = []; + $animation_post = []; + $decoderHint = []; if ( $params['mimeType'] == 'image/jpeg' ) { $qualityVal = isset( $params['quality'] ) ? (string)$params['quality'] : null; - $quality = array( '-quality', $qualityVal ?: '80' ); // 80% + $quality = [ '-quality', $qualityVal ?: '80' ]; // 80% if ( $params['interlace'] ) { - $animation_post = array( '-interlace', 'JPEG' ); + $animation_post = [ '-interlace', 'JPEG' ]; } # Sharpening, see bug 6193 if ( ( $params['physicalWidth'] + $params['physicalHeight'] ) / ( $params['srcWidth'] + $params['srcHeight'] ) < $wgSharpenReductionThreshold ) { - $sharpen = array( '-sharpen', $wgSharpenParameter ); + $sharpen = [ '-sharpen', $wgSharpenParameter ]; } if ( version_compare( $this->getMagickVersion(), "6.5.6" ) >= 0 ) { // JPEG decoder hint to reduce memory, available since IM 6.5.6-2 - $decoderHint = array( '-define', "jpeg:size={$params['physicalDimensions']}" ); + $decoderHint = [ '-define', "jpeg:size={$params['physicalDimensions']}" ]; } } elseif ( $params['mimeType'] == 'image/png' ) { - $quality = array( '-quality', '95' ); // zlib 9, adaptive filtering + $quality = [ '-quality', '95' ]; // zlib 9, adaptive filtering if ( $params['interlace'] ) { - $animation_post = array( '-interlace', 'PNG' ); + $animation_post = [ '-interlace', 'PNG' ]; } } elseif ( $params['mimeType'] == 'image/webp' ) { - $quality = array( '-quality', '95' ); // zlib 9, adaptive filtering + $quality = [ '-quality', '95' ]; // zlib 9, adaptive filtering } elseif ( $params['mimeType'] == 'image/gif' ) { if ( $this->getImageArea( $image ) > $wgMaxAnimatedGifArea ) { // Extract initial frame only; we're so big it'll @@ -155,11 +155,11 @@ class BitmapHandler extends TransformationalImageHandler { $scene = 0; } elseif ( $this->isAnimatedImage( $image ) ) { // Coalesce is needed to scale animated GIFs properly (bug 1017). - $animation_pre = array( '-coalesce' ); + $animation_pre = [ '-coalesce' ]; // We optimize the output, but -optimize is broken, // use optimizeTransparency instead (bug 11822) if ( version_compare( $this->getMagickVersion(), "6.3.5" ) >= 0 ) { - $animation_post = array( '-fuzz', '5%', '-layers', 'optimizeTransparency' ); + $animation_post = [ '-fuzz', '5%', '-layers', 'optimizeTransparency' ]; } } if ( $params['interlace'] && version_compare( $this->getMagickVersion(), "6.3.4" ) >= 0 @@ -174,11 +174,11 @@ class BitmapHandler extends TransformationalImageHandler { // background colour. After merging we reset the background // to be white for the default background colour setting // in the PNG image (which is used in old IE) - $animation_pre = array( + $animation_pre = [ '-background', 'transparent', '-layers', 'merge', '-background', 'white', - ); + ]; MediaWiki\suppressWarnings(); $xcfMeta = unserialize( $image->getMetadata() ); MediaWiki\restoreWarnings(); @@ -189,13 +189,13 @@ class BitmapHandler extends TransformationalImageHandler { ) { // bug 66323 - Greyscale images not rendered properly. // So only take the "red" channel. - $channelOnly = array( '-channel', 'R', '-separate' ); + $channelOnly = [ '-channel', 'R', '-separate' ]; $animation_pre = array_merge( $animation_pre, $channelOnly ); } } // Use one thread only, to avoid deadlock bugs on OOM - $env = array( 'OMP_NUM_THREADS' => 1 ); + $env = [ 'OMP_NUM_THREADS' => 1 ]; if ( strval( $wgImageMagickTempDir ) !== '' ) { $env['MAGICK_TMPDIR'] = $wgImageMagickTempDir; } @@ -204,29 +204,29 @@ class BitmapHandler extends TransformationalImageHandler { list( $width, $height ) = $this->extractPreRotationDimensions( $params, $rotation ); $cmd = call_user_func_array( 'wfEscapeShellArg', array_merge( - array( $wgImageMagickConvertCommand ), + [ $wgImageMagickConvertCommand ], $quality, // Specify white background color, will be used for transparent images // in Internet Explorer/Windows instead of default black. - array( '-background', 'white' ), + [ '-background', 'white' ], $decoderHint, - array( $this->escapeMagickInput( $params['srcPath'], $scene ) ), + [ $this->escapeMagickInput( $params['srcPath'], $scene ) ], $animation_pre, // For the -thumbnail option a "!" is needed to force exact size, // or ImageMagick may decide your ratio is wrong and slice off // a pixel. - array( '-thumbnail', "{$width}x{$height}!" ), + [ '-thumbnail', "{$width}x{$height}!" ], // Add the source url as a comment to the thumb, but don't add the flag if there's no comment ( $params['comment'] !== '' - ? array( '-set', 'comment', $this->escapeMagickProperty( $params['comment'] ) ) - : array() ), + ? [ '-set', 'comment', $this->escapeMagickProperty( $params['comment'] ) ] + : [] ), // T108616: Avoid exposure of local file path - array( '+set', 'Thumb::URI' ), - array( '-depth', 8 ), + [ '+set', 'Thumb::URI' ], + [ '-depth', 8 ], $sharpen, - array( '-rotate', "-$rotation" ), + [ '-rotate', "-$rotation" ], $animation_post, - array( $this->escapeMagickOutput( $params['dstPath'] ) ) ) ); + [ $this->escapeMagickOutput( $params['dstPath'] ) ] ) ); wfDebug( __METHOD__ . ": running ImageMagick: $cmd\n" ); $retval = 0; @@ -377,14 +377,14 @@ class BitmapHandler extends TransformationalImageHandler { # First find out what kind of file this is, and select the correct # input routine for this. - $typemap = array( - 'image/gif' => array( 'imagecreatefromgif', 'palette', false, 'imagegif' ), - 'image/jpeg' => array( 'imagecreatefromjpeg', 'truecolor', true, - array( __CLASS__, 'imageJpegWrapper' ) ), - 'image/png' => array( 'imagecreatefrompng', 'bits', false, 'imagepng' ), - 'image/vnd.wap.wbmp' => array( 'imagecreatefromwbmp', 'palette', false, 'imagewbmp' ), - 'image/xbm' => array( 'imagecreatefromxbm', 'palette', false, 'imagexbm' ), - ); + $typemap = [ + 'image/gif' => [ 'imagecreatefromgif', 'palette', false, 'imagegif' ], + 'image/jpeg' => [ 'imagecreatefromjpeg', 'truecolor', true, + [ __CLASS__, 'imageJpegWrapper' ] ], + 'image/png' => [ 'imagecreatefrompng', 'bits', false, 'imagepng' ], + 'image/vnd.wap.wbmp' => [ 'imagecreatefromwbmp', 'palette', false, 'imagewbmp' ], + 'image/xbm' => [ 'imagecreatefromxbm', 'palette', false, 'imagexbm' ], + ]; if ( !isset( $typemap[$params['mimeType']] ) ) { $err = 'Image type not supported'; @@ -447,7 +447,7 @@ class BitmapHandler extends TransformationalImageHandler { imagesavealpha( $dst_image, true ); - $funcParams = array( $dst_image, $params['dstPath'] ); + $funcParams = [ $dst_image, $params['dstPath'] ]; if ( $useQuality && isset( $params['quality'] ) ) { $funcParams[] = $params['quality']; } diff --git a/includes/media/BitmapMetadataHandler.php b/includes/media/BitmapMetadataHandler.php index a5cddac9d8..7999bbbf86 100644 --- a/includes/media/BitmapMetadataHandler.php +++ b/includes/media/BitmapMetadataHandler.php @@ -35,19 +35,19 @@ use MediaWiki\Logger\LoggerFactory; */ class BitmapMetadataHandler { /** @var array */ - private $metadata = array(); + private $metadata = []; /** @var array Metadata priority */ - private $metaPriority = array( - 20 => array( 'other' ), - 40 => array( 'native' ), - 60 => array( 'iptc-good-hash', 'iptc-no-hash' ), - 70 => array( 'xmp-deprecated' ), - 80 => array( 'xmp-general' ), - 90 => array( 'xmp-exif' ), - 100 => array( 'iptc-bad-hash' ), - 120 => array( 'exif' ), - ); + private $metaPriority = [ + 20 => [ 'other' ], + 40 => [ 'native' ], + 60 => [ 'iptc-good-hash', 'iptc-no-hash' ], + 70 => [ 'xmp-deprecated' ], + 80 => [ 'xmp-general' ], + 90 => [ 'xmp-exif' ], + 100 => [ 'iptc-bad-hash' ], + 120 => [ 'exif' ], + ]; /** @var string */ private $iptcType = 'iptc-no-hash'; @@ -123,7 +123,7 @@ class BitmapMetadataHandler { function getMetadataArray() { // this seems a bit ugly... This is all so its merged in right order // based on the MWG recomendation. - $temp = array(); + $temp = []; krsort( $this->metaPriority ); foreach ( $this->metaPriority as $pri ) { foreach ( $pri as $type ) { @@ -161,7 +161,7 @@ class BitmapMetadataHandler { $seg = JpegMetadataExtractor::segmentSplitter( $filename ); if ( isset( $seg['COM'] ) && isset( $seg['COM'][0] ) ) { - $meta->addMetadata( array( 'JPEGFileComment' => $seg['COM'] ), 'native' ); + $meta->addMetadata( [ 'JPEGFileComment' => $seg['COM'] ], 'native' ); } if ( isset( $seg['PSIR'] ) && count( $seg['PSIR'] ) > 0 ) { foreach ( $seg['PSIR'] as $curPSIRValue ) { @@ -235,7 +235,7 @@ class BitmapMetadataHandler { $baseArray = GIFMetadataExtractor::getMetadata( $filename ); if ( count( $baseArray['comment'] ) > 0 ) { - $meta->addMetadata( array( 'GIFFileComment' => $baseArray['comment'] ), 'native' ); + $meta->addMetadata( [ 'GIFFileComment' => $baseArray['comment'] ], 'native' ); } if ( $baseArray['xmp'] !== '' && XMPReader::isSupported() ) { diff --git a/includes/media/DjVu.php b/includes/media/DjVu.php index 5cc05f2705..0d2ed29b00 100644 --- a/includes/media/DjVu.php +++ b/includes/media/DjVu.php @@ -72,10 +72,10 @@ class DjVuHandler extends ImageHandler { * @return array */ function getParamMap() { - return array( + return [ 'img_width' => 'width', 'img_page' => 'page', - ); + ]; } /** @@ -89,7 +89,7 @@ class DjVuHandler extends ImageHandler { // e.g. [[File:Foo.djvu|thumb|Page 3 of the document shows foo]] return false; } - if ( in_array( $name, array( 'width', 'height', 'page' ) ) ) { + if ( in_array( $name, [ 'width', 'height', 'page' ] ) ) { if ( $value <= 0 ) { return false; } else { @@ -120,7 +120,7 @@ class DjVuHandler extends ImageHandler { function parseParamString( $str ) { $m = false; if ( preg_match( '/^page(\d+)-(\d+)px$/', $str, $m ) ) { - return array( 'width' => $m[2], 'page' => $m[1] ); + return [ 'width' => $m[2], 'page' => $m[1] ]; } else { return false; } @@ -131,10 +131,10 @@ class DjVuHandler extends ImageHandler { * @return array */ function getScriptParams( $params ) { - return array( + return [ 'width' => $params['width'], 'page' => $params['page'], - ); + ]; } /** @@ -156,11 +156,11 @@ class DjVuHandler extends ImageHandler { $page = $params['page']; if ( $flags & self::TRANSFORM_LATER ) { - $params = array( + $params = [ 'width' => $width, 'height' => $height, 'page' => $page - ); + ]; return new ThumbnailImage( $image, $dstUrl, $dstPath, $params ); } @@ -179,11 +179,11 @@ class DjVuHandler extends ImageHandler { // Provide a way to pool count limit the number of downloaders. if ( $image->getSize() >= 1e7 ) { // 10MB $work = new PoolCounterWorkViaCallback( 'GetLocalFileCopy', sha1( $image->getName() ), - array( + [ 'doWork' => function () use ( $image ) { return $image->getLocalRefPath(); } - ) + ] ); $srcPath = $work->execute(); } else { @@ -222,11 +222,11 @@ class DjVuHandler extends ImageHandler { $this->logErrorForExternalProcess( $retval, $err, $cmd ); return new MediaTransformError( 'thumbnail_error', $width, $height, $err ); } else { - $params = array( + $params = [ 'width' => $width, 'height' => $height, 'page' => $page - ); + ]; return new ThumbnailImage( $image, $dstUrl, $dstPath, $params ); } @@ -352,7 +352,7 @@ class DjVuHandler extends ImageHandler { $mime = $magic->guessTypesForExtension( $wgDjvuOutputExtension ); } - return array( $wgDjvuOutputExtension, $mime ); + return [ $wgDjvuOutputExtension, $mime ]; } function getMetadata( $image, $path ) { @@ -361,9 +361,9 @@ class DjVuHandler extends ImageHandler { $xml = $this->getDjVuImage( $image, $path )->retrieveMetaData(); if ( $xml === false ) { // Special value so that we don't repetitively try and decode a broken file. - return serialize( array( 'error' => 'Error extracting metadata' ) ); + return serialize( [ 'error' => 'Error extracting metadata' ] ); } else { - return serialize( array( 'xml' => $xml ) ); + return serialize( [ 'xml' => $xml ] ); } } @@ -372,7 +372,7 @@ class DjVuHandler extends ImageHandler { } function isMetadataValid( $image, $metadata ) { - return !empty( $metadata ) && $metadata != serialize( array() ); + return !empty( $metadata ) && $metadata != serialize( [] ); } function pageCount( File $image ) { @@ -404,21 +404,21 @@ class DjVuHandler extends ImageHandler { return false; } - $dimsByPage = array(); + $dimsByPage = []; $count = count( $tree->xpath( '//OBJECT' ) ); for ( $i = 0; $i < $count; ++$i ) { $o = $tree->BODY[0]->OBJECT[$i]; if ( $o ) { - $dimsByPage[$i] = array( + $dimsByPage[$i] = [ 'width' => (int)$o['width'], 'height' => (int)$o['height'] - ); + ]; } else { $dimsByPage[$i] = false; } } - return array( 'pageCount' => $count, 'dimensionsByPage' => $dimsByPage ); + return [ 'pageCount' => $count, 'dimensionsByPage' => $dimsByPage ]; } ); } diff --git a/includes/media/DjVuImage.php b/includes/media/DjVuImage.php index 3b9b7c97b6..16740d840a 100644 --- a/includes/media/DjVuImage.php +++ b/includes/media/DjVuImage.php @@ -69,8 +69,8 @@ class DjVuImage { $width = $data['width']; $height = $data['height']; - return array( $width, $height, 'DjVu', - "width=\"$width\" height=\"$height\"" ); + return [ $width, $height, 'DjVu', + "width=\"$width\" height=\"$height\"" ]; } return false; @@ -166,7 +166,7 @@ class DjVuImage { private function readChunk( $file ) { $header = fread( $file, 8 ); if ( strlen( $header ) < 8 ) { - return array( false, 0 ); + return [ false, 0 ]; } else { // @todo FIXME: Would be good to replace this extract() call with // something that explicitly initializes local variables. @@ -174,7 +174,7 @@ class DjVuImage { /** @var string $chunk * @var string $length */ - return array( $chunk, $length ); + return [ $chunk, $length ]; } } @@ -255,12 +255,12 @@ class DjVuImage { * @var string $resolution * @var string $length * @var string $gamma */ - return array( + return [ 'width' => $width, 'height' => $height, 'version' => "$major.$minor", 'resolution' => $resolution, - 'gamma' => $gamma / 10.0 ); + 'gamma' => $gamma / 10.0 ]; } /** @@ -292,7 +292,7 @@ class DjVuImage { $cmd = wfEscapeShellArg( $wgDjvuTxt ) . ' --detail=page ' . wfEscapeShellArg( $this->mFilename ); wfDebug( __METHOD__ . ": $cmd\n" ); $retval = ''; - $txt = wfShellExec( $cmd, $retval, array(), array( 'memory' => self::DJVUTXT_MEMORY_LIMIT ) ); + $txt = wfShellExec( $cmd, $retval, [], [ 'memory' => self::DJVUTXT_MEMORY_LIMIT ] ); if ( $retval == 0 ) { # Strip some control characters $txt = preg_replace( "/[\013\035\037]/", "", $txt ); @@ -307,7 +307,7 @@ class DjVuImage { | # Or page can be empty ; in this case, djvutxt dumps () \(\s*()\)/sx EOR; - $txt = preg_replace_callback( $reg, array( $this, 'pageTextCallback' ), $txt ); + $txt = preg_replace_callback( $reg, [ $this, 'pageTextCallback' ], $txt ); $txt = "' . $link . '
'; } @@ -1890,7 +1890,7 @@ class Article implements Page { $outputPage->addWikiMsg( 'deletedtext', wfEscapeWikiText( $deleted ), $loglink ); - Hooks::run( 'ArticleDeleteAfterSuccess', array( $this->getTitle(), $outputPage ) ); + Hooks::run( 'ArticleDeleteAfterSuccess', [ $this->getTitle(), $outputPage ] ); $outputPage->returnToMain( false ); } else { @@ -1943,7 +1943,7 @@ class Article implements Page { return true; } else { wfDebug( "Article::tryFileCache(): starting buffer\n" ); - ob_start( array( &$cache, 'saveToFileCache' ) ); + ob_start( [ &$cache, 'saveToFileCache' ] ); } } else { wfDebug( "Article::tryFileCache(): not cacheable\n" ); @@ -1964,7 +1964,7 @@ class Article implements Page { && !$this->mRedirectedFrom && !$this->getTitle()->isRedirect(); // Extension may have reason to disable file caching on some pages. if ( $cacheable ) { - $cacheable = Hooks::run( 'IsFileCacheable', array( &$this ) ); + $cacheable = Hooks::run( 'IsFileCacheable', [ &$this ] ); } } @@ -2076,7 +2076,7 @@ class Article implements Page { # wfWarn( "Access to raw $fname field of " . __CLASS__ ); $this->mPage->$fname = $fvalue; // Note: extensions may want to toss on new fields - } elseif ( !in_array( $fname, array( 'mContext', 'mPage' ) ) ) { + } elseif ( !in_array( $fname, [ 'mContext', 'mPage' ] ) ) { $this->mPage->$fname = $fvalue; } else { trigger_error( 'Inaccessible property via __set(): ' . $fname, E_USER_NOTICE ); @@ -2152,7 +2152,7 @@ class Article implements Page { * Call to WikiPage function for backwards compatibility. * @see WikiPage::doEditUpdates */ - public function doEditUpdates( Revision $revision, User $user, array $options = array() ) { + public function doEditUpdates( Revision $revision, User $user, array $options = [] ) { return $this->mPage->doEditUpdates( $revision, $user, $options ); } @@ -2498,7 +2498,7 @@ class Article implements Page { * Call to WikiPage function for backwards compatibility. * @see WikiPage::pageDataFromId */ - public function pageDataFromId( $dbr, $id, $options = array() ) { + public function pageDataFromId( $dbr, $id, $options = [] ) { return $this->mPage->pageDataFromId( $dbr, $id, $options ); } @@ -2506,7 +2506,7 @@ class Article implements Page { * Call to WikiPage function for backwards compatibility. * @see WikiPage::pageDataFromTitle */ - public function pageDataFromTitle( $dbr, $title, $options = array() ) { + public function pageDataFromTitle( $dbr, $title, $options = [] ) { return $this->mPage->pageDataFromTitle( $dbr, $title, $options ); } @@ -2675,8 +2675,8 @@ class Article implements Page { * @param array $expiry * @return bool */ - public function updateRestrictions( $limit = array(), $reason = '', - &$cascade = 0, $expiry = array() + public function updateRestrictions( $limit = [], $reason = '', + &$cascade = 0, $expiry = [] ) { return $this->mPage->doUpdateRestrictions( $limit, diff --git a/includes/page/CategoryPage.php b/includes/page/CategoryPage.php index 50cb96ca0d..55fe1562da 100644 --- a/includes/page/CategoryPage.php +++ b/includes/page/CategoryPage.php @@ -66,7 +66,7 @@ class CategoryPage extends Article { return; } - if ( !Hooks::run( 'CategoryPageView', array( &$this ) ) ) { + if ( !Hooks::run( 'CategoryPageView', [ &$this ] ) ) { return; } @@ -94,8 +94,8 @@ class CategoryPage extends Article { $reqArray = $request->getValues(); - $from = $until = array(); - foreach ( array( 'page', 'subcat', 'file' ) as $type ) { + $from = $until = []; + foreach ( [ 'page', 'subcat', 'file' ] as $type ) { $from[$type] = $request->getVal( "{$type}from", $oldFrom ); $until[$type] = $request->getVal( "{$type}until", $oldUntil ); diff --git a/includes/page/ImageHistoryList.php b/includes/page/ImageHistoryList.php index 4c36729794..607357fcd1 100644 --- a/includes/page/ImageHistoryList.php +++ b/includes/page/ImageHistoryList.php @@ -80,12 +80,12 @@ class ImageHistoryList extends ContextSource { * @return string */ public function beginImageHistoryList( $navLinks = '' ) { - return Xml::element( 'h2', array( 'id' => 'filehistory' ), $this->msg( 'filehist' )->text() ) + return Xml::element( 'h2', [ 'id' => 'filehistory' ], $this->msg( 'filehist' )->text() ) . "\n" . "' . Xml::inputLabel( $this->msg( 'booksources-isbn' )->text(), @@ -135,12 +135,12 @@ class SpecialBookSources extends SpecialPage { 'isbn', 20, $this->isbn, - array( 'autofocus' => '', 'class' => 'mw-ui-input-inline' ) + [ 'autofocus' => '', 'class' => 'mw-ui-input-inline' ] ); $form .= ' ' . Html::submitButton( $this->msg( 'booksources-search' )->text(), - array(), array( 'mw-ui-progressive' ) + [], [ 'mw-ui-progressive' ] ) . "
\n"; $form .= Html::closeElement( 'form' ) . "\n"; @@ -161,7 +161,7 @@ class SpecialBookSources extends SpecialPage { # Hook to allow extensions to insert additional HTML, # e.g. for API-interacting plugins and so on - Hooks::run( 'BookInformation', array( $this->isbn, $this->getOutput() ) ); + Hooks::run( 'BookInformation', [ $this->isbn, $this->getOutput() ] ); # Check for a local page such as Project:Book_sources and use that if available $page = $this->msg( 'booksources' )->inContentLanguage()->text(); @@ -204,8 +204,8 @@ class SpecialBookSources extends SpecialPage { private function makeListItem( $label, $url ) { $url = str_replace( '$1', $this->isbn, $url ); - return Html::rawElement( 'li', array(), - Html::element( 'a', array( 'href' => $url, 'class' => 'external' ), $label ) ); + return Html::rawElement( 'li', [], + Html::element( 'a', [ 'href' => $url, 'class' => 'external' ], $label ) ); } protected function getGroupName() { diff --git a/includes/specials/SpecialBotPasswords.php b/includes/specials/SpecialBotPasswords.php index 93c36abca7..47e3316365 100644 --- a/includes/specials/SpecialBotPasswords.php +++ b/includes/specials/SpecialBotPasswords.php @@ -64,7 +64,7 @@ class SpecialBotPasswords extends FormSpecialPage { $par = null; } elseif ( strlen( $par ) > BotPassword::APPID_MAXLENGTH ) { throw new ErrorPageError( 'botpasswords', 'botpasswords-bad-appid', - array( htmlspecialchars( $par ) ) ); + [ htmlspecialchars( $par ) ] ); } parent::execute( $par ); @@ -88,40 +88,40 @@ class SpecialBotPasswords extends FormSpecialPage { $user = $this->getUser(); $request = $this->getRequest(); - $fields = array(); + $fields = []; if ( $this->par !== null ) { $this->botPassword = BotPassword::newFromCentralId( $this->userId, $this->par ); if ( !$this->botPassword ) { - $this->botPassword = BotPassword::newUnsaved( array( + $this->botPassword = BotPassword::newUnsaved( [ 'centralId' => $this->userId, 'appId' => $this->par, - ) ); + ] ); } $sep = BotPassword::getSeparator(); - $fields[] = array( + $fields[] = [ 'type' => 'info', 'label-message' => 'username', 'default' => $this->getUser()->getName() . $sep . $this->par - ); + ]; if ( $this->botPassword->isSaved() ) { - $fields['resetPassword'] = array( + $fields['resetPassword'] = [ 'type' => 'check', 'label-message' => 'botpasswords-label-resetpassword', - ); + ]; } $lang = $this->getLanguage(); $showGrants = MWGrants::getValidGrants(); - $fields['grants'] = array( + $fields['grants'] = [ 'type' => 'checkmatrix', 'label-message' => 'botpasswords-label-grants', 'help-message' => 'botpasswords-help-grants', - 'columns' => array( + 'columns' => [ $this->msg( 'botpasswords-label-grants-column' )->escaped() => 'grant' - ), + ], 'rows' => array_combine( array_map( 'MWGrants::getGrantsLink', $showGrants ), $showGrants @@ -147,9 +147,9 @@ class SpecialBotPasswords extends FormSpecialPage { }, MWGrants::getHiddenGrants() ), - ); + ]; - $fields['restrictions'] = array( + $fields['restrictions'] = [ 'type' => 'textarea', 'label-message' => 'botpasswords-label-restrictions', 'required' => true, @@ -163,32 +163,32 @@ class SpecialBotPasswords extends FormSpecialPage { return $ex->getMessage(); } }, - ); + ]; } else { $dbr = BotPassword::getDB( DB_SLAVE ); $res = $dbr->select( 'bot_passwords', - array( 'bp_app_id' ), - array( 'bp_user' => $this->userId ), + [ 'bp_app_id' ], + [ 'bp_user' => $this->userId ], __METHOD__ ); foreach ( $res as $row ) { - $fields[] = array( + $fields[] = [ 'section' => 'existing', 'type' => 'info', 'raw' => true, 'default' => Linker::link( $this->getPageTitle( $row->bp_app_id ), htmlspecialchars( $row->bp_app_id ), - array(), - array(), - array( 'known' ) + [], + [], + [ 'known' ] ), - ); + ]; } - $fields['appId'] = array( + $fields['appId'] = [ 'section' => 'createnew', 'type' => 'textwithbutton', 'label-message' => 'botpasswords-label-appid', @@ -200,13 +200,13 @@ class SpecialBotPasswords extends FormSpecialPage { $v = trim( $v ); return $v !== '' && strlen( $v ) <= BotPassword::APPID_MAXLENGTH; }, - ); + ]; - $fields[] = array( + $fields[] = [ 'type' => 'hidden', 'default' => 'new', 'name' => 'op', - ); + ]; } return $fields; @@ -221,33 +221,33 @@ class SpecialBotPasswords extends FormSpecialPage { if ( $this->par !== null ) { if ( $this->botPassword->isSaved() ) { $form->setWrapperLegendMsg( 'botpasswords-editexisting' ); - $form->addButton( array( + $form->addButton( [ 'name' => 'op', 'value' => 'update', 'label-message' => 'botpasswords-label-update', - 'flags' => array( 'primary', 'progressive' ), - ) ); - $form->addButton( array( + 'flags' => [ 'primary', 'progressive' ], + ] ); + $form->addButton( [ 'name' => 'op', 'value' => 'delete', 'label-message' => 'botpasswords-label-delete', - 'flags' => array( 'destructive' ), - ) ); + 'flags' => [ 'destructive' ], + ] ); } else { $form->setWrapperLegendMsg( 'botpasswords-createnew' ); - $form->addButton( array( + $form->addButton( [ 'name' => 'op', 'value' => 'create', 'label-message' => 'botpasswords-label-create', - 'flags' => array( 'primary', 'constructive' ), - ) ); + 'flags' => [ 'primary', 'constructive' ], + ] ); } - $form->addButton( array( + $form->addButton( [ 'name' => 'op', 'value' => 'cancel', 'label-message' => 'botpasswords-label-cancel' - ) ); + ] ); } } @@ -284,7 +284,7 @@ class SpecialBotPasswords extends FormSpecialPage { } private function save( array $data ) { - $bp = BotPassword::newUnsaved( array( + $bp = BotPassword::newUnsaved( [ 'centralId' => $this->userId, 'appId' => $this->par, 'restrictions' => MWRestrictions::newFromJson( $data['restrictions'] ), @@ -292,7 +292,7 @@ class SpecialBotPasswords extends FormSpecialPage { MWGrants::getHiddenGrants(), preg_replace( '/^grant-/', '', $data['grants'] ) ) - ) ); + ] ); if ( $this->operation === 'insert' || !empty( $data['resetPassword'] ) ) { $this->password = PasswordFactory::generateRandomPasswordString( diff --git a/includes/specials/SpecialBrokenRedirects.php b/includes/specials/SpecialBrokenRedirects.php index 71616fa2a2..4c3fbe5b18 100644 --- a/includes/specials/SpecialBrokenRedirects.php +++ b/includes/specials/SpecialBrokenRedirects.php @@ -51,44 +51,44 @@ class BrokenRedirectsPage extends QueryPage { public function getQueryInfo() { $dbr = wfGetDB( DB_SLAVE ); - return array( - 'tables' => array( + return [ + 'tables' => [ 'redirect', 'p1' => 'page', 'p2' => 'page', - ), - 'fields' => array( + ], + 'fields' => [ 'namespace' => 'p1.page_namespace', 'title' => 'p1.page_title', 'value' => 'p1.page_title', 'rd_namespace', 'rd_title', - ), - 'conds' => array( + ], + 'conds' => [ // Exclude pages that don't exist locally as wiki pages, // but aren't "broken" either. // Special pages and interwiki links 'rd_namespace >= 0', 'rd_interwiki IS NULL OR rd_interwiki = ' . $dbr->addQuotes( '' ), 'p2.page_namespace IS NULL', - ), - 'join_conds' => array( - 'p1' => array( 'JOIN', array( + ], + 'join_conds' => [ + 'p1' => [ 'JOIN', [ 'rd_from=p1.page_id', - ) ), - 'p2' => array( 'LEFT JOIN', array( + ] ], + 'p2' => [ 'LEFT JOIN', [ 'rd_namespace=p2.page_namespace', 'rd_title=p2.page_title' - ) ), - ), - ); + ] ], + ], + ]; } /** * @return array */ function getOrderFields() { - return array( 'rd_namespace', 'rd_title', 'rd_from' ); + return [ 'rd_namespace', 'rd_title', 'rd_from' ]; } /** @@ -117,10 +117,10 @@ class BrokenRedirectsPage extends QueryPage { $from = Linker::linkKnown( $fromObj, null, - array(), - array( 'redirect' => 'no' ) + [], + [ 'redirect' => 'no' ] ); - $links = array(); + $links = []; // if the page is editable, add an edit link if ( // check user permissions @@ -131,16 +131,16 @@ class BrokenRedirectsPage extends QueryPage { $links[] = Linker::linkKnown( $fromObj, $this->msg( 'brokenredirects-edit' )->escaped(), - array(), - array( 'action' => 'edit' ) + [], + [ 'action' => 'edit' ] ); } $to = Linker::link( $toObj, null, - array(), - array(), - array( 'broken' ) + [], + [], + [ 'broken' ] ); $arr = $this->getLanguage()->getArrow(); @@ -150,8 +150,8 @@ class BrokenRedirectsPage extends QueryPage { $links[] = Linker::linkKnown( $fromObj, $this->msg( 'brokenredirects-delete' )->escaped(), - array(), - array( 'action' => 'delete' ) + [], + [ 'action' => 'delete' ] ); } diff --git a/includes/specials/SpecialCachedPage.php b/includes/specials/SpecialCachedPage.php index cb9b07cde4..14c84e9d97 100644 --- a/includes/specials/SpecialCachedPage.php +++ b/includes/specials/SpecialCachedPage.php @@ -92,7 +92,7 @@ abstract class SpecialCachedPage extends SpecialPage implements ICacheHelper { $this->cacheHelper = new CacheHelper(); $this->cacheHelper->setCacheEnabled( $this->cacheEnabled ); - $this->cacheHelper->setOnInitializedHandler( array( $this, 'onCacheInitialized' ) ); + $this->cacheHelper->setOnInitializedHandler( [ $this, 'onCacheInitialized' ] ); $keyArgs = $this->getCacheKey(); @@ -124,7 +124,7 @@ abstract class SpecialCachedPage extends SpecialPage implements ICacheHelper { * * @return mixed */ - public function getCachedValue( $computeFunction, $args = array(), $key = null ) { + public function getCachedValue( $computeFunction, $args = [], $key = null ) { return $this->cacheHelper->getCachedValue( $computeFunction, $args, $key ); } @@ -140,7 +140,7 @@ abstract class SpecialCachedPage extends SpecialPage implements ICacheHelper { * @param array $args * @param string|null $key */ - public function addCachedHTML( $computeFunction, $args = array(), $key = null ) { + public function addCachedHTML( $computeFunction, $args = [], $key = null ) { $this->getOutput()->addHTML( $this->cacheHelper->getCachedValue( $computeFunction, $args, @@ -180,10 +180,10 @@ abstract class SpecialCachedPage extends SpecialPage implements ICacheHelper { * @return array */ protected function getCacheKey() { - return array( + return [ $this->mName, $this->getLanguage()->getCode() - ); + ]; } /** diff --git a/includes/specials/SpecialCategories.php b/includes/specials/SpecialCategories.php index 564579a8bb..5314f63489 100644 --- a/includes/specials/SpecialCategories.php +++ b/includes/specials/SpecialCategories.php @@ -78,7 +78,7 @@ class SpecialCategories extends SpecialPage { $cap->doQuery(); $this->getOutput()->addHTML( - Html::openElement( 'div', array( 'class' => 'mw-spcontent' ) ) . + Html::openElement( 'div', [ 'class' => 'mw-spcontent' ] ) . $this->msg( 'categoriespagetext', $cap->getNumRows() )->parseAsBlock() . $cap->getStartForm( $from ) . $cap->getNavigationBar() . @@ -125,12 +125,12 @@ class CategoryPager extends AlphabeticPager { } function getQueryInfo() { - return array( - 'tables' => array( 'category' ), - 'fields' => array( 'cat_title', 'cat_pages' ), - 'conds' => array( 'cat_pages > 0' ), - 'options' => array( 'USE INDEX' => 'cat_title' ), - ); + return [ + 'tables' => [ 'category' ], + 'fields' => [ 'cat_title', 'cat_pages' ], + 'conds' => [ 'cat_pages > 0' ], + 'options' => [ 'USE INDEX' => 'cat_title' ], + ]; } function getIndexField() { @@ -182,17 +182,17 @@ class CategoryPager extends AlphabeticPager { public function getStartForm( $from ) { return Xml::tags( 'form', - array( 'method' => 'get', 'action' => wfScript() ), + [ 'method' => 'get', 'action' => wfScript() ], Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) . Xml::fieldset( $this->msg( 'categories' )->text(), Xml::inputLabel( $this->msg( 'categoriesfrom' )->text(), - 'from', 'from', 20, $from, array( 'class' => 'mw-ui-input-inline' ) ) . + 'from', 'from', 20, $from, [ 'class' => 'mw-ui-input-inline' ] ) . ' ' . Html::submitButton( $this->msg( 'categories-submit' )->text(), - array(), array( 'mw-ui-progressive' ) + [], [ 'mw-ui-progressive' ] ) ) ); diff --git a/includes/specials/SpecialChangeContentModel.php b/includes/specials/SpecialChangeContentModel.php index 1f32e3f808..d495120e0c 100644 --- a/includes/specials/SpecialChangeContentModel.php +++ b/includes/specials/SpecialChangeContentModel.php @@ -69,26 +69,26 @@ class SpecialChangeContentModel extends FormSpecialPage { protected function getFormFields() { $that = $this; - $fields = array( - 'pagetitle' => array( + $fields = [ + 'pagetitle' => [ 'type' => 'title', 'creatable' => true, 'name' => 'pagetitle', 'default' => $this->par, 'label-message' => 'changecontentmodel-title-label', - 'validation-callback' => array( $this, 'validateTitle' ), - ), - ); + 'validation-callback' => [ $this, 'validateTitle' ], + ], + ]; if ( $this->title ) { $fields['pagetitle']['readonly'] = true; - $fields += array( - 'model' => array( + $fields += [ + 'model' => [ 'type' => 'select', 'name' => 'model', 'options' => $this->getOptionsForTitle( $this->title ), 'label-message' => 'changecontentmodel-model-label' - ), - 'reason' => array( + ], + 'reason' => [ 'type' => 'text', 'name' => 'reason', 'validation-callback' => function( $reason ) use ( $that ) { @@ -100,8 +100,8 @@ class SpecialChangeContentModel extends FormSpecialPage { return true; }, 'label-message' => 'changecontentmodel-reason-label', - ), - ); + ], + ]; } return $fields; @@ -109,7 +109,7 @@ class SpecialChangeContentModel extends FormSpecialPage { private function getOptionsForTitle( Title $title = null ) { $models = ContentHandler::getContentModels(); - $options = array(); + $options = []; foreach ( $models as $model ) { $handler = ContentHandler::getForModelID( $model ); if ( !$handler->supportsDirectEditing() ) { @@ -152,7 +152,7 @@ class SpecialChangeContentModel extends FormSpecialPage { $out = $this->getOutput(); $wikitext = $out->formatPermissionsErrorMessage( $errors ); // Hack to get our wikitext parsed - return Status::newFatal( new RawMessage( '$1', array( $wikitext ) ) ); + return Status::newFatal( new RawMessage( '$1', [ $wikitext ] ) ); } $page = WikiPage::factory( $this->title ); @@ -188,10 +188,10 @@ class SpecialChangeContentModel extends FormSpecialPage { $log->setPerformer( $user ); $log->setTarget( $this->title ); $log->setComment( $data['reason'] ); - $log->setParameters( array( + $log->setParameters( [ '4::oldmodel' => $oldModel, '5::newmodel' => $data['model'] - ) ); + ] ); $formatter = LogFormatter::newFromEntry( $log ); $formatter->setContext( RequestContext::newExtraneousContext( $this->title ) ); diff --git a/includes/specials/SpecialChangeEmail.php b/includes/specials/SpecialChangeEmail.php index 989bae9945..4c3fc0e114 100644 --- a/includes/specials/SpecialChangeEmail.php +++ b/includes/specials/SpecialChangeEmail.php @@ -81,30 +81,30 @@ class SpecialChangeEmail extends FormSpecialPage { protected function getFormFields() { $user = $this->getUser(); - $fields = array( - 'Name' => array( + $fields = [ + 'Name' => [ 'type' => 'info', 'label-message' => 'username', 'default' => $user->getName(), - ), - 'OldEmail' => array( + ], + 'OldEmail' => [ 'type' => 'info', 'label-message' => 'changeemail-oldemail', 'default' => $user->getEmail() ?: $this->msg( 'changeemail-none' )->text(), - ), - 'NewEmail' => array( + ], + 'NewEmail' => [ 'type' => 'email', 'label-message' => 'changeemail-newemail', 'autofocus' => true, 'help-message' => 'changeemail-newemail-help', - ), - ); + ], + ]; if ( $this->getConfig()->get( 'RequirePasswordforEmailChange' ) ) { - $fields['Password'] = array( + $fields['Password'] = [ 'type' => 'password', 'label-message' => 'changeemail-password' - ); + ]; } return $fields; @@ -200,7 +200,7 @@ class SpecialChangeEmail extends FormSpecialPage { return $status; } - Hooks::run( 'PrefsEmailAudit', array( $user, $oldaddr, $newaddr ) ); + Hooks::run( 'PrefsEmailAudit', [ $user, $oldaddr, $newaddr ] ); $user->saveSettings(); diff --git a/includes/specials/SpecialChangePassword.php b/includes/specials/SpecialChangePassword.php index 3e5a936ba3..4f7ba25dcb 100644 --- a/includes/specials/SpecialChangePassword.php +++ b/includes/specials/SpecialChangePassword.php @@ -90,55 +90,55 @@ class SpecialChangePassword extends FormSpecialPage { $oldpassMsg = $user->isLoggedIn() ? 'oldpassword' : 'resetpass-temp-password'; } - $fields = array( - 'Name' => array( + $fields = [ + 'Name' => [ 'type' => 'info', 'label-message' => 'username', 'default' => $request->getVal( 'wpName', $user->getName() ), - ), - 'Password' => array( + ], + 'Password' => [ 'type' => 'password', 'label-message' => $oldpassMsg, - ), - 'NewPassword' => array( + ], + 'NewPassword' => [ 'type' => 'password', 'label-message' => 'newpassword', - ), - 'Retype' => array( + ], + 'Retype' => [ 'type' => 'password', 'label-message' => 'retypenew', - ), - ); + ], + ]; if ( !$this->getUser()->isLoggedIn() ) { - $fields['LoginOnChangeToken'] = array( + $fields['LoginOnChangeToken'] = [ 'type' => 'hidden', 'label' => 'Change Password Token', 'default' => LoginForm::getLoginToken()->toString(), - ); + ]; } - $extraFields = array(); - Hooks::run( 'ChangePasswordForm', array( &$extraFields ) ); + $extraFields = []; + Hooks::run( 'ChangePasswordForm', [ &$extraFields ] ); foreach ( $extraFields as $extra ) { list( $name, $label, $type, $default ) = $extra; - $fields[$name] = array( + $fields[$name] = [ 'type' => $type, 'name' => $name, 'label-message' => $label, 'default' => $default, - ); + ]; } if ( !$user->isLoggedIn() ) { - $fields['Remember'] = array( + $fields['Remember'] = [ 'type' => 'check', 'label' => $this->msg( 'remembermypassword' ) ->numParams( ceil( $this->getConfig()->get( 'CookieExpiration' ) / ( 3600 * 24 ) ) )->text(), 'default' => $request->getVal( 'wpRemember' ), - ); + ]; } return $fields; @@ -153,10 +153,10 @@ class SpecialChangePassword extends FormSpecialPage { ? 'resetpass-submit-loggedin' : 'resetpass_submit' ); - $form->addButton( array( + $form->addButton( [ 'name' => 'wpCancel', 'value' => $this->msg( 'resetpass-submit-cancel' )->text() - ) ); + ] ); $form->setHeaderText( $this->msg( 'resetpass_text' )->parseAsBlock() ); if ( $this->mPreTextMessage instanceof Message ) { $form->addPreText( $this->mPreTextMessage->parseAsBlock() ); @@ -217,13 +217,13 @@ class SpecialChangePassword extends FormSpecialPage { $request = $this->getRequest(); LoginForm::clearLoginToken(); $token = LoginForm::getLoginToken()->toString(); - $data = array( + $data = [ 'action' => 'submitlogin', 'wpName' => $this->mUserName, 'wpDomain' => $this->mDomain, 'wpLoginToken' => $token, 'wpPassword' => $request->getVal( 'wpNewPassword' ), - ) + $request->getValues( 'wpRemember', 'returnto', 'returntoquery' ); + ] + $request->getValues( 'wpRemember', 'returnto', 'returntoquery' ); $login = new LoginForm( new DerivativeRequest( $request, $data, true ) ); $login->setContext( $this->getContext() ); $login->execute( null ); @@ -253,7 +253,7 @@ class SpecialChangePassword extends FormSpecialPage { } if ( $newpass !== $retype ) { - Hooks::run( 'PrefsPasswordAudit', array( $user, $newpass, 'badretype' ) ); + Hooks::run( 'PrefsPasswordAudit', [ $user, $newpass, 'badretype' ] ); return Status::newFatal( $this->msg( 'badretype' ) ); } @@ -268,7 +268,7 @@ class SpecialChangePassword extends FormSpecialPage { // @todo Make these separate messages, since the message is written for both cases if ( !$user->checkTemporaryPassword( $oldpass ) && !$user->checkPassword( $oldpass ) ) { - Hooks::run( 'PrefsPasswordAudit', array( $user, $newpass, 'wrongpassword' ) ); + Hooks::run( 'PrefsPasswordAudit', [ $user, $newpass, 'wrongpassword' ] ); return Status::newFatal( $this->msg( 'resetpass-wrong-oldpass' ) ); } @@ -280,8 +280,8 @@ class SpecialChangePassword extends FormSpecialPage { // Do AbortChangePassword after checking mOldpass, so we don't leak information // by possibly aborting a new password before verifying the old password. $abortMsg = 'resetpass-abort-generic'; - if ( !Hooks::run( 'AbortChangePassword', array( $user, $oldpass, $newpass, &$abortMsg ) ) ) { - Hooks::run( 'PrefsPasswordAudit', array( $user, $newpass, 'abortreset' ) ); + if ( !Hooks::run( 'AbortChangePassword', [ $user, $oldpass, $newpass, &$abortMsg ] ) ) { + Hooks::run( 'PrefsPasswordAudit', [ $user, $newpass, 'abortreset' ] ); return Status::newFatal( $this->msg( $abortMsg ) ); } @@ -292,9 +292,9 @@ class SpecialChangePassword extends FormSpecialPage { try { $user->setPassword( $newpass ); - Hooks::run( 'PrefsPasswordAudit', array( $user, $newpass, 'success' ) ); + Hooks::run( 'PrefsPasswordAudit', [ $user, $newpass, 'success' ] ); } catch ( PasswordError $e ) { - Hooks::run( 'PrefsPasswordAudit', array( $user, $newpass, 'error' ) ); + Hooks::run( 'PrefsPasswordAudit', [ $user, $newpass, 'error' ] ); return Status::newFatal( new RawMessage( $e->getMessage() ) ); } @@ -331,12 +331,12 @@ class SpecialChangePassword extends FormSpecialPage { ); } // Give extensions a chance to force an expiration - Hooks::run( 'ResetPasswordExpiration', array( $this, &$newExpire ) ); + Hooks::run( 'ResetPasswordExpiration', [ $this, &$newExpire ] ); $dbw = wfGetDB( DB_MASTER ); $dbw->update( 'user', - array( 'user_password_expires' => $dbw->timestampOrNull( $newExpire ) ), - array( 'user_id' => $user->getID() ), + [ 'user_password_expires' => $dbw->timestampOrNull( $newExpire ) ], + [ 'user_id' => $user->getID() ], __METHOD__ ); } diff --git a/includes/specials/SpecialComparePages.php b/includes/specials/SpecialComparePages.php index fbc5984e02..35cc6b84f2 100644 --- a/includes/specials/SpecialComparePages.php +++ b/includes/specials/SpecialComparePages.php @@ -51,56 +51,56 @@ class SpecialComparePages extends SpecialPage { $this->outputHeader(); $this->getOutput()->addModuleStyles( 'mediawiki.special.comparepages.styles' ); - $form = HTMLForm::factory( 'ooui', array( - 'Page1' => array( + $form = HTMLForm::factory( 'ooui', [ + 'Page1' => [ 'type' => 'title', 'name' => 'page1', 'label-message' => 'compare-page1', 'size' => '40', 'section' => 'page1', - 'validation-callback' => array( $this, 'checkExistingTitle' ), - ), - 'Revision1' => array( + 'validation-callback' => [ $this, 'checkExistingTitle' ], + ], + 'Revision1' => [ 'type' => 'int', 'name' => 'rev1', 'label-message' => 'compare-rev1', 'size' => '8', 'section' => 'page1', - 'validation-callback' => array( $this, 'checkExistingRevision' ), - ), - 'Page2' => array( + 'validation-callback' => [ $this, 'checkExistingRevision' ], + ], + 'Page2' => [ 'type' => 'title', 'name' => 'page2', 'label-message' => 'compare-page2', 'size' => '40', 'section' => 'page2', - 'validation-callback' => array( $this, 'checkExistingTitle' ), - ), - 'Revision2' => array( + 'validation-callback' => [ $this, 'checkExistingTitle' ], + ], + 'Revision2' => [ 'type' => 'int', 'name' => 'rev2', 'label-message' => 'compare-rev2', 'size' => '8', 'section' => 'page2', - 'validation-callback' => array( $this, 'checkExistingRevision' ), - ), - 'Action' => array( + 'validation-callback' => [ $this, 'checkExistingRevision' ], + ], + 'Action' => [ 'type' => 'hidden', 'name' => 'action', - ), - 'Diffonly' => array( + ], + 'Diffonly' => [ 'type' => 'hidden', 'name' => 'diffonly', - ), - 'Unhide' => array( + ], + 'Unhide' => [ 'type' => 'hidden', 'name' => 'unhide', - ), - ), $this->getContext(), 'compare' ); + ], + ], $this->getContext(), 'compare' ); $form->setSubmitTextMsg( 'compare-submit' ); $form->suppressReset(); $form->setMethod( 'get' ); - $form->setSubmitCallback( array( __CLASS__, 'showDiff' ) ); + $form->setSubmitCallback( [ __CLASS__, 'showDiff' ] ); $form->loadData(); $form->displayForm( '' ); diff --git a/includes/specials/SpecialConfirmemail.php b/includes/specials/SpecialConfirmemail.php index 5ed33e052c..914781c16a 100644 --- a/includes/specials/SpecialConfirmemail.php +++ b/includes/specials/SpecialConfirmemail.php @@ -83,17 +83,17 @@ class EmailConfirmation extends UnlistedSpecialPage { $out = $this->getOutput(); if ( !$user->isEmailConfirmed() ) { - $descriptor = array(); + $descriptor = []; if ( $user->isEmailConfirmationPending() ) { - $descriptor += array( - 'pending' => array( + $descriptor += [ + 'pending' => [ 'type' => 'info', 'raw' => true, 'default' => "';
- $tagSelect = $this->getTagSelect( array(), $this->msg( 'tags-edit-add' )->plain() );
+ $tagSelect = $this->getTagSelect( [], $this->msg( 'tags-edit-add' )->plain() );
$html .= ' ' . $tagSelect[0] . ' ' . $tagSelect[1] . ' | ';
$html .= Xml::element( 'p', null, $this->msg( 'tags-edit-remove' )->plain() );
$html .= Xml::checkLabel( $this->msg( 'tags-edit-remove-all-tags' )->plain(),
@@ -328,10 +328,10 @@ class SpecialEditTags extends UnlistedSpecialPage {
$i = 0; // used for generating checkbox IDs only
foreach ( $tags as $tag ) {
$html .= Xml::element( 'br' ) . "\n" . Xml::checkLabel( $tag,
- 'wpTagsToRemove[]', 'mw-edittags-remove-' . $i++, false, array(
+ 'wpTagsToRemove[]', 'mw-edittags-remove-' . $i++, false, [
'value' => $tag,
'class' => 'mw-edittags-remove-checkbox',
- ) );
+ ] );
}
}
@@ -356,7 +356,7 @@ class SpecialEditTags extends UnlistedSpecialPage {
* index 1
*/
protected function getTagSelect( $selectedTags, $label ) {
- $result = array();
+ $result = [];
$result[0] = Xml::label( $label, 'mw-edittags-tag-list' );
$select = new XmlSelect( 'wpTagList[]', 'mw-edittags-tag-list', $selectedTags );
@@ -390,11 +390,11 @@ class SpecialEditTags extends UnlistedSpecialPage {
// Evaluate incoming request data
$tagList = $request->getArray( 'wpTagList' );
if ( is_null( $tagList ) ) {
- $tagList = array();
+ $tagList = [];
}
$existingTags = $request->getVal( 'wpExistingTags' );
if ( is_null( $existingTags ) || $existingTags === '' ) {
- $existingTags = array();
+ $existingTags = [];
} else {
$existingTags = explode( ',', $existingTags );
}
diff --git a/includes/specials/SpecialEditWatchlist.php b/includes/specials/SpecialEditWatchlist.php
index 13ee8b3ac4..1a9d09662b 100644
--- a/includes/specials/SpecialEditWatchlist.php
+++ b/includes/specials/SpecialEditWatchlist.php
@@ -47,7 +47,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
protected $toc;
- private $badItems = array();
+ private $badItems = [];
public function __construct() {
parent::__construct( 'EditWatchlist', 'editmywatchlist' );
@@ -147,10 +147,10 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
public function getSubpagesForPrefixSearch() {
// SpecialWatchlist uses SpecialEditWatchlist::getMode, so new types should be added
// here and there - no 'edit' here, because that the default for this page
- return array(
+ return [
'clear',
'raw',
- );
+ ];
}
/**
@@ -163,10 +163,10 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
private function extractTitles( $list ) {
$list = explode( "\n", trim( $list ) );
if ( !is_array( $list ) ) {
- return array();
+ return [];
}
- $titles = array();
+ $titles = [];
foreach ( $list as $text ) {
$text = trim( $text );
@@ -180,7 +180,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
GenderCache::singleton()->doTitlesArray( $titles );
- $list = array();
+ $list = [];
/** @var Title $title */
foreach ( $titles as $title ) {
$list[] = $title->getPrefixedText();
@@ -305,24 +305,24 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
* @return array
*/
private function getWatchlist() {
- $list = array();
+ $list = [];
$index = $this->getRequest()->wasPosted() ? DB_MASTER : DB_SLAVE;
$dbr = wfGetDB( $index );
$res = $dbr->select(
'watchlist',
- array(
+ [
'wl_namespace', 'wl_title'
- ), array(
+ ], [
'wl_user' => $this->getUser()->getId(),
- ),
+ ],
__METHOD__
);
if ( $res->numRows() > 0 ) {
/** @var Title[] $titles */
- $titles = array();
+ $titles = [];
foreach ( $res as $row ) {
$title = Title::makeTitleSafe( $row->wl_namespace, $row->wl_title );
@@ -353,15 +353,15 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
* @return array
*/
protected function getWatchlistInfo() {
- $titles = array();
+ $titles = [];
$dbr = wfGetDB( DB_SLAVE );
$res = $dbr->select(
- array( 'watchlist' ),
- array( 'wl_namespace', 'wl_title' ),
- array( 'wl_user' => $this->getUser()->getId() ),
+ [ 'watchlist' ],
+ [ 'wl_namespace', 'wl_title' ],
+ [ 'wl_user' => $this->getUser()->getId() ],
__METHOD__,
- array( 'ORDER BY' => array( 'wl_namespace', 'wl_title' ) )
+ [ 'ORDER BY' => [ 'wl_namespace', 'wl_title' ] ]
);
$lb = new LinkBatch();
@@ -399,7 +399,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
|| $title->getNamespace() != $namespace
|| $title->getDBkey() != $dbKey
) {
- $this->badItems[] = array( $title, $namespace, $dbKey );
+ $this->badItems[] = [ $title, $namespace, $dbKey ];
}
return (bool)$title;
@@ -422,11 +422,11 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
wfDebug( "User {$user->getName()} has broken watchlist item ns($namespace):$dbKey, $action.\n" );
$dbw->delete( 'watchlist',
- array(
+ [
'wl_user' => $user->getId(),
'wl_namespace' => $namespace,
'wl_title' => $dbKey,
- ),
+ ],
__METHOD__
);
@@ -444,7 +444,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
$dbw = wfGetDB( DB_MASTER );
$dbw->delete(
'watchlist',
- array( 'wl_user' => $this->getUser()->getId() ),
+ [ 'wl_user' => $this->getUser()->getId() ],
__METHOD__
);
}
@@ -459,7 +459,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
*/
private function watchTitles( $titles ) {
$dbw = wfGetDB( DB_MASTER );
- $rows = array();
+ $rows = [];
foreach ( $titles as $title ) {
if ( !$title instanceof Title ) {
@@ -467,18 +467,18 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
}
if ( $title instanceof Title ) {
- $rows[] = array(
+ $rows[] = [
'wl_user' => $this->getUser()->getId(),
'wl_namespace' => MWNamespace::getSubject( $title->getNamespace() ),
'wl_title' => $title->getDBkey(),
'wl_notificationtimestamp' => null,
- );
- $rows[] = array(
+ ];
+ $rows[] = [
'wl_user' => $this->getUser()->getId(),
'wl_namespace' => MWNamespace::getTalk( $title->getNamespace() ),
'wl_title' => $title->getDBkey(),
'wl_notificationtimestamp' => null,
- );
+ ];
}
}
@@ -504,32 +504,32 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
if ( $title instanceof Title ) {
$dbw->delete(
'watchlist',
- array(
+ [
'wl_user' => $this->getUser()->getId(),
'wl_namespace' => MWNamespace::getSubject( $title->getNamespace() ),
'wl_title' => $title->getDBkey(),
- ),
+ ],
__METHOD__
);
$dbw->delete(
'watchlist',
- array(
+ [
'wl_user' => $this->getUser()->getId(),
'wl_namespace' => MWNamespace::getTalk( $title->getNamespace() ),
'wl_title' => $title->getDBkey(),
- ),
+ ],
__METHOD__
);
$page = WikiPage::factory( $title );
- Hooks::run( 'UnwatchArticleComplete', array( $this->getUser(), &$page ) );
+ Hooks::run( 'UnwatchArticleComplete', [ $this->getUser(), &$page ] );
}
}
}
public function submitNormal( $data ) {
- $removed = array();
+ $removed = [];
foreach ( $data as $titles ) {
$this->unwatchTitles( $titles );
@@ -555,7 +555,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
protected function getNormalForm() {
global $wgContLang;
- $fields = array();
+ $fields = [];
$count = 0;
// Allow subscribers to manipulate the list of watched pages (or use it
@@ -563,11 +563,11 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
$watchlistInfo = $this->getWatchlistInfo();
Hooks::run(
'WatchlistEditorBeforeFormRender',
- array( &$watchlistInfo )
+ [ &$watchlistInfo ]
);
foreach ( $watchlistInfo as $namespace => $pages ) {
- $options = array();
+ $options = [];
foreach ( array_keys( $pages ) as $dbkey ) {
$title = Title::makeTitleSafe( $namespace, $dbkey );
@@ -581,11 +581,11 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
// checkTitle can filter some options out, avoid empty sections
if ( count( $options ) > 0 ) {
- $fields['TitlesNs' . $namespace] = array(
+ $fields['TitlesNs' . $namespace] = [
'class' => 'EditWatchlistCheckboxSeriesField',
'options' => $options,
'section' => "ns$namespace",
- );
+ ];
}
}
$this->cleanupWatchlist();
@@ -620,7 +620,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
$form->setSubmitTooltip( 'watchlistedit-normal-submit' );
$form->setWrapperLegendMsg( 'watchlistedit-normal-legend' );
$form->addHeaderText( $this->msg( 'watchlistedit-normal-explain' )->parse() );
- $form->setSubmitCallback( array( $this, 'submitNormal' ) );
+ $form->setSubmitCallback( [ $this, 'submitNormal' ] );
return $form;
}
@@ -643,8 +643,8 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
$tools['history'] = Linker::linkKnown(
$title,
$this->msg( 'history_short' )->escaped(),
- array(),
- array( 'action' => 'history' )
+ [],
+ [ 'action' => 'history' ]
);
}
@@ -657,7 +657,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
Hooks::run(
'WatchlistEditorBuildRemoveLine',
- array( &$tools, $title, $title->isRedirect(), $this->getSkin(), &$link )
+ [ &$tools, $title, $title->isRedirect(), $this->getSkin(), &$link ]
);
if ( $title->isRedirect() ) {
@@ -676,13 +676,13 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
*/
protected function getRawForm() {
$titles = implode( $this->getWatchlist(), "\n" );
- $fields = array(
- 'Titles' => array(
+ $fields = [
+ 'Titles' => [
'type' => 'textarea',
'label-message' => 'watchlistedit-raw-titles',
'default' => $titles,
- ),
- );
+ ],
+ ];
$context = new DerivativeContext( $this->getContext() );
$context->setTitle( $this->getPageTitle( 'raw' ) ); // Reset subpage
$form = new HTMLForm( $fields, $context );
@@ -691,7 +691,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
$form->setSubmitTooltip( 'watchlistedit-raw-submit' );
$form->setWrapperLegendMsg( 'watchlistedit-raw-legend' );
$form->addHeaderText( $this->msg( 'watchlistedit-raw-explain' )->parse() );
- $form->setSubmitCallback( array( $this, 'submitRaw' ) );
+ $form->setSubmitCallback( [ $this, 'submitRaw' ] );
return $form;
}
@@ -704,13 +704,13 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
protected function getClearForm() {
$context = new DerivativeContext( $this->getContext() );
$context->setTitle( $this->getPageTitle( 'clear' ) ); // Reset subpage
- $form = new HTMLForm( array(), $context );
+ $form = new HTMLForm( [], $context );
$form->setSubmitTextMsg( 'watchlistedit-clear-submit' );
# Used message keys: 'accesskey-watchlistedit-clear-submit', 'tooltip-watchlistedit-clear-submit'
$form->setSubmitTooltip( 'watchlistedit-clear-submit' );
$form->setWrapperLegendMsg( 'watchlistedit-clear-legend' );
$form->addHeaderText( $this->msg( 'watchlistedit-clear-explain' )->parse() );
- $form->setSubmitCallback( array( $this, 'submitClear' ) );
+ $form->setSubmitCallback( [ $this, 'submitClear' ] );
$form->setSubmitDestructive();
return $form;
@@ -752,13 +752,13 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
public static function buildTools( $unused ) {
global $wgLang;
- $tools = array();
- $modes = array(
- 'view' => array( 'Watchlist', false ),
- 'edit' => array( 'EditWatchlist', false ),
- 'raw' => array( 'EditWatchlist', 'raw' ),
- 'clear' => array( 'EditWatchlist', 'clear' ),
- );
+ $tools = [];
+ $modes = [
+ 'view' => [ 'Watchlist', false ],
+ 'edit' => [ 'EditWatchlist', false ],
+ 'raw' => [ 'EditWatchlist', 'raw' ],
+ 'clear' => [ 'EditWatchlist', 'clear' ],
+ ];
foreach ( $modes as $mode => $arr ) {
// can use messages 'watchlisttools-view', 'watchlisttools-edit', 'watchlisttools-raw'
@@ -770,7 +770,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
return Html::rawElement(
'span',
- array( 'class' => 'mw-watchlist-toollinks' ),
+ [ 'class' => 'mw-watchlist-toollinks' ],
wfMessage( 'parentheses' )->rawParams( $wgLang->pipeList( $tools ) )->escaped()
);
}
diff --git a/includes/specials/SpecialEmailuser.php b/includes/specials/SpecialEmailuser.php
index c036d3d2cf..cdf350d5ca 100644
--- a/includes/specials/SpecialEmailuser.php
+++ b/includes/specials/SpecialEmailuser.php
@@ -52,8 +52,8 @@ class SpecialEmailUser extends UnlistedSpecialPage {
}
protected function getFormFields() {
- return array(
- 'From' => array(
+ return [
+ 'From' => [
'type' => 'info',
'raw' => 1,
'default' => Linker::link(
@@ -62,8 +62,8 @@ class SpecialEmailUser extends UnlistedSpecialPage {
),
'label-message' => 'emailfrom',
'id' => 'mw-emailuser-sender',
- ),
- 'To' => array(
+ ],
+ 'To' => [
'type' => 'info',
'raw' => 1,
'default' => Linker::link(
@@ -72,12 +72,12 @@ class SpecialEmailUser extends UnlistedSpecialPage {
),
'label-message' => 'emailto',
'id' => 'mw-emailuser-recipient',
- ),
- 'Target' => array(
+ ],
+ 'Target' => [
'type' => 'hidden',
'default' => $this->mTargetObj->getName(),
- ),
- 'Subject' => array(
+ ],
+ 'Subject' => [
'type' => 'text',
'default' => $this->msg( 'defemailsubject',
$this->getUser()->getName() )->inContentLanguage()->text(),
@@ -85,20 +85,20 @@ class SpecialEmailUser extends UnlistedSpecialPage {
'maxlength' => 200,
'size' => 60,
'required' => true,
- ),
- 'Text' => array(
+ ],
+ 'Text' => [
'type' => 'textarea',
'rows' => 20,
'cols' => 80,
'label-message' => 'emailmessage',
'required' => true,
- ),
- 'CCMe' => array(
+ ],
+ 'CCMe' => [
'type' => 'check',
'label-message' => 'emailccme',
'default' => $this->getUser()->getBoolOption( 'ccmeonemails' ),
- ),
- );
+ ],
+ ];
}
public function execute( $par ) {
@@ -160,11 +160,11 @@ class SpecialEmailUser extends UnlistedSpecialPage {
// By now we are supposed to be sure that $this->mTarget is a user name
$form->addPreText( $this->msg( 'emailpagetext', $this->mTarget )->parse() );
$form->setSubmitTextMsg( 'emailsend' );
- $form->setSubmitCallback( array( __CLASS__, 'uiSubmit' ) );
+ $form->setSubmitCallback( [ __CLASS__, 'uiSubmit' ] );
$form->setWrapperLegendMsg( 'email-legend' );
$form->loadData();
- if ( !Hooks::run( 'EmailUserForm', array( &$form ) ) ) {
+ if ( !Hooks::run( 'EmailUserForm', [ &$form ] ) ) {
return;
}
@@ -247,8 +247,8 @@ class SpecialEmailUser extends UnlistedSpecialPage {
$hookErr = false;
- Hooks::run( 'UserCanSendEmail', array( &$user, &$hookErr ) );
- Hooks::run( 'EmailUserPermissionsErrors', array( $user, $editToken, &$hookErr ) );
+ Hooks::run( 'UserCanSendEmail', [ &$user, &$hookErr ] );
+ Hooks::run( 'EmailUserPermissionsErrors', [ $user, $editToken, &$hookErr ] );
if ( $hookErr ) {
return $hookErr;
@@ -267,7 +267,7 @@ class SpecialEmailUser extends UnlistedSpecialPage {
$this->getOutput()->addModules( 'mediawiki.userSuggest' );
$string = Xml::openElement(
'form',
- array( 'method' => 'get', 'action' => wfScript(), 'id' => 'askusername' )
+ [ 'method' => 'get', 'action' => wfScript(), 'id' => 'askusername' ]
) .
Html::hidden( 'title', $this->getPageTitle()->getPrefixedText() ) .
Xml::openElement( 'fieldset' ) .
@@ -278,10 +278,10 @@ class SpecialEmailUser extends UnlistedSpecialPage {
'emailusertarget',
30,
$name,
- array(
+ [
'class' => 'mw-autocomplete-user', // used by mediawiki.userSuggest
'autofocus' => true,
- )
+ ]
) .
' ' .
Xml::submitButton( $this->msg( 'emailusernamesubmit' )->text() ) .
@@ -333,7 +333,7 @@ class SpecialEmailUser extends UnlistedSpecialPage {
$from->name, $to->name )->inContentLanguage()->text();
$error = '';
- if ( !Hooks::run( 'EmailUser', array( &$to, &$from, &$subject, &$text, &$error ) ) ) {
+ if ( !Hooks::run( 'EmailUser', [ &$to, &$from, &$subject, &$text, &$error ] ) ) {
return $error;
}
@@ -369,9 +369,9 @@ class SpecialEmailUser extends UnlistedSpecialPage {
$replyTo = null;
}
- $status = UserMailer::send( $to, $mailFrom, $subject, $text, array(
+ $status = UserMailer::send( $to, $mailFrom, $subject, $text, [
'replyTo' => $replyTo,
- ) );
+ ] );
if ( !$status->isGood() ) {
return $status;
@@ -384,13 +384,13 @@ class SpecialEmailUser extends UnlistedSpecialPage {
$target->getName(), $subject )->text();
// target and sender are equal, because this is the CC for the sender
- Hooks::run( 'EmailUserCC', array( &$from, &$from, &$cc_subject, &$text ) );
+ Hooks::run( 'EmailUserCC', [ &$from, &$from, &$cc_subject, &$text ] );
$ccStatus = UserMailer::send( $from, $from, $cc_subject, $text );
$status->merge( $ccStatus );
}
- Hooks::run( 'EmailUserComplete', array( $to, $from, $subject, $text ) );
+ Hooks::run( 'EmailUserComplete', [ $to, $from, $subject, $text ] );
return $status;
}
@@ -408,7 +408,7 @@ class SpecialEmailUser extends UnlistedSpecialPage {
$user = User::newFromName( $search );
if ( !$user ) {
// No prefix suggestion for invalid user
- return array();
+ return [];
}
// Autocomplete subpage as user list - public to allow caching
return UserNamePrefixSearch::search( 'public', $search, $limit, $offset );
diff --git a/includes/specials/SpecialExpandTemplates.php b/includes/specials/SpecialExpandTemplates.php
index 00f6609826..ca0d13930e 100644
--- a/includes/specials/SpecialExpandTemplates.php
+++ b/includes/specials/SpecialExpandTemplates.php
@@ -107,7 +107,7 @@ class SpecialExpandTemplates extends SpecialPage {
if ( $this->removeNowiki ) {
$tmp = preg_replace(
- array( '_<nowiki>_', '_</nowiki>_', '_<nowiki */>_' ),
+ [ '_<nowiki>_', '_</nowiki>_', '_<nowiki */>_' ],
'',
$tmp
);
@@ -154,8 +154,8 @@ class SpecialExpandTemplates extends SpecialPage {
* @return string
*/
private function makeForm( $title, $input ) {
- $fields = array(
- 'contexttitle' => array(
+ $fields = [
+ 'contexttitle' => [
'type' => 'text',
'label' => $this->msg( 'expand_templates_title' )->plain(),
'name' => 'wpContextTitle',
@@ -164,51 +164,51 @@ class SpecialExpandTemplates extends SpecialPage {
'default' => $title,
'autofocus' => true,
'cssclass' => 'mw-ui-input-inline',
- ),
- 'input' => array(
+ ],
+ 'input' => [
'type' => 'textarea',
'name' => 'wpInput',
'label' => $this->msg( 'expand_templates_input' )->text(),
'rows' => 10,
'default' => $input,
'id' => 'input',
- ),
- 'removecomments' => array(
+ ],
+ 'removecomments' => [
'type' => 'check',
'label' => $this->msg( 'expand_templates_remove_comments' )->text(),
'name' => 'wpRemoveComments',
'id' => 'removecomments',
'default' => $this->removeComments,
- ),
- 'removenowiki' => array(
+ ],
+ 'removenowiki' => [
'type' => 'check',
'label' => $this->msg( 'expand_templates_remove_nowiki' )->text(),
'name' => 'wpRemoveNowiki',
'id' => 'removenowiki',
'default' => $this->removeNowiki,
- ),
- 'generate_xml' => array(
+ ],
+ 'generate_xml' => [
'type' => 'check',
'label' => $this->msg( 'expand_templates_generate_xml' )->text(),
'name' => 'wpGenerateXml',
'id' => 'generate_xml',
'default' => $this->generateXML,
- ),
- 'generate_rawhtml' => array(
+ ],
+ 'generate_rawhtml' => [
'type' => 'check',
'label' => $this->msg( 'expand_templates_generate_rawhtml' )->text(),
'name' => 'wpGenerateRawHtml',
'id' => 'generate_rawhtml',
'default' => $this->generateRawHtml,
- ),
- );
+ ],
+ ];
$form = HTMLForm::factory( 'ooui', $fields, $this->getContext() );
$form
->setSubmitTextMsg( 'expand_templates_ok' )
->setWrapperLegendMsg( 'expandtemplates' )
->setHeaderText( $this->msg( 'expand_templates_intro' )->parse() )
- ->setSubmitCallback( array( $this, 'onSubmitInput' ) )
+ ->setSubmitCallback( [ $this, 'onSubmitInput' ] )
->showAlways();
}
@@ -226,7 +226,7 @@ class SpecialExpandTemplates extends SpecialPage {
$output,
10,
10,
- array( 'id' => 'output', 'readonly' => 'readonly' )
+ [ 'id' => 'output', 'readonly' => 'readonly' ]
);
return $out;
@@ -267,9 +267,9 @@ class SpecialExpandTemplates extends SpecialPage {
// does not currently provide logged-out users with CSRF protection; in that case,
// do not show the preview unless anonymous editing is allowed.
if ( $user->isAnon() && !$user->isAllowed( 'edit' ) ) {
- $error = array( 'expand_templates_preview_fail_html_anon' );
+ $error = [ 'expand_templates_preview_fail_html_anon' ];
} elseif ( !$user->matchEditToken( $request->getVal( 'wpEditToken' ), '', $request ) ) {
- $error = array( 'expand_templates_preview_fail_html' );
+ $error = [ 'expand_templates_preview_fail_html' ];
} else {
$error = false;
}
@@ -280,11 +280,11 @@ class SpecialExpandTemplates extends SpecialPage {
}
}
- $out->addHTML( Html::openElement( 'div', array(
+ $out->addHTML( Html::openElement( 'div', [
'class' => 'mw-content-' . $lang->getDir(),
'dir' => $lang->getDir(),
'lang' => $lang->getHtmlCode(),
- ) ) );
+ ] ) );
$out->addParserOutputContent( $pout );
$out->addHTML( Html::closeElement( 'div' ) );
$out->setCategoryLinks( $pout->getCategories() );
diff --git a/includes/specials/SpecialExport.php b/includes/specials/SpecialExport.php
index f9b50504f5..ede367ee08 100644
--- a/includes/specials/SpecialExport.php
+++ b/includes/specials/SpecialExport.php
@@ -109,11 +109,11 @@ class SpecialExport extends SpecialPage {
$maxHistory = $config->get( 'ExportMaxHistory' );
$limit = $request->getInt( 'limit' );
$dir = $request->getVal( 'dir' );
- $history = array(
+ $history = [
'dir' => 'asc',
'offset' => false,
'limit' => $maxHistory,
- );
+ ];
$historyCheck = $request->getCheck( 'history' );
if ( $this->curonly ) {
@@ -189,8 +189,8 @@ class SpecialExport extends SpecialPage {
$categoryName = '';
}
- $formDescriptor = array(
- 'catname' => array(
+ $formDescriptor = [
+ 'catname' => [
'type' => 'textwithbutton',
'name' => 'catname',
'horizontal-label' => true,
@@ -200,11 +200,11 @@ class SpecialExport extends SpecialPage {
'buttontype' => 'submit',
'buttonname' => 'addcat',
'buttondefault' => $this->msg( 'export-addcat' )->text(),
- ),
- );
+ ],
+ ];
if ( $config->get( 'ExportFromNamespaces' ) ) {
- $formDescriptor += array(
- 'nsindex' => array(
+ $formDescriptor += [
+ 'nsindex' => [
'type' => 'namespaceselectwithbutton',
'default' => $nsindex,
'label-message' => 'export-addnstext',
@@ -215,90 +215,90 @@ class SpecialExport extends SpecialPage {
'buttontype' => 'submit',
'buttonname' => 'addns',
'buttondefault' => $this->msg( 'export-addns' )->text(),
- ),
- );
+ ],
+ ];
}
if ( $config->get( 'ExportAllowAll' ) ) {
- $formDescriptor += array(
- 'exportall' => array(
+ $formDescriptor += [
+ 'exportall' => [
'type' => 'check',
'label-message' => 'exportall',
'name' => 'exportall',
'id' => 'exportall',
'default' => $request->wasPosted() ? $request->getCheck( 'exportall' ) : false,
- ),
- );
+ ],
+ ];
}
- $formDescriptor += array(
- 'textarea' => array(
+ $formDescriptor += [
+ 'textarea' => [
'class' => 'HTMLTextAreaField',
'name' => 'pages',
'label-message' => 'export-manual',
'nodata' => true,
'rows' => 10,
'default' => $page,
- ),
- );
+ ],
+ ];
if ( $config->get( 'ExportAllowHistory' ) ) {
- $formDescriptor += array(
- 'curonly' => array(
+ $formDescriptor += [
+ 'curonly' => [
'type' => 'check',
'label-message' => 'exportcuronly',
'name' => 'curonly',
'id' => 'curonly',
'default' => $request->wasPosted() ? $request->getCheck( 'curonly' ) : true,
- ),
- );
+ ],
+ ];
} else {
$out->addWikiMsg( 'exportnohistory' );
}
- $formDescriptor += array(
- 'templates' => array(
+ $formDescriptor += [
+ 'templates' => [
'type' => 'check',
'label-message' => 'export-templates',
'name' => 'templates',
'id' => 'wpExportTemplates',
'default' => $request->wasPosted() ? $request->getCheck( 'templates' ) : false,
- ),
- );
+ ],
+ ];
if ( $config->get( 'ExportMaxLinkDepth' ) || $this->userCanOverrideExportDepth() ) {
- $formDescriptor += array(
- 'pagelink-depth' => array(
+ $formDescriptor += [
+ 'pagelink-depth' => [
'type' => 'text',
'name' => 'pagelink-depth',
'id' => 'pagelink-depth',
'label-message' => 'export-pagelinks',
'default' => '0',
'size' => 20,
- ),
- );
+ ],
+ ];
}
- $formDescriptor += array(
- 'wpDownload' => array(
+ $formDescriptor += [
+ 'wpDownload' => [
'type' => 'check',
'name' =>'wpDownload',
'id' => 'wpDownload',
'default' => $request->wasPosted() ? $request->getCheck( 'wpDownload' ) : true,
'label-message' => 'export-download',
- ),
- );
+ ],
+ ];
if ( $config->get( 'ExportAllowListContributors' ) ) {
- $formDescriptor += array(
- 'listauthors' => array(
+ $formDescriptor += [
+ 'listauthors' => [
'type' => 'check',
'label-message' => 'exportlistauthors',
'default' => $request->wasPosted() ? $request->getCheck( 'listauthors' ) : false,
'name' => 'listauthors',
'id' => 'listauthors',
- ),
- );
+ ],
+ ];
}
$htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() );
@@ -329,7 +329,7 @@ class SpecialExport extends SpecialPage {
if ( $exportall ) {
$history = WikiExporter::FULL;
} else {
- $pageSet = array(); // Inverted index of all pages to look up
+ $pageSet = []; // Inverted index of all pages to look up
// Split up and normalize input
foreach ( explode( "\n", $page ) as $pageName ) {
@@ -424,14 +424,14 @@ class SpecialExport extends SpecialPage {
$dbr = wfGetDB( DB_SLAVE );
$res = $dbr->select(
- array( 'page', 'categorylinks' ),
- array( 'page_namespace', 'page_title' ),
- array( 'cl_from=page_id', 'cl_to' => $name ),
+ [ 'page', 'categorylinks' ],
+ [ 'page_namespace', 'page_title' ],
+ [ 'cl_from=page_id', 'cl_to' => $name ],
__METHOD__,
- array( 'LIMIT' => $maxPages )
+ [ 'LIMIT' => $maxPages ]
);
- $pages = array();
+ $pages = [];
foreach ( $res as $row ) {
$n = $row->page_title;
@@ -458,13 +458,13 @@ class SpecialExport extends SpecialPage {
$dbr = wfGetDB( DB_SLAVE );
$res = $dbr->select(
'page',
- array( 'page_namespace', 'page_title' ),
- array( 'page_namespace' => $nsindex ),
+ [ 'page_namespace', 'page_title' ],
+ [ 'page_namespace' => $nsindex ],
__METHOD__,
- array( 'LIMIT' => $maxPages )
+ [ 'LIMIT' => $maxPages ]
);
- $pages = array();
+ $pages = [];
foreach ( $res as $row ) {
$n = $row->page_title;
@@ -489,8 +489,8 @@ class SpecialExport extends SpecialPage {
private function getTemplates( $inputPages, $pageSet ) {
return $this->getLinks( $inputPages, $pageSet,
'templatelinks',
- array( 'namespace' => 'tl_namespace', 'title' => 'tl_title' ),
- array( 'page_id=tl_from' )
+ [ 'namespace' => 'tl_namespace', 'title' => 'tl_title' ],
+ [ 'page_id=tl_from' ]
);
}
@@ -533,8 +533,8 @@ class SpecialExport extends SpecialPage {
// @codingStandardsIgnoreEnd
$pageSet = $this->getLinks(
$inputPages, $pageSet, 'pagelinks',
- array( 'namespace' => 'pl_namespace', 'title' => 'pl_title' ),
- array( 'page_id=pl_from' )
+ [ 'namespace' => 'pl_namespace', 'title' => 'pl_title' ],
+ [ 'page_id=pl_from' ]
);
$inputPages = array_keys( $pageSet );
}
@@ -562,14 +562,14 @@ class SpecialExport extends SpecialPage {
/// @todo FIXME: May or may not be more efficient to batch these
/// by namespace when given multiple input pages.
$result = $dbr->select(
- array( 'page', $table ),
+ [ 'page', $table ],
$fields,
array_merge(
$join,
- array(
+ [
'page_namespace' => $title->getNamespace(),
'page_title' => $title->getDBkey()
- )
+ ]
),
__METHOD__
);
diff --git a/includes/specials/SpecialFewestrevisions.php b/includes/specials/SpecialFewestrevisions.php
index 406233b475..b86a95e8aa 100644
--- a/includes/specials/SpecialFewestrevisions.php
+++ b/includes/specials/SpecialFewestrevisions.php
@@ -41,27 +41,27 @@ class FewestrevisionsPage extends QueryPage {
}
public function getQueryInfo() {
- return array(
- 'tables' => array( 'revision', 'page' ),
- 'fields' => array(
+ return [
+ 'tables' => [ 'revision', 'page' ],
+ 'fields' => [
'namespace' => 'page_namespace',
'title' => 'page_title',
'value' => 'COUNT(*)',
'redirect' => 'page_is_redirect'
- ),
- 'conds' => array(
+ ],
+ 'conds' => [
'page_namespace' => MWNamespace::getContentNamespaces(),
- 'page_id = rev_page' ),
- 'options' => array(
+ 'page_id = rev_page' ],
+ 'options' => [
'HAVING' => 'COUNT(*) > 1',
// ^^^ This was probably here to weed out redirects.
// Since we mark them as such now, it might be
// useful to remove this. People _do_ create pages
// and never revise them, they aren't necessarily
// redirects.
- 'GROUP BY' => array( 'page_namespace', 'page_title', 'page_is_redirect' )
- )
- );
+ 'GROUP BY' => [ 'page_namespace', 'page_title', 'page_is_redirect' ]
+ ]
+ ];
}
function sortDescending() {
@@ -80,7 +80,7 @@ class FewestrevisionsPage extends QueryPage {
if ( !$nt ) {
return Html::element(
'span',
- array( 'class' => 'mw-invalidtitle' ),
+ [ 'class' => 'mw-invalidtitle' ],
Linker::getInvalidTitleDescription(
$this->getContext(),
$result->namespace,
@@ -98,8 +98,8 @@ class FewestrevisionsPage extends QueryPage {
$nlink = Linker::linkKnown(
$nt,
$nl,
- array(),
- array( 'action' => 'history' )
+ [],
+ [ 'action' => 'history' ]
) . $redirect;
return $this->getLanguage()->specialList( $plink, $nlink );
diff --git a/includes/specials/SpecialFileDuplicateSearch.php b/includes/specials/SpecialFileDuplicateSearch.php
index 9970dfa971..35861e3dfb 100644
--- a/includes/specials/SpecialFileDuplicateSearch.php
+++ b/includes/specials/SpecialFileDuplicateSearch.php
@@ -53,7 +53,7 @@ class FileDuplicateSearchPage extends QueryPage {
}
function linkParameters() {
- return array( 'filename' => $this->filename );
+ return [ 'filename' => $this->filename ];
}
/**
@@ -70,7 +70,7 @@ class FileDuplicateSearchPage extends QueryPage {
* @param array $dupes Array of File objects
*/
function showList( $dupes ) {
- $html = array();
+ $html = [];
$html[] = $this->openList( 0 );
foreach ( $dupes as $dupe ) {
@@ -83,16 +83,16 @@ class FileDuplicateSearchPage extends QueryPage {
}
public function getQueryInfo() {
- return array(
- 'tables' => array( 'image' ),
- 'fields' => array(
+ return [
+ 'tables' => [ 'image' ],
+ 'fields' => [
'title' => 'img_name',
'value' => 'img_sha1',
'img_user_text',
'img_timestamp'
- ),
- 'conds' => array( 'img_sha1' => $this->hash )
- );
+ ],
+ 'conds' => [ 'img_sha1' => $this->hash ]
+ ];
}
public function execute( $par ) {
@@ -110,8 +110,8 @@ class FileDuplicateSearchPage extends QueryPage {
$out = $this->getOutput();
# Create the input form
- $formFields = array(
- 'filename' => array(
+ $formFields = [
+ 'filename' => [
'type' => 'text',
'name' => 'filename',
'label-message' => 'fileduplicatesearch-filename',
@@ -119,11 +119,11 @@ class FileDuplicateSearchPage extends QueryPage {
'size' => 50,
'value' => $this->filename,
'cssclass' => 'mw-ui-input-inline'
- ),
- );
- $hiddenFields = array(
+ ],
+ ];
+ $hiddenFields = [
'title' => $this->getPageTitle()->getPrefixedDBKey(),
- );
+ ];
$htmlForm = HTMLForm::factory( 'inline', $formFields, $this->getContext() );
$htmlForm->addHiddenFields( $hiddenFields );
$htmlForm->setAction( wfScript() );
@@ -141,7 +141,7 @@ class FileDuplicateSearchPage extends QueryPage {
} elseif ( $this->filename !== '' ) {
$out->wrapWikiMsg(
" \n$1\n ", - array( 'fileduplicatesearch-noresults', wfEscapeWikiText( $this->filename ) ) + [ 'fileduplicatesearch-noresults', wfEscapeWikiText( $this->filename ) ] ); } @@ -149,11 +149,11 @@ class FileDuplicateSearchPage extends QueryPage { # Show a thumbnail of the file $img = $this->file; if ( $img ) { - $thumb = $img->transform( array( 'width' => 120, 'height' => 120 ) ); + $thumb = $img->transform( [ 'width' => 120, 'height' => 120 ] ); if ( $thumb ) { $out->addModuleStyles( 'mediawiki.special' ); $out->addHTML( '' .
- $thumb->toHtml( array( 'desc-link' => false ) ) . ' ' . + $thumb->toHtml( [ 'desc-link' => false ] ) . ' ' . $this->msg( 'fileduplicatesearch-info' )->numParams( $img->getWidth(), $img->getHeight() )->params( $this->getLanguage()->formatSize( $img->getSize() ), @@ -169,13 +169,13 @@ class FileDuplicateSearchPage extends QueryPage { if ( $numRows == 1 ) { $out->wrapWikiMsg( " \n$1\n ", - array( 'fileduplicatesearch-result-1', wfEscapeWikiText( $this->filename ) ) + [ 'fileduplicatesearch-result-1', wfEscapeWikiText( $this->filename ) ] ); } elseif ( $numRows ) { $out->wrapWikiMsg( "\n$1\n ", - array( 'fileduplicatesearch-result-n', wfEscapeWikiText( $this->filename ), - $this->getLanguage()->formatNum( $numRows - 1 ) ) + [ 'fileduplicatesearch-result-n', wfEscapeWikiText( $this->filename ), + $this->getLanguage()->formatNum( $numRows - 1 ) ] ); } @@ -244,12 +244,12 @@ class FileDuplicateSearchPage extends QueryPage { $title = Title::newFromText( $search, NS_FILE ); if ( !$title || $title->getNamespace() !== NS_FILE ) { // No prefix suggestion outside of file namespace - return array(); + return []; } $search = SearchEngine::create(); $search->setLimitOffset( $limit, $offset ); // Autocomplete subpage the same as a normal search, but just for files - $search->setNamespaces( array( NS_FILE ) ); + $search->setNamespaces( [ NS_FILE ] ); $result = $search->defaultPrefixSearch( $search ); return array_map( function ( Title $t ) { diff --git a/includes/specials/SpecialFilepath.php b/includes/specials/SpecialFilepath.php index 542589f333..49caaa3a1d 100644 --- a/includes/specials/SpecialFilepath.php +++ b/includes/specials/SpecialFilepath.php @@ -29,7 +29,7 @@ class SpecialFilepath extends RedirectSpecialPage { public function __construct() { parent::__construct( 'Filepath' ); - $this->mAllowedRedirectParams = array( 'width', 'height' ); + $this->mAllowedRedirectParams = [ 'width', 'height' ]; } /** diff --git a/includes/specials/SpecialImport.php b/includes/specials/SpecialImport.php index 0574dbc115..72f8cca28f 100644 --- a/includes/specials/SpecialImport.php +++ b/includes/specials/SpecialImport.php @@ -72,7 +72,7 @@ class SpecialImport extends SpecialPage { $this->getOutput()->addModules( 'mediawiki.special.import' ); $this->importSources = $this->getConfig()->get( 'ImportSources' ); - Hooks::run( 'ImportSources', array( &$this->importSources ) ); + Hooks::run( 'ImportSources', [ &$this->importSources ] ); $user = $this->getUser(); if ( !$user->isAllowedAny( 'import', 'importupload' ) ) { @@ -85,11 +85,11 @@ class SpecialImport extends SpecialPage { $errors = wfMergeErrorArrays( $this->getPageTitle()->getUserPermissionsErrors( 'import', $user, true, - array( 'ns-specialprotected', 'badaccess-group0', 'badaccess-groups' ) + [ 'ns-specialprotected', 'badaccess-group0', 'badaccess-groups' ] ), $this->getPageTitle()->getUserPermissionsErrors( 'importupload', $user, true, - array( 'ns-specialprotected', 'badaccess-group0', 'badaccess-groups' ) + [ 'ns-specialprotected', 'badaccess-group0', 'badaccess-groups' ] ) ); @@ -176,7 +176,7 @@ class SpecialImport extends SpecialPage { if ( !$source->isGood() ) { $out->wrapWikiMsg( "\n$1\n ", - array( 'importfailed', $source->getWikiText() ) + [ 'importfailed', $source->getWikiText() ] ); } else { $importer = new WikiImporter( $source->value, $this->getConfig() ); @@ -187,11 +187,11 @@ class SpecialImport extends SpecialPage { if ( !$statusRootPage->isGood() ) { $out->wrapWikiMsg( "\n$1\n ", - array( + [ 'import-options-wrong', $statusRootPage->getWikiText(), count( $statusRootPage->getErrorsArray() ) - ) + ] ); return; @@ -221,13 +221,13 @@ class SpecialImport extends SpecialPage { # No source or XML parse error $out->wrapWikiMsg( "\n$1\n ", - array( 'importfailed', $exception->getMessage() ) + [ 'importfailed', $exception->getMessage() ] ); } elseif ( !$result->isGood() ) { # Zero revisions $out->wrapWikiMsg( "\n$1\n ", - array( 'importfailed', $result->getWikiText() ) + [ 'importfailed', $result->getWikiText() ] ); } else { # Success! @@ -271,16 +271,16 @@ class SpecialImport extends SpecialPage { !is_null( $defaultNamespace ) ) ) . ' ' . Html::namespaceSelector( - array( + [ 'selected' => ( $isSameSourceAsBefore ? $this->namespace : ( $defaultNamespace || '' ) ), - ), array( + ], [ 'name' => "namespace", // mw-import-namespace-interwiki, mw-import-namespace-upload 'id' => "mw-import-namespace-$sourceName", 'class' => 'namespaceselector', - ) + ] ) . " |
|
" . Xml::label( $this->msg( 'import-upload-filename' )->text(), 'xmlimport' ) . " | " . - Html::input( 'xmlimport', '', 'file', array( 'id' => 'xmlimport' ) ) . ' ' . + Html::input( 'xmlimport', '', 'file', [ 'id' => 'xmlimport' ] ) . ' ' . " | |
" . Xml::input( 'log-comment', 50, ( $this->sourceName === 'upload' ? $this->logcomment : '' ), - array( 'id' => 'mw-import-comment', 'type' => 'text' ) ) . ' ' . + [ 'id' => 'mw-import-comment', 'type' => 'text' ] ) . ' ' . " | ||
" . Xml::label( $this->msg( 'import-interwiki-sourcewiki' )->text(), 'interwiki' ) . @@ -406,7 +406,7 @@ class SpecialImport extends SpecialPage { | " . Xml::openElement( 'select', - array( 'name' => 'interwiki', 'id' => 'interwiki' ) + [ 'name' => 'interwiki', 'id' => 'interwiki' ] ) ); @@ -418,9 +418,9 @@ class SpecialImport extends SpecialPage { $needSubprojectField = true; } - $attribs = array( + $attribs = [ 'value' => $key, - ); + ]; if ( is_array( $value ) ) { $attribs['data-subprojects'] = implode( ' ', $value ); } @@ -438,11 +438,11 @@ class SpecialImport extends SpecialPage { $out->addHTML( Xml::openElement( 'select', - array( 'name' => 'subproject', 'id' => 'subproject' ) + [ 'name' => 'subproject', 'id' => 'subproject' ] ) ); - $subprojectsToAdd = array(); + $subprojectsToAdd = []; foreach ( $this->importSources as $key => $value ) { if ( is_array( $value ) ) { $subprojectsToAdd = array_merge( $subprojectsToAdd, $value ); @@ -467,7 +467,7 @@ class SpecialImport extends SpecialPage { Xml::label( $this->msg( 'import-interwiki-sourcepage' )->text(), 'frompage' ) . " | " . - Xml::input( 'frompage', 50, $this->frompage, array( 'id' => 'frompage' ) ) . + Xml::input( 'frompage', 50, $this->frompage, [ 'id' => 'frompage' ] ) . " |
" . Xml::input( 'log-comment', 50, ( $this->sourceName === 'interwiki' ? $this->logcomment : '' ), - array( 'id' => 'mw-interwiki-comment', 'type' => 'text' ) ) . ' ' . + [ 'id' => 'mw-interwiki-comment', 'type' => 'text' ] ) . ' ' . " | ||
" . $this->msg( "grant-$grant" )->escaped() . " | " . "" . $grantCellHtml . ' | ' ) ); diff --git a/includes/specials/SpecialListgrouprights.php b/includes/specials/SpecialListgrouprights.php index 241db93b96..d64306beab 100644 --- a/includes/specials/SpecialListgrouprights.php +++ b/includes/specials/SpecialListgrouprights.php @@ -47,7 +47,7 @@ class SpecialListGroupRights extends SpecialPage { $out->wrapWikiMsg( "|
$grouppage$grouplink | " .
$this->formatPermissions( $permissions, $revoke, $addgroups, $removegroups,
@@ -149,19 +149,19 @@ class SpecialListGroupRights extends SpecialPage {
$header = $this->msg( 'listgrouprights-namespaceprotection-header' )->parse();
$out->addHTML(
- Html::rawElement( 'h2', array(), Html::element( 'span', array(
+ Html::rawElement( 'h2', [], Html::element( 'span', [
'class' => 'mw-headline',
'id' => $wgParser->guessSectionNameFromWikiText( $header )
- ), $header ) ) .
- Xml::openElement( 'table', array( 'class' => 'wikitable' ) ) .
+ ], $header ) ) .
+ Xml::openElement( 'table', [ 'class' => 'wikitable' ] ) .
Html::element(
'th',
- array(),
+ [],
$this->msg( 'listgrouprights-namespaceprotection-namespace' )->text()
) .
Html::element(
'th',
- array(),
+ [],
$this->msg( 'listgrouprights-namespaceprotection-restrictedto' )->text()
)
);
@@ -182,29 +182,29 @@ class SpecialListGroupRights extends SpecialPage {
Xml::openElement( 'tr' ) .
Html::rawElement(
'td',
- array(),
+ [],
Linker::link(
SpecialPage::getTitleFor( 'Allpages' ),
htmlspecialchars( $namespaceText ),
- array(),
- array( 'namespace' => $namespace )
+ [],
+ [ 'namespace' => $namespace ]
)
) .
Xml::openElement( 'td' ) . Xml::openElement( 'ul' )
);
if ( !is_array( $rights ) ) {
- $rights = array( $rights );
+ $rights = [ $rights ];
}
foreach ( $rights as $right ) {
$out->addHTML(
- Html::rawElement( 'li', array(), $this->msg(
+ Html::rawElement( 'li', [], $this->msg(
'listgrouprights-right-display',
User::getRightDescription( $right ),
Html::element(
'span',
- array( 'class' => 'mw-listgrouprights-right-name' ),
+ [ 'class' => 'mw-listgrouprights-right-name' ],
$right
)
)->parse() )
@@ -232,7 +232,7 @@ class SpecialListGroupRights extends SpecialPage {
* @return string List of all granted permissions, separated by comma separator
*/
private function formatPermissions( $permissions, $revoke, $add, $remove, $addSelf, $removeSelf ) {
- $r = array();
+ $r = [];
foreach ( $permissions as $permission => $granted ) {
// show as granted only if it isn't revoked to prevent duplicate display of permissions
if ( $granted && ( !isset( $revoke[$permission] ) || !$revoke[$permission] ) ) {
@@ -256,12 +256,12 @@ class SpecialListGroupRights extends SpecialPage {
$lang = $this->getLanguage();
$allGroups = User::getAllGroups();
- $changeGroups = array(
+ $changeGroups = [
'addgroup' => $add,
'removegroup' => $remove,
'addgroup-self' => $addSelf,
'removegroup-self' => $removeSelf
- );
+ ];
foreach ( $changeGroups as $messageKey => $changeGroup ) {
if ( $changeGroup === true ) {
@@ -274,7 +274,7 @@ class SpecialListGroupRights extends SpecialPage {
// For grep: listgrouprights-addgroup, listgrouprights-removegroup,
// listgrouprights-addgroup-self, listgrouprights-removegroup-self
$r[] = $this->msg( 'listgrouprights-' . $messageKey,
- $lang->listToText( array_map( array( 'User', 'makeGroupLinkWiki' ), $changeGroup ) ),
+ $lang->listToText( array_map( [ 'User', 'makeGroupLinkWiki' ], $changeGroup ) ),
count( $changeGroup )
)->parse();
}
diff --git a/includes/specials/SpecialListredirects.php b/includes/specials/SpecialListredirects.php
index fa94b4ab68..ace6d02cb2 100644
--- a/includes/specials/SpecialListredirects.php
+++ b/includes/specials/SpecialListredirects.php
@@ -46,27 +46,27 @@ class ListredirectsPage extends QueryPage {
}
public function getQueryInfo() {
- return array(
- 'tables' => array( 'p1' => 'page', 'redirect', 'p2' => 'page' ),
- 'fields' => array( 'namespace' => 'p1.page_namespace',
+ return [
+ 'tables' => [ 'p1' => 'page', 'redirect', 'p2' => 'page' ],
+ 'fields' => [ 'namespace' => 'p1.page_namespace',
'title' => 'p1.page_title',
'value' => 'p1.page_title',
'rd_namespace',
'rd_title',
'rd_fragment',
'rd_interwiki',
- 'redirid' => 'p2.page_id' ),
- 'conds' => array( 'p1.page_is_redirect' => 1 ),
- 'join_conds' => array( 'redirect' => array(
- 'LEFT JOIN', 'rd_from=p1.page_id' ),
- 'p2' => array( 'LEFT JOIN', array(
+ 'redirid' => 'p2.page_id' ],
+ 'conds' => [ 'p1.page_is_redirect' => 1 ],
+ 'join_conds' => [ 'redirect' => [
+ 'LEFT JOIN', 'rd_from=p1.page_id' ],
+ 'p2' => [ 'LEFT JOIN', [
'p2.page_namespace=rd_namespace',
- 'p2.page_title=rd_title' ) ) )
- );
+ 'p2.page_title=rd_title' ] ] ]
+ ];
}
function getOrderFields() {
- return array( 'p1.page_namespace', 'p1.page_title' );
+ return [ 'p1.page_namespace', 'p1.page_title' ];
}
/**
@@ -116,8 +116,8 @@ class ListredirectsPage extends QueryPage {
$rd_link = Linker::link(
$rd_title,
null,
- array(),
- array( 'redirect' => 'no' )
+ [],
+ [ 'redirect' => 'no' ]
);
# Find out where the redirect leads
diff --git a/includes/specials/SpecialListusers.php b/includes/specials/SpecialListusers.php
index d43a263f7e..da31f009a2 100644
--- a/includes/specials/SpecialListusers.php
+++ b/includes/specials/SpecialListusers.php
@@ -53,7 +53,7 @@ class UsersPager extends AlphabeticPager {
$request = $this->getRequest();
$par = ( $par !== null ) ? $par : '';
$parms = explode( '/', $par );
- $symsForAll = array( '*', 'user' );
+ $symsForAll = [ '*', 'user' ];
if ( $parms[0] != '' &&
( in_array( $par, User::getAllGroups() ) || in_array( $par, $symsForAll ) )
@@ -103,14 +103,14 @@ class UsersPager extends AlphabeticPager {
*/
function getQueryInfo() {
$dbr = wfGetDB( DB_SLAVE );
- $conds = array();
+ $conds = [];
// Don't show hidden names
if ( !$this->getUser()->isAllowed( 'hideuser' ) ) {
$conds[] = 'ipb_deleted IS NULL OR ipb_deleted = 0';
}
- $options = array();
+ $options = [];
if ( $this->requestedGroup != '' ) {
$conds['ug_group'] = $this->requestedGroup;
@@ -131,29 +131,29 @@ class UsersPager extends AlphabeticPager {
$options['GROUP BY'] = $this->creationSort ? 'user_id' : 'user_name';
- $query = array(
- 'tables' => array( 'user', 'user_groups', 'ipblocks' ),
- 'fields' => array(
+ $query = [
+ 'tables' => [ 'user', 'user_groups', 'ipblocks' ],
+ 'fields' => [
'user_name' => $this->creationSort ? 'MAX(user_name)' : 'user_name',
'user_id' => $this->creationSort ? 'user_id' : 'MAX(user_id)',
'edits' => 'MAX(user_editcount)',
'creation' => 'MIN(user_registration)',
'ipb_deleted' => 'MAX(ipb_deleted)' // block/hide status
- ),
+ ],
'options' => $options,
- 'join_conds' => array(
- 'user_groups' => array( 'LEFT JOIN', 'user_id=ug_user' ),
- 'ipblocks' => array(
- 'LEFT JOIN', array(
+ 'join_conds' => [
+ 'user_groups' => [ 'LEFT JOIN', 'user_id=ug_user' ],
+ 'ipblocks' => [
+ 'LEFT JOIN', [
'user_id=ipb_user',
'ipb_auto' => 0
- )
- ),
- ),
+ ]
+ ],
+ ],
'conds' => $conds
- );
+ ];
- Hooks::run( 'SpecialListusersQueryInfo', array( $this, &$query ) );
+ Hooks::run( 'SpecialListusersQueryInfo', [ $this, &$query ] );
return $query;
}
@@ -182,7 +182,7 @@ class UsersPager extends AlphabeticPager {
$groups_list = self::getGroups( intval( $row->user_id ), $this->userGroupCache );
if ( !$this->including && count( $groups_list ) > 0 ) {
- $list = array();
+ $list = [];
foreach ( $groups_list as $group ) {
$list[] = self::buildGroupLink( $group, $userName );
}
@@ -214,14 +214,14 @@ class UsersPager extends AlphabeticPager {
' ' . $this->msg( 'listusers-blocked', $userName )->escaped() :
'';
- Hooks::run( 'SpecialListusersFormatRow', array( &$item, $row ) );
+ Hooks::run( 'SpecialListusersFormatRow', [ &$item, $row ] );
- return Html::rawElement( 'li', array(), "{$item}{$edits}{$created}{$blocked}" );
+ return Html::rawElement( 'li', [], "{$item}{$edits}{$created}{$blocked}" );
}
function doBatchLookups() {
$batch = new LinkBatch();
- $userIds = array();
+ $userIds = [];
# Give some pointers to make user links
foreach ( $this->mResult as $row ) {
$batch->add( NS_USER, $row->user_name );
@@ -233,12 +233,12 @@ class UsersPager extends AlphabeticPager {
$dbr = wfGetDB( DB_SLAVE );
$groupRes = $dbr->select(
'user_groups',
- array( 'ug_user', 'ug_group' ),
- array( 'ug_user' => $userIds ),
+ [ 'ug_user', 'ug_group' ],
+ [ 'ug_user' => $userIds ],
__METHOD__
);
- $cache = array();
- $groups = array();
+ $cache = [];
+ $groups = [];
foreach ( $groupRes as $row ) {
$cache[intval( $row->ug_user )][] = $row->ug_group;
$groups[$row->ug_group] = true;
@@ -268,7 +268,7 @@ class UsersPager extends AlphabeticPager {
# Form tag
$out = Xml::openElement(
'form',
- array( 'method' => 'get', 'action' => wfScript(), 'id' => 'mw-listusers-form' )
+ [ 'method' => 'get', 'action' => wfScript(), 'id' => 'mw-listusers-form' ]
) .
Xml::fieldset( $this->msg( 'listusers' )->text() ) .
Html::hidden( 'title', $self );
@@ -279,12 +279,12 @@ class UsersPager extends AlphabeticPager {
'username',
$this->requestedUser,
'text',
- array(
+ [
'class' => 'mw-autocomplete-user',
'id' => 'offset',
'size' => 20,
'autofocus' => $this->requestedUser === ''
- )
+ ]
) . ' ';
# Group drop-down list
@@ -318,12 +318,12 @@ class UsersPager extends AlphabeticPager {
);
$out .= ' '; - Hooks::run( 'SpecialListusersHeaderForm', array( $this, &$out ) ); + Hooks::run( 'SpecialListusersHeaderForm', [ $this, &$out ] ); # Submit button and form bottom $out .= Html::hidden( 'limit', $this->mLimit ); $out .= Xml::submitButton( $this->msg( 'listusers-submit' )->text() ); - Hooks::run( 'SpecialListusersHeader', array( $this, &$out ) ); + Hooks::run( 'SpecialListusersHeader', [ $this, &$out ] ); $out .= Xml::closeElement( 'fieldset' ) . Xml::closeElement( 'form' ); @@ -335,7 +335,7 @@ class UsersPager extends AlphabeticPager { * @return array */ function getAllGroups() { - $result = array(); + $result = []; foreach ( User::getAllGroups() as $group ) { $result[$group] = User::getGroupName( $group ); } @@ -356,7 +356,7 @@ class UsersPager extends AlphabeticPager { if ( $this->requestedUser != '' ) { $query['username'] = $this->requestedUser; } - Hooks::run( 'SpecialListusersDefaultQuery', array( $this, &$query ) ); + Hooks::run( 'SpecialListusersDefaultQuery', [ $this, &$query ] ); return $query; } @@ -373,7 +373,7 @@ class UsersPager extends AlphabeticPager { $user = User::newFromId( $uid ); $effectiveGroups = $user->getEffectiveGroups(); } else { - $effectiveGroups = isset( $cache[$uid] ) ? $cache[$uid] : array(); + $effectiveGroups = isset( $cache[$uid] ) ? $cache[$uid] : []; } $groups = array_diff( $effectiveGroups, User::getImplicitGroups() ); @@ -427,7 +427,7 @@ class SpecialListUsers extends IncludableSpecialPage { if ( $usersbody ) { $s .= $up->getNavigationBar(); - $s .= Html::rawElement( 'ul', array(), $usersbody ); + $s .= Html::rawElement( 'ul', [], $usersbody ); $s .= $up->getNavigationBar(); } else { $s .= $this->msg( 'listusers-noresult' )->parseAsBlock(); diff --git a/includes/specials/SpecialLockdb.php b/includes/specials/SpecialLockdb.php index 0d495a00cf..a229fa34f4 100644 --- a/includes/specials/SpecialLockdb.php +++ b/includes/specials/SpecialLockdb.php @@ -50,18 +50,18 @@ class SpecialLockdb extends FormSpecialPage { } protected function getFormFields() { - return array( - 'Reason' => array( + return [ + 'Reason' => [ 'type' => 'textarea', 'rows' => 4, 'vertical-label' => true, 'label-message' => 'enterlockreason', - ), - 'Confirm' => array( + ], + 'Confirm' => [ 'type' => 'toggle', 'label-message' => 'lockconfirm', - ), - ); + ], + ]; } protected function alterForm( HTMLForm $form ) { diff --git a/includes/specials/SpecialLog.php b/includes/specials/SpecialLog.php index a164c1e0d2..bec871b9e8 100644 --- a/includes/specials/SpecialLog.php +++ b/includes/specials/SpecialLog.php @@ -76,19 +76,19 @@ class SpecialLog extends SpecialPage { } # Handle type-specific inputs - $qc = array(); + $qc = []; if ( $opts->getValue( 'type' ) == 'suppress' ) { $offender = User::newFromName( $opts->getValue( 'offender' ), false ); if ( $offender && $offender->getId() > 0 ) { - $qc = array( 'ls_field' => 'target_author_id', 'ls_value' => $offender->getId() ); + $qc = [ 'ls_field' => 'target_author_id', 'ls_value' => $offender->getId() ]; } elseif ( $offender && IP::isIPAddress( $offender->getName() ) ) { - $qc = array( 'ls_field' => 'target_author_ip', 'ls_value' => $offender->getName() ); + $qc = [ 'ls_field' => 'target_author_ip', 'ls_value' => $offender->getName() ]; } } else { // Allow extensions to add relations to their search types Hooks::run( 'SpecialLogAddLogSearchRelations', - array( $opts->getValue( 'type' ), $this->getRequest(), &$qc ) + [ $opts->getValue( 'type' ), $this->getRequest(), &$qc ] ); } @@ -122,13 +122,13 @@ class SpecialLog extends SpecialPage { if ( $types !== null ) { return $types; } - $types = array( + $types = [ 'block', 'newusers', 'rights', - ); + ]; - Hooks::run( 'GetLogTypesOnUser', array( &$types ) ); + Hooks::run( 'GetLogTypesOnUser', [ &$types ] ); return $types; } @@ -147,7 +147,7 @@ class SpecialLog extends SpecialPage { private function parseParams( FormOptions $opts, $par ) { # Get parameters $parms = explode( '/', ( $par = ( $par !== null ) ? $par : '' ) ); - $symsForAll = array( '*', 'all' ); + $symsForAll = [ '*', 'all' ]; if ( $parms[0] != '' && ( in_array( $par, $this->getConfig()->get( 'LogTypes' ) ) || in_array( $par, $symsForAll ) ) ) { @@ -228,7 +228,7 @@ class SpecialLog extends SpecialPage { # Show button to hide log entries and/or edit change tags $s = Html::openElement( 'form', - array( 'action' => wfScript(), 'id' => 'mw-log-deleterevision-submit' ) + [ 'action' => wfScript(), 'id' => 'mw-log-deleterevision-submit' ] ) . "\n"; $s .= Html::hidden( 'action', 'historysubmit' ) . "\n"; $s .= Html::hidden( 'type', 'logging' ) . "\n"; @@ -237,47 +237,47 @@ class SpecialLog extends SpecialPage { if ( $canRevDelete ) { $buttons .= Html::element( 'button', - array( + [ 'type' => 'submit', 'name' => 'revisiondelete', 'value' => '1', 'class' => "deleterevision-log-submit mw-log-deleterevision-button" - ), + ], $this->msg( 'showhideselectedlogentries' )->text() ) . "\n"; } if ( $showTagEditUI ) { $buttons .= Html::element( 'button', - array( + [ 'type' => 'submit', 'name' => 'editchangetags', 'value' => '1', 'class' => "editchangetags-log-submit mw-log-editchangetags-button" - ), + ], $this->msg( 'log-edit-tags' )->text() ) . "\n"; } // Select: All, None, Invert - $links = array(); + $links = []; $links[] = Html::element( - 'a', array( 'href' => '#', 'class' => 'mw-checkbox-all' ), + 'a', [ 'href' => '#', 'class' => 'mw-checkbox-all' ], $this->msg( 'checkbox-all' )->text() ); $links[] = Html::element( - 'a', array( 'href' => '#', 'class' => 'mw-checkbox-none' ), + 'a', [ 'href' => '#', 'class' => 'mw-checkbox-none' ], $this->msg( 'checkbox-none' )->text() ); $links[] = Html::element( - 'a', array( 'href' => '#', 'class' => 'mw-checkbox-invert' ), + 'a', [ 'href' => '#', 'class' => 'mw-checkbox-invert' ], $this->msg( 'checkbox-invert' )->text() ); $buttons .= Html::rawElement( 'p', - array( + [ 'class' => "mw-checkbox-toggle-controls" - ), + ], $this->msg( 'checkbox-select' ) ->rawParams( $this->getLanguage()->commaList( $links ) )->escaped() ); diff --git a/includes/specials/SpecialLonelypages.php b/includes/specials/SpecialLonelypages.php index c072491b8e..ff76a4b47d 100644 --- a/includes/specials/SpecialLonelypages.php +++ b/includes/specials/SpecialLonelypages.php @@ -49,50 +49,50 @@ class LonelyPagesPage extends PageQueryPage { } function getQueryInfo() { - $tables = array( 'page', 'pagelinks', 'templatelinks' ); - $conds = array( + $tables = [ 'page', 'pagelinks', 'templatelinks' ]; + $conds = [ 'pl_namespace IS NULL', 'page_namespace' => MWNamespace::getContentNamespaces(), 'page_is_redirect' => 0, 'tl_namespace IS NULL' - ); - $joinConds = array( - 'pagelinks' => array( - 'LEFT JOIN', array( + ]; + $joinConds = [ + 'pagelinks' => [ + 'LEFT JOIN', [ 'pl_namespace = page_namespace', 'pl_title = page_title' - ) - ), - 'templatelinks' => array( - 'LEFT JOIN', array( + ] + ], + 'templatelinks' => [ + 'LEFT JOIN', [ 'tl_namespace = page_namespace', 'tl_title = page_title' - ) - ) - ); + ] + ] + ]; // Allow extensions to modify the query - Hooks::run( 'LonelyPagesQuery', array( &$tables, &$conds, &$joinConds ) ); + Hooks::run( 'LonelyPagesQuery', [ &$tables, &$conds, &$joinConds ] ); - return array( + return [ 'tables' => $tables, - 'fields' => array( + 'fields' => [ 'namespace' => 'page_namespace', 'title' => 'page_title', 'value' => 'page_title' - ), + ], 'conds' => $conds, 'join_conds' => $joinConds - ); + ]; } function getOrderFields() { // For some crazy reason ordering by a constant // causes a filesort in MySQL 5 if ( count( MWNamespace::getContentNamespaces() ) > 1 ) { - return array( 'page_namespace', 'page_title' ); + return [ 'page_namespace', 'page_title' ]; } else { - return array( 'page_title' ); + return [ 'page_title' ]; } } diff --git a/includes/specials/SpecialMIMEsearch.php b/includes/specials/SpecialMIMEsearch.php index 32344a84a8..defca7de3d 100644 --- a/includes/specials/SpecialMIMEsearch.php +++ b/includes/specials/SpecialMIMEsearch.php @@ -47,18 +47,18 @@ class MIMEsearchPage extends QueryPage { } function linkParameters() { - return array( 'mime' => "{$this->major}/{$this->minor}" ); + return [ 'mime' => "{$this->major}/{$this->minor}" ]; } public function getQueryInfo() { - $minorType = array(); + $minorType = []; if ( $this->minor !== '*' ) { // Allow wildcard searching $minorType['img_minor_mime'] = $this->minor; } - $qi = array( - 'tables' => array( 'image' ), - 'fields' => array( + $qi = [ + 'tables' => [ 'image' ], + 'fields' => [ 'namespace' => NS_FILE, 'title' => 'img_name', // Still have a value field just in case, @@ -69,12 +69,12 @@ class MIMEsearchPage extends QueryPage { 'img_height', 'img_user_text', 'img_timestamp' - ), - 'conds' => array( + ], + 'conds' => [ 'img_major_mime' => $this->major, // This is in order to trigger using // the img_media_mime index in "range" mode. - 'img_media_type' => array( + 'img_media_type' => [ MEDIATYPE_BITMAP, MEDIATYPE_DRAWING, MEDIATYPE_AUDIO, @@ -85,9 +85,9 @@ class MIMEsearchPage extends QueryPage { MEDIATYPE_TEXT, MEDIATYPE_EXECUTABLE, MEDIATYPE_ARCHIVE, - ), - ) + $minorType, - ); + ], + ] + $minorType, + ]; return $qi; } @@ -102,7 +102,7 @@ class MIMEsearchPage extends QueryPage { * @return array */ function getOrderFields() { - return array(); + return []; } /** @@ -111,7 +111,7 @@ class MIMEsearchPage extends QueryPage { function getPageHeader() { return Xml::openElement( 'form', - array( 'id' => 'specialmimesearch', 'method' => 'get', 'action' => wfScript() ) + [ 'id' => 'specialmimesearch', 'method' => 'get', 'action' => wfScript() ] ) . Xml::openElement( 'fieldset' ) . Html::hidden( 'title', $this->getPageTitle()->getPrefixedText() ) . @@ -178,7 +178,7 @@ class MIMEsearchPage extends QueryPage { */ protected static function isValidType( $type ) { // From maintenance/tables.sql => img_major_mime - $types = array( + $types = [ 'unknown', 'application', 'audio', @@ -189,7 +189,7 @@ class MIMEsearchPage extends QueryPage { 'model', 'multipart', 'chemical' - ); + ]; return in_array( $type, $types ); } diff --git a/includes/specials/SpecialMediaStatistics.php b/includes/specials/SpecialMediaStatistics.php index fb78a400bf..ed12e047c7 100644 --- a/includes/specials/SpecialMediaStatistics.php +++ b/includes/specials/SpecialMediaStatistics.php @@ -63,7 +63,7 @@ class MediaStatisticsPage extends QueryPage { */ public function getQueryInfo() { $dbr = wfGetDB( DB_SLAVE ); - $fakeTitle = $dbr->buildConcat( array( + $fakeTitle = $dbr->buildConcat( [ 'img_media_type', $dbr->addQuotes( ';' ), 'img_major_mime', @@ -73,26 +73,26 @@ class MediaStatisticsPage extends QueryPage { 'COUNT(*)', $dbr->addQuotes( ';' ), 'SUM( img_size )' - ) ); - return array( - 'tables' => array( 'image' ), - 'fields' => array( + ] ); + return [ + 'tables' => [ 'image' ], + 'fields' => [ 'title' => $fakeTitle, 'namespace' => NS_MEDIA, /* needs to be something */ 'value' => '1' - ), - 'conds' => array( + ], + 'conds' => [ // WMF has a random null row in the db 'img_media_type IS NOT NULL' - ), - 'options' => array( - 'GROUP BY' => array( + ], + 'options' => [ + 'GROUP BY' => [ 'img_media_type', 'img_major_mime', 'img_minor_mime', - ) - ) - ); + ] + ] + ]; } /** @@ -103,7 +103,7 @@ class MediaStatisticsPage extends QueryPage { * @return Array Fields to sort by */ function getOrderFields() { - return array( 'img_media_type', 'count(*)', 'img_major_mime', 'img_minor_mime' ); + return [ 'img_media_type', 'count(*)', 'img_major_mime', 'img_minor_mime' ]; } /** @@ -176,18 +176,18 @@ class MediaStatisticsPage extends QueryPage { $mimeSearch = SpecialPage::getTitleFor( 'MIMEsearch', $mime ); $row = Html::rawElement( 'td', - array(), + [], Linker::link( $mimeSearch, htmlspecialchars( $mime ) ) ); $row .= Html::element( 'td', - array(), + [], $this->getExtensionList( $mime ) ); $row .= Html::rawElement( 'td', // Make sure js sorts it in numeric order - array( 'data-sort-value' => $count ), + [ 'data-sort-value' => $count ], $this->msg( 'mediastatistics-nfiles' ) ->numParams( $count ) /** @todo Check to be sure this really should have number formatting */ @@ -197,7 +197,7 @@ class MediaStatisticsPage extends QueryPage { $row .= Html::rawElement( 'td', // Make sure js sorts it in numeric order - array( 'data-sort-value' => $bytes ), + [ 'data-sort-value' => $bytes ], $this->msg( 'mediastatistics-nbytes' ) ->numParams( $bytes ) ->sizeParams( $bytes ) @@ -206,7 +206,7 @@ class MediaStatisticsPage extends QueryPage { ->parse() ); $this->totalPerType += $bytes; - $this->getOutput()->addHTML( Html::rawElement( 'tr', array(), $row ) ); + $this->getOutput()->addHTML( Html::rawElement( 'tr', [], $row ) ); } /** @@ -256,12 +256,12 @@ class MediaStatisticsPage extends QueryPage { $this->getOutput()->addHTML( Html::openElement( 'table', - array( 'class' => array( + [ 'class' => [ 'mw-mediastats-table', 'mw-mediastats-table-' . strtolower( $mediaType ), 'sortable', 'wikitable' - ) ) + ] ] ) ); $this->getOutput()->addHTML( $this->getTableHeaderRow() ); @@ -273,19 +273,19 @@ class MediaStatisticsPage extends QueryPage { * @return String the header row of the able */ protected function getTableHeaderRow() { - $headers = array( 'mimetype', 'extensions', 'count', 'totalbytes' ); + $headers = [ 'mimetype', 'extensions', 'count', 'totalbytes' ]; $ths = ''; foreach ( $headers as $header ) { $ths .= Html::rawElement( 'th', - array(), + [], // for grep: // mediastatistics-table-mimetype, mediastatistics-table-extensions // tatistics-table-count, mediastatistics-table-totalbytes $this->msg( 'mediastatistics-table-' . $header )->parse() ); } - return Html::rawElement( 'tr', array(), $ths ); + return Html::rawElement( 'tr', [], $ths ); } /** @@ -297,10 +297,10 @@ class MediaStatisticsPage extends QueryPage { $this->getOutput()->addHTML( Html::element( 'h2', - array( 'class' => array( + [ 'class' => [ 'mw-mediastats-mediatype', 'mw-mediastats-mediatype-' . strtolower( $mediaType ) - ) ), + ] ], // for grep // mediastatistics-header-unknown, mediastatistics-header-bitmap, // mediastatistics-header-drawing, mediastatistics-header-audio, diff --git a/includes/specials/SpecialMergeHistory.php b/includes/specials/SpecialMergeHistory.php index 0cefb38920..3310538a59 100644 --- a/includes/specials/SpecialMergeHistory.php +++ b/includes/specials/SpecialMergeHistory.php @@ -126,7 +126,7 @@ class SpecialMergeHistory extends SpecialPage { return; } - $errors = array(); + $errors = []; if ( !$this->mTargetObj instanceof Title ) { $errors[] = $this->msg( 'mergehistory-invalid-source' )->parseAsBlock(); } elseif ( !$this->mTargetObj->exists() ) { @@ -160,11 +160,11 @@ class SpecialMergeHistory extends SpecialPage { $out->addWikiMsg( 'mergehistory-header' ); $out->addHTML( - Xml::openElement( 'form', array( + Xml::openElement( 'form', [ 'method' => 'get', - 'action' => wfScript() ) ) . + 'action' => wfScript() ] ) . ' |