Ladsgroup has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/300807

Change subject: Clean up array() in docs, Part I
......................................................................

Clean up array() in docs, Part I

Change-Id: Ia6bb3944c05b056677979035cb38385554ee8a4f
---
M includes/GlobalFunctions.php
M includes/SiteConfiguration.php
M includes/api/ApiBase.php
M includes/api/ApiContinuationManager.php
M includes/api/ApiMain.php
M includes/api/ApiModuleManager.php
M includes/api/ApiPageSet.php
M includes/api/ApiQueryBase.php
M includes/api/ApiQueryDuplicateFiles.php
M includes/api/ApiQueryInfo.php
M includes/api/ApiQueryRecentChanges.php
M includes/api/ApiQuerySiteinfo.php
M includes/api/ApiResult.php
13 files changed, 55 insertions(+), 56 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/07/300807/1

diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php
index 66e2440..0ff4dca 100644
--- a/includes/GlobalFunctions.php
+++ b/includes/GlobalFunctions.php
@@ -222,17 +222,17 @@
  * Merge arrays in the style of getUserPermissionsErrors, with duplicate 
removal
  * e.g.
  *     wfMergeErrorArrays(
- *             array( array( 'x' ) ),
- *             array( array( 'x', '2' ) ),
- *             array( array( 'x' ) ),
- *             array( array( 'y' ) )
+ *             [ [ 'x' ] ],
+ *             [ [ 'x', '2' ] ],
+ *             [ [ 'x' ] ],
+ *             [ [ 'y' ] ]
  *     );
  * returns:
- *             array(
- *             array( 'x', '2' ),
- *             array( 'x' ),
- *             array( 'y' )
- *     )
+ *             [
+ *             [ 'x', '2' ],
+ *             [ 'x' ],
+ *             [ 'y' ]
+ *     ]
  *
  * @param array $array1,...
  * @return array
@@ -827,7 +827,7 @@
        $bits = parse_url( $url );
        MediaWiki\restoreWarnings();
        // parse_url() returns an array without scheme for some invalid URLs, 
e.g.
-       // parse_url("%0Ahttp://example.com";) == array( 'host' => '%0Ahttp', 
'path' => 'example.com' )
+       // parse_url("%0Ahttp://example.com";) == [ 'host' => '%0Ahttp', 'path' 
=> 'example.com' ]
        if ( !$bits || !isset( $bits['scheme'] ) ) {
                return false;
        }
diff --git a/includes/SiteConfiguration.php b/includes/SiteConfiguration.php
index 5b9bdfa..ffeb44d 100644
--- a/includes/SiteConfiguration.php
+++ b/includes/SiteConfiguration.php
@@ -36,15 +36,15 @@
  *
  * @code
  * $conf = new SiteConfiguration;
- * $conf->wikis = array( 'de', 'en', 'beta' );
+ * $conf->wikis = [ 'de', 'en', 'beta' ];
  * @endcode
  *
  * When configuring the MediaWiki global settings (the $wg variables),
  * the identifiers will be available to specify settings on a per wiki basis.
  *
  * @code
- * $conf->settings = array(
- *     'wgSomeSetting' => array(
+ * $conf->settings = [
+ *     'wgSomeSetting' => [
  *
  *             # production:
  *             'de'     => false,
@@ -52,8 +52,8 @@
  *
  *             # test:
  *             'beta    => true,
- *     ),
- * );
+ *     ],
+ * ];
  * @endcode
  *
  * With three wikis, that is easy to manage. But what about a farm with
@@ -62,15 +62,15 @@
  * the above code could be written:
  *
  * @code
- * $conf->settings = array(
- *     'wgSomeSetting' => array(
+ * $conf->settings = [
+ *     'wgSomeSetting' => [
  *
  *             'default' => false,
  *
  *             # Enable feature on test
  *             'beta'    => true,
- *     ),
- * );
+ *     ],
+ * ];
  * @endcode
  *
  *
@@ -80,23 +80,23 @@
  * on a per wiki basis.
  *
  * @code
- * $conf->settings = array(
- *     'wgMergeSetting' = array(
+ * $conf->settings = [
+ *     'wgMergeSetting' = [
  *             # Value that will be shared among all wikis:
- *             'default' => array( NS_USER => true ),
+ *             'default' => [ NS_USER => true ],
  *
  *             # Leading '+' means merging the array of value with the defaults
- *             '+beta' => array( NS_HELP => true ),
- *     ),
- * );
+ *             '+beta' => [ NS_HELP => true ],
+ *     ],
+ * ];
  *
  * # Get configuration for the German site:
  * $conf->get( 'wgMergeSetting', 'de' );
- * // --> array( NS_USER => true );
+ * // --> [ NS_USER => true ];
  *
  * # Get configuration for the testing site:
  * $conf->get( 'wgMergeSetting', 'beta' );
- * // --> array( NS_USER => true, NS_HELP => true );
+ * // --> [ NS_USER => true, NS_HELP => true ];
  * @endcode
  *
  * Finally, to load all configuration settings, extract them in global context:
@@ -110,7 +110,7 @@
  *
  * @todo Give examples for,
  * suffixes:
- * $conf->suffixes = array( 'wiki' );
+ * $conf->suffixes = [ 'wiki' ];
  * localVHosts
  * callbacks!
  */
diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php
index 3e57e89..b45eacb 100644
--- a/includes/api/ApiBase.php
+++ b/includes/api/ApiBase.php
@@ -2144,7 +2144,7 @@
        /**
         * Return the error message related to a certain array
         * @param array|string|MessageSpecifier $error Element of a 
getUserPermissionsErrors()-style array
-        * @return array('code' => code, 'info' => info)
+        * @return [ 'code' => code, 'info' => info ]
         */
        public function parseMsg( $error ) {
                // Check whether someone passed the whole array, instead of one 
element as
diff --git a/includes/api/ApiContinuationManager.php 
b/includes/api/ApiContinuationManager.php
index 8f1bd19..6601fb7 100644
--- a/includes/api/ApiContinuationManager.php
+++ b/includes/api/ApiContinuationManager.php
@@ -167,7 +167,7 @@
 
        /**
         * Fetch continuation result data
-        * @return array Array( (array)$data, (bool)$batchcomplete )
+        * @return array [ (array)$data, (bool)$batchcomplete ]
         */
        public function getContinuation() {
                $data = [];
diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php
index 592df53..0478027 100644
--- a/includes/api/ApiMain.php
+++ b/includes/api/ApiMain.php
@@ -117,9 +117,9 @@
        // @codingStandardsIgnoreStart String contenation on "msg" not allowed 
to break long line
        /**
         * List of user roles that are specifically relevant to the API.
-        * array( 'right' => array ( 'msg'    => 'Some message with a $1',
-        *                           'params' => array ( $someVarToSubst ) ),
-        *                          );
+        * [ 'right' => [ 'msg'    => 'Some message with a $1',
+        *                'params' => [ $someVarToSubst ] ],
+        * ];
         */
        private static $mRights = [
                'writeapi' => [
diff --git a/includes/api/ApiModuleManager.php 
b/includes/api/ApiModuleManager.php
index fe24c2a..42dfb71 100644
--- a/includes/api/ApiModuleManager.php
+++ b/includes/api/ApiModuleManager.php
@@ -81,14 +81,14 @@
         *
         * @code
         *  $modules['foo'] = 'ApiFoo';
-        *  $modules['bar'] = array(
+        *  $modules['bar'] = [
         *      'class' => 'ApiBar',
         *      'factory' => function( $main, $name ) { ... }
-        *  );
-        *  $modules['xyzzy'] = array(
+        *  ];
+        *  $modules['xyzzy'] = [
         *      'class' => 'ApiXyzzy',
-        *      'factory' => array( 'XyzzyFactory', 'newApiModule' )
-        *  );
+        *      'factory' => [ 'XyzzyFactory', 'newApiModule' ]
+        *  ];
         * @endcode
         *
         * @param array $modules A map of ModuleName => ModuleSpec; The 
ModuleSpec
diff --git a/includes/api/ApiPageSet.php b/includes/api/ApiPageSet.php
index af4e536..8045447 100644
--- a/includes/api/ApiPageSet.php
+++ b/includes/api/ApiPageSet.php
@@ -58,7 +58,7 @@
        private $mGoodTitles = [];
        private $mMissingPages = []; // [ns][dbkey] => fake page_id
        private $mMissingTitles = [];
-       /** @var array [fake_page_id] => array( 'title' => $title, 
'invalidreason' => $reason ) */
+       /** @var array [fake_page_id] => [ 'title' => $title, 'invalidreason' 
=> $reason ] */
        private $mInvalidTitles = [];
        private $mMissingPageIDs = [];
        private $mRedirectTitles = [];
@@ -777,7 +777,7 @@
                $res = $db->select( 'page', $this->getPageTableFields(), $set,
                        __METHOD__ );
 
-               // Hack: get the ns:titles stored in array(ns => array(titles)) 
format
+               // Hack: get the ns:titles stored in [ ns => [ titles ] ] format
                $this->initFromQueryResult( $res, $linkBatch->data, true ); // 
process Titles
 
                // Resolve any found redirects
diff --git a/includes/api/ApiQueryBase.php b/includes/api/ApiQueryBase.php
index 318af58..57d504a 100644
--- a/includes/api/ApiQueryBase.php
+++ b/includes/api/ApiQueryBase.php
@@ -176,10 +176,9 @@
        /**
         * Add a set of JOIN conditions to the internal array
         *
-        * JOIN conditions are formatted as array( tablename => array(jointype,
-        * conditions) e.g. array('page' => array('LEFT JOIN',
-        * 'page_id=rev_page')) . conditions may be a string or an
-        * addWhere()-style array
+        * JOIN conditions are formatted as [ tablename => [ jointype, 
conditions ] ]
+        * e.g. [ 'page' => [ 'LEFT JOIN', 'page_id=rev_page' ] ].
+        * Conditions may be a string or an addWhere()-style array.
         * @param array $join_conds JOIN conditions
         */
        protected function addJoinConds( $join_conds ) {
@@ -219,12 +218,12 @@
 
        /**
         * Add a set of WHERE clauses to the internal array.
-        * Clauses can be formatted as 'foo=bar' or array('foo' => 'bar'),
+        * Clauses can be formatted as 'foo=bar' or [ 'foo' => 'bar' ],
         * the latter only works if the value is a constant (i.e. not another 
field)
         *
         * If $value is an empty array, this function does nothing.
         *
-        * For example, array('foo=bar', 'baz' => 3, 'bla' => 'foo') translates
+        * For example, [ 'foo=bar', 'baz' => 3, 'bla' => 'foo'] translates
         * to "foo=bar AND baz='3' AND bla='foo'"
         * @param string|array $value
         */
@@ -341,13 +340,13 @@
         * @param string $method Function the query should be attributed to.
         *  You should usually use __METHOD__ here
         * @param array $extraQuery Query data to add but not store in the 
object
-        *  Format is array(
+        *  Format is [
         *    'tables' => ...,
         *    'fields' => ...,
         *    'where' => ...,
         *    'options' => ...,
         *    'join_conds' => ...
-        *  )
+        *  ]
         * @return ResultWrapper
         */
        protected function select( $method, $extraQuery = [] ) {
diff --git a/includes/api/ApiQueryDuplicateFiles.php 
b/includes/api/ApiQueryDuplicateFiles.php
index ae93bb1..2402b9c 100644
--- a/includes/api/ApiQueryDuplicateFiles.php
+++ b/includes/api/ApiQueryDuplicateFiles.php
@@ -96,7 +96,7 @@
                }
 
                // find all files with the hashes, result format is:
-               // array( hash => array( dup1, dup2 ), hash1 => ... )
+               // [ hash => array( dup1, dup2 ), hash1 => ... ]
                $filesToFindBySha1s = array_unique( array_values( $sha1s ) );
                if ( $params['localonly'] ) {
                        $filesBySha1s = 
RepoGroup::singleton()->getLocalRepo()->findBySha1s( $filesToFindBySha1s );
diff --git a/includes/api/ApiQueryInfo.php b/includes/api/ApiQueryInfo.php
index f5c49ad..d287020 100644
--- a/includes/api/ApiQueryInfo.php
+++ b/includes/api/ApiQueryInfo.php
@@ -92,7 +92,7 @@
         * The prototype for a token function is func($pageid, $title)
         * it should return a token or false (permission denied)
         * @deprecated since 1.24
-        * @return array Array(tokenname => function)
+        * @return array [ tokenname => function ]
         */
        protected function getTokenFunctions() {
                // Don't call the hooks twice
diff --git a/includes/api/ApiQueryRecentChanges.php 
b/includes/api/ApiQueryRecentChanges.php
index 63c95d3..cc3ca60 100644
--- a/includes/api/ApiQueryRecentChanges.php
+++ b/includes/api/ApiQueryRecentChanges.php
@@ -48,7 +48,7 @@
         * The prototype for a token function is func($pageid, $title, $rc)
         * it should return a token or false (permission denied)
         * @deprecated since 1.24
-        * @return array Array(tokenname => function)
+        * @return array [ tokenname => function ]
         */
        protected function getTokenFunctions() {
                // Don't call the hooks twice
diff --git a/includes/api/ApiQuerySiteinfo.php 
b/includes/api/ApiQuerySiteinfo.php
index 97042af..5d32497 100644
--- a/includes/api/ApiQuerySiteinfo.php
+++ b/includes/api/ApiQuerySiteinfo.php
@@ -594,7 +594,7 @@
                                        $ret['description'] = 
$ext['description'];
                                }
                                if ( isset( $ext['descriptionmsg'] ) ) {
-                                       // Can be a string or array( key, 
param1, param2, ... )
+                                       // Can be a string or [ key, param1, 
param2, ... ]
                                        if ( is_array( $ext['descriptionmsg'] ) 
) {
                                                $ret['descriptionmsg'] = 
$ext['descriptionmsg'][0];
                                                $ret['descriptionmsgparams'] = 
array_slice( $ext['descriptionmsg'], 1 );
diff --git a/includes/api/ApiResult.php b/includes/api/ApiResult.php
index 5d5c829..3a4b012 100644
--- a/includes/api/ApiResult.php
+++ b/includes/api/ApiResult.php
@@ -217,7 +217,7 @@
         *    set to '*'. This may be skipped by including 'no*' in the value
         *    array.
         *  - Tags listed in META_BC_SUBELEMENTS will have their values changed 
to
-        *    array( '*' => $value ). This may be skipped by including 'nosub' 
in
+        *    [ '*' => $value ]. This may be skipped by including 'nosub' in
         *    the value array.
         *  - If META_TYPE is 'BCarray', set it to 'default'
         *  - If META_TYPE is 'BCassoc', set it to 'default'
@@ -230,9 +230,9 @@
         *    as objects.
         *  - ArmorKVP: (string) If provided, transform arrays with META_TYPE 
'kvp'
         *    and 'BCkvp' into arrays of two-element arrays, something like 
this:
-        *      $output = array();
+        *      $output = [];
         *      foreach ( $input as $key => $value ) {
-        *          $pair = array();
+        *          $pair = [];
         *          $pair[$META_KVP_KEY_NAME ?: $ArmorKVP_value] = $key;
         *          ApiResult::setContentValue( $pair, 'value', $value );
         *          $output[] = $pair;
@@ -390,7 +390,7 @@
         * Add value to the output data at the given path.
         *
         * Path can be an indexed array, each element specifying the branch at 
which to add the new
-        * value. Setting $path to array('a','b','c') is equivalent to 
data['a']['b']['c'] = $value.
+        * value. Setting $path to [ 'a', 'b', 'c' ] is equivalent to 
data['a']['b']['c'] = $value.
         * If $path is null, the value will be inserted at the data root.
         *
         * @param array|string|int|null $path

-- 
To view, visit https://gerrit.wikimedia.org/r/300807
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia6bb3944c05b056677979035cb38385554ee8a4f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Ladsgroup <ladsgr...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to