To create a batch, you can use the following code:
-$pages = array( 'Main Page', 'Project:Help', /* ... */ );
-$titles = array();
+$pages = [ 'Main Page', 'Project:Help', /* ... */ ];
+$titles = [];
foreach( $pages as $page ){
$titles[] = Title::newFromText( $page );
----
<?php
-$magicWords = array();
+$magicWords = [];
-$magicWords['en'] = array(
+$magicWords['en'] = [
// Case sensitive.
- 'mag_custom' => array( 1, 'CUSTOM' ),
-);
+ 'mag_custom' => [ 1, 'CUSTOM' ],
+];
-$magicWords['es'] = array(
- 'mag_custom' => array( 1, 'ADUANERO' ),
-);
+$magicWords['es'] = [
+ 'mag_custom' => [ 1, 'ADUANERO' ],
+];
----
$wgExtensionMessagesFiles['ExtensionNameMagic'] = __DIR__ . '/ExtensionName.i18n.magic.php';
----
<?php
-$magicWords = array();
+$magicWords = [];
-$magicWords['en'] = array(
+$magicWords['en'] = [
// Case insensitive.
- 'mag_custom' => array( 0, 'custom' ),
-);
+ 'mag_custom' => [ 0, 'custom' ],
+];
-$magicWords['es'] = array(
- 'mag_custom' => array( 0, 'aduanero' ),
-);
+$magicWords['es'] = [
+ 'mag_custom' => [ 0, 'aduanero' ],
+];
----
$wgExtensionMessagesFiles['ExtensionNameMagic'] = __DIR__ . '/ExtensionName.i18n.magic.php';
In your LocalSettings.php file, set:
$wgMainCacheType = CACHE_MEMCACHED;
- $wgMemCachedServers = array( "127.0.0.1:11211" );
+ $wgMemCachedServers = [ "127.0.0.1:11211" ];
The wiki should then use memcached to cache various data. To use
multiple servers (physically separate boxes or multiple caches
it has twice the memory of the others and you want to spread
usage evenly), make its entry a subarray:
- $wgMemCachedServers = array(
+ $wgMemCachedServers = [
"127.0.0.1:11211", # one gig on this box
- array("192.168.0.1:11211", 2 ) # two gigs on the other box
- );
+ [ "192.168.0.1:11211", 2 ] # two gigs on the other box
+ ];
== PHP client for memcached ==
require 'MemCachedClient.inc.php';
// set the servers, with the last one having an integer weight value of 3
-$options["servers"] = array("10.0.0.15:11000","10.0.0.16:11001",array("10.0.0.17:11002", 3));
+$options["servers"] = ["10.0.0.15:11000","10.0.0.16:11001",["10.0.0.17:11002", 3]];
$options["debug"] = false;
$memc = new MemCachedClient($options);
/***********************
* STORE AN ARRAY
***********************/
-$myarr = array("one","two", 3);
+$myarr = ["one","two", 3];
$memc->set("key_one", $myarr);
$val = $memc->get("key_one");
print $val[0]."\n"; // prints 'one'
/**
* Recursively check a condition. Conditions are in the form
- * array( '&' or '|' or '^' or '!', cond1, cond2, ... )
+ * [ '&' or '|' or '^' or '!', cond1, cond2, ... ]
* where cond1, cond2, ... are themselves conditions; *OR*
* APCOND_EMAILCONFIRMED, *OR*
- * array( APCOND_EMAILCONFIRMED ), *OR*
- * array( APCOND_EDITCOUNT, number of edits ), *OR*
- * array( APCOND_AGE, seconds since registration ), *OR*
+ * [ APCOND_EMAILCONFIRMED ], *OR*
+ * [ APCOND_EDITCOUNT, number of edits ], *OR*
+ * [ APCOND_AGE, seconds since registration ], *OR*
* similar constructs defined by extensions.
* This function evaluates the former type recursively, and passes off to
* self::checkCondition for evaluation of the latter type.
*
* The basic syntax for `$wgAutopromote` is:
*
- * $wgAutopromote = array(
+ * $wgAutopromote = [
* 'groupname' => cond,
* 'group2' => cond2,
- * );
+ * ];
*
* A `cond` may be:
* - a single condition without arguments:
* Note that Autopromote wraps a single non-array value into an array
* e.g. `APCOND_EMAILCONFIRMED` OR
- * array( `APCOND_EMAILCONFIRMED` )
+ * [ `APCOND_EMAILCONFIRMED` ]
* - a single condition with arguments:
- * e.g. `array( APCOND_EDITCOUNT, 100 )`
+ * e.g. `[ APCOND_EDITCOUNT, 100 ]`
* - a set of conditions:
- * e.g. `array( 'operand', cond1, cond2, ... )`
+ * e.g. `[ 'operand', cond1, cond2, ... ]`
*
* When constructing a set of conditions, the following conditions are available:
* - `&` (**AND**):
* promote if user matches **ONLY ONE OF THE CONDITIONS**
* - `!` (**NOT**):
* promote if user matces **NO** condition
- * - array( APCOND_EMAILCONFIRMED ):
+ * - [ APCOND_EMAILCONFIRMED ]:
* true if user has a confirmed e-mail
- * - array( APCOND_EDITCOUNT, number of edits ):
+ * - [ APCOND_EDITCOUNT, number of edits ]:
* true if user has the at least the number of edits as the passed parameter
- * - array( APCOND_AGE, seconds since registration ):
+ * - [ APCOND_AGE, seconds since registration ]:
* true if the length of time since the user created his/her account
* is at least the same length of time as the passed parameter
- * - array( APCOND_AGE_FROM_EDIT, seconds since first edit ):
+ * - [ APCOND_AGE_FROM_EDIT, seconds since first edit ]:
* true if the length of time since the user made his/her first edit
* is at least the same length of time as the passed parameter
- * - array( APCOND_INGROUPS, group1, group2, ... ):
+ * - [ APCOND_INGROUPS, group1, group2, ... ]:
* true if the user is a member of each of the passed groups
- * - array( APCOND_ISIP, ip ):
+ * - [ APCOND_ISIP, ip ]:
* true if the user has the passed IP address
- * - array( APCOND_IPINRANGE, range ):
+ * - [ APCOND_IPINRANGE, range ]:
* true if the user has an IP address in the range of the passed parameter
- * - array( APCOND_BLOCKED ):
+ * - [ APCOND_BLOCKED ]:
* true if the user is blocked
- * - array( APCOND_ISBOT ):
+ * - [ APCOND_ISBOT ]:
* true if the user is a bot
* - similar constructs can be defined by extensions
*
*
* @code
* $wgProfiler['class'] = 'ProfilerXhprof';
- * $wgProfiler['output'] = array( 'ProfilerOutputDb' );
+ * $wgProfiler['output'] = [ 'ProfilerOutputDb' ];
* $wgProfiler['sampling'] = 50; // one every 50 requests
* @endcode
*
$newValue = [];
foreach ( $value as $k => $v ) {
if ( is_string( $v ) ) {
- // String values should be normal `array( 'foo' )`
+ // String values should be normal `[ 'foo' ]`
// Just append them
if ( !isset( $value[$v] ) ) {
// As a special case don't set 'foo' if a
/**
* Get the files used on this page
*
- * @return array (dbKey => array('time' => MW timestamp or null, 'sha1' => sha1 or ''))
+ * @return array [ dbKey => [ 'time' => MW timestamp or null, 'sha1' => sha1 or '' ] ]
* @since 1.18
*/
public function getFileSearchOptions() {
* - In a pattern $1, $2, etc... will be replaced with the relevant contents
* - If you used a keyed array as a path pattern, $key will be replaced with
* the relevant contents
- * - The default behavior is equivalent to `array( 'title' => '$1' )`,
- * if you don't want the title parameter you can explicitly use `array( 'title' => false )`
+ * - The default behavior is equivalent to `[ 'title' => '$1' ]`,
+ * if you don't want the title parameter you can explicitly use `[ 'title' => false ]`
* - You can specify a value that won't have replacements in it
* using `'foo' => [ 'value' => 'bar' ];`
*
/**
* Protected helper to do the actual bulk work of adding a single pattern.
* This is in a separate method so that add() can handle the difference between
- * a single string $path and an array() $path that contains multiple path
+ * a single string $path and an array $path that contains multiple path
* patterns each with an associated $key to pass on.
* @param string $path
* @param array $params
}
// We know the difference between null (no matches) and
- // array() (a match with no data) but our WebRequest caller
- // expects array() even when we have no matches so return
- // a array() when we have null
+ // [] (a match with no data) but our WebRequest caller
+ // expects [] even when we have no matches so return
+ // a [] when we have null
return $matches ?? [];
}
*
* @param string|string[] $query An optional query string,
* not used for interwiki links. Can be specified as an associative array as well,
- * e.g., array( 'action' => 'edit' ) (keys and values will be URL-escaped).
+ * e.g., [ 'action' => 'edit' ] (keys and values will be URL-escaped).
* Some query patterns will trigger various shorturl path replacements.
* @param string|string[]|bool $query2 An optional secondary query array. This one MUST
* be an array. If a string is passed it will be interpreted as a deprecated
/**
* Read the global and extract title objects from the corresponding messages
- * @return array Array( 'msg' => Title, 'cats' => Title[] )
+ * @return array [ 'msg' => Title, 'cats' => Title[] ]
*/
public function getTrackingCategories() {
$categories = array_merge(
/**
* Parse the Accept-Language header sent by the client into an array
*
- * @return array Array( languageCode => q-value ) sorted by q-value in
+ * @return array [ languageCode => q-value ] sorted by q-value in
* descending order then appearing time in the header in ascending order.
* May contain the "language" '*', which applies to languages other than those explicitly listed.
* This is aligned with rfc2616 section 14.4
}
/**
- * Equivalent to addWhere(array($field => $value))
+ * Equivalent to addWhere( [ $field => $value ] )
* @param string $field Field name
* @param string|string[] $value Value; ignored if null or empty array
*/
* ChangeTags::updateTags() instead, unless directly handling a user request
* to add or remove tags from an existing revision or log entry.
*
- * @param array|null $tagsToAdd If none, pass array() or null
- * @param array|null $tagsToRemove If none, pass array() or null
+ * @param array|null $tagsToAdd If none, pass [] or null
+ * @param array|null $tagsToRemove If none, pass [] or null
* @param int|null $rc_id The rc_id of the change to add the tags to
* @param int|null $rev_id The rev_id of the change to add the tags to
* @param int|null $log_id The log_id of the change to add the tags to
/**
* Get an array of existing inline interwiki links, as a 2-D array
- * @return array (prefix => array(dbkey => 1))
+ * @return array [ prefix => [ dbkey => 1 ] ]
*/
private function getExistingInterwikis() {
$res = $this->getDB()->select( 'iwlinks', [ 'iwl_prefix', 'iwl_title' ],
* that return value has no taint.
*
* @param string $value The value of the input
- * @return array array( $errors, $errorClass )
+ * @return array [ $errors, $errorClass ]
* @return-taint none
*/
public function getErrorsAndErrorClass( $value ) {
* @code
* $job = new JobSpecification(
* 'null',
- * array( 'lives' => 1, 'usleep' => 100, 'pi' => 3.141569 ),
- * array( 'removeDuplicates' => 1 )
+ * [ 'lives' => 1, 'usleep' => 100, 'pi' => 3.141569 ],
+ * [ 'removeDuplicates' => 1 ]
* );
* JobQueueGroup::singleton()->push( $job )
* @endcode
* @param User|null $user User performing the action, or null to use $wgUser
* @param string|string[]|null $tags Change tags to add to log entry
* ($user should be able to add the specified tags before this is called)
- * @return array|bool array(number of file revisions restored, number of image revisions
- * restored, log message) on success, false on failure.
+ * @return array|bool [ number of file revisions restored, number of image revisions
+ * restored, log message ] on success, false on failure.
*/
public function undelete( $timestamps, $comment = '', $fileVersions = [],
$unsuppress = false, User $user = null, $tags = null
* (with ChangeTags::canAddTagsAccompanyingChange)
*
* @return array Array of errors, each error formatted as
- * array(messagekey, param1, param2, ...).
+ * [ messagekey, param1, param2, ... ].
* On success, the array is empty. This array can also be passed to
* OutputPage::showPermissionsErrorPage().
*/
* HTML5 definition of id attribute
*
* @param string $id Id to escape
- * @param string|array $options String or array of strings (default is array()):
+ * @param string|array $options String or array of strings (default is []):
* 'noninitial': This is a non-initial fragment of an id, not a full id,
* so don't pay attention if the first character isn't valid at the
* beginning of an id.
# rbc
'rb' => $common,
'rp' => $common,
- 'rt' => $common, # array_merge( $common, array( 'rbspan' ) ),
+ 'rt' => $common, # array_merge( $common, [ 'rbspan' ] ),
'rtc' => $common,
# MathML root element, where used for extensions
*
* @par Example:
* @code
- * $wgRCFeeds['redis'] = array(
+ * $wgRCFeeds['redis'] = [
* 'formatter' => 'JSONRCFeedFormatter',
* 'uri' => "redis://127.0.0.1:6379/rc.$wgDBname",
- * );
+ * ];
* @endcode
*
* @since 1.22
* to $IP
* @param string|null $remoteBasePath Path to use if not provided in module definition. Defaults
* to $wgResourceBasePath
- * @return array Array( localBasePath, remoteBasePath )
+ * @return array [ localBasePath, remoteBasePath ]
*/
public static function extractBasePaths(
$options = [],
* For example, if a page supports subpages "foo", "bar" and "baz" (as in Special:PageName/foo,
* etc.):
*
- * - `prefixSearchSubpages( "ba" )` should return `array( "bar", "baz" )`
- * - `prefixSearchSubpages( "f" )` should return `array( "foo" )`
- * - `prefixSearchSubpages( "z" )` should return `array()`
- * - `prefixSearchSubpages( "" )` should return `array( foo", "bar", "baz" )`
+ * - `prefixSearchSubpages( "ba" )` should return `[ "bar", "baz" ]`
+ * - `prefixSearchSubpages( "f" )` should return `[ "foo" ]`
+ * - `prefixSearchSubpages( "z" )` should return `[]`
+ * - `prefixSearchSubpages( "" )` should return `[ foo", "bar", "baz" ]`
*
* @param string $search Prefix to search for
* @param int $limit Maximum number of results to return (usually 10)
* subpage.
*
* @param string $alias
- * @return array Array( String, String|null ), or array( null, null ) if the page is invalid
+ * @return array [ String, String|null ], or [ null, null ] if the page is invalid
*/
public function resolveAlias( $alias ) {
$bits = explode( '/', $alias, 2 );
* Submit callback for an HTMLForm object
* @param array $data
* @param HTMLForm $form
- * @return array|bool Array(message key, parameters)
+ * @return array|bool [ message key, parameters ]
*/
public static function processUIUnblock( array $data, HTMLForm $form ) {
return self::processUnblock( $data, $form->getContext() );
* @param array $data
* @param IContextSource $context
* @throws ErrorPageError
- * @return array|bool Array( Array( message key, parameters ) ) on failure, True on success
+ * @return array|bool [ [ message key, parameters ] ] on failure, True on success
*/
public static function processUnblock( array $data, IContextSource $context ) {
$performer = $context->getUser();
/**
* Returns $this->getUser()->changeableGroups()
*
- * @return array Array(
- * 'add' => array( addablegroups ),
- * 'remove' => array( removablegroups ),
- * 'add-self' => array( addablegroups to self ),
- * 'remove-self' => array( removable groups from self )
- * )
+ * @return array [
+ * 'add' => [ addablegroups ],
+ * 'remove' => [ removablegroups ],
+ * 'add-self' => [ addablegroups to self ],
+ * 'remove-self' => [ removable groups from self ]
+ * ]
*/
function changeableGroups() {
return $this->getUser()->changeableGroups();
}
// ... and generate the description; which can be a parameterized l10n message
- // in the form array( <msgname>, <parameter>, <parameter>... ) or just a straight
+ // in the form [ <msgname>, <parameter>, <parameter>... ] or just a straight
// up string
if ( isset( $extension['descriptionmsg'] ) ) {
// Localized description of extension
* and 'all', which forces a reset of *all* preferences and overrides everything else.
*
* @param array|string $resetKinds Which kinds of preferences to reset. Defaults to
- * array( 'registered', 'registered-multiselect', 'registered-checkmatrix', 'unused' )
+ * [ 'registered', 'registered-multiselect', 'registered-checkmatrix', 'unused' ]
* for backwards-compatibility.
* @param IContextSource|null $context Context source used when $resetKinds
* does not contain 'all', passed to getOptionKinds().
* Returns an array of the groups that a particular group can add/remove.
*
* @param string $group The group to check for whether it can add/remove
- * @return array Array( 'add' => array( addablegroups ),
- * 'remove' => array( removablegroups ),
- * 'add-self' => array( addablegroups to self),
- * 'remove-self' => array( removable groups from self) )
+ * @return array [ 'add' => [ addablegroups ],
+ * 'remove' => [ removablegroups ],
+ * 'add-self' => [ addablegroups to self ],
+ * 'remove-self' => [ removable groups from self ] ]
*/
public static function changeableByGroup( $group ) {
global $wgAddGroups, $wgRemoveGroups, $wgGroupsAddToSelf, $wgGroupsRemoveFromSelf;
/**
* Returns an array of groups that this user can add and remove
- * @return array Array( 'add' => array( addablegroups ),
- * 'remove' => array( removablegroups ),
- * 'add-self' => array( addablegroups to self),
- * 'remove-self' => array( removable groups from self) )
+ * @return array [ 'add' => [ addablegroups ],
+ * 'remove' => [ removablegroups ],
+ * 'add-self' => [ addablegroups to self ],
+ * 'remove-self' => [ removable groups from self ] ]
*/
public function changeableGroups() {
if ( $this->isAllowed( 'userrights' ) ) {
*
* @since 1.22
* @param string $code Language code
- * @return array Array( fallbacks, site fallbacks )
+ * @return array [ fallbacks, site fallbacks ]
*/
public static function getFallbacksIncludingSiteLanguage( $code ) {
global $wgLanguageCode;
}
} else {
throw new MWException( __METHOD__ . " given invalid expectation for "
- . "'$server'. Should be a string or an array( <http server name> => <string> ).\n" );
+ . "'$server'. Should be a string or an array [ <http server name> => <string> ].\n" );
}
}
/**
* How do we handle duplicate keys in HTML attributes expansion?
- * We could pass a "class" the values: 'GREEN' and array( 'GREEN' => false )
+ * We could pass a "class" the values: 'GREEN' and [ 'GREEN' => false ]
* The latter will take precedence.
*
* Feature added by r96188
}
/**
- * @param array $messageDetails E.g. array( 'KEY' => array(/PARAMS/) )
+ * @param array $messageDetails E.g. [ 'KEY' => [ /PARAMS/ ] ]
* @return Message[]
*/
protected function getMockMessages( $messageDetails ) {
/**
* Return the collected logs
- * @return array Array of array( string $level, string $message ), or
- * array( string $level, string $message, array $context ) if $collectContext was true.
+ * @return array Array of [ string $level, string $message ], or
+ * [ string $level, string $message, array $context ] if $collectContext was true.
*/
public function getBuffer() {
return $this->buffer;
public function testWgWhitelistReadRegexp( $whitelistRegexp, $source, $action, $expected ) {
// $wgWhitelistReadRegexp must be an array. Since the provided test cases
// usually have only one regex, it is more concise to write the lonely regex
- // as a string. Thus we cast to an array() to honor $wgWhitelistReadRegexp
+ // as a string. Thus we cast to a [] to honor $wgWhitelistReadRegexp
// type requisite.
if ( is_string( $whitelistRegexp ) ) {
$whitelistRegexp = [ $whitelistRegexp ];
/**
* Checks that the request's result matches the expected results.
* Assumes no rawcontinue and a complete batch.
- * @param array $values Array is a two element array( request, expected_results )
+ * @param array $values Array is a two element [ request, expected_results ]
* @param array|null $session
* @param bool $appendModule
* @param User|null $user
$this->assertFalseCIDR( '192.0.2.0/33', "mask > 32" );
// Check internal logic
- # 0 mask always result in array(0,0)
+ # 0 mask always result in [ 0, 0 ]
$this->assertEquals( [ 0, 0 ], IP::parseCIDR( '192.0.0.2/0' ) );
$this->assertEquals( [ 0, 0 ], IP::parseCIDR( '0.0.0.0/0' ) );
$this->assertEquals( [ 0, 0 ], IP::parseCIDR( '255.255.255.255/0' ) );
* @covers SpecialSearch::load
* @dataProvider provideSearchOptionsTests
* @param array $requested Request parameters. For example:
- * array( 'ns5' => true, 'ns6' => true). Null to use default options.
+ * [ 'ns5' => true, 'ns6' => true ]. Null to use default options.
* @param array $userOptions User options to test with. For example:
- * array('searchNs5' => 1 );. Null to use default options.
+ * [ 'searchNs5' => 1 ];. Null to use default options.
* @param string $expectedProfile An expected search profile name
* @param array $expectedNS Expected namespaces
* @param string $message
$this->assertEquals( $response[$pos], $rows, "Testing row in position $pos" );
$pos++;
}
- // -1 is because the final array() marks the end and isnt included
+ // -1 is because the final [] marks the end and isn't included
$this->assertEquals( count( $response ) - 1, $pos );
}
}
/**
- * array( method, length, bits, hostbits )
+ * [ method, length, bits, hostbits ]
* NOTE: When adding a new method name here please update the covers tags for the tests!
*/
public static function provider_testTimestampedUID() {