From 7fd83c2102a649e70f48575fffa3bb3b2df6e75d Mon Sep 17 00:00:00 2001 From: Amir Sarabadani Date: Mon, 25 Jul 2016 05:55:09 +0430 Subject: [PATCH] Clean up array() in docs, Part I Change-Id: Ia6bb3944c05b056677979035cb38385554ee8a4f --- includes/GlobalFunctions.php | 20 +++++++------- includes/SiteConfiguration.php | 36 ++++++++++++------------- includes/api/ApiBase.php | 2 +- includes/api/ApiContinuationManager.php | 2 +- includes/api/ApiMain.php | 6 ++--- includes/api/ApiModuleManager.php | 10 +++---- includes/api/ApiPageSet.php | 4 +-- includes/api/ApiQueryBase.php | 15 +++++------ includes/api/ApiQueryDuplicateFiles.php | 2 +- includes/api/ApiQueryInfo.php | 2 +- includes/api/ApiQueryRecentChanges.php | 2 +- includes/api/ApiQuerySiteinfo.php | 2 +- includes/api/ApiResult.php | 8 +++--- 13 files changed, 55 insertions(+), 56 deletions(-) diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 66e244082e..0ff4dcaa4c 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -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; } diff --git a/includes/SiteConfiguration.php b/includes/SiteConfiguration.php index 5b9bdfa1b1..ffeb44d3af 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 3e57e8997a..b45eacb693 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -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 diff --git a/includes/api/ApiContinuationManager.php b/includes/api/ApiContinuationManager.php index 8f1bd19191..6601fb7463 100644 --- a/includes/api/ApiContinuationManager.php +++ b/includes/api/ApiContinuationManager.php @@ -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 = []; diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index 592df534da..0478027678 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -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' => [ diff --git a/includes/api/ApiModuleManager.php b/includes/api/ApiModuleManager.php index fe24c2acd7..42dfb719bb 100644 --- a/includes/api/ApiModuleManager.php +++ b/includes/api/ApiModuleManager.php @@ -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 diff --git a/includes/api/ApiPageSet.php b/includes/api/ApiPageSet.php index af4e536bb4..8045447822 100644 --- a/includes/api/ApiPageSet.php +++ b/includes/api/ApiPageSet.php @@ -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 diff --git a/includes/api/ApiQueryBase.php b/includes/api/ApiQueryBase.php index 318af58c55..b35eec2c39 100644 --- a/includes/api/ApiQueryBase.php +++ b/includes/api/ApiQueryBase.php @@ -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 = [] ) { diff --git a/includes/api/ApiQueryDuplicateFiles.php b/includes/api/ApiQueryDuplicateFiles.php index ae93bb1b4a..02b7883d7b 100644 --- a/includes/api/ApiQueryDuplicateFiles.php +++ b/includes/api/ApiQueryDuplicateFiles.php @@ -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 ); diff --git a/includes/api/ApiQueryInfo.php b/includes/api/ApiQueryInfo.php index f5c49ad04f..d287020536 100644 --- a/includes/api/ApiQueryInfo.php +++ b/includes/api/ApiQueryInfo.php @@ -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 diff --git a/includes/api/ApiQueryRecentChanges.php b/includes/api/ApiQueryRecentChanges.php index 63c95d3675..cc3ca60f3d 100644 --- a/includes/api/ApiQueryRecentChanges.php +++ b/includes/api/ApiQueryRecentChanges.php @@ -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 diff --git a/includes/api/ApiQuerySiteinfo.php b/includes/api/ApiQuerySiteinfo.php index 97042afe15..5d324973b6 100644 --- a/includes/api/ApiQuerySiteinfo.php +++ b/includes/api/ApiQuerySiteinfo.php @@ -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 ); diff --git a/includes/api/ApiResult.php b/includes/api/ApiResult.php index 5d5c829bf7..3a4b012c30 100644 --- a/includes/api/ApiResult.php +++ b/includes/api/ApiResult.php @@ -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 -- 2.20.1