Skip to content

Commit 5e72e62

Browse files
thiemowmdeWMDE bot
authored andcommitted
Streamline various places that construct PHP arrays
This is only about code style and doesn't change anything. The main benefit is that the array is one unit, there are much less confusing square brackets, and no variable name needs to be repeated. Change-Id: Ibfcdbbcf8dafdef7887f795b91d5fa96dc3a6342
1 parent 91ee099 commit 5e72e62

2 files changed

Lines changed: 12 additions & 16 deletions

File tree

src/Diff/ItemDiffer.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,12 @@ public function diffItems( Item $from, Item $to ): ItemDiff {
7474
}
7575

7676
private function toDiffArray( Item $item ): array {
77-
$array = [];
78-
79-
$array['aliases'] = $item->getAliasGroups()->toTextArray();
80-
$array['label'] = $item->getLabels()->toTextArray();
81-
$array['description'] = $item->getDescriptions()->toTextArray();
82-
$array['links'] = $this->getSiteLinksInDiffFormat( $item->getSiteLinkList() );
83-
84-
return $array;
77+
return [
78+
'aliases' => $item->getAliasGroups()->toTextArray(),
79+
'label' => $item->getLabels()->toTextArray(),
80+
'description' => $item->getDescriptions()->toTextArray(),
81+
'links' => $this->getSiteLinksInDiffFormat( $item->getSiteLinkList() ),
82+
];
8583
}
8684

8785
private function getSiteLinksInDiffFormat( SiteLinkList $siteLinks ): array {

src/Diff/PropertyDiffer.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,12 @@ private function diffPropertyArrays( array $from, array $to ) {
8888
*
8989
* @return array[]
9090
*/
91-
private function toDiffArray( Property $property ) {
92-
$array = [];
93-
94-
$array['aliases'] = $property->getAliasGroups()->toTextArray();
95-
$array['label'] = $property->getLabels()->toTextArray();
96-
$array['description'] = $property->getDescriptions()->toTextArray();
97-
98-
return $array;
91+
private function toDiffArray( Property $property ): array {
92+
return [
93+
'aliases' => $property->getAliasGroups()->toTextArray(),
94+
'label' => $property->getLabels()->toTextArray(),
95+
'description' => $property->getDescriptions()->toTextArray(),
96+
];
9997
}
10098

10199
/**

0 commit comments

Comments
 (0)