aboutsummaryrefslogtreecommitdiffstats
path: root/includes/libs
diff options
context:
space:
mode:
Diffstat (limited to 'includes/libs')
-rw-r--r--includes/libs/ArrayUtils.php6
-rw-r--r--includes/libs/BufferingStatsdDataFactory.php4
-rw-r--r--includes/libs/CSSMin.php24
-rw-r--r--includes/libs/Cookie.php6
-rw-r--r--includes/libs/GenericArrayObject.php6
-rw-r--r--includes/libs/HashRing.php16
-rw-r--r--includes/libs/HttpStatus.php4
-rw-r--r--includes/libs/IEContentAnalyzer.php56
-rw-r--r--includes/libs/IEUrlExtension.php12
-rw-r--r--includes/libs/MapCacheLRU.php4
-rw-r--r--includes/libs/MappedIterator.php8
-rw-r--r--includes/libs/MemoizedCallable.php4
-rw-r--r--includes/libs/MultiHttpClient.php34
-rw-r--r--includes/libs/ObjectFactory.php4
-rw-r--r--includes/libs/ProcessCacheLRU.php8
-rw-r--r--includes/libs/ReplacementArray.php2
-rw-r--r--includes/libs/RiffExtractor.php10
-rw-r--r--includes/libs/SamplingStatsdClient.php4
-rw-r--r--includes/libs/ScopedCallback.php2
-rw-r--r--includes/libs/StatusValue.php22
-rw-r--r--includes/libs/StringUtils.php10
-rw-r--r--includes/libs/Timing.php22
-rw-r--r--includes/libs/Xhprof.php36
-rw-r--r--includes/libs/XmlTypeCheck.php16
-rw-r--r--includes/libs/composer/ComposerInstalled.php10
-rw-r--r--includes/libs/composer/ComposerJson.php2
-rw-r--r--includes/libs/composer/ComposerLock.php10
-rw-r--r--includes/libs/eventrelayer/EventRelayer.php2
-rw-r--r--includes/libs/eventrelayer/EventRelayerMCRD.php10
-rw-r--r--includes/libs/objectcache/APCBagOStuff.php2
-rw-r--r--includes/libs/objectcache/BagOStuff.php12
-rw-r--r--includes/libs/objectcache/CachedBagOStuff.php2
-rw-r--r--includes/libs/objectcache/HashBagOStuff.php10
-rw-r--r--includes/libs/objectcache/MultiWriteBagOStuff.php8
-rw-r--r--includes/libs/objectcache/WANObjectCache.php70
-rw-r--r--includes/libs/objectcache/WinCacheBagOStuff.php2
-rw-r--r--includes/libs/replacers/RegexlikeReplacer.php2
-rw-r--r--includes/libs/replacers/Replacer.php2
-rw-r--r--includes/libs/virtualrest/ParsoidVirtualRESTService.php6
-rw-r--r--includes/libs/virtualrest/RestbaseVirtualRESTService.php8
-rw-r--r--includes/libs/virtualrest/SwiftVirtualRESTService.php36
-rw-r--r--includes/libs/virtualrest/VirtualRESTService.php4
-rw-r--r--includes/libs/virtualrest/VirtualRESTServiceClient.php32
43 files changed, 275 insertions, 275 deletions
diff --git a/includes/libs/ArrayUtils.php b/includes/libs/ArrayUtils.php
index f93402108ade..fb35801130c5 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 a0020dabb3f4..9c18b10f10a9 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 246de75c9983..5f4dda970306 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 0fe944443f0a..cc236e289c3a 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 93ae83b2723b..dec55c95406c 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 e7a10997cca8..70ce31d713dd 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 3d7dee7da1c2..72fc33386935 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 c31a35278a81..0d1e527ba638 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 216d9b78604c..16163fb3041d 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 a49eb0106cbc..2370ed3a8ac0 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 7fdde8a81afd..73ffb1474763 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 14de6b903455..39faf3d08fe8 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 6ad77411dc74..4e19025bbcd7 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 2ffc1d3be84d..c96a8a1643e7 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 eec31cee56dc..5a933914c61f 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 02762f36d146..4512a4b13d93 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 f987c59d21c7..3a8b55e21c89 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 f77b2116376a..2e780c972873 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 1ec9eaa62702..96075aad6656 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 35de084b5fee..b4206a21fc95 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 c56ed07a8864..d2226b6daa2d 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 00ceda3e7818..62baaf1e93f5 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 d2cd0e4ea848..d0f067f6e1b8 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 34afb6891463..b3ea08da9ccf 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 5f87b54b1db8..9f15078c64c1 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 bb55ac638074..311508f7c060 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 22c33191d7f8..e93127c16754 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 f95ba3f0e9e7..c385c38dfbb5 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 1e8b2a40580a..4bcdf123abc0 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 c7f9c574da27..8f70fc7a771c 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 a7e8a4780b36..1aed28036ae8 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 fc156187fefb..c71b16e50245 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 7b85d9258020..6e7fb0cae096 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 73bdabd1c2ce..ec588cee00f5 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 4aa868efceb3..e43d37b8ca5e 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 8b0161090c9d..3d72abe84f39 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 2b1fa740231d..9874f524c2a2 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 f4850bf6ad1b..3b978357ede4 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 5be4aeab41ed..da47d356512f 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 81442adc4218..d2dd89f8093b 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 88b0e1f14a6c..679d51c5ac32 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 01a4ea6edfeb..ccb14db0204f 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 519da4313cf0..c64fe34af76e 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 ) {