Make use of native array_column() function where possible
Change-Id: I78108e7dc5a10d892e97b0101c1b72cb8d363e97
This commit is contained in:
parent
89e454c7fe
commit
6f901ef17c
4 changed files with 5 additions and 22 deletions
|
|
@ -724,10 +724,7 @@ class ApiUpload extends ApiBase {
|
|||
ApiResult::setIndexedTagName( $warnings, 'warning' );
|
||||
|
||||
if ( isset( $warnings['duplicate'] ) ) {
|
||||
$dupes = [];
|
||||
foreach ( $warnings['duplicate'] as $dupe ) {
|
||||
$dupes[] = $dupe['fileName'];
|
||||
}
|
||||
$dupes = array_column( $warnings['duplicate'], 'fileName' );
|
||||
ApiResult::setIndexedTagName( $dupes, 'duplicate' );
|
||||
$warnings['duplicate'] = $dupes;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1168,11 +1168,7 @@ class LinksUpdate extends DataUpdate {
|
|||
if ( $this->externalLinkInsertions === null ) {
|
||||
return null;
|
||||
}
|
||||
$result = [];
|
||||
foreach ( $this->externalLinkInsertions as $key => $value ) {
|
||||
$result[] = $value['el_to'];
|
||||
}
|
||||
return $result;
|
||||
return array_column( $this->externalLinkInsertions, 'el_to' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -243,18 +243,11 @@ class NamespaceDupes extends Maintenance {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the interwiki list
|
||||
*
|
||||
* @return array
|
||||
* @return string[]
|
||||
*/
|
||||
private function getInterwikiList() {
|
||||
$result = MediaWikiServices::getInstance()->getInterwikiLookup()->getAllPrefixes();
|
||||
$prefixes = [];
|
||||
foreach ( $result as $row ) {
|
||||
$prefixes[] = $row['iw_prefix'];
|
||||
}
|
||||
|
||||
return $prefixes;
|
||||
return array_column( $result, 'iw_prefix' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -41,10 +41,7 @@ class ApiQuerySearchTest extends ApiTestCase {
|
|||
'list' => 'search',
|
||||
'srsearch' => 'my query',
|
||||
] );
|
||||
$titles = [];
|
||||
foreach ( $response['query']['search'] as $result ) {
|
||||
$titles[] = $result['title'];
|
||||
}
|
||||
$titles = array_column( $response['query']['search'], 'title' );
|
||||
$this->assertEquals( $expect, $titles );
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue