Skip to content

Commit de81a98

Browse files
ENGCOM-8261: Use one format in all places for array_merge #30002
2 parents 3373b49 + fa5e131 commit de81a98

File tree

69 files changed

+160
-174
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+160
-174
lines changed

app/code/Magento/Catalog/Block/Product/ListProduct.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ public function getIdentities()
367367
$identities[] = $item->getIdentities();
368368
}
369369
}
370-
$identities = array_merge(...$identities);
370+
$identities = array_merge([], ...$identities);
371371

372372
return $identities;
373373
}

app/code/Magento/Catalog/Block/Product/ProductList/Related.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,11 @@ public function getItems()
143143
*/
144144
public function getIdentities()
145145
{
146-
$identities = [[]];
146+
$identities = [];
147147
foreach ($this->getItems() as $item) {
148148
$identities[] = $item->getIdentities();
149149
}
150-
return array_merge(...$identities);
150+
return array_merge([], ...$identities);
151151
}
152152

153153
/**

app/code/Magento/Catalog/Block/Product/ProductList/Upsell.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,10 @@ public function getItemLimit($type = '')
267267
*/
268268
public function getIdentities()
269269
{
270-
$identities = array_map(function (DataObject $item) {
271-
return $item->getIdentities();
272-
}, $this->getItems()) ?: [[]];
273-
274-
return array_merge(...$identities);
270+
$identities = [];
271+
foreach ($this->getItems() as $item) {
272+
$identities[] = $item->getIdentities();
273+
}
274+
return array_merge([], ...$identities);
275275
}
276276
}

app/code/Magento/Catalog/Model/Indexer/Product/Category/Action/Rows.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,14 +270,14 @@ private function getCategoryIdsFromIndex(array $productIds): array
270270
);
271271
$categoryIds[] = $storeCategories;
272272
}
273-
$categoryIds = array_merge(...$categoryIds);
273+
$categoryIds = array_merge([], ...$categoryIds);
274274

275275
$parentCategories = [$categoryIds];
276276
foreach ($categoryIds as $categoryId) {
277277
$parentIds = explode('/', $this->getPathFromCategoryId($categoryId));
278278
$parentCategories[] = $parentIds;
279279
}
280-
$categoryIds = array_unique(array_merge(...$parentCategories));
280+
$categoryIds = array_unique(array_merge([], ...$parentCategories));
281281

282282
return $categoryIds;
283283
}

app/code/Magento/Catalog/Model/Indexer/Product/Flat/FlatTableBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ protected function _fillTemporaryFlatTable(array $tables, $storeId, $valueFieldS
261261

262262
$select->from(
263263
['et' => $entityTemporaryTableName],
264-
array_merge(...$allColumns)
264+
array_merge([], ...$allColumns)
265265
)->joinInner(
266266
['e' => $this->resource->getTableName('catalog_product_entity')],
267267
'e.entity_id = et.entity_id',
@@ -306,7 +306,7 @@ protected function _fillTemporaryFlatTable(array $tables, $storeId, $valueFieldS
306306
$allColumns[] = $columnValueNames;
307307
}
308308
}
309-
$sql = $select->insertFromSelect($temporaryFlatTableName, array_merge(...$allColumns), false);
309+
$sql = $select->insertFromSelect($temporaryFlatTableName, array_merge([], ...$allColumns), false);
310310
$this->_connection->query($sql);
311311
}
312312

app/code/Magento/Catalog/Model/Product.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -836,10 +836,7 @@ public function getStoreIds()
836836
$storeIds[] = $websiteStores;
837837
}
838838
}
839-
if ($storeIds) {
840-
$storeIds = array_merge(...$storeIds);
841-
}
842-
$this->setStoreIds($storeIds);
839+
$this->setStoreIds(array_merge([], ...$storeIds));
843840
}
844841
return $this->getData('store_ids');
845842
}

app/code/Magento/Catalog/Model/Product/Price/TierPriceStorage.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
use Magento\Catalog\Model\Product\Price\Validation\TierPriceValidator;
1313
use Magento\Catalog\Model\ProductIdLocatorInterface;
1414

15-
/**
16-
* Tier price storage.
17-
*/
1815
class TierPriceStorage implements TierPriceStorageInterface
1916
{
2017
/**
@@ -220,7 +217,7 @@ private function retrieveAffectedIds(array $skus): array
220217
$affectedIds[] = array_keys($productId);
221218
}
222219

223-
return $affectedIds ? array_unique(array_merge(...$affectedIds)) : [];
220+
return array_unique(array_merge([], ...$affectedIds));
224221
}
225222

226223
/**

app/code/Magento/Catalog/Model/ProductLink/ProductLinkQuery.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ private function extractRequestedLinkTypes(array $criteria): array
103103
if (count($linkTypesToLoad) === 1) {
104104
$linkTypesToLoad = $linkTypesToLoad[0];
105105
} else {
106-
$linkTypesToLoad = array_merge(...$linkTypesToLoad);
106+
$linkTypesToLoad = array_merge([], ...$linkTypesToLoad);
107107
}
108108
$linkTypesToLoad = array_flip($linkTypesToLoad);
109109
$linkTypes = array_filter(

app/code/Magento/Catalog/Model/ResourceModel/Product/LinkedProductSelectBuilderComposite.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function build(int $productId, int $storeId) : array
3333
foreach ($this->linkedProductSelectBuilder as $productSelectBuilder) {
3434
$selects[] = $productSelectBuilder->build($productId, $storeId);
3535
}
36-
$selects = array_merge(...$selects);
36+
$selects = array_merge([], ...$selects);
3737

3838
return $selects;
3939
}

app/code/Magento/CatalogGraphQl/DataProvider/Product/LayeredNavigation/Builder/Attribute.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ function (AggregationValueInterface $value) {
155155
return [];
156156
}
157157

158-
return $this->attributeOptionProvider->getOptions(\array_merge(...$attributeOptionIds), $storeId, $attributes);
158+
return $this->attributeOptionProvider->getOptions(
159+
\array_merge([], ...$attributeOptionIds),
160+
$storeId,
161+
$attributes
162+
);
159163
}
160164
}

app/code/Magento/CatalogGraphQl/DataProvider/Product/LayeredNavigation/LayerBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function build(AggregationInterface $aggregation, ?int $storeId): array
3636
foreach ($this->builders as $builder) {
3737
$layers[] = $builder->build($aggregation, $storeId);
3838
}
39-
$layers = \array_merge(...$layers);
39+
$layers = \array_merge([], ...$layers);
4040

4141
return \array_filter($layers);
4242
}

app/code/Magento/CatalogGraphQl/Model/AttributesJoiner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function getQueryFields(FieldNode $fieldNode, ResolveInfo $resolveInfo):
8888
}
8989
}
9090
if ($fragmentFields) {
91-
$selectedFields = array_merge($selectedFields, array_merge(...$fragmentFields));
91+
$selectedFields = array_merge([], $selectedFields, ...$fragmentFields);
9292
}
9393
$this->setSelectionsForFieldNode($fieldNode, array_unique($selectedFields));
9494
}

app/code/Magento/CatalogGraphQl/Model/Resolver/Products/SearchCriteria/CollectionProcessor/FilterProcessor/CategoryFilter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function apply(Filter $filter, AbstractDb $collection)
6464
$collection->addCategoryFilter($category);
6565
}
6666

67-
$categoryProductIds = array_unique(array_merge(...$categoryProducts));
67+
$categoryProductIds = array_unique(array_merge([], ...$categoryProducts));
6868
$collection->addIdFilter($categoryProductIds);
6969
return true;
7070
}

app/code/Magento/CatalogInventory/Model/StockIndex.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,11 @@ protected function processChildren(
169169

170170
$requiredChildrenIds = $typeInstance->getChildrenIds($productId, true);
171171
if ($requiredChildrenIds) {
172-
$childrenIds = [[]];
172+
$childrenIds = [];
173173
foreach ($requiredChildrenIds as $groupedChildrenIds) {
174174
$childrenIds[] = $groupedChildrenIds;
175175
}
176-
$childrenIds = array_merge(...$childrenIds);
176+
$childrenIds = array_merge([], ...$childrenIds);
177177

178178
$childrenWebsites = $this->productWebsite->getWebsites($childrenIds);
179179
foreach ($websitesWithStores as $websiteId => $storeId) {
@@ -232,13 +232,13 @@ protected function getWebsitesWithDefaultStores($websiteId = null)
232232
*/
233233
protected function processParents($productId, $websiteId)
234234
{
235-
$parentIds = [[]];
235+
$parentIds = [];
236236
foreach ($this->getProductTypeInstances() as $typeInstance) {
237237
/* @var ProductType\AbstractType $typeInstance */
238238
$parentIds[] = $typeInstance->getParentIdsByChild($productId);
239239
}
240240

241-
$parentIds = array_merge(...$parentIds);
241+
$parentIds = array_merge([], ...$parentIds);
242242

243243
if (empty($parentIds)) {
244244
return;

app/code/Magento/CatalogSearch/Model/Layer/Filter/Attribute.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function apply(\Magento\Framework\App\RequestInterface $request)
7070
$label = $this->getOptionText($value);
7171
$labels[] = is_array($label) ? $label : [$label];
7272
}
73-
$label = implode(',', array_unique(array_merge(...$labels)));
73+
$label = implode(',', array_unique(array_merge([], ...$labels)));
7474
$this->getLayer()
7575
->getState()
7676
->addFilter($this->_createItem($label, $attributeValue));

app/code/Magento/CatalogUrlRewrite/Model/Category/Plugin/Store/Group.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public function afterSave(
121121
*/
122122
protected function generateProductUrls($websiteId, $originWebsiteId)
123123
{
124-
$urls = [[]];
124+
$urls = [];
125125
$websiteIds = $websiteId != $originWebsiteId
126126
? [$websiteId, $originWebsiteId]
127127
: [$websiteId];
@@ -136,7 +136,7 @@ protected function generateProductUrls($websiteId, $originWebsiteId)
136136
$urls[] = $this->productUrlRewriteGenerator->generate($product);
137137
}
138138

139-
return array_merge(...$urls);
139+
return array_merge([], ...$urls);
140140
}
141141

142142
/**
@@ -148,7 +148,7 @@ protected function generateProductUrls($websiteId, $originWebsiteId)
148148
*/
149149
protected function generateCategoryUrls($rootCategoryId, $storeIds)
150150
{
151-
$urls = [[]];
151+
$urls = [];
152152
$categories = $this->categoryFactory->create()->getCategories($rootCategoryId, 1, false, true);
153153
foreach ($categories as $category) {
154154
/** @var \Magento\Catalog\Model\Category $category */
@@ -157,6 +157,6 @@ protected function generateCategoryUrls($rootCategoryId, $storeIds)
157157
$urls[] = $this->categoryUrlRewriteGenerator->generate($category);
158158
}
159159

160-
return array_merge(...$urls);
160+
return array_merge([], ...$urls);
161161
}
162162
}

app/code/Magento/CatalogUrlRewrite/Observer/AfterImportDataObserver.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@
3737
use RuntimeException;
3838

3939
/**
40-
* Class AfterImportDataObserver
41-
*
4240
* @SuppressWarnings(PHPMD.TooManyFields)
4341
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
4442
*/
@@ -459,8 +457,7 @@ private function categoriesUrlRewriteGenerate(): array
459457
}
460458
}
461459
}
462-
$result = !empty($urls) ? array_merge(...$urls) : [];
463-
return $result;
460+
return array_merge([], ...$urls);
464461
}
465462

466463
/**

app/code/Magento/CatalogWidget/Block/Product/ProductsList.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,15 +510,15 @@ public function getPagerHtml()
510510
*/
511511
public function getIdentities()
512512
{
513-
$identities = [[]];
513+
$identities = [];
514514
if ($this->getProductCollection()) {
515515
foreach ($this->getProductCollection() as $product) {
516516
if ($product instanceof IdentityInterface) {
517517
$identities[] = $product->getIdentities();
518518
}
519519
}
520520
}
521-
$identities = array_merge(...$identities);
521+
$identities = array_merge([], ...$identities);
522522

523523
return $identities ?: [Product::CACHE_TAG];
524524
}

app/code/Magento/CheckoutAgreements/Model/AgreementsValidator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ public function __construct($list = null)
3535
public function isValid($agreementIds = [])
3636
{
3737
$agreementIds = $agreementIds === null ? [] : $agreementIds;
38-
$requiredAgreements = [[]];
38+
$requiredAgreements = [];
3939
foreach ($this->agreementsProviders as $agreementsProvider) {
4040
$requiredAgreements[] = $agreementsProvider->getRequiredAgreementIds();
4141
}
4242

43-
$agreementsDiff = array_diff(array_merge(...$requiredAgreements), $agreementIds);
43+
$agreementsDiff = array_diff(array_merge([], ...$requiredAgreements), $agreementIds);
4444

4545
return empty($agreementsDiff);
4646
}

app/code/Magento/Cms/view/adminhtml/templates/browser/content/uploader.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ $filters = $block->getConfig()->getFilters() ?? [];
1111
$allowedExtensions = [];
1212
$blockHtmlId = $block->getHtmlId();
1313

14-
$listExtensions = [[]];
14+
$listExtensions = [];
1515
foreach ($filters as $media_type) {
1616
$listExtensions[] = array_map(function ($fileExt) {
1717
return ltrim($fileExt, '.*');
1818
}, $media_type['files']);
1919
}
2020

21-
$allowedExtensions = array_merge(...$listExtensions);
21+
$allowedExtensions = array_merge([], ...$listExtensions);
2222

2323
$resizeConfig = $block->getImageUploadConfigData()->getIsResizeEnabled()
2424
? "{action: 'resize', maxWidth: "

app/code/Magento/Csp/Helper/InlineUtil.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,14 @@ private function extractHost(string $url): ?string
110110
*/
111111
private function extractRemoteFonts(string $styleContent): array
112112
{
113-
$urlsFound = [[]];
113+
$urlsFound = [];
114114
preg_match_all('/\@font\-face\s*?\{([^\}]*)[^\}]*?\}/im', $styleContent, $fontFaces);
115115
foreach ($fontFaces[1] as $fontFaceContent) {
116116
preg_match_all('/url\([\'\"]?(http(s)?\:[^\)]+)[\'\"]?\)/i', $fontFaceContent, $urls);
117117
$urlsFound[] = $urls[1];
118118
}
119119

120-
return array_map([$this, 'extractHost'], array_merge(...$urlsFound));
120+
return array_map([$this, 'extractHost'], array_merge([], ...$urlsFound));
121121
}
122122

123123
/**

app/code/Magento/CurrencySymbol/Model/System/Currencysymbol.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ protected function _unserializeStoreConfig($configPath, $storeId = null)
292292
*/
293293
protected function getAllowedCurrencies()
294294
{
295-
$allowedCurrencies = [[]];
295+
$allowedCurrencies = [];
296296
$allowedCurrencies[] = explode(
297297
self::ALLOWED_CURRENCIES_CONFIG_SEPARATOR,
298298
$this->_scopeConfig->getValue(
@@ -330,6 +330,6 @@ protected function getAllowedCurrencies()
330330
}
331331
}
332332
}
333-
return array_unique(array_merge(...$allowedCurrencies));
333+
return array_unique(array_merge([], ...$allowedCurrencies));
334334
}
335335
}

app/code/Magento/Customer/Model/Address/CompositeValidator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ public function __construct(
3030
*/
3131
public function validate(AbstractAddress $address)
3232
{
33-
$errors = [[]];
33+
$errors = [];
3434
foreach ($this->validators as $validator) {
3535
$errors[] = $validator->validate($address);
3636
}
3737

38-
return array_merge(...$errors);
38+
return array_merge([], ...$errors);
3939
}
4040
}

app/code/Magento/Customer/Model/Metadata/Form.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,11 +363,11 @@ public function validateData(array $data)
363363
{
364364
$validator = $this->_getValidator($data);
365365
if (!$validator->isValid(false)) {
366-
$messages = [[]];
366+
$messages = [];
367367
foreach ($validator->getMessages() as $errorMessages) {
368368
$messages[] = (array)$errorMessages;
369369
}
370-
return array_merge(...$messages);
370+
return array_merge([], ...$messages);
371371
}
372372
return true;
373373
}

app/code/Magento/Customer/Model/ResourceModel/Address/Attribute/Source/CountryWithWebsites.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function getAllOptions($withEmpty = true, $defaultValues = false)
8484
$websiteIds = [];
8585

8686
if (!$this->shareConfig->isGlobalScope()) {
87-
$allowedCountries = [[]];
87+
$allowedCountries = [];
8888

8989
foreach ($this->storeManager->getWebsites() as $website) {
9090
$countries = $this->allowedCountriesReader
@@ -96,7 +96,7 @@ public function getAllOptions($withEmpty = true, $defaultValues = false)
9696
}
9797
}
9898

99-
$allowedCountries = array_unique(array_merge(...$allowedCountries));
99+
$allowedCountries = array_unique(array_merge([], ...$allowedCountries));
100100
} else {
101101
$allowedCountries = $this->allowedCountriesReader->getAllowedCountries();
102102
}

app/code/Magento/CustomerImportExport/Model/Import/Address.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,12 +525,12 @@ public function validateData()
525525
protected function _importData()
526526
{
527527
//Preparing data for mass validation/import.
528-
$rows = [[]];
528+
$rows = [];
529529
while ($bunch = $this->_dataSourceModel->getNextBunch()) {
530530
$rows[] = $bunch;
531531
}
532532

533-
$this->prepareCustomerData(array_merge(...$rows));
533+
$this->prepareCustomerData(array_merge([], ...$rows));
534534
unset($bunch, $rows);
535535
$this->_dataSourceModel->getIterator()->rewind();
536536

0 commit comments

Comments
 (0)