From efa0d7af44326489052468b8f65b54f4b61298c3 Mon Sep 17 00:00:00 2001 From: Amir Sarabadani Date: Sat, 13 Aug 2016 05:40:40 +0430 Subject: [PATCH] Clean up array() syntax in docs, part III Also fixing some typos here and there Change-Id: I29c29acf87f84ba9993ba75ebf2ad8091d981574 --- includes/cache/BacklinkCache.php | 2 +- includes/db/Database.php | 4 +-- includes/exception/MWException.php | 2 +- includes/filerepo/RepoGroup.php | 4 +-- includes/objectcache/ObjectCache.php | 2 +- includes/pager/IndexPager.php | 4 +-- includes/resourceloader/ResourceLoader.php | 26 +++++++++---------- .../resourceloader/ResourceLoaderContext.php | 6 ++--- .../ResourceLoaderFileModule.php | 22 ++++++++-------- .../resourceloader/ResourceLoaderImage.php | 4 +-- 10 files changed, 38 insertions(+), 38 deletions(-) diff --git a/includes/cache/BacklinkCache.php b/includes/cache/BacklinkCache.php index 361fe23236..8c2a19eb67 100644 --- a/includes/cache/BacklinkCache.php +++ b/includes/cache/BacklinkCache.php @@ -48,7 +48,7 @@ class BacklinkCache { * > (string) links table name * > (int) batch size * > 'numRows' : Number of rows for this link table - * > 'batches' : array( $start, $end ) + * > 'batches' : [ $start, $end ] * * @see BacklinkCache::partitionResult() * diff --git a/includes/db/Database.php b/includes/db/Database.php index 4e358d4c78..5023acd868 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -1864,7 +1864,7 @@ abstract class DatabaseBase implements IDatabase { /** * Gets an array of aliased table names * - * @param array $tables Array( [alias] => table ) + * @param array $tables [ [alias] => table ] * @return string[] See tableNameWithAlias() */ public function tableNamesWithAlias( $tables ) { @@ -1898,7 +1898,7 @@ abstract class DatabaseBase implements IDatabase { /** * Gets an array of aliased field names * - * @param array $fields Array( [alias] => field ) + * @param array $fields [ [alias] => field ] * @return string[] See fieldNameWithAlias() */ public function fieldNamesWithAlias( $fields ) { diff --git a/includes/exception/MWException.php b/includes/exception/MWException.php index bebd91580f..0a174fe471 100644 --- a/includes/exception/MWException.php +++ b/includes/exception/MWException.php @@ -91,7 +91,7 @@ class MWException extends Exception { is_string( $hook ) || ( is_array( $hook ) && count( $hook ) >= 2 && is_string( $hook[0] ) ) ) { - // 'function' or array( 'class', hook' ) + // 'function' or [ 'class', 'hook' ] $result = call_user_func_array( $hook, $callargs ); } else { $result = null; diff --git a/includes/filerepo/RepoGroup.php b/includes/filerepo/RepoGroup.php index 08a40ebf24..d515b05088 100644 --- a/includes/filerepo/RepoGroup.php +++ b/includes/filerepo/RepoGroup.php @@ -177,8 +177,8 @@ class RepoGroup { * @param array $inputItems An array of titles, or an array of findFile() options with * the "title" option giving the title. Example: * - * $findItem = array( 'title' => $title, 'private' => true ); - * $findBatch = array( $findItem ); + * $findItem = [ 'title' => $title, 'private' => true ]; + * $findBatch = [ $findItem ]; * $repo->findFiles( $findBatch ); * * No title should appear in $items twice, as the result use titles as keys diff --git a/includes/objectcache/ObjectCache.php b/includes/objectcache/ObjectCache.php index 108339387f..bcdf62f59d 100644 --- a/includes/objectcache/ObjectCache.php +++ b/includes/objectcache/ObjectCache.php @@ -249,7 +249,7 @@ class ObjectCache { * ObjectCache::getLocalServerInstance( $fallbackType ); * * // From $wgObjectCaches via newFromParams() - * ObjectCache::getLocalServerInstance( array( 'fallback' => $fallbackType ) ); + * ObjectCache::getLocalServerInstance( [ 'fallback' => $fallbackType ] ); * * @param int|string|array $fallback Fallback cache or parameter map with 'fallback' * @return BagOStuff diff --git a/includes/pager/IndexPager.php b/includes/pager/IndexPager.php index 393644fc9d..a96ca87316 100644 --- a/includes/pager/IndexPager.php +++ b/includes/pager/IndexPager.php @@ -700,8 +700,8 @@ abstract class IndexPager extends ContextSource implements Pager { * not be used in the pager offset or in any links for users. * * If getIndexField() returns an array of 'querykey' => 'indexfield' pairs then - * this must return a corresponding array of 'querykey' => array( fields...) pairs - * in order for a request with &count=querykey to use array( fields...) to sort. + * this must return a corresponding array of 'querykey' => [ fields... ] pairs + * in order for a request with &count=querykey to use [ fields... ] to sort. * * This is useful for pagers that GROUP BY a unique column (say page_id) * and ORDER BY another (say page_len). Using GROUP BY and ORDER BY both on diff --git a/includes/resourceloader/ResourceLoader.php b/includes/resourceloader/ResourceLoader.php index d145566087..6426feacaf 100644 --- a/includes/resourceloader/ResourceLoader.php +++ b/includes/resourceloader/ResourceLoader.php @@ -60,13 +60,13 @@ class ResourceLoader implements LoggerAwareInterface { /** * Associative array mapping framework ids to a list of names of test suite modules - * like array( 'qunit' => array( 'mediawiki.tests.qunit.suites', 'ext.foo.tests', .. ), .. ) + * like [ 'qunit' => [ 'mediawiki.tests.qunit.suites', 'ext.foo.tests', ... ], ... ] * @var array */ protected $testModuleNames = []; /** - * E.g. array( 'source-id' => 'http://.../load.php' ) + * E.g. [ 'source-id' => 'http://.../load.php' ] * @var array */ protected $sources = []; @@ -433,7 +433,7 @@ class ResourceLoader implements LoggerAwareInterface { * * Source IDs are typically the same as the Wiki ID or database name (e.g. lowercase a-z). * - * @param array|string $id Source ID (string), or array( id1 => loadUrl, id2 => loadUrl, ... ) + * @param array|string $id Source ID (string), or [ id1 => loadUrl, id2 => loadUrl, ... ] * @param string|array $loadUrl load.php url (string), or array with loadUrl key for * backwards-compatibility. * @throws MWException @@ -573,7 +573,7 @@ class ResourceLoader implements LoggerAwareInterface { /** * Get the list of sources. * - * @return array Like array( id => load.php url, .. ) + * @return array Like [ id => load.php url, ... ] */ public function getSources() { return $this->sources; @@ -1173,7 +1173,7 @@ MESSAGE; * - ResourceLoader::makeLoaderStateScript( $name, $state ): * Set the state of a single module called $name to $state * - * - ResourceLoader::makeLoaderStateScript( array( $name => $state, ... ) ): + * - ResourceLoader::makeLoaderStateScript( [ $name => $state, ... ] ): * Set the state of modules with the given names to the given states * * @param string $name @@ -1264,14 +1264,14 @@ MESSAGE; * ): * Register a single module. * - * - ResourceLoader::makeLoaderRegisterScript( array( $name1, $name2 ) ): + * - ResourceLoader::makeLoaderRegisterScript( [ $name1, $name2 ] ): * Register modules with the given names. * - * - ResourceLoader::makeLoaderRegisterScript( array( - * array( $name1, $version1, $dependencies1, $group1, $source1, $skip1 ), - * array( $name2, $version2, $dependencies1, $group2, $source2, $skip2 ), + * - ResourceLoader::makeLoaderRegisterScript( [ + * [ $name1, $version1, $dependencies1, $group1, $source1, $skip1 ], + * [ $name2, $version2, $dependencies1, $group2, $source2, $skip2 ], * ... - * ) ): + * ] ): * Registers modules with the given names and parameters. * * @param string $name Module name @@ -1329,7 +1329,7 @@ MESSAGE; * - ResourceLoader::makeLoaderSourcesScript( $id, $properties ): * Register a single source * - * - ResourceLoader::makeLoaderSourcesScript( array( $id1 => $loadUrl, $id2 => $loadUrl, ... ) ); + * - ResourceLoader::makeLoaderSourcesScript( [ $id1 => $loadUrl, $id2 => $loadUrl, ... ] ); * Register sources with the given IDs and properties. * * @param string $id Source ID @@ -1402,13 +1402,13 @@ MESSAGE; /** * Convert an array of module names to a packed query string. * - * For example, array( 'foo.bar', 'foo.baz', 'bar.baz', 'bar.quux' ) + * For example, [ 'foo.bar', 'foo.baz', 'bar.baz', 'bar.quux' ] * becomes 'foo.bar,baz|bar.baz,quux' * @param array $modules List of module names (strings) * @return string Packed query string */ public static function makePackedModulesString( $modules ) { - $groups = []; // array( prefix => array( suffixes ) ) + $groups = []; // [ prefix => [ suffixes ] ] foreach ( $modules as $module ) { $pos = strrpos( $module, '.' ); $prefix = $pos === false ? '' : substr( $module, 0, $pos ); diff --git a/includes/resourceloader/ResourceLoaderContext.php b/includes/resourceloader/ResourceLoaderContext.php index 8fa04118c0..79b71df18b 100644 --- a/includes/resourceloader/ResourceLoaderContext.php +++ b/includes/resourceloader/ResourceLoaderContext.php @@ -91,8 +91,8 @@ class ResourceLoaderContext { /** * Expand a string of the form jquery.foo,bar|jquery.ui.baz,quux to - * an array of module names like array( 'jquery.foo', 'jquery.bar', - * 'jquery.ui.baz', 'jquery.ui.quux' ) + * an array of module names like [ 'jquery.foo', 'jquery.bar', + * 'jquery.ui.baz', 'jquery.ui.quux' ] * @param string $modules Packed module name list * @return array Array of module names */ @@ -113,7 +113,7 @@ class ResourceLoaderContext { } else { // We have a prefix and a bunch of suffixes $prefix = substr( $group, 0, $pos ); // 'foo' - $suffixes = explode( ',', substr( $group, $pos + 1 ) ); // array( 'bar', 'baz' ) + $suffixes = explode( ',', substr( $group, $pos + 1 ) ); // [ 'bar', 'baz' ] foreach ( $suffixes as $suffix ) { $retval[] = "$prefix.$suffix"; } diff --git a/includes/resourceloader/ResourceLoaderFileModule.php b/includes/resourceloader/ResourceLoaderFileModule.php index 2816126036..574e5358eb 100644 --- a/includes/resourceloader/ResourceLoaderFileModule.php +++ b/includes/resourceloader/ResourceLoaderFileModule.php @@ -41,7 +41,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { * @var array List of paths to JavaScript files to always include * @par Usage: * @code - * array( [file-path], [file-path], ... ) + * [ [file-path], [file-path], ... ] * @endcode */ protected $scripts = []; @@ -50,7 +50,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { * @var array List of JavaScript files to include when using a specific language * @par Usage: * @code - * array( [language-code] => array( [file-path], [file-path], ... ), ... ) + * [ [language-code] => [ [file-path], [file-path], ... ], ... ] * @endcode */ protected $languageScripts = []; @@ -59,7 +59,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { * @var array List of JavaScript files to include when using a specific skin * @par Usage: * @code - * array( [skin-name] => array( [file-path], [file-path], ... ), ... ) + * [ [skin-name] => [ [file-path], [file-path], ... ], ... ] * @endcode */ protected $skinScripts = []; @@ -68,7 +68,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { * @var array List of paths to JavaScript files to include in debug mode * @par Usage: * @code - * array( [skin-name] => array( [file-path], [file-path], ... ), ... ) + * [ [skin-name] => [ [file-path], [file-path], ... ], ... ] * @endcode */ protected $debugScripts = []; @@ -77,7 +77,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { * @var array List of paths to CSS files to always include * @par Usage: * @code - * array( [file-path], [file-path], ... ) + * [ [file-path], [file-path], ... ] * @endcode */ protected $styles = []; @@ -86,7 +86,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { * @var array List of paths to CSS files to include when using specific skins * @par Usage: * @code - * array( [file-path], [file-path], ... ) + * [ [file-path], [file-path], ... ] * @endcode */ protected $skinStyles = []; @@ -95,7 +95,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { * @var array List of modules this module depends on * @par Usage: * @code - * array( [file-path], [file-path], ... ) + * [ [file-path], [file-path], ... ] * @endcode */ protected $dependencies = []; @@ -109,7 +109,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { * @var array List of message keys used by this module * @par Usage: * @code - * array( [message-key], [message-key], ... ) + * [ [message-key], [message-key], ... ] * @endcode */ protected $messages = []; @@ -138,7 +138,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { * @var array Place where readStyleFile() tracks file dependencies * @par Usage: * @code - * array( [file-path], [file-path], ... ) + * [ [file-path], [file-path], ... ] * @endcode */ protected $localFileRefs = []; @@ -165,7 +165,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { * @throws InvalidArgumentException * @par Construction options: * @code - * array( + * [ * // Base path to prepend to all local paths in $options. Defaults to $IP * 'localBasePath' => [base path], * // Base path to prepend to all remote paths in $options. Defaults to $wgResourceBasePath @@ -207,7 +207,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { * // The file must contain valid JavaScript for execution in a private function. * // The file must not contain the "function () {" and "}" wrapper though. * 'skipFunction' => [file path] - * ) + * ] * @endcode */ public function __construct( diff --git a/includes/resourceloader/ResourceLoaderImage.php b/includes/resourceloader/ResourceLoaderImage.php index 87e5fd7b82..2503b22e59 100644 --- a/includes/resourceloader/ResourceLoaderImage.php +++ b/includes/resourceloader/ResourceLoaderImage.php @@ -54,8 +54,8 @@ class ResourceLoaderImage { $this->variants = $variants; // Expand shorthands: - // array( "en,de,fr" => "foo.svg" ) - // → array( "en" => "foo.svg", "de" => "foo.svg", "fr" => "foo.svg" ) + // [ "en,de,fr" => "foo.svg" ] + // → [ "en" => "foo.svg", "de" => "foo.svg", "fr" => "foo.svg" ] if ( is_array( $this->descriptor ) && isset( $this->descriptor['lang'] ) ) { foreach ( array_keys( $this->descriptor['lang'] ) as $langList ) { if ( strpos( $langList, ',' ) !== false ) { -- 2.20.1