From d56829dca8d33e4e69fe5a57dea4ffdbfbccf873 Mon Sep 17 00:00:00 2001 From: Amir Sarabadani Date: Mon, 12 Sep 2016 14:36:37 +0430 Subject: [PATCH] Clean up array() syntax from docs, part VI Change-Id: Ib0eea494e2065c7ab356dc45fd174544a9c1c942 --- includes/EditPage.php | 4 +-- includes/MagicWord.php | 10 +++---- includes/PathRouter.php | 16 +++++------ includes/debug/logger/LegacySpi.php | 4 +-- includes/debug/logger/NullSpi.php | 4 +-- includes/exception/UserNotLoggedIn.php | 2 +- includes/resourceloader/ResourceLoader.php | 4 +-- .../ResourceLoaderFileModule.php | 16 +++++------ .../ResourceLoaderImageModule.php | 28 +++++++++---------- .../resourceloader/ResourceLoaderModule.php | 4 +-- includes/skins/BaseTemplate.php | 6 ++-- includes/skins/Skin.php | 2 +- 12 files changed, 50 insertions(+), 50 deletions(-) diff --git a/includes/EditPage.php b/includes/EditPage.php index 7e4e411d5e..c5330eeea3 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -3042,14 +3042,14 @@ class EditPage { * subclasses may reorganize the form. * Note that you do not need to worry about the label's for=, it will be * inferred by the id given to the input. You can remove them both by - * passing array( 'id' => false ) to $userInputAttrs. + * passing [ 'id' => false ] to $userInputAttrs. * * @param string $summary The value of the summary input * @param string $labelText The html to place inside the label * @param array $inputAttrs Array of attrs to use on the input * @param array $spanLabelAttrs Array of attrs to use on the span inside the label * - * @return array An array in the format array( $label, $input ) + * @return array An array in the format [ $label, $input ] */ function getSummaryInput( $summary = "", $labelText = null, $inputAttrs = null, $spanLabelAttrs = null diff --git a/includes/MagicWord.php b/includes/MagicWord.php index 13f706dee4..391e05aea1 100644 --- a/includes/MagicWord.php +++ b/includes/MagicWord.php @@ -43,12 +43,12 @@ * * @par Example: * @code - * $magicWords = array(); + * $magicWords = []; * - * $magicWords['en'] = array( - * 'magicwordkey' => array( 0, 'case_insensitive_magic_word' ), - * 'magicwordkey2' => array( 1, 'CASE_sensitive_magic_word2' ), - * ); + * $magicWords['en'] = [ + * 'magicwordkey' => [ 0, 'case_insensitive_magic_word' ], + * 'magicwordkey2' => [ 1, 'CASE_sensitive_magic_word2' ], + * ]; * @endcode * * For magic words which are also Parser variables, add a MagicWordwgVariableIDs diff --git a/includes/PathRouter.php b/includes/PathRouter.php index 005c34138c..049b32f64e 100644 --- a/includes/PathRouter.php +++ b/includes/PathRouter.php @@ -27,20 +27,20 @@ * * $router->add( "/wiki/$1" ); * - Matches /wiki/Foo style urls and extracts the title - * $router->add( array( 'edit' => "/edit/$key" ), array( 'action' => '$key' ) ); + * $router->add( [ 'edit' => "/edit/$key" ], [ 'action' => '$key' ] ); * - Matches /edit/Foo style urls and sets action=edit * $router->add( '/$2/$1', - * array( 'variant' => '$2' ), - * array( '$2' => array( 'zh-hant', 'zh-hans' ) + * [ 'variant' => '$2' ], + * [ '$2' => [ 'zh-hant', 'zh-hans' ] ] * ); * - Matches /zh-hant/Foo or /zh-hans/Foo - * $router->addStrict( "/foo/Bar", array( 'title' => 'Baz' ) ); + * $router->addStrict( "/foo/Bar", [ 'title' => 'Baz' ] ); * - Matches /foo/Bar explicitly and uses "Baz" as the title - * $router->add( '/help/$1', array( 'title' => 'Help:$1' ) ); + * $router->add( '/help/$1', [ 'title' => 'Help:$1' ] ); * - Matches /help/Foo with "Help:Foo" as the title - * $router->add( '/$1', array( 'foo' => array( 'value' => 'bar$2' ) ); + * $router->add( '/$1', [ 'foo' => [ 'value' => 'bar$2' ] ] ); * - Matches /Foo and sets 'foo' to 'bar$2' without $2 being replaced - * $router->add( '/$1', array( 'data:foo' => 'bar' ), array( 'callback' => 'functionname' ) ); + * $router->add( '/$1', [ 'data:foo' => 'bar' ], [ 'callback' => 'functionname' ] ); * - Matches /Foo, adds the key 'foo' with the value 'bar' to the data array * and calls functionname( &$matches, $data ); * @@ -56,7 +56,7 @@ * - The default behavior is equivalent to `array( 'title' => '$1' )`, * if you don't want the title parameter you can explicitly use `array( 'title' => false )` * - You can specify a value that won't have replacements in it - * using `'foo' => array( 'value' => 'bar' );` + * using `'foo' => [ 'value' => 'bar' ];` * * Options: * - The option keys $1, $2, etc... can be specified to restrict the possible values diff --git a/includes/debug/logger/LegacySpi.php b/includes/debug/logger/LegacySpi.php index a6b53ecc21..4cf8313dc1 100644 --- a/includes/debug/logger/LegacySpi.php +++ b/includes/debug/logger/LegacySpi.php @@ -25,9 +25,9 @@ namespace MediaWiki\Logger; * * Usage: * @code - * $wgMWLoggerDefaultSpi = array( + * $wgMWLoggerDefaultSpi = [ * 'class' => '\\MediaWiki\\Logger\\LegacySpi', - * ); + * ]; * @endcode * * @see \MediaWiki\Logger\LoggerFactory diff --git a/includes/debug/logger/NullSpi.php b/includes/debug/logger/NullSpi.php index f92ff7d11f..82308d0e9f 100644 --- a/includes/debug/logger/NullSpi.php +++ b/includes/debug/logger/NullSpi.php @@ -28,9 +28,9 @@ use Psr\Log\NullLogger; * * Usage: * - * $wgMWLoggerDefaultSpi = array( + * $wgMWLoggerDefaultSpi = [ * 'class' => '\\MediaWiki\\Logger\\NullSpi', - * ); + * ]; * * @see \MediaWiki\Logger\LoggerFactory * @since 1.25 diff --git a/includes/exception/UserNotLoggedIn.php b/includes/exception/UserNotLoggedIn.php index b7c3489b26..43c5b09126 100644 --- a/includes/exception/UserNotLoggedIn.php +++ b/includes/exception/UserNotLoggedIn.php @@ -62,7 +62,7 @@ class UserNotLoggedIn extends ErrorPageError { * @param string $titleMsg A message key to set the page title. * Optional, default: 'exception-nologin' * @param array $params Parameters to wfMessage(). - * Optional, default: array() + * Optional, default: [] */ public function __construct( $reasonMsg = 'exception-nologin-text', diff --git a/includes/resourceloader/ResourceLoader.php b/includes/resourceloader/ResourceLoader.php index ad1ed49fef..97a86c3a0b 100644 --- a/includes/resourceloader/ResourceLoader.php +++ b/includes/resourceloader/ResourceLoader.php @@ -1273,9 +1273,9 @@ MESSAGE; * Values considered empty: * * - null - * - array() + * - [] * - new XmlJsCode( '{}' ) - * - new stdClass() // (object) array() + * - new stdClass() // (object) [] * * @param Array $array */ diff --git a/includes/resourceloader/ResourceLoaderFileModule.php b/includes/resourceloader/ResourceLoaderFileModule.php index 574e5358eb..2dcc841e92 100644 --- a/includes/resourceloader/ResourceLoaderFileModule.php +++ b/includes/resourceloader/ResourceLoaderFileModule.php @@ -177,26 +177,26 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { * // Scripts to always include * 'scripts' => [file path string or array of file path strings], * // Scripts to include in specific language contexts - * 'languageScripts' => array( + * 'languageScripts' => [ * [language code] => [file path string or array of file path strings], - * ), + * ], * // Scripts to include in specific skin contexts - * 'skinScripts' => array( + * 'skinScripts' => [ * [skin name] => [file path string or array of file path strings], - * ), + * ], * // Scripts to include in debug contexts * 'debugScripts' => [file path string or array of file path strings], * // Modules which must be loaded before this module * 'dependencies' => [module name string or array of module name strings], - * 'templates' => array( + * 'templates' => [ * [template alias with file.ext] => [file path to a template file], - * ), + * ], * // Styles to always load * 'styles' => [file path string or array of file path strings], * // Styles to include in specific skin contexts - * 'skinStyles' => array( + * 'skinStyles' => [ * [skin name] => [file path string or array of file path strings], - * ), + * ], * // Messages to always load * 'messages' => [array of message key strings], * // Group which this module should be loaded together with diff --git a/includes/resourceloader/ResourceLoaderImageModule.php b/includes/resourceloader/ResourceLoaderImageModule.php index 43327c91cc..6a8957e932 100644 --- a/includes/resourceloader/ResourceLoaderImageModule.php +++ b/includes/resourceloader/ResourceLoaderImageModule.php @@ -59,7 +59,7 @@ class ResourceLoaderImageModule extends ResourceLoaderModule { * Below is a description for the $options array: * @par Construction options: * @code - * array( + * [ * // Base path to prepend to all local paths in $options. Defaults to $IP * 'localBasePath' => [base path], * // Path to JSON file that contains any of the settings below @@ -72,33 +72,33 @@ class ResourceLoaderImageModule extends ResourceLoaderModule { * 'selectorWithoutVariant' => [CSS selector template, variables: {prefix} {name}], * 'selectorWithVariant' => [CSS selector template, variables: {prefix} {name} {variant}], * // List of variants that may be used for the image files - * 'variants' => array( - * [theme name] => array( - * [variant name] => array( + * 'variants' => [ + * [theme name] => [ + * [variant name] => [ * 'color' => [color string, e.g. '#ffff00'], * 'global' => [boolean, if true, this variant is available * for all images of this type], - * ), + * ], * ... - * ), + * ], * ... - * ), + * ], * // List of image files and their options - * 'images' => array( - * [theme name] => array( - * [icon name] => array( + * 'images' => [ + * [theme name] => [ + * [icon name] => [ * 'file' => [file path string or array whose values are file path strings * and whose keys are 'default', 'ltr', 'rtl', a single * language code like 'en', or a list of language codes like * 'en,de,ar'], * 'variants' => [array of variant name strings, variants * available for this image], - * ), + * ], * ... - * ), + * ], * ... - * ), - * ) + * ], + * ] * @endcode * @throws InvalidArgumentException */ diff --git a/includes/resourceloader/ResourceLoaderModule.php b/includes/resourceloader/ResourceLoaderModule.php index 44f7e1265f..2351efdaea 100644 --- a/includes/resourceloader/ResourceLoaderModule.php +++ b/includes/resourceloader/ResourceLoaderModule.php @@ -789,10 +789,10 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface { * * @code * $summary = parent::getDefinitionSummary( $context ); - * $summary[] = array( + * $summary[] = [ * 'foo' => 123, * 'bar' => 'quux', - * ); + * ]; * return $summary; * @endcode * diff --git a/includes/skins/BaseTemplate.php b/includes/skins/BaseTemplate.php index 71ca57bf09..2d37a0f7e6 100644 --- a/includes/skins/BaseTemplate.php +++ b/includes/skins/BaseTemplate.php @@ -320,10 +320,10 @@ abstract class BaseTemplate extends QuickTemplate { * * If a "data" key is present, it must be an array, where the keys represent * the data-xxx properties with their provided values. For example, - * $item['data'] = array( + * $item['data'] = [ * 'foo' => 1, * 'bar' => 'baz', - * ); + * ]; * will render as element properties: * data-foo='1' data-bar='baz' * @@ -333,7 +333,7 @@ abstract class BaseTemplate extends QuickTemplate { * a link in. This should be an array of arrays containing a 'tag' and * optionally an 'attributes' key. If you only have one element you don't * need to wrap it in another array. eg: To use ... - * in all links use array( 'text-wrapper' => array( 'tag' => 'span' ) ) + * in all links use [ 'text-wrapper' => [ 'tag' => 'span' ] ] * for your options. * - 'link-class' key can be used to specify additional classes to apply * to all links. diff --git a/includes/skins/Skin.php b/includes/skins/Skin.php index 6b4acfa2d3..b60aa10f27 100644 --- a/includes/skins/Skin.php +++ b/includes/skins/Skin.php @@ -1169,7 +1169,7 @@ abstract class Skin extends ContextSource { * * BaseTemplate::getSidebar can be used to simplify the format and id generation in new skins. * - * The format of the returned array is array( heading => content, ... ), where: + * The format of the returned array is [ heading => content, ... ], where: * - heading is the heading of a navigation portlet. It is either: * - magic string to be handled by the skins ('SEARCH' / 'LANGUAGES' / 'TOOLBOX' / ...) * - a message name (e.g. 'navigation'), the message should be HTML-escaped by the skin -- 2.20.1