Clean up array() in docs, Part I
authorAmir Sarabadani <Ladsgroup@gmail.com>
Mon, 25 Jul 2016 01:25:09 +0000 (05:55 +0430)
committerAmir Sarabadani <Ladsgroup@gmail.com>
Mon, 25 Jul 2016 12:45:18 +0000 (17:15 +0430)
Change-Id: Ia6bb3944c05b056677979035cb38385554ee8a4f

13 files changed:
includes/GlobalFunctions.php
includes/SiteConfiguration.php
includes/api/ApiBase.php
includes/api/ApiContinuationManager.php
includes/api/ApiMain.php
includes/api/ApiModuleManager.php
includes/api/ApiPageSet.php
includes/api/ApiQueryBase.php
includes/api/ApiQueryDuplicateFiles.php
includes/api/ApiQueryInfo.php
includes/api/ApiQueryRecentChanges.php
includes/api/ApiQuerySiteinfo.php
includes/api/ApiResult.php

index 66e2440..0ff4dca 100644 (file)
@@ -222,17 +222,17 @@ function wfAppendToArrayIfNotDefault( $key, $value, $default, &$changed ) {
  * 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 @@ function wfParseUrl( $url ) {
        $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;
        }
index 5b9bdfa..ffeb44d 100644 (file)
  *
  * @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
  * the above code could be written:
  *
  * @code
- * $conf->settings = array(
- *     'wgSomeSetting' => array(
+ * $conf->settings = [
+ *     'wgSomeSetting' => [
  *
  *             'default' => false,
  *
  *             # Enable feature on test
  *             'beta'    => true,
- *     ),
- * );
+ *     ],
+ * ];
  * @endcode
  *
  *
  * 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:
  *
  * @todo Give examples for,
  * suffixes:
- * $conf->suffixes = array( 'wiki' );
+ * $conf->suffixes = [ 'wiki' ];
  * localVHosts
  * callbacks!
  */
index 3e57e89..b45eacb 100644 (file)
@@ -2144,7 +2144,7 @@ abstract class ApiBase extends ContextSource {
        /**
         * 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
index 8f1bd19..6601fb7 100644 (file)
@@ -167,7 +167,7 @@ class ApiContinuationManager {
 
        /**
         * Fetch continuation result data
-        * @return array Array( (array)$data, (bool)$batchcomplete )
+        * @return array [ (array)$data, (bool)$batchcomplete ]
         */
        public function getContinuation() {
                $data = [];
index 592df53..0478027 100644 (file)
@@ -117,9 +117,9 @@ class ApiMain extends ApiBase {
        // @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' => [
index fe24c2a..42dfb71 100644 (file)
@@ -81,14 +81,14 @@ class ApiModuleManager extends ContextSource {
         *
         * @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
index af4e536..8045447 100644 (file)
@@ -58,7 +58,7 @@ class ApiPageSet extends ApiBase {
        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 @@ class ApiPageSet extends ApiBase {
                $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
index 318af58..b35eec2 100644 (file)
@@ -176,10 +176,9 @@ abstract class ApiQueryBase extends ApiBase {
        /**
         * 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 @@ abstract class ApiQueryBase extends ApiBase {
 
        /**
         * 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 @@ abstract class ApiQueryBase extends ApiBase {
         * @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 = [] ) {
index ae93bb1..02b7883 100644 (file)
@@ -96,7 +96,7 @@ class ApiQueryDuplicateFiles extends ApiQueryGeneratorBase {
                }
 
                // find all files with the hashes, result format is:
-               // array( hash => array( dup1, dup2 ), hash1 => ... )
+               // [ hash => [ dup1, dup2 ], hash1 => ... ]
                $filesToFindBySha1s = array_unique( array_values( $sha1s ) );
                if ( $params['localonly'] ) {
                        $filesBySha1s = RepoGroup::singleton()->getLocalRepo()->findBySha1s( $filesToFindBySha1s );
index f5c49ad..d287020 100644 (file)
@@ -92,7 +92,7 @@ class ApiQueryInfo extends ApiQueryBase {
         * 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
index 63c95d3..cc3ca60 100644 (file)
@@ -48,7 +48,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
         * 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
index 97042af..5d32497 100644 (file)
@@ -594,7 +594,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                                        $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 );
index 5d5c829..3a4b012 100644 (file)
@@ -217,7 +217,7 @@ class ApiResult implements ApiSerializable {
         *    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 @@ class ApiResult implements ApiSerializable {
         *    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 @@ class ApiResult implements ApiSerializable {
         * 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