Skip to content

Commit e48193e

Browse files
author
Lars Roettig
committed
Update implementation
1 parent eecaa67 commit e48193e

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

Magento2/Sniffs/Performance/ForeachArrayMergeSniff.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public function process(File $phpcsFile, $stackPtr)
6262
continue;
6363
}
6464

65+
$this->foreachCache[$cacheKey] = '';
6566
$phpcsFile->addWarning($this->warningMessage, $i, $this->warningCode);
6667
}
6768
}

Magento2/Tests/Performance/ForeachArrayMergeUnitTest.inc

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,25 @@ for ($i = 0; $i <= $itemCount; $i++) {
1919
$options = array_merge($options, $source));
2020
}
2121

22-
class CSV
22+
class SelectBuilder
2323
{
24-
public static function getColumns()
24+
private $columns = [];
25+
26+
public function getColumns()
2527
{
26-
return [];
28+
return $this->columns;
29+
}
30+
31+
public function setColumns(array $columns)
32+
{
33+
$this->columns = $columns;
2734
}
2835
}
2936

37+
$selectBuilder = new SelectBuilder();
38+
3039
foreach ([] as $collection) {
3140
foreach ($configurationSources as $source) {
32-
$options = array_merge(CSV::getColumns(), $source);
41+
$selectBuilder->setColumns(array_merge($selectBuilder->getColumns(), $source));
3342
}
3443
}

Magento2/Tests/Performance/ForeachArrayMergeUnitTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function getWarningList()
2727
{
2828
return [
2929
11 => 1,
30-
19 => 1,
30+
19 => 1
3131
];
3232
}
3333
}

0 commit comments

Comments
 (0)