Remove unused key variable from foreach loops
Change-Id: Id2d91e30a6f7cc4eb93427b50efc1c5c77f14b75
This commit is contained in:
parent
a8edb65c0e
commit
5c5498a202
35 changed files with 46 additions and 46 deletions
|
|
@ -398,7 +398,7 @@ class ActorMigrationBase {
|
|||
if ( $tempTableInfo ) {
|
||||
$func = __METHOD__;
|
||||
$callback = static function ( $pk, array $extra ) use ( $tempTableInfo, $func ) {
|
||||
foreach ( $tempTableInfo['extra'] as $to => $from ) {
|
||||
foreach ( $tempTableInfo['extra'] as $from ) {
|
||||
if ( !array_key_exists( $from, $extra ) ) {
|
||||
throw new InvalidArgumentException( "$func callback: \$extra[$from] is not provided" );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -377,8 +377,8 @@ class ContentSecurityPolicy {
|
|||
}
|
||||
}
|
||||
$RLSources = $this->mwConfig->get( MainConfigNames::ResourceLoaderSources );
|
||||
foreach ( $RLSources as $wiki => $sources ) {
|
||||
foreach ( $sources as $id => $value ) {
|
||||
foreach ( $RLSources as $sources ) {
|
||||
foreach ( $sources as $value ) {
|
||||
$url = $this->prepareUrlForCSP( $value );
|
||||
if ( $url ) {
|
||||
$additionalUrls[] = $url;
|
||||
|
|
@ -433,8 +433,8 @@ class ContentSecurityPolicy {
|
|||
}
|
||||
$RLSources = $this->mwConfig->get( MainConfigNames::ResourceLoaderSources );
|
||||
|
||||
foreach ( $RLSources as $wiki => $sources ) {
|
||||
foreach ( $sources as $id => $value ) {
|
||||
foreach ( $RLSources as $sources ) {
|
||||
foreach ( $sources as $value ) {
|
||||
$url = $this->prepareUrlForCSP( $value );
|
||||
if ( $url ) {
|
||||
$additionalSelfUrls[] = $url;
|
||||
|
|
|
|||
|
|
@ -2773,7 +2773,7 @@ class OutputPage extends ContextSource {
|
|||
public function loadSkinModules( $sk ) {
|
||||
foreach ( $sk->getDefaultModules() as $group => $modules ) {
|
||||
if ( $group === 'styles' ) {
|
||||
foreach ( $modules as $key => $moduleMembers ) {
|
||||
foreach ( $modules as $moduleMembers ) {
|
||||
$this->addModuleStyles( $moduleMembers );
|
||||
}
|
||||
} else {
|
||||
|
|
@ -4134,7 +4134,7 @@ class OutputPage extends ContextSource {
|
|||
// Things that go after the ResourceLoaderDynamicStyles marker
|
||||
$append = [];
|
||||
$separateReq = [ 'site.styles', 'user.styles' ];
|
||||
foreach ( $this->rlExemptStyleModules as $group => $moduleNames ) {
|
||||
foreach ( $this->rlExemptStyleModules as $moduleNames ) {
|
||||
if ( $moduleNames ) {
|
||||
$append[] = $this->makeResourceLoaderLink(
|
||||
array_diff( $moduleNames, $separateReq ),
|
||||
|
|
|
|||
|
|
@ -917,7 +917,7 @@ class FileModule extends Module {
|
|||
|
||||
$result = [];
|
||||
|
||||
foreach ( $collatedStyleFiles as $media => $styleFiles ) {
|
||||
foreach ( $collatedStyleFiles as $styleFiles ) {
|
||||
foreach ( $styleFiles as $styleFile ) {
|
||||
$result[] = $this->getLocalPath( $styleFile );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@ class ImageModule extends Module {
|
|||
// Backwards compatibility
|
||||
$option = [ 'default' => $option ];
|
||||
}
|
||||
foreach ( $option as $skin => $data ) {
|
||||
foreach ( $option as $data ) {
|
||||
if ( !is_array( $data ) ) {
|
||||
throw new InvalidArgumentException(
|
||||
"Invalid list error. '$data' given, array expected."
|
||||
|
|
@ -450,7 +450,7 @@ class ImageModule extends Module {
|
|||
private function getFileHashes( Context $context ) {
|
||||
$this->loadFromDefinition();
|
||||
$files = [];
|
||||
foreach ( $this->getImages( $context ) as $name => $image ) {
|
||||
foreach ( $this->getImages( $context ) as $image ) {
|
||||
$files[] = $image->getPath( $context );
|
||||
}
|
||||
$files = array_values( array_unique( $files ) );
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ trait OOUIModule {
|
|||
|
||||
// Allow custom themes' paths to be relative to the skin/extension that defines them,
|
||||
// like with ResourceModuleSkinStyles
|
||||
foreach ( $themePaths as $theme => &$paths ) {
|
||||
foreach ( $themePaths as &$paths ) {
|
||||
list( $localBasePath, $remoteBasePath ) =
|
||||
FileModule::extractBasePaths( $paths );
|
||||
if ( $localBasePath !== $defaultLocalBasePath || $remoteBasePath !== $defaultRemoteBasePath ) {
|
||||
|
|
|
|||
|
|
@ -1291,7 +1291,7 @@ MESSAGE;
|
|||
}
|
||||
} elseif ( is_array( $scripts ) && isset( $scripts['files'] ) ) {
|
||||
$files = $scripts['files'];
|
||||
foreach ( $files as $path => &$file ) {
|
||||
foreach ( $files as &$file ) {
|
||||
// $file is changed (by reference) from a descriptor array to the content of the file
|
||||
// All of these essentially do $file = $file['content'];, some just have wrapping around it
|
||||
if ( $file['type'] === 'script' ) {
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ class StartUpModule extends Module {
|
|||
* @phan-param array<string,array{version:string,dependencies:array,group:?string,source:string}> &$registryData
|
||||
*/
|
||||
public static function compileUnresolvedDependencies( array &$registryData ): void {
|
||||
foreach ( $registryData as $name => &$data ) {
|
||||
foreach ( $registryData as &$data ) {
|
||||
$dependencies = $data['dependencies'];
|
||||
try {
|
||||
foreach ( $data['dependencies'] as $dependency ) {
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ class PathMatcher {
|
|||
$part = $parts[$index];
|
||||
$result = false;
|
||||
if ( $this->isParam( $part ) ) {
|
||||
foreach ( $node as $key => $childNode ) {
|
||||
foreach ( $node as $childNode ) {
|
||||
$result = $this->findConflict( $childNode, $parts, $index + 1 );
|
||||
if ( $result !== false ) {
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -88,11 +88,11 @@ class MutableRevisionRecord extends RevisionRecord {
|
|||
$newRevisionRecord->setParentId( $revision->getParentId( $revision->getWikiId() ) );
|
||||
$newRevisionRecord->setUser( $revision->getUser() );
|
||||
|
||||
foreach ( $revision->getSlots()->getSlots() as $role => $slot ) {
|
||||
foreach ( $revision->getSlots()->getSlots() as $slot ) {
|
||||
$newRevisionRecord->setSlot( $slot );
|
||||
}
|
||||
|
||||
foreach ( $slots as $role => $slot ) {
|
||||
foreach ( $slots as $slot ) {
|
||||
$newRevisionRecord->setSlot( $slot );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ class CheckBlocksSecondaryAuthenticationProvider extends AbstractSecondaryAuthen
|
|||
'local-createaccount' => $user->isBlockedFromCreateAccount(),
|
||||
'local' => $user->getBlock(),
|
||||
];
|
||||
foreach ( $blocks as $type => $block ) {
|
||||
foreach ( $blocks as $block ) {
|
||||
/** @var AbstractBlock $block */
|
||||
if ( $block && $block->isSitewide()
|
||||
// This method is for checking a given account/username, not the current user, so
|
||||
|
|
|
|||
|
|
@ -358,7 +358,7 @@ abstract class ChangesListFilterGroup {
|
|||
return $b->getPriority() <=> $a->getPriority();
|
||||
} );
|
||||
|
||||
foreach ( $this->filters as $filterName => $filter ) {
|
||||
foreach ( $this->filters as $filter ) {
|
||||
if ( $filter->displaysOnStructuredUi() ) {
|
||||
$filterData = $filter->getJsData();
|
||||
$output['messageKeys'] = array_merge(
|
||||
|
|
|
|||
|
|
@ -2197,7 +2197,7 @@ class HTMLForm extends ContextSource {
|
|||
* @since 1.29
|
||||
*/
|
||||
public function needsJSForHtml5FormValidation() {
|
||||
foreach ( $this->mFlatFields as $fieldname => $field ) {
|
||||
foreach ( $this->mFlatFields as $field ) {
|
||||
if ( $field->needsJSForHtml5FormValidation() ) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -260,7 +260,7 @@ abstract class HTMLFormField {
|
|||
case 'OR':
|
||||
case 'NAND':
|
||||
case 'NOR':
|
||||
foreach ( $params as $i => $p ) {
|
||||
foreach ( $params as $p ) {
|
||||
if ( $valueChk[$op] === $this->checkStateRecurse( $alldata, $p ) ) {
|
||||
return !$valueRet[$op];
|
||||
}
|
||||
|
|
@ -300,7 +300,7 @@ abstract class HTMLFormField {
|
|||
case 'NAND':
|
||||
case 'NOR':
|
||||
$ret = [ $op ];
|
||||
foreach ( $params as $i => $p ) {
|
||||
foreach ( $params as $p ) {
|
||||
$ret[] = $this->parseCondState( $p );
|
||||
}
|
||||
return $ret;
|
||||
|
|
|
|||
|
|
@ -1443,7 +1443,7 @@ abstract class Installer {
|
|||
// so the first extension is the one we want to load,
|
||||
// everything else is a dependency
|
||||
$i = 0;
|
||||
foreach ( $info['credits'] as $name => $credit ) {
|
||||
foreach ( $info['credits'] as $credit ) {
|
||||
$i++;
|
||||
if ( $i == 1 ) {
|
||||
// Extension we want to load
|
||||
|
|
|
|||
|
|
@ -977,7 +977,7 @@ class WebInstaller extends Installer {
|
|||
}
|
||||
|
||||
$s = "<ul>\n";
|
||||
foreach ( $items as $value => $item ) {
|
||||
foreach ( $items as $item ) {
|
||||
$s .= "<li>$item</li>\n";
|
||||
}
|
||||
$s .= "</ul>\n";
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ class LCStoreStaticArray implements LCStore {
|
|||
* @return bool
|
||||
*/
|
||||
private static function isValueArray( array $arr ) {
|
||||
foreach ( $arr as $key => $value ) {
|
||||
foreach ( $arr as $value ) {
|
||||
if ( is_scalar( $value )
|
||||
|| $value === null
|
||||
|| ( is_array( $value ) && self::isValueArray( $value ) )
|
||||
|
|
|
|||
|
|
@ -228,7 +228,7 @@ class ArrayUtils {
|
|||
while ( !$done ) {
|
||||
// Construct the output array element
|
||||
$element = [];
|
||||
foreach ( $inputArrays as $paramIndex => $inputArray ) {
|
||||
foreach ( $inputArrays as $inputArray ) {
|
||||
$element[] = current( $inputArray );
|
||||
}
|
||||
$outputArrays[] = $element;
|
||||
|
|
|
|||
|
|
@ -411,7 +411,7 @@ class HashRing implements Serializable {
|
|||
if ( count( $this->ejectExpiryByLocation ) ) {
|
||||
// Some locations are still ejected from the ring
|
||||
$liveRing = [];
|
||||
foreach ( $this->baseRing as $i => $nodeInfo ) {
|
||||
foreach ( $this->baseRing as $nodeInfo ) {
|
||||
$location = $nodeInfo[self::KEY_LOCATION];
|
||||
if ( !isset( $this->ejectExpiryByLocation[$location] ) ) {
|
||||
$liveRing[] = $nodeInfo;
|
||||
|
|
|
|||
|
|
@ -486,7 +486,7 @@ class ChronologyProtector implements LoggerAwareInterface {
|
|||
|
||||
if ( $indexReached && $this->hasImplicitClientId ) {
|
||||
$isWithinPossibleCookieTTL = false;
|
||||
foreach ( $this->startupTimestampsByCluster as $cluster => $timestamp ) {
|
||||
foreach ( $this->startupTimestampsByCluster as $timestamp ) {
|
||||
if ( ( $this->startupTimestamp - $timestamp ) < self::POSITION_COOKIE_TTL ) {
|
||||
$isWithinPossibleCookieTTL = true;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -402,8 +402,8 @@ class RedisConnectionPool implements LoggerAwareInterface {
|
|||
* Make sure connections are closed
|
||||
*/
|
||||
public function __destruct() {
|
||||
foreach ( $this->connections as $server => &$serverConnections ) {
|
||||
foreach ( $serverConnections as $key => &$connection ) {
|
||||
foreach ( $this->connections as &$serverConnections ) {
|
||||
foreach ( $serverConnections as &$connection ) {
|
||||
try {
|
||||
/** @var Redis $conn */
|
||||
$conn = $connection['conn'];
|
||||
|
|
|
|||
|
|
@ -374,7 +374,7 @@ class LogPager extends ReverseChronologicalPager {
|
|||
} elseif ( array_key_exists( 'log_actor', $this->mConds ) ) {
|
||||
// Optimizer doesn't pick the right index when a user has lots of log actions (T303089)
|
||||
$index = 'log_actor_time';
|
||||
foreach ( $this->getFilterParams() as $type => $hide ) {
|
||||
foreach ( $this->getFilterParams() as $hide ) {
|
||||
if ( !$hide ) {
|
||||
$index = 'log_actor_type_time';
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -369,7 +369,7 @@ class LinkHolderArray {
|
|||
$ns = $title->getNamespace();
|
||||
$text = $title->getText();
|
||||
|
||||
foreach ( $titlesAllVariants as $variantName => $textVariants ) {
|
||||
foreach ( $titlesAllVariants as $textVariants ) {
|
||||
$textVariant = $textVariants[$i];
|
||||
if ( $textVariant === $text ) {
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -315,7 +315,7 @@ class PPNode_Hash_Tree implements PPNode {
|
|||
*/
|
||||
public static function splitRawHeading( array $children ) {
|
||||
$bits = [];
|
||||
foreach ( $children as $i => $child ) {
|
||||
foreach ( $children as $child ) {
|
||||
if ( !is_array( $child ) ) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -794,7 +794,7 @@ class ParserOutput extends CacheTime implements ContentMetadataCollector {
|
|||
public function getJsConfigVars( bool $showStrategyKeys = false ) {
|
||||
$result = $this->mJsConfigVars;
|
||||
// Don't expose the internal strategy key
|
||||
foreach ( $result as $key => &$value ) {
|
||||
foreach ( $result as &$value ) {
|
||||
if ( is_array( $value ) && !$showStrategyKeys ) {
|
||||
unset( $value[self::MW_MERGE_STRATEGY_KEY] );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1937,7 +1937,7 @@ abstract class Skin extends ContextSource {
|
|||
|
||||
$linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
|
||||
$linksHtml = [];
|
||||
foreach ( $links as $k => $linkDetails ) {
|
||||
foreach ( $links as $linkDetails ) {
|
||||
$linksHtml[] = $linkRenderer->makeKnownLink(
|
||||
$linkDetails['targetTitle'],
|
||||
$linkDetails['text'],
|
||||
|
|
|
|||
|
|
@ -838,7 +838,7 @@ class SkinTemplate extends Skin {
|
|||
$icons = [];
|
||||
foreach ( $footerIcons as $blockName => $blockIcons ) {
|
||||
$html = '';
|
||||
foreach ( $blockIcons as $key => $icon ) {
|
||||
foreach ( $blockIcons as $icon ) {
|
||||
$html .= $this->makeFooterIcon( $icon );
|
||||
}
|
||||
// For historic reasons this mimics the `icononly` option
|
||||
|
|
|
|||
|
|
@ -611,7 +611,7 @@ abstract class AuthManagerSpecialPage extends SpecialPage {
|
|||
* @return bool
|
||||
*/
|
||||
protected function hasOwnSubmitButton( AuthenticationRequest $req ) {
|
||||
foreach ( $req->getFieldInfo() as $field => $info ) {
|
||||
foreach ( $req->getFieldInfo() as $info ) {
|
||||
if ( $info['type'] === 'button' ) {
|
||||
return true;
|
||||
}
|
||||
|
|
@ -626,7 +626,7 @@ abstract class AuthManagerSpecialPage extends SpecialPage {
|
|||
*/
|
||||
protected function addTabIndex( &$formDescriptor ) {
|
||||
$i = 1;
|
||||
foreach ( $formDescriptor as $field => &$definition ) {
|
||||
foreach ( $formDescriptor as &$definition ) {
|
||||
$class = false;
|
||||
if ( array_key_exists( 'class', $definition ) ) {
|
||||
$class = $definition['class'];
|
||||
|
|
|
|||
|
|
@ -1178,7 +1178,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
|
|||
return $b->getPriority() <=> $a->getPriority();
|
||||
} );
|
||||
|
||||
foreach ( $this->filterGroups as $groupName => $group ) {
|
||||
foreach ( $this->filterGroups as $group ) {
|
||||
$groupOutput = $group->getJsData();
|
||||
if ( $groupOutput !== null ) {
|
||||
$output['messageKeys'] = array_merge(
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ class SpecialTrackingCategories extends SpecialPage {
|
|||
$categoryList = $this->trackingCategories->getTrackingCategories();
|
||||
|
||||
$batch = $this->linkBatchFactory->newLinkBatch();
|
||||
foreach ( $categoryList as $catMsg => $data ) {
|
||||
foreach ( $categoryList as $data ) {
|
||||
$batch->addObj( $data['msg'] );
|
||||
foreach ( $data['cats'] as $catTitle ) {
|
||||
$batch->addObj( $catTitle );
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ class SpecialUncategorizedCategories extends SpecialUncategorizedPages {
|
|||
$exList = $this->msg( 'uncategorized-categories-exceptionlist' )
|
||||
->inContentLanguage()->plain();
|
||||
$proposedTitles = explode( "\n", $exList );
|
||||
foreach ( $proposedTitles as $count => $titleStr ) {
|
||||
foreach ( $proposedTitles as $titleStr ) {
|
||||
if ( strpos( $titleStr, '*' ) !== 0 ) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ class SpecialVersion extends SpecialPage {
|
|||
*/
|
||||
public static function getCredits( ExtensionRegistry $reg, Config $conf ): array {
|
||||
$credits = $conf->get( MainConfigNames::ExtensionCredits );
|
||||
foreach ( $reg->getAllThings() as $name => $credit ) {
|
||||
foreach ( $reg->getAllThings() as $credit ) {
|
||||
$credits[$credit['type']][] = $credit;
|
||||
}
|
||||
return $credits;
|
||||
|
|
@ -94,7 +94,7 @@ class SpecialVersion extends SpecialPage {
|
|||
if ( isset( $parts[1] ) ) {
|
||||
$extName = str_replace( '_', ' ', $parts[1] );
|
||||
// Find it!
|
||||
foreach ( $credits as $group => $extensions ) {
|
||||
foreach ( $credits as $extensions ) {
|
||||
foreach ( $extensions as $ext ) {
|
||||
if ( isset( $ext['name'] ) && ( $ext['name'] === $extName ) ) {
|
||||
$extNode = &$ext;
|
||||
|
|
|
|||
|
|
@ -253,8 +253,8 @@ class WatchedItemStore implements WatchedItemStoreInterface, StatsdAwareInterfac
|
|||
*/
|
||||
private function uncacheUser( UserIdentity $user ) {
|
||||
$this->stats->increment( 'WatchedItemStore.uncacheUser' );
|
||||
foreach ( $this->cacheIndex as $ns => $dbKeyArray ) {
|
||||
foreach ( $dbKeyArray as $dbKey => $userArray ) {
|
||||
foreach ( $this->cacheIndex as $dbKeyArray ) {
|
||||
foreach ( $dbKeyArray as $userArray ) {
|
||||
if ( isset( $userArray[$user->getId()] ) ) {
|
||||
$this->stats->increment( 'WatchedItemStore.uncacheUser.items' );
|
||||
$this->cache->delete( $userArray[$user->getId()] );
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ class DeprecatedInterfaceFinder extends FileAwareNodeVisitor {
|
|||
|
||||
public function getFoundNodes() {
|
||||
// Sort results by version, then by filename, then by name.
|
||||
foreach ( $this->foundNodes as $version => &$nodes ) {
|
||||
foreach ( $this->foundNodes as &$nodes ) {
|
||||
uasort( $nodes, static function ( $a, $b ) {
|
||||
return ( $a['filename'] . $a['name'] ) <=> ( $b['filename'] . $b['name'] );
|
||||
} );
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ class GetConfiguration extends Maintenance {
|
|||
|
||||
private function isAllowedVariable( $value ) {
|
||||
if ( is_array( $value ) ) {
|
||||
foreach ( $value as $k => $v ) {
|
||||
foreach ( $value as $v ) {
|
||||
if ( !$this->isAllowedVariable( $v ) ) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue