Make use of existing array value variables in foreach loops
In all these cases, the foreach() loop specifies a variable for the current value. We don't need two ways to access the same value. This makes the code harder to read. Change-Id: I6ed7a518439963b7091057194de993a7e977be32
This commit is contained in:
parent
c21b978408
commit
b39a56d74e
9 changed files with 17 additions and 17 deletions
|
|
@ -439,8 +439,8 @@ class SiteConfiguration {
|
|||
}
|
||||
|
||||
foreach ( $default as $name => $def ) {
|
||||
if ( !isset( $ret[$name] ) || ( is_array( $default[$name] ) && !is_array( $ret[$name] ) ) ) {
|
||||
$ret[$name] = $default[$name];
|
||||
if ( !isset( $ret[$name] ) || ( is_array( $def ) && !is_array( $ret[$name] ) ) ) {
|
||||
$ret[$name] = $def;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -205,7 +205,7 @@ class EnhancedChangesList extends ChangesList {
|
|||
# Default values for RC flags
|
||||
$collectedRcFlags = [];
|
||||
foreach ( $recentChangesFlags as $key => $value ) {
|
||||
$flagGrouping = ( $recentChangesFlags[$key]['grouping'] ?? 'any' );
|
||||
$flagGrouping = $value['grouping'] ?? 'any';
|
||||
switch ( $flagGrouping ) {
|
||||
case 'all':
|
||||
$collectedRcFlags[$key] = true;
|
||||
|
|
|
|||
|
|
@ -776,9 +776,9 @@ class LinksUpdate extends DataUpdate {
|
|||
$del = [];
|
||||
foreach ( $existing as $ns => $dbkeys ) {
|
||||
if ( isset( $this->mLinks[$ns] ) ) {
|
||||
$del[$ns] = array_diff_key( $existing[$ns], $this->mLinks[$ns] );
|
||||
$del[$ns] = array_diff_key( $dbkeys, $this->mLinks[$ns] );
|
||||
} else {
|
||||
$del[$ns] = $existing[$ns];
|
||||
$del[$ns] = $dbkeys;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -795,9 +795,9 @@ class LinksUpdate extends DataUpdate {
|
|||
$del = [];
|
||||
foreach ( $existing as $ns => $dbkeys ) {
|
||||
if ( isset( $this->mTemplates[$ns] ) ) {
|
||||
$del[$ns] = array_diff_key( $existing[$ns], $this->mTemplates[$ns] );
|
||||
$del[$ns] = array_diff_key( $dbkeys, $this->mTemplates[$ns] );
|
||||
} else {
|
||||
$del[$ns] = $existing[$ns];
|
||||
$del[$ns] = $dbkeys;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -863,9 +863,9 @@ class LinksUpdate extends DataUpdate {
|
|||
$del = [];
|
||||
foreach ( $existing as $prefix => $dbkeys ) {
|
||||
if ( isset( $this->mInterwikis[$prefix] ) ) {
|
||||
$del[$prefix] = array_diff_key( $existing[$prefix], $this->mInterwikis[$prefix] );
|
||||
$del[$prefix] = array_diff_key( $dbkeys, $this->mInterwikis[$prefix] );
|
||||
} else {
|
||||
$del[$prefix] = $existing[$prefix];
|
||||
$del[$prefix] = $dbkeys;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ class FileOpBatch {
|
|||
foreach ( $performOpsBatch as $i => $fileOp ) {
|
||||
$status->success[$i] = false;
|
||||
++$status->failCount;
|
||||
$performOpsBatch[$i]->logFailure( 'attempt_aborted' );
|
||||
$fileOp->logFailure( 'attempt_aborted' );
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -683,7 +683,7 @@ abstract class IndexPager extends ContextSource implements Pager {
|
|||
if ( $query !== false ) {
|
||||
$links[$type] = $this->makeLink(
|
||||
$linkTexts[$type],
|
||||
$queries[$type],
|
||||
$query,
|
||||
$type
|
||||
);
|
||||
} elseif ( isset( $disabledTexts[$type] ) ) {
|
||||
|
|
|
|||
|
|
@ -198,7 +198,7 @@ class UserPasswordPolicy {
|
|||
if ( in_array( $group, $userGroups ) ) {
|
||||
$effectivePolicy = self::maxOfPolicies(
|
||||
$effectivePolicy,
|
||||
$policies[$group]
|
||||
$policy
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,14 +53,14 @@ class ResourceLoaderOOUIImageModule extends ResourceLoaderImageModule {
|
|||
// Images and color variants are defined per-theme, here converted to per-skin
|
||||
case 'images':
|
||||
case 'variants':
|
||||
$definition[$key][$skin] = $data[$key];
|
||||
$definition[$key][$skin] = $value;
|
||||
break;
|
||||
|
||||
// Other options must be identical for each theme (or only defined in the default one)
|
||||
default:
|
||||
if ( !isset( $definition[$key] ) ) {
|
||||
$definition[$key] = $data[$key];
|
||||
} elseif ( $definition[$key] !== $data[$key] ) {
|
||||
$definition[$key] = $value;
|
||||
} elseif ( $definition[$key] !== $value ) {
|
||||
throw new Exception(
|
||||
"Mismatched OOUI theme images definition: " .
|
||||
"key '$key' of theme '$theme' for module '$module' " .
|
||||
|
|
|
|||
|
|
@ -305,7 +305,7 @@ class PHPSessionHandler implements \SessionHandlerInterface {
|
|||
if ( !array_key_exists( $key, $data ) && $session->exists( $key ) &&
|
||||
\Wikimedia\PhpSessionSerializer::encode( [ $key => true ] )
|
||||
) {
|
||||
if ( $cache[$key] === $session->get( $key ) ) {
|
||||
if ( $value === $session->get( $key ) ) {
|
||||
// Unchanged in Session, delete it
|
||||
$session->remove( $key );
|
||||
$changed = true;
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ class PreferencesFormOOUI extends OOUIHTMLForm {
|
|||
$content =
|
||||
$this->getHeaderText( $key ) .
|
||||
$this->displaySection(
|
||||
$this->mFieldTree[$key],
|
||||
$val,
|
||||
"",
|
||||
"mw-prefsection-$key-"
|
||||
) .
|
||||
|
|
|
|||
Loading…
Reference in a new issue