This code is functionally identical, but less error prone (not so easy
to forget or mix these numerical indexes).
This patch happens to touch the Parser, which might be a bit scary. We
can remove this file from this patch if you prefer.
Change-Id: I8cbe3a9a6725d1c42b86e67678c1af15fbc5961a
15 files changed:
static function splitTrail( $trail ) {
$regex = MediaWikiServices::getInstance()->getContentLanguage()->linkTrail();
$inside = '';
static function splitTrail( $trail ) {
$regex = MediaWikiServices::getInstance()->getContentLanguage()->linkTrail();
$inside = '';
- if ( $trail !== '' ) {
- $m = [];
- if ( preg_match( $regex, $trail, $m ) ) {
- $inside = $m[1];
- $trail = $m[2];
- }
+ if ( $trail !== '' && preg_match( $regex, $trail, $m ) ) {
+ list( , $inside, $trail ) = $m;
}
return [ $inside, $trail ];
}
}
return [ $inside, $trail ];
}
- $type = $encoded[0];
- $data = $encoded[1];
+ list( $type, $data ) = $encoded;
switch ( $type ) {
case 'a':
switch ( $type ) {
case 'a':
// need to store these so we don't lose them when they're
// overwritten by the recursion
// need to store these so we don't lose them when they're
// overwritten by the recursion
- $len = $snake[2];
- $startx = $snake[0];
- $starty = $snake[1];
+ list( $startx, $starty, $len ) = $snake;
// the middle snake is part of the LCS, store it
for ( $i = 0; $i < $len; ++$i ) {
// the middle snake is part of the LCS, store it
for ( $i = 0; $i < $len; ++$i ) {
$lang = $this->getRenderLang();
# Output each image...
foreach ( $this->mImages as $pair ) {
$lang = $this->getRenderLang();
# Output each image...
foreach ( $this->mImages as $pair ) {
+ // "text" means "caption" here
- $nt = $pair[0];
- $text = $pair[1]; # "text" means "caption" here
- $alt = $pair[2];
- $link = $pair[3];
+ list( $nt, $text, $alt, $link ) = $pair;
$descQuery = false;
if ( $nt->getNamespace() === NS_FILE ) {
$descQuery = false;
if ( $nt->getNamespace() === NS_FILE ) {
$this->updatesSkipped = [];
foreach ( $updates as $funcList ) {
$this->updatesSkipped = [];
foreach ( $updates as $funcList ) {
- $func = $funcList[0];
- $args = $funcList[1];
- $origParams = $funcList[2];
+ list( $func, $args, $origParams ) = $funcList;
$func( ...$args );
flush();
$this->updatesSkipped[] = $origParams;
$func( ...$args );
flush();
$this->updatesSkipped[] = $origParams;
} elseif ( substr_count( $realServer, ':' ) == 1 ) {
// If we have a colon and something that's not a port number
// inside the hostname, assume it's the socket location
} elseif ( substr_count( $realServer, ':' ) == 1 ) {
// If we have a colon and something that's not a port number
// inside the hostname, assume it's the socket location
- $hostAndSocket = explode( ':', $realServer, 2 );
- $realServer = $hostAndSocket[0];
- $socket = $hostAndSocket[1];
+ list( $realServer, $socket ) = explode( ':', $realServer, 2 );
}
$mysqli = mysqli_init();
}
$mysqli = mysqli_init();
$dirmark = $lang->getDirMarkEntity();
$request = $this->getContext()->getRequest();
$dirmark = $lang->getDirMarkEntity();
$request = $this->getContext()->getRequest();
- $max = $this->getImageLimitsFromOption( $user, 'imagesize' );
- $maxWidth = $max[0];
- $maxHeight = $max[1];
+ list( $maxWidth, $maxHeight ) = $this->getImageLimitsFromOption( $user, 'imagesize' );
if ( $this->displayImg->exists() ) {
# image
if ( $this->displayImg->exists() ) {
# image
*
* @param User $user
* @param string $optionName Name of a option to check, typically imagesize or thumbsize
*
* @param User $user
* @param string $optionName Name of a option to check, typically imagesize or thumbsize
* @since 1.21
*/
public function getImageLimitsFromOption( $user, $optionName ) {
* @since 1.21
*/
public function getImageLimitsFromOption( $user, $optionName ) {
* @private
*/
public function replaceTextCallback( $matches ) {
* @private
*/
public function replaceTextCallback( $matches ) {
- $type = $matches[1];
- $key = $matches[2];
+ list( , $type, $key ) = $matches;
if ( $type == 'LINK' ) {
list( $ns, $index ) = explode( ':', $key, 2 );
if ( isset( $this->internals[$ns][$index]['text'] ) ) {
if ( $type == 'LINK' ) {
list( $ns, $index ) = explode( ':', $key, 2 );
if ( isset( $this->internals[$ns][$index]['text'] ) ) {
$inside = $p[5];
} else {
# tag
$inside = $p[5];
} else {
# tag
- $element = $p[1];
- $attributes = $p[2];
- $close = $p[3];
- $inside = $p[4];
+ list( , $element, $attributes, $close, $inside ) = $p;
}
$marker = self::MARKER_PREFIX . "-$element-" . sprintf( '%08X', $n++ ) . self::MARKER_SUFFIX;
}
$marker = self::MARKER_PREFIX . "-$element-" . sprintf( '%08X', $n++ ) . self::MARKER_SUFFIX;
$tail = '';
$text = '';
} else {
$tail = '';
$text = '';
} else {
- $tail = $q[1];
- $text = $q[2];
+ list( , $tail, $text ) = $q;
if ( $useLinkPrefixExtension ) {
if ( preg_match( $e2, $s, $m ) ) {
if ( $useLinkPrefixExtension ) {
if ( preg_match( $e2, $s, $m ) ) {
- $prefix = $m[2];
- $s = $m[1];
+ list( , $s, $prefix ) = $m;
$time = $info['time'];
$counter = $info['offsetCounter'];
} else {
$time = $info['time'];
$counter = $info['offsetCounter'];
} else {
- $time = $info[0];
- $counter = $info[1];
+ list( $time, $counter ) = $info;
}
// Take the 46 LSBs of "milliseconds since epoch"
$id_bin = $this->millisecondsSinceEpochBinary( $time );
}
// Take the 46 LSBs of "milliseconds since epoch"
$id_bin = $this->millisecondsSinceEpochBinary( $time );
$counter = $info['offsetCounter'];
$clkSeq = $info['clkSeq'];
} else {
$counter = $info['offsetCounter'];
$clkSeq = $info['clkSeq'];
} else {
- $time = $info[0];
- $counter = $info[1];
- $clkSeq = $info[2];
+ list( $time, $counter, $clkSeq ) = $info;
}
// Take the 46 LSBs of "milliseconds since epoch"
$id_bin = $this->millisecondsSinceEpochBinary( $time );
}
// Take the 46 LSBs of "milliseconds since epoch"
$id_bin = $this->millisecondsSinceEpochBinary( $time );
$secondPerson = [ "з" ]; // 1st plural, 2nd formal
$thirdPerson = [ "ы", "і" ]; // 3rd
$secondPerson = [ "з" ]; // 1st plural, 2nd formal
$thirdPerson = [ "ы", "і" ]; // 3rd
- $lastLetter = $this->lastLetter( $word, $allVowels );
- $wordEnding =& $lastLetter[0];
- $wordLastVowel =& $lastLetter[1];
+ list( $wordEnding, $wordLastVowel ) = $this->lastLetter( $word, $allVowels );
// Now convert the word
switch ( $case ) {
// Now convert the word
switch ( $case ) {
$secondPerson = [ "z" ]; // 1st plural, 2nd formal
$thirdPerson = [ "ı", "i" ]; // 3rd
$secondPerson = [ "z" ]; // 1st plural, 2nd formal
$thirdPerson = [ "ı", "i" ]; // 3rd
- $lastLetter = $this->lastLetter( $word, $allVowels );
- $wordEnding =& $lastLetter[0];
- $wordLastVowel =& $lastLetter[1];
+ list( $wordEnding, $wordLastVowel ) = $this->lastLetter( $word, $allVowels );
// Now convert the word
switch ( $case ) {
// Now convert the word
switch ( $case ) {
$secondPerson = [ "ز" ]; // 1st plural, 2nd formal
$thirdPerson = [ "ى", "ٸ" ]; // 3rd
$secondPerson = [ "ز" ]; // 1st plural, 2nd formal
$thirdPerson = [ "ى", "ٸ" ]; // 3rd
- $lastLetter = $this->lastLetter( $word, $allVowels );
- $wordEnding = $lastLetter[0];
- $wordLastVowel = $lastLetter[1];
+ list( $wordEnding, $wordLastVowel ) = $this->lastLetter( $word, $allVowels );
// Now convert the word
switch ( $case ) {
// Now convert the word
switch ( $case ) {
/**
* @param string $word
/**
* @param string $word
- * @param array $allVowels
+ * @param string[] $allVowels
* @return array
*/
function lastLetter( $word, $allVowels ) {
* @return array
*/
function lastLetter( $word, $allVowels ) {
* @param array $tableParams A child array of self::$tables
*/
protected function cleanupTable( $tableParams ) {
* @param array $tableParams A child array of self::$tables
*/
protected function cleanupTable( $tableParams ) {
- $table = $tableParams[0];
- $prefix = $tableParams[1];
+ list( $table, $prefix ) = $tableParams;
$idField = $tableParams['idField'] ?? "{$prefix}_id";
$nsField = $tableParams['nsField'] ?? "{$prefix}_namespace";
$titleField = $tableParams['titleField'] ?? "{$prefix}_title";
$idField = $tableParams['idField'] ?? "{$prefix}_id";
$nsField = $tableParams['nsField'] ?? "{$prefix}_namespace";
$titleField = $tableParams['titleField'] ?? "{$prefix}_title";
$options = $this->orderedOptions;
foreach ( $options as $arg ) {
$options = $this->orderedOptions;
foreach ( $options as $arg ) {
- $opt = $arg[0];
- $param = $arg[1];
+ list( $opt, $param ) = $arg;
switch ( $opt ) {
case 'plugin':
switch ( $opt ) {
case 'plugin':
} elseif ( substr_count( $realServer, ':' ) == 1 ) {
// If we have a colon and something that's not a port number
// inside the hostname, assume it's the socket location
} elseif ( substr_count( $realServer, ':' ) == 1 ) {
// If we have a colon and something that's not a port number
// inside the hostname, assume it's the socket location
- $hostAndSocket = explode( ':', $realServer, 2 );
- $realServer = $hostAndSocket[0];
- $socket = $hostAndSocket[1];
+ list( $realServer, $socket ) = explode( ':', $realServer, 2 );
}
if ( $dbName === false ) {
}
if ( $dbName === false ) {
parent::__construct();
foreach ( QueryPage::getPages() as $page ) {
parent::__construct();
foreach ( QueryPage::getPages() as $page ) {
- $class = $page[0];
- $name = $page[1];
+ list( $class, $name ) = $page;
if ( !in_array( $class, $this->manualTest ) ) {
$this->queryPages[$class] =
MediaWikiServices::getInstance()->getSpecialPageFactory()->getPage( $name );
if ( !in_array( $class, $this->manualTest ) ) {
$this->queryPages[$class] =
MediaWikiServices::getInstance()->getSpecialPageFactory()->getPage( $name );