Skip to content

Commit d62e097

Browse files
authored
Merge pull request #195 from magento/ihor-sviziev-patch-1
Better solution for fixing array_merge in loop
2 parents 7f6fd20 + 30ed54f commit d62e097

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

Magento2/Sniffs/Performance/ForeachArrayMergeSniff.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@ Typical example when `array_merge` is being used in the loop:
1515

1616
In order to reduce execution time `array_merge` can be called only once:
1717
``` php
18-
$options = [[]];
18+
$options = [];
1919
foreach ($configurationSources as $source) {
2020
// code here
2121
$options[] = $source->getOptions();
2222
}
2323

24-
// PHP 5.6+
25-
$options = array_merge(...$options);
24+
$options = array_merge([], ...$options);
2625
```

0 commit comments

Comments
 (0)