From 9850c542c6275dfa97eeaf458826ffbd47bbd684 Mon Sep 17 00:00:00 2001 From: Amir Sarabadani Date: Tue, 27 Sep 2016 06:45:08 +0330 Subject: [PATCH] Clean up array() syntax in docs, part VII Last part Change-Id: I38f015e2122ef4fd2d2141718bd889794c29f06c --- includes/Html.php | 52 +++++++++---------- includes/OutputPage.php | 2 +- includes/TemplateParser.php | 4 +- includes/htmlform/OOUIHTMLForm.php | 4 +- includes/media/MediaHandler.php | 20 +++---- .../media/TransformationalImageHandler.php | 2 +- languages/Language.php | 2 +- languages/LanguageConverter.php | 4 +- languages/classes/LanguageKm.php | 2 +- languages/classes/LanguageMy.php | 2 +- languages/messages/MessagesEn.php | 6 +-- maintenance/language/checkDupeMessages.php | 4 +- maintenance/language/digit2html.php | 4 +- maintenance/preprocessorFuzzTest.php | 2 +- maintenance/storage/compressOld.php | 2 +- .../includes/api/RandomImageGenerator.php | 4 +- 16 files changed, 58 insertions(+), 58 deletions(-) diff --git a/includes/Html.php b/includes/Html.php index 2ef891d168..48b30c7802 100644 --- a/includes/Html.php +++ b/includes/Html.php @@ -155,8 +155,8 @@ class Html { * * @param string $contents The raw HTML contents of the element: *not* * escaped! - * @param array $attrs Associative array of attributes, e.g., array( - * 'href' => 'http://www.mediawiki.org/' ). See expandAttributes() for + * @param array $attrs Associative array of attributes, e.g., [ + * 'href' => 'http://www.mediawiki.org/' ]. See expandAttributes() for * further documentation. * @param string[] $modifiers classes to add to the button * @see http://tools.wmflabs.org/styleguide/desktop/index.html for guidance on available modifiers @@ -175,8 +175,8 @@ class Html { * * @param string $contents The raw HTML contents of the element: *not* * escaped! - * @param array $attrs Associative array of attributes, e.g., array( - * 'href' => 'http://www.mediawiki.org/' ). See expandAttributes() for + * @param array $attrs Associative array of attributes, e.g., [ + * 'href' => 'http://www.mediawiki.org/' ]. See expandAttributes() for * further documentation. * @param string[] $modifiers classes to add to the button * @see http://tools.wmflabs.org/styleguide/desktop/index.html for guidance on available modifiers @@ -199,8 +199,8 @@ class Html { * content model. * * @param string $element The element's name, e.g., 'a' - * @param array $attribs Associative array of attributes, e.g., array( - * 'href' => 'http://www.mediawiki.org/' ). See expandAttributes() for + * @param array $attribs Associative array of attributes, e.g., [ + * 'href' => 'http://www.mediawiki.org/' ]. See expandAttributes() for * further documentation. * @param string $contents The raw HTML contents of the element: *not* * escaped! @@ -320,8 +320,8 @@ class Html { * to the input array (currently per the HTML 5 draft as of 2009-09-06). * * @param string $element Name of the element, e.g., 'a' - * @param array $attribs Associative array of attributes, e.g., array( - * 'href' => 'http://www.mediawiki.org/' ). See expandAttributes() for + * @param array $attribs Associative array of attributes, e.g., [ + * 'href' => 'http://www.mediawiki.org/' ]. See expandAttributes() for * further documentation. * @return array An array of attributes functionally identical to $attribs */ @@ -430,8 +430,8 @@ class Html { /** * Given an associative array of element attributes, generate a string - * to stick after the element name in HTML output. Like array( 'href' => - * 'http://www.mediawiki.org/' ) becomes something like + * to stick after the element name in HTML output. Like [ 'href' => + * 'http://www.mediawiki.org/' ] becomes something like * ' href="http://www.mediawiki.org"'. Again, this is like * Xml::expandAttributes(), but it implements some HTML-specific logic. * @@ -443,25 +443,25 @@ class Html { * * @par Numerical array * @code - * Html::element( 'em', array( - * 'class' => array( 'foo', 'bar' ) - * ) ); + * Html::element( 'em', [ + * 'class' => [ 'foo', 'bar' ] + * ] ); * // gives '' * @endcode * * @par Associative array * @code - * Html::element( 'em', array( - * 'class' => array( 'foo', 'bar', 'foo' => false, 'quux' => true ) - * ) ); + * Html::element( 'em', [ + * 'class' => [ 'foo', 'bar', 'foo' => false, 'quux' => true ] + * ] ); * // gives '' * @endcode * - * @param array $attribs Associative array of attributes, e.g., array( - * 'href' => 'http://www.mediawiki.org/' ). Values will be HTML-escaped. + * @param array $attribs Associative array of attributes, e.g., [ + * 'href' => 'http://www.mediawiki.org/' ]. Values will be HTML-escaped. * A value of false means to omit the attribute. For boolean attributes, - * you can omit the key, e.g., array( 'checked' ) instead of - * array( 'checked' => 'checked' ) or such. + * you can omit the key, e.g., [ 'checked' ] instead of + * [ 'checked' => 'checked' ] or such. * * @throws MWException If an attribute that doesn't allow lists is set to an array * @return string HTML fragment that goes between element name and '>' @@ -470,13 +470,13 @@ class Html { public static function expandAttributes( array $attribs ) { $ret = ''; foreach ( $attribs as $key => $value ) { - // Support intuitive array( 'checked' => true/false ) form + // Support intuitive [ 'checked' => true/false ] form if ( $value === false || is_null( $value ) ) { continue; } - // For boolean attributes, support array( 'foo' ) instead of - // requiring array( 'foo' => 'meaningless' ). + // For boolean attributes, support [ 'foo' ] instead of + // requiring [ 'foo' => 'meaningless' ]. if ( is_int( $key ) && in_array( strtolower( $value ), self::$boolAttribs ) ) { $key = $value; } @@ -533,7 +533,7 @@ class Html { } } elseif ( $v ) { // If the value is truthy but not a string this is likely - // an array( 'foo' => true ), falsy values don't add strings + // an [ 'foo' => true ], falsy values don't add strings $newValue[] = $k; } } @@ -1009,11 +1009,11 @@ class Html { * * @par Example: * @code - * Html::srcSet( array( + * Html::srcSet( [ * '1x' => 'standard.jpeg', * '1.5x' => 'large.jpeg', * '3x' => 'extra-large.jpeg', - * ) ); + * ] ); * // gives 'standard.jpeg 1x, large.jpeg 1.5x, extra-large.jpeg 2x' * @endcode * diff --git a/includes/OutputPage.php b/includes/OutputPage.php index f5405d79e1..b2e7d94337 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -2356,7 +2356,7 @@ class OutputPage extends ContextSource { * Output a standard error page * * showErrorPage( 'titlemsg', 'pagetextmsg' ); - * showErrorPage( 'titlemsg', 'pagetextmsg', array( 'param1', 'param2' ) ); + * showErrorPage( 'titlemsg', 'pagetextmsg', [ 'param1', 'param2' ] ); * showErrorPage( 'titlemsg', $messageObject ); * showErrorPage( $titleMessageObject, $messageObject ); * diff --git a/includes/TemplateParser.php b/includes/TemplateParser.php index 20142a784b..a1e6d5b5a7 100644 --- a/includes/TemplateParser.php +++ b/includes/TemplateParser.php @@ -186,10 +186,10 @@ class TemplateParser { * @code * echo $templateParser->processTemplate( * 'ExampleTemplate', - * array( + * [ * 'username' => $user->getName(), * 'message' => 'Hello!' - * ) + * ] * ); * @endcode * @param string $templateName The name of the template diff --git a/includes/htmlform/OOUIHTMLForm.php b/includes/htmlform/OOUIHTMLForm.php index bbd3473af9..6fbf15b66d 100644 --- a/includes/htmlform/OOUIHTMLForm.php +++ b/includes/htmlform/OOUIHTMLForm.php @@ -202,8 +202,8 @@ class OOUIHTMLForm extends HTMLForm { } else { $errors = $elements->getErrorsByType( $elementsType ); foreach ( $errors as &$error ) { - // Input: array( 'message' => 'foo', 'errors' => array( 'a', 'b', 'c' ) ) - // Output: array( 'foo', 'a', 'b', 'c' ) + // Input: [ 'message' => 'foo', 'errors' => [ 'a', 'b', 'c' ] ] + // Output: [ 'foo', 'a', 'b', 'c' ] $error = array_merge( [ $error['message'] ], $error['params'] ); } } diff --git a/includes/media/MediaHandler.php b/includes/media/MediaHandler.php index 4ca2663be6..4bc36ba6cb 100644 --- a/includes/media/MediaHandler.php +++ b/includes/media/MediaHandler.php @@ -463,16 +463,16 @@ abstract class MediaHandler { /** * Get an array structure that looks like this: * - * array( - * 'visible' => array( + * [ + * 'visible' => [ * 'Human-readable name' => 'Human readable value', * ... - * ), - * 'collapsed' => array( + * ], + * 'collapsed' => [ * 'Human-readable name' => 'Human readable value', * ... - * ) - * ) + * ] + * ] * The UI will format this into a table where the visible fields are always * visible, and the collapsed fields are optionally visible. * @@ -843,11 +843,11 @@ abstract class MediaHandler { /** * Gets configuration for the file warning message. Return value of * the following structure: - * array( + * [ * // Required, module with messages loaded for the client * 'module' => 'example.filewarning.messages', * // Required, array of names of messages - * 'messages' => array( + * 'messages' => [ * // Required, main warning message * 'main' => 'example-filewarning-main', * // Optional, header for warning dialog @@ -856,10 +856,10 @@ abstract class MediaHandler { * 'footer' => 'example-filewarning-footer', * // Optional, text for more-information link (see below) * 'info' => 'example-filewarning-info', - * ), + * ], * // Optional, link for more information * 'link' => 'http://example.com', - * ) + * ] * * Returns null if no warning is necessary. * @param File $file diff --git a/includes/media/TransformationalImageHandler.php b/includes/media/TransformationalImageHandler.php index 3287fac8cf..3ebda75c80 100644 --- a/includes/media/TransformationalImageHandler.php +++ b/includes/media/TransformationalImageHandler.php @@ -302,7 +302,7 @@ abstract class TransformationalImageHandler extends ImageHandler { * Values can be one of client, im, custom, gd, imext, or an array * of object, method-name to call that specific method. * - * If specifying a custom scaler command with array( Obj, method ), + * If specifying a custom scaler command with [ Obj, method ], * the method in question should take 2 parameters, a File object, * and a $scalerParams array with various options (See doTransform * for what is in $scalerParams). On error it should return a diff --git a/languages/Language.php b/languages/Language.php index db71c5c7c9..3e28759234 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -2303,7 +2303,7 @@ class Language { /** * Takes a number of seconds and returns an array with a set of corresponding intervals. - * For example 65 will be turned into array( minutes => 1, seconds => 5 ). + * For example 65 will be turned into [ minutes => 1, seconds => 5 ]. * * @since 1.20 * diff --git a/languages/LanguageConverter.php b/languages/LanguageConverter.php index b31b10ffc7..13ba7e84b7 100644 --- a/languages/LanguageConverter.php +++ b/languages/LanguageConverter.php @@ -1086,11 +1086,11 @@ class LanguageConverter { // -{zh-hans:xxx;zh-hant:\ // yyy;}- // we should split it as: - // array( + // [ // [0] => 'zh-hans:xxx' // [1] => 'zh-hant:yyy' // [2] => '' - // ) + // ] $pat = '/;\s*(?='; foreach ( $this->mVariants as $variant ) { // zh-hans:xxx;zh-hant:yyy diff --git a/languages/classes/LanguageKm.php b/languages/classes/LanguageKm.php index 1e0bb004da..87d2127f87 100644 --- a/languages/classes/LanguageKm.php +++ b/languages/classes/LanguageKm.php @@ -35,7 +35,7 @@ class LanguageKm extends Language { */ function commafy( $_ ) { /* NO-op for Khmer. Cannot use - * $separatorTransformTable = array( ',' => '' ) + * $separatorTransformTable = [ ',' => '' ] * That would break when parsing and doing strstr '' => 'foo'; */ return $_; diff --git a/languages/classes/LanguageMy.php b/languages/classes/LanguageMy.php index 236ae4f5b0..f8b50fcc11 100644 --- a/languages/classes/LanguageMy.php +++ b/languages/classes/LanguageMy.php @@ -35,7 +35,7 @@ class LanguageMy extends Language { */ function commafy( $_ ) { /* NO-op. Cannot use - * $separatorTransformTable = array( ',' => '' ) + * $separatorTransformTable = [ ',' => '' ] * That would break when parsing and doing strstr '' => 'foo'; */ return $_; diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 589144c40c..67369e2ec4 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -104,9 +104,9 @@ $namespaceAliases = []; * Mapping NS_xxx to array of GENDERKEY to alias. * Example: * @code - * $namespaceGenderAliases = array( - * NS_USER => array( 'male' => 'Male_user', 'female' => 'Female_user' ), - * ); + * $namespaceGenderAliases = [ + * NS_USER => [ 'male' => 'Male_user', 'female' => 'Female_user' ], + * ]; * @endcode */ $namespaceGenderAliases = []; diff --git a/maintenance/language/checkDupeMessages.php b/maintenance/language/checkDupeMessages.php index baa9c713a8..baf917c90a 100644 --- a/maintenance/language/checkDupeMessages.php +++ b/maintenance/language/checkDupeMessages.php @@ -96,7 +96,7 @@ if ( $run ) { if ( !strcmp( $runMode, 'php' ) ) { print " $value ) { foreach ( $wgMessages[$langCode] as $ckey => $cvalue ) { @@ -118,7 +118,7 @@ if ( $run ) { } } if ( !strcmp( $runMode, 'php' ) ) { - print ");\n"; + print "];\n"; } if ( !strcmp( $runMode, 'text' ) ) { if ( $count == 1 ) { diff --git a/maintenance/language/digit2html.php b/maintenance/language/digit2html.php index 46616db56b..5bdc8a7894 100644 --- a/maintenance/language/digit2html.php +++ b/maintenance/language/digit2html.php @@ -55,12 +55,12 @@ class Digit2Html extends Maintenance { continue; } - $this->output( "OK\n\$digitTransformTable = array(\n" ); + $this->output( "OK\n\$digitTransformTable = [\n" ); foreach ( $digitTransformTable as $latin => $translation ) { $htmlent = utf8ToHexSequence( $translation ); $this->output( "'$latin' => '$translation', # &#x$htmlent;\n" ); } - $this->output( ");\n" ); + $this->output( "];\n" ); } } } diff --git a/maintenance/preprocessorFuzzTest.php b/maintenance/preprocessorFuzzTest.php index d102e08c2d..2503ed25e2 100644 --- a/maintenance/preprocessorFuzzTest.php +++ b/maintenance/preprocessorFuzzTest.php @@ -43,7 +43,7 @@ class PPFuzzTester { public $minLength = 0; public $maxLength = 20; public $maxTemplates = 5; - // public $outputTypes = array( 'OT_HTML', 'OT_WIKI', 'OT_PREPROCESS' ); + // public $outputTypes = [ 'OT_HTML', 'OT_WIKI', 'OT_PREPROCESS' ]; public $entryPoints = [ 'testSrvus', 'testPst', 'testPreprocess' ]; public $verbose = false; diff --git a/maintenance/storage/compressOld.php b/maintenance/storage/compressOld.php index 289d22d9a9..28be6a3311 100644 --- a/maintenance/storage/compressOld.php +++ b/maintenance/storage/compressOld.php @@ -384,7 +384,7 @@ class CompressOld extends Maintenance { if ( $text === false ) { $this->error( "\nError, unable to get text in old_id $oldid" ); - # $dbw->delete( 'old', array( 'old_id' => $oldid ) ); + # $dbw->delete( 'old', [ 'old_id' => $oldid ] ); } if ( $extdb == "" && $j == 0 ) { diff --git a/tests/phpunit/includes/api/RandomImageGenerator.php b/tests/phpunit/includes/api/RandomImageGenerator.php index 78cb7fb152..d5c17ee8ba 100644 --- a/tests/phpunit/includes/api/RandomImageGenerator.php +++ b/tests/phpunit/includes/api/RandomImageGenerator.php @@ -218,7 +218,7 @@ class RandomImageGenerator { } /** - * Given array( array('x' => 10, 'y' => 20), array( 'x' => 30, y=> 5 ) ) + * Given [ [ 'x' => 10, 'y' => 20 ], [ 'x' => 30, y=> 5 ] ] * returns "10,20 30,5" * Useful for SVG and imagemagick command line arguments * @param array $shape Array of arrays, each array containing x & y keys mapped to numeric values @@ -430,7 +430,7 @@ class RandomImageGenerator { /** * Get an array of random pairs of random words, like - * array( array( 'foo', 'bar' ), array( 'quux', 'baz' ) ); + * [ [ 'foo', 'bar' ], [ 'quux', 'baz' ] ]; * * @param int $number Number of pairs * @return array Two-element arrays -- 2.20.1