diff --git a/app/code/Magento/AdvancedPricingImportExport/Model/Export/AdvancedPricing.php b/app/code/Magento/AdvancedPricingImportExport/Model/Export/AdvancedPricing.php
index 27e2713995653..af43562984134 100644
--- a/app/code/Magento/AdvancedPricingImportExport/Model/Export/AdvancedPricing.php
+++ b/app/code/Magento/AdvancedPricingImportExport/Model/Export/AdvancedPricing.php
@@ -158,6 +158,8 @@ public function __construct(
protected function initTypeModels()
{
$productTypes = $this->_exportConfig->getEntityTypes(CatalogProduct::ENTITY);
+ $disabledAttrs = [];
+ $indexValueAttributes = [];
foreach ($productTypes as $productTypeName => $productTypeConfig) {
if (!($model = $this->_typeFactory->create($productTypeConfig['model']))) {
throw new \Magento\Framework\Exception\LocalizedException(
@@ -174,13 +176,8 @@ protected function initTypeModels()
}
if ($model->isSuitable()) {
$this->_productTypeModels[$productTypeName] = $model;
- // phpcs:ignore Magento2.Performance.ForeachArrayMerge
- $this->_disabledAttrs = array_merge($this->_disabledAttrs, $model->getDisabledAttrs());
- // phpcs:ignore Magento2.Performance.ForeachArrayMerge
- $this->_indexValueAttributes = array_merge(
- $this->_indexValueAttributes,
- $model->getIndexValueAttributes()
- );
+ $disabledAttrs[] = $model->getDisabledAttrs();
+ $indexValueAttributes[] = $model->getIndexValueAttributes();
}
}
if (!$this->_productTypeModels) {
@@ -188,7 +185,10 @@ protected function initTypeModels()
__('There are no product types available for export')
);
}
- $this->_disabledAttrs = array_unique($this->_disabledAttrs);
+ $this->_disabledAttrs = array_unique(array_merge([], $this->_disabledAttrs, ...$disabledAttrs));
+ $this->_indexValueAttributes = array_unique(
+ array_merge([], $this->_indexValueAttributes, ...$indexValueAttributes)
+ );
return $this;
}
@@ -518,6 +518,8 @@ protected function getTierPrices(array $listSku, $table)
if (isset($this->_parameters[\Magento\ImportExport\Model\Export::FILTER_ELEMENT_GROUP])) {
$exportFilter = $this->_parameters[\Magento\ImportExport\Model\Export::FILTER_ELEMENT_GROUP];
}
+ $selectFields = [];
+ $exportData = false;
if ($table == ImportAdvancedPricing::TABLE_TIER_PRICE) {
$selectFields = [
ImportAdvancedPricing::COL_SKU => 'cpe.sku',
diff --git a/app/code/Magento/AsynchronousOperations/Model/OperationProcessor.php b/app/code/Magento/AsynchronousOperations/Model/OperationProcessor.php
index 5c5619a4b41d1..60b031c984e6a 100644
--- a/app/code/Magento/AsynchronousOperations/Model/OperationProcessor.php
+++ b/app/code/Magento/AsynchronousOperations/Model/OperationProcessor.php
@@ -117,6 +117,7 @@ public function process(string $encodedMessage)
$status = OperationInterface::STATUS_TYPE_COMPLETE;
$errorCode = null;
$messages = [];
+ $entityParams = [];
$topicName = $operation->getTopicName();
$handlers = $this->configuration->getHandlers($topicName);
try {
@@ -127,7 +128,7 @@ public function process(string $encodedMessage)
$this->logger->error($e->getMessage());
$status = OperationInterface::STATUS_TYPE_NOT_RETRIABLY_FAILED;
$errorCode = $e->getCode();
- $messages[] = $e->getMessage();
+ $messages[] = [$e->getMessage()];
}
$outputData = null;
@@ -136,9 +137,7 @@ public function process(string $encodedMessage)
$result = $this->executeHandler($callback, $entityParams);
$status = $result['status'];
$errorCode = $result['error_code'];
- // phpcs:disable Magento2.Performance.ForeachArrayMerge
- $messages = array_merge($messages, $result['messages']);
- // phpcs:enable Magento2.Performance.ForeachArrayMerge
+ $messages[] = $result['messages'];
$outputData = $result['output_data'];
}
}
@@ -157,7 +156,7 @@ public function process(string $encodedMessage)
);
$outputData = $this->jsonHelper->serialize($outputData);
} catch (\Exception $e) {
- $messages[] = $e->getMessage();
+ $messages[] = [$e->getMessage()];
}
}
@@ -167,7 +166,7 @@ public function process(string $encodedMessage)
$operation->getId(),
$status,
$errorCode,
- implode('; ', $messages),
+ implode('; ', array_merge([], ...$messages)),
$serializedData,
$outputData
);
diff --git a/app/code/Magento/Bundle/Test/Unit/Pricing/Adjustment/CalculatorTest.php b/app/code/Magento/Bundle/Test/Unit/Pricing/Adjustment/CalculatorTest.php
index e3762632b45fd..a14a1e06dab2d 100644
--- a/app/code/Magento/Bundle/Test/Unit/Pricing/Adjustment/CalculatorTest.php
+++ b/app/code/Magento/Bundle/Test/Unit/Pricing/Adjustment/CalculatorTest.php
@@ -166,9 +166,10 @@ public function testGetterAmount($amountForBundle, $optionList, $expectedResult)
$optionSelections = [];
foreach ($options as $option) {
- // phpcs:ignore Magento2.Performance.ForeachArrayMerge
- $optionSelections = array_merge($optionSelections, $option->getSelections());
+ $optionSelections[] = $option->getSelections();
}
+ $optionSelections = array_merge([], ...$optionSelections);
+
$this->selectionPriceListProvider->expects($this->any())->method('getPriceList')->willReturn($optionSelections);
$price = $this->createMock(BundleOptionPrice::class);
diff --git a/app/code/Magento/BundleImportExport/Model/Import/Product/Type/Bundle.php b/app/code/Magento/BundleImportExport/Model/Import/Product/Type/Bundle.php
index 49881f67f5c9a..04384ca71cfbe 100644
--- a/app/code/Magento/BundleImportExport/Model/Import/Product/Type/Bundle.php
+++ b/app/code/Magento/BundleImportExport/Model/Import/Product/Type/Bundle.php
@@ -603,11 +603,7 @@ protected function populateInsertOptionValues(array $optionIds): array
if ($assoc['position'] == $this->_cachedOptions[$entityId][$key]['index']
&& $assoc['parent_id'] == $entityId) {
$option['parent_id'] = $entityId;
- //phpcs:ignore Magento2.Performance.ForeachArrayMerge
- $optionValues = array_merge(
- $optionValues,
- $this->populateOptionValueTemplate($option, $optionId)
- );
+ $optionValues[] = $this->populateOptionValueTemplate($option, $optionId);
$this->_cachedOptions[$entityId][$key]['option_id'] = $optionId;
break;
}
@@ -615,7 +611,7 @@ protected function populateInsertOptionValues(array $optionIds): array
}
}
- return $optionValues;
+ return array_merge([], ...$optionValues);
}
/**
diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/TableBuilder.php b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/TableBuilder.php
index c14ea4bc363f8..0f3c186eaffd9 100644
--- a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/TableBuilder.php
+++ b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/TableBuilder.php
@@ -86,12 +86,13 @@ public function build($storeId, $changedIds, $valueFieldSuffix)
//Create list of temporary tables based on available attributes attributes
$valueTables = [];
foreach ($temporaryEavAttributes as $tableName => $columns) {
- // phpcs:ignore Magento2.Performance.ForeachArrayMerge
- $valueTables = array_merge(
- $valueTables,
- $this->_createTemporaryTable($this->_getTemporaryTableName($tableName), $columns, $valueFieldSuffix)
+ $valueTables[] = $this->_createTemporaryTable(
+ $this->_getTemporaryTableName($tableName),
+ $columns,
+ $valueFieldSuffix
);
}
+ $valueTables = array_merge([], ...$valueTables);
//Fill "base" table which contains all available products
$this->_fillTemporaryEntityTable($entityTableName, $entityTableColumns, $changedIds);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/CategoryLinkTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/CategoryLinkTest.php
index 4f684f4d98ea9..b2dd2c7b1e29e 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/CategoryLinkTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/CategoryLinkTest.php
@@ -145,11 +145,11 @@ public function testSaveCategoryLinks($newCategoryLinks, $dbCategoryLinks, $affe
$expectedResult = [];
foreach ($affectedIds as $type => $ids) {
- // phpcs:ignore Magento2.Performance.ForeachArrayMerge
- $expectedResult = array_merge($expectedResult, $ids);
+ $expectedResult[] = $ids;
// Verify if the correct insert, update and/or delete actions are performed:
$this->setupExpectationsForConnection($type, $ids);
}
+ $expectedResult = array_merge([], ...$expectedResult);
$actualResult = $this->model->saveCategoryLinks($product, $newCategoryLinks);
diff --git a/app/code/Magento/CatalogImportExport/Model/Export/Product.php b/app/code/Magento/CatalogImportExport/Model/Export/Product.php
index bcd103c6d62ba..63fed0a5dda5e 100644
--- a/app/code/Magento/CatalogImportExport/Model/Export/Product.php
+++ b/app/code/Magento/CatalogImportExport/Model/Export/Product.php
@@ -478,6 +478,8 @@ protected function initCategories()
protected function initTypeModels()
{
$productTypes = $this->_exportConfig->getEntityTypes($this->getEntityTypeCode());
+ $disabledAttrs = [];
+ $indexValueAttributes = [];
foreach ($productTypes as $productTypeName => $productTypeConfig) {
if (!($model = $this->_typeFactory->create($productTypeConfig['model']))) {
throw new \Magento\Framework\Exception\LocalizedException(
@@ -494,13 +496,8 @@ protected function initTypeModels()
}
if ($model->isSuitable()) {
$this->_productTypeModels[$productTypeName] = $model;
- // phpcs:ignore Magento2.Performance.ForeachArrayMerge
- $this->_disabledAttrs = array_merge($this->_disabledAttrs, $model->getDisabledAttrs());
- // phpcs:ignore Magento2.Performance.ForeachArrayMerge
- $this->_indexValueAttributes = array_merge(
- $this->_indexValueAttributes,
- $model->getIndexValueAttributes()
- );
+ $disabledAttrs[] = $model->getDisabledAttrs();
+ $indexValueAttributes[] = $model->getIndexValueAttributes();
}
}
if (!$this->_productTypeModels) {
@@ -508,7 +505,10 @@ protected function initTypeModels()
__('There are no product types available for export.')
);
}
- $this->_disabledAttrs = array_unique($this->_disabledAttrs);
+ $this->_disabledAttrs = array_unique(array_merge([], $this->_disabledAttrs, ...$disabledAttrs));
+ $this->_indexValueAttributes = array_unique(
+ array_merge([], $this->_indexValueAttributes, ...$indexValueAttributes)
+ );
return $this;
}
@@ -1128,7 +1128,7 @@ private function wrapValue($value)
protected function collectMultirawData()
{
$data = [];
- $productIds = [];
+ $productLinkIds = [];
$rowWebsites = [];
$rowCategories = [];
@@ -1138,7 +1138,6 @@ protected function collectMultirawData()
/** @var \Magento\Catalog\Model\Product $item */
foreach ($collection as $item) {
$productLinkIds[] = $item->getData($this->getProductEntityLinkField());
- $productIds[] = $item->getId();
$rowWebsites[$item->getId()] = array_intersect(
array_keys($this->_websiteIdToCode),
$item->getWebsites()
diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product.php b/app/code/Magento/CatalogImportExport/Model/Import/Product.php
index 74c6576e6bcdf..065840426fdd3 100644
--- a/app/code/Magento/CatalogImportExport/Model/Import/Product.php
+++ b/app/code/Magento/CatalogImportExport/Model/Import/Product.php
@@ -1212,6 +1212,8 @@ private function initImagesArrayKeys()
protected function _initTypeModels()
{
$productTypes = $this->_importConfig->getEntityTypes($this->getEntityTypeCode());
+ $fieldsMap = [];
+ $specialAttributes = [];
foreach ($productTypes as $productTypeName => $productTypeConfig) {
$params = [$this, $productTypeName];
if (!($model = $this->_productTypeFactory->create($productTypeConfig['model'], ['params' => $params]))
@@ -1231,14 +1233,13 @@ protected function _initTypeModels()
if ($model->isSuitable()) {
$this->_productTypeModels[$productTypeName] = $model;
}
- // phpcs:disable Magento2.Performance.ForeachArrayMerge.ForeachArrayMerge
- $this->_fieldsMap = array_merge($this->_fieldsMap, $model->getCustomFieldsMapping());
- $this->_specialAttributes = array_merge($this->_specialAttributes, $model->getParticularAttributes());
- // phpcs:enable
+ $fieldsMap[] = $model->getCustomFieldsMapping();
+ $specialAttributes[] = $model->getParticularAttributes();
}
+ $this->_fieldsMap = array_merge([], $this->_fieldsMap, ...$fieldsMap);
$this->_initErrorTemplates();
// remove doubles
- $this->_specialAttributes = array_unique($this->_specialAttributes);
+ $this->_specialAttributes = array_unique(array_merge([], $this->_specialAttributes, ...$specialAttributes));
return $this;
}
diff --git a/app/code/Magento/Config/Model/Config.php b/app/code/Magento/Config/Model/Config.php
index f61e99529c3cc..eda02612ded1a 100644
--- a/app/code/Magento/Config/Model/Config.php
+++ b/app/code/Magento/Config/Model/Config.php
@@ -207,10 +207,9 @@ public function save()
$deleteTransaction
);
- $groupChangedPaths = $this->getChangedPaths($sectionId, $groupId, $groupData, $oldConfig, $extraOldGroups);
- // phpcs:ignore Magento2.Performance.ForeachArrayMerge
- $changedPaths = \array_merge($changedPaths, $groupChangedPaths);
+ $changedPaths[] = $this->getChangedPaths($sectionId, $groupId, $groupData, $oldConfig, $extraOldGroups);
}
+ $changedPaths = array_merge([], ...$changedPaths);
try {
$deleteTransaction->delete();
@@ -356,7 +355,7 @@ private function getChangedPaths(
$field = $this->getField($sectionId, $groupId, $fieldId);
$path = $this->getFieldPath($field, $fieldId, $oldConfig, $extraOldGroups);
if ($this->isValueChanged($oldConfig, $path, $fieldData)) {
- $changedPaths[] = $path;
+ $changedPaths[] = [$path];
}
}
}
@@ -371,12 +370,11 @@ private function getChangedPaths(
$oldConfig,
$extraOldGroups
);
- // phpcs:ignore Magento2.Performance.ForeachArrayMerge
- $changedPaths = \array_merge($changedPaths, $subGroupChangedPaths);
+ $changedPaths[] = $subGroupChangedPaths;
}
}
- return $changedPaths;
+ return \array_merge([], ...$changedPaths);
}
/**
diff --git a/app/code/Magento/Config/Model/Config/Structure.php b/app/code/Magento/Config/Model/Config/Structure.php
index 437aca04ec577..156867f34318a 100644
--- a/app/code/Magento/Config/Model/Config/Structure.php
+++ b/app/code/Magento/Config/Model/Config/Structure.php
@@ -292,20 +292,16 @@ public function getFieldPathsByAttribute($attributeName, $attributeValue)
foreach ($section['children'] as $group) {
if (isset($group['children'])) {
$path = $section['id'] . '/' . $group['id'];
- // phpcs:ignore Magento2.Performance.ForeachArrayMerge.ForeachArrayMerge
- $result = array_merge(
- $result,
- $this->_getGroupFieldPathsByAttribute(
- $group['children'],
- $path,
- $attributeName,
- $attributeValue
- )
+ $result[] = $this->_getGroupFieldPathsByAttribute(
+ $group['children'],
+ $path,
+ $attributeName,
+ $attributeValue
);
}
}
}
- return $result;
+ return array_merge([], ...$result);
}
/**
diff --git a/app/code/Magento/Deploy/Package/Processor/PreProcessor/Css.php b/app/code/Magento/Deploy/Package/Processor/PreProcessor/Css.php
index 42775a2e2f6bf..152c95f86552c 100644
--- a/app/code/Magento/Deploy/Package/Processor/PreProcessor/Css.php
+++ b/app/code/Magento/Deploy/Package/Processor/PreProcessor/Css.php
@@ -10,12 +10,12 @@
use Magento\Deploy\Package\Package;
use Magento\Deploy\Package\PackageFile;
use Magento\Deploy\Package\Processor\ProcessorInterface;
+use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Css\PreProcessor\Instruction\Import;
use Magento\Framework\Filesystem;
use Magento\Framework\Filesystem\Directory\ReadInterface;
-use Magento\Framework\App\Filesystem\DirectoryList;
-use Magento\Framework\View\Url\CssResolver;
use Magento\Framework\View\Asset\Minification;
+use Magento\Framework\View\Url\CssResolver;
/**
* Pre-processor for speeding up deployment of CSS files
@@ -137,7 +137,7 @@ private function buildMap($packagePath, $filePath, $fullPath)
$content = $this->staticDir->readFile($this->minification->addMinifiedSign($fullPath));
- $callback = function ($matchContent) use ($packagePath, $filePath, & $imports) {
+ $callback = function ($matchContent) use ($packagePath, $filePath, &$imports) {
$importRelPath = $this->normalize(pathinfo($filePath, PATHINFO_DIRNAME) . '/' . $matchContent['path']);
$imports[$importRelPath] = $this->normalize(
$packagePath . '/' . pathinfo($filePath, PATHINFO_DIRNAME) . '/' . $matchContent['path']
@@ -175,15 +175,17 @@ private function buildMap($packagePath, $filePath, $fullPath)
*
* @param string $fileName
* @return array
- * phpcs:disable Magento2.Performance.ForeachArrayMerge
*/
- private function collectFileMap($fileName)
+ private function collectFileMap(string $fileName): array
{
- $result = isset($this->map[$fileName]) ? $this->map[$fileName] : [];
- foreach ($result as $path) {
- $result = array_merge($result, $this->collectFileMap($path));
+ $valueFromMap = $this->map[$fileName] ?? [];
+ $result = [$valueFromMap];
+
+ foreach ($valueFromMap as $path) {
+ $result[] = $this->collectFileMap($path);
}
- return array_unique($result);
+
+ return array_unique(array_merge([], ...$result));
}
/**
diff --git a/app/code/Magento/MediaContentApi/Model/Composite/GetAssetIdsByContentField.php b/app/code/Magento/MediaContentApi/Model/Composite/GetAssetIdsByContentField.php
index 61df8504b4c77..946550dc70a4d 100644
--- a/app/code/Magento/MediaContentApi/Model/Composite/GetAssetIdsByContentField.php
+++ b/app/code/Magento/MediaContentApi/Model/Composite/GetAssetIdsByContentField.php
@@ -42,9 +42,8 @@ public function execute(string $field, string $value): array
$ids = [];
/** @var GetAssetIdsByContentFieldInterface $fieldHandler */
foreach ($this->fieldHandlers[$field] as $fieldHandler) {
- // phpcs:ignore Magento2.Performance.ForeachArrayMerge
- $ids = array_merge($ids, $fieldHandler->execute($value));
+ $ids[] = $fieldHandler->execute($value);
}
- return array_unique($ids);
+ return array_unique(array_merge([], ...$ids));
}
}
diff --git a/app/code/Magento/Sales/Model/AdminOrder/Create.php b/app/code/Magento/Sales/Model/AdminOrder/Create.php
index 8ef12e5889520..5b9f254201bda 100644
--- a/app/code/Magento/Sales/Model/AdminOrder/Create.php
+++ b/app/code/Magento/Sales/Model/AdminOrder/Create.php
@@ -1999,15 +1999,17 @@ protected function _validate()
$this->_errors[] = __('Please specify order items.');
}
+ $errors = [];
foreach ($items as $item) {
/** @var \Magento\Quote\Model\Quote\Item $item */
$messages = $item->getMessage(false);
if ($item->getHasError() && is_array($messages) && !empty($messages)) {
- // phpcs:ignore Magento2.Performance.ForeachArrayMerge
- $this->_errors = array_merge($this->_errors, $messages);
+ $errors[] = $messages;
}
}
+ $this->_errors = array_merge([], $this->_errors, ...$errors);
+
if (!$this->getQuote()->isVirtual()) {
if (!$this->getQuote()->getShippingAddress()->getShippingMethod()) {
$this->_errors[] = __('The shipping method is missing. Select the shipping method and try again.');
diff --git a/app/code/Magento/Tax/Model/Sales/Total/Quote/CommonTaxCollector.php b/app/code/Magento/Tax/Model/Sales/Total/Quote/CommonTaxCollector.php
index c7cc4ded1bf07..a9acef7c178da 100644
--- a/app/code/Magento/Tax/Model/Sales/Total/Quote/CommonTaxCollector.php
+++ b/app/code/Magento/Tax/Model/Sales/Total/Quote/CommonTaxCollector.php
@@ -367,7 +367,7 @@ public function mapItems(
$priceIncludesTax,
$useBaseCurrency
);
- $itemDataObjects[] = $parentItemDataObject;
+ $itemDataObjects[] = [$parentItemDataObject];
foreach ($item->getChildren() as $child) {
$childItemDataObject = $this->mapItem(
$itemDataObjectFactory,
@@ -376,31 +376,29 @@ public function mapItems(
$useBaseCurrency,
$parentItemDataObject->getCode()
);
- $itemDataObjects[] = $childItemDataObject;
+ $itemDataObjects[] = [$childItemDataObject];
$extraTaxableItems = $this->mapItemExtraTaxables(
$itemDataObjectFactory,
$item,
$priceIncludesTax,
$useBaseCurrency
);
- //phpcs:ignore Magento2.Performance.ForeachArrayMerge
- $itemDataObjects = array_merge($itemDataObjects, $extraTaxableItems);
+ $itemDataObjects[] = $extraTaxableItems;
}
} else {
$itemDataObject = $this->mapItem($itemDataObjectFactory, $item, $priceIncludesTax, $useBaseCurrency);
- $itemDataObjects[] = $itemDataObject;
+ $itemDataObjects[] = [$itemDataObject];
$extraTaxableItems = $this->mapItemExtraTaxables(
$itemDataObjectFactory,
$item,
$priceIncludesTax,
$useBaseCurrency
);
- //phpcs:ignore Magento2.Performance.ForeachArrayMerge
- $itemDataObjects = array_merge($itemDataObjects, $extraTaxableItems);
+ $itemDataObjects[] = $extraTaxableItems;
}
}
- return $itemDataObjects;
+ return array_merge([], ...$itemDataObjects);
}
/**
diff --git a/app/code/Magento/Ui/Model/Manager.php b/app/code/Magento/Ui/Model/Manager.php
index 357a41285e275..ce9e4e51ea7fe 100644
--- a/app/code/Magento/Ui/Model/Manager.php
+++ b/app/code/Magento/Ui/Model/Manager.php
@@ -298,6 +298,7 @@ protected function createDataForComponent($name, array $componentsPool)
$createdComponents = [];
$rootComponent = $this->createRawComponentData($name, false);
foreach ($componentsPool as $key => $component) {
+ $resultConfiguration = [];
$resultConfiguration = [ManagerInterface::CHILDREN_KEY => []];
$instanceName = $this->createName($component, $key, $name);
$resultConfiguration[ManagerInterface::COMPONENT_ARGUMENTS_KEY] = $this->mergeArguments(
@@ -312,15 +313,16 @@ protected function createDataForComponent($name, array $componentsPool)
unset($component[Converter::DATA_ATTRIBUTES_KEY]);
// Create inner components
+ $children = [];
foreach ($component as $subComponentName => $subComponent) {
if (is_array($subComponent)) {
- // phpcs:ignore Magento2.Performance.ForeachArrayMerge
- $resultConfiguration[ManagerInterface::CHILDREN_KEY] = array_merge(
- $resultConfiguration[ManagerInterface::CHILDREN_KEY],
- $this->createDataForComponent($subComponentName, $subComponent)
- );
+ $children[] = $this->createDataForComponent($subComponentName, $subComponent);
}
}
+
+ // phpcs:ignore Magento2.Performance.ForeachArrayMerge
+ $resultConfiguration[ManagerInterface::CHILDREN_KEY] = array_merge([], ...$children);
+
$createdComponents[$instanceName] = $resultConfiguration;
}
diff --git a/dev/tests/integration/framework/Magento/TestFramework/Annotation/AbstractDataFixture.php b/dev/tests/integration/framework/Magento/TestFramework/Annotation/AbstractDataFixture.php
index 9172d7cf857e5..14799cd56e635 100644
--- a/dev/tests/integration/framework/Magento/TestFramework/Annotation/AbstractDataFixture.php
+++ b/dev/tests/integration/framework/Magento/TestFramework/Annotation/AbstractDataFixture.php
@@ -68,7 +68,7 @@ protected function _getFixtures(TestCase $test, $scope = null)
protected function getAnnotations(TestCase $test): array
{
$annotations = $test->getAnnotations();
- return array_replace($annotations['class'], $annotations['method']);
+ return array_replace((array)$annotations['class'], (array)$annotations['method']);
}
/**
diff --git a/dev/tests/integration/framework/Magento/TestFramework/Annotation/AppIsolation.php b/dev/tests/integration/framework/Magento/TestFramework/Annotation/AppIsolation.php
index 7cb305bd525c7..ddc267a4d3ebd 100644
--- a/dev/tests/integration/framework/Magento/TestFramework/Annotation/AppIsolation.php
+++ b/dev/tests/integration/framework/Magento/TestFramework/Annotation/AppIsolation.php
@@ -9,6 +9,11 @@
*/
namespace Magento\TestFramework\Annotation;
+use Magento\Framework\Exception\LocalizedException;
+use Magento\TestFramework\Application;
+use Magento\TestFramework\TestCase\AbstractController;
+use PHPUnit\Framework\TestCase;
+
class AppIsolation
{
/**
@@ -16,12 +21,12 @@ class AppIsolation
*
* @var bool
*/
- private $_hasNonIsolatedTests = true;
+ private $hasNonIsolatedTests = true;
/**
- * @var \Magento\TestFramework\Application
+ * @var Application
*/
- private $_application;
+ private $application;
/**
* @var array
@@ -31,11 +36,11 @@ class AppIsolation
/**
* Constructor
*
- * @param \Magento\TestFramework\Application $application
+ * @param Application $application
*/
- public function __construct(\Magento\TestFramework\Application $application)
+ public function __construct(Application $application)
{
- $this->_application = $application;
+ $this->application = $application;
}
/**
@@ -43,12 +48,12 @@ public function __construct(\Magento\TestFramework\Application $application)
*/
protected function _isolateApp()
{
- if ($this->_hasNonIsolatedTests) {
- $this->_application->reinitialize();
+ if ($this->hasNonIsolatedTests) {
+ $this->application->reinitialize();
$_SESSION = [];
$_COOKIE = [];
session_write_close();
- $this->_hasNonIsolatedTests = false;
+ $this->hasNonIsolatedTests = false;
}
}
@@ -72,31 +77,44 @@ public function endTestSuite()
/**
* Handler for 'endTest' event
*
- * @param \PHPUnit\Framework\TestCase $test
- * @throws \Magento\Framework\Exception\LocalizedException
+ * @param TestCase $test
+ * @throws LocalizedException
*/
- public function endTest(\PHPUnit\Framework\TestCase $test)
+ public function endTest(TestCase $test)
{
- $this->_hasNonIsolatedTests = true;
+ $this->hasNonIsolatedTests = true;
/* Determine an isolation from doc comment */
- $annotations = $test->getAnnotations();
- $annotations = array_replace((array) $annotations['class'], (array) $annotations['method']);
+ $annotations = $this->getAnnotations($test);
if (isset($annotations['magentoAppIsolation'])) {
$isolation = $annotations['magentoAppIsolation'];
if ($isolation !== ['enabled'] && $isolation !== ['disabled']) {
- throw new \Magento\Framework\Exception\LocalizedException(
+ throw new LocalizedException(
__('Invalid "@magentoAppIsolation" annotation, can be "enabled" or "disabled" only.')
);
}
$isIsolationEnabled = $isolation === ['enabled'];
} else {
/* Controller tests should be isolated by default */
- $isIsolationEnabled = $test instanceof \Magento\TestFramework\TestCase\AbstractController;
+ $isIsolationEnabled = $test instanceof AbstractController;
}
if ($isIsolationEnabled) {
$this->_isolateApp();
}
}
+
+ /**
+ * Get method annotations.
+ *
+ * Overwrites class-defined annotations.
+ *
+ * @param TestCase $test
+ * @return array
+ */
+ private function getAnnotations(TestCase $test): array
+ {
+ $annotations = $test->getAnnotations();
+ return array_replace((array)$annotations['class'], (array)$annotations['method']);
+ }
}
diff --git a/dev/tests/integration/framework/Magento/TestFramework/Annotation/DbIsolation.php b/dev/tests/integration/framework/Magento/TestFramework/Annotation/DbIsolation.php
index e1ae5ab15b033..819d5ee4e57f2 100644
--- a/dev/tests/integration/framework/Magento/TestFramework/Annotation/DbIsolation.php
+++ b/dev/tests/integration/framework/Magento/TestFramework/Annotation/DbIsolation.php
@@ -5,6 +5,10 @@
*/
namespace Magento\TestFramework\Annotation;
+use Magento\Framework\Exception\LocalizedException;
+use Magento\TestFramework\Event\Param\Transaction;
+use PHPUnit\Framework\TestCase;
+
/**
* Implementation of the @magentoDbIsolation DocBlock annotation
*/
@@ -20,13 +24,11 @@ class DbIsolation
/**
* Handler for 'startTestTransactionRequest' event
*
- * @param \PHPUnit\Framework\TestCase $test
- * @param \Magento\TestFramework\Event\Param\Transaction $param
+ * @param TestCase $test
+ * @param Transaction $param
*/
- public function startTestTransactionRequest(
- \PHPUnit\Framework\TestCase $test,
- \Magento\TestFramework\Event\Param\Transaction $param
- ) {
+ public function startTestTransactionRequest(TestCase $test, Transaction $param)
+ {
$methodIsolation = $this->_getIsolation($test);
if ($this->_isIsolationActive) {
if ($methodIsolation === false) {
@@ -40,13 +42,11 @@ public function startTestTransactionRequest(
/**
* Handler for 'endTestTransactionRequest' event
*
- * @param \PHPUnit\Framework\TestCase $test
- * @param \Magento\TestFramework\Event\Param\Transaction $param
+ * @param TestCase $test
+ * @param Transaction $param
*/
- public function endTestTransactionRequest(
- \PHPUnit\Framework\TestCase $test,
- \Magento\TestFramework\Event\Param\Transaction $param
- ) {
+ public function endTestTransactionRequest(TestCase $test, Transaction $param)
+ {
if ($this->_isIsolationActive && $this->_getIsolation($test)) {
$param->requestTransactionRollback();
}
@@ -55,11 +55,11 @@ public function endTestTransactionRequest(
/**
* Handler for 'startTransaction' event
*
- * @param \PHPUnit\Framework\TestCase $test
+ * @param TestCase $test
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
- public function startTransaction(\PHPUnit\Framework\TestCase $test)
+ public function startTransaction(TestCase $test)
{
$this->_isIsolationActive = true;
}
@@ -79,17 +79,17 @@ public function rollbackTransaction()
* TRUE - annotation is defined as 'enabled'
* FALSE - annotation is defined as 'disabled'
*
- * @param \PHPUnit\Framework\TestCase $test
+ * @param TestCase $test
* @return bool|null Returns NULL, if isolation is not defined for the current scope
- * @throws \Magento\Framework\Exception\LocalizedException
+ * @throws LocalizedException
*/
- protected function _getIsolation(\PHPUnit\Framework\TestCase $test)
+ protected function _getIsolation(TestCase $test)
{
$annotations = $this->getAnnotations($test);
if (isset($annotations[self::MAGENTO_DB_ISOLATION])) {
$isolation = $annotations[self::MAGENTO_DB_ISOLATION];
if ($isolation !== ['enabled'] && $isolation !== ['disabled']) {
- throw new \Magento\Framework\Exception\LocalizedException(
+ throw new LocalizedException(
__('Invalid "@magentoDbIsolation" annotation, can be "enabled" or "disabled" only.')
);
}
@@ -99,12 +99,16 @@ protected function _getIsolation(\PHPUnit\Framework\TestCase $test)
}
/**
- * @param \PHPUnit\Framework\TestCase $test
+ * Get method annotations.
+ *
+ * Overwrites class-defined annotations.
+ *
+ * @param TestCase $test
* @return array
*/
- private function getAnnotations(\PHPUnit\Framework\TestCase $test)
+ private function getAnnotations(TestCase $test)
{
$annotations = $test->getAnnotations();
- return array_replace($annotations['class'], $annotations['method']);
+ return array_replace((array)$annotations['class'], (array)$annotations['method']);
}
}
diff --git a/dev/tests/integration/framework/Magento/TestFramework/Workaround/Override/Config/RelationsCollector.php b/dev/tests/integration/framework/Magento/TestFramework/Workaround/Override/Config/RelationsCollector.php
index 2a17e7dba4904..af09f4cf16546 100644
--- a/dev/tests/integration/framework/Magento/TestFramework/Workaround/Override/Config/RelationsCollector.php
+++ b/dev/tests/integration/framework/Magento/TestFramework/Workaround/Override/Config/RelationsCollector.php
@@ -46,14 +46,14 @@ public function getParents(string $className): array
*/
private function getRelations(string $className): array
{
- $result = $this->getRelationsReader()->getParents($className);
+ $parents = $this->getRelationsReader()->getParents($className);
+ $result = [$parents];
- foreach ($result as $parent) {
- // phpcs:ignore Magento2.Performance.ForeachArrayMerge
- $result = array_merge($result, $this->getRelations($parent));
+ foreach ($parents as $parent) {
+ $result[] = $this->getRelations($parent);
}
- return $result;
+ return array_merge([], ...$result);
}
/**
diff --git a/dev/tests/integration/testsuite/Magento/Customer/Model/Config/Source/Group/MultiselectTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/Config/Source/Group/MultiselectTest.php
index 962933f026d9e..9fc9a10df27c4 100644
--- a/dev/tests/integration/testsuite/Magento/Customer/Model/Config/Source/Group/MultiselectTest.php
+++ b/dev/tests/integration/testsuite/Magento/Customer/Model/Config/Source/Group/MultiselectTest.php
@@ -23,12 +23,12 @@ public function testToOptionArray()
$optionsToCompare = [];
foreach ($options as $option) {
if (is_array($option['value'])) {
- // phpcs:ignore Magento2.Performance.ForeachArrayMerge
- $optionsToCompare = array_merge($optionsToCompare, $option['value']);
+ $optionsToCompare[] = $option['value'];
} else {
- $optionsToCompare[] = $option;
+ $optionsToCompare[] = [$option];
}
}
+ $optionsToCompare = array_merge([], ...$optionsToCompare);
sort($optionsToCompare);
foreach ($optionsToCompare as $item) {
$this->assertTrue(
diff --git a/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Import/AddressTest.php b/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Import/AddressTest.php
index 0a5e6cdfe21bd..6aa5589ba7799 100644
--- a/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Import/AddressTest.php
+++ b/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Import/AddressTest.php
@@ -329,13 +329,13 @@ public function testImportDataAddUpdate()
// form attribute list
$keyAttribute = 'postcode';
- $requiredAttributes[] = $keyAttribute;
+ $requiredAttributes[] = [$keyAttribute];
foreach (['update', 'remove'] as $action) {
foreach ($this->_updateData[$action] as $attributes) {
- // phpcs:ignore Magento2.Performance.ForeachArrayMerge
- $requiredAttributes = array_merge($requiredAttributes, array_keys($attributes));
+ $requiredAttributes[] = array_keys($attributes);
}
}
+ $requiredAttributes = array_merge([], ...$requiredAttributes);
// get addresses
$addressCollection = Bootstrap::getObjectManager()->create(
diff --git a/dev/tests/integration/testsuite/Magento/GraphQlCache/Controller/Catalog/DeepNestedCategoriesAndProductsTest.php b/dev/tests/integration/testsuite/Magento/GraphQlCache/Controller/Catalog/DeepNestedCategoriesAndProductsTest.php
index 6228feae37c15..0cb53cd69d199 100644
--- a/dev/tests/integration/testsuite/Magento/GraphQlCache/Controller/Catalog/DeepNestedCategoriesAndProductsTest.php
+++ b/dev/tests/integration/testsuite/Magento/GraphQlCache/Controller/Catalog/DeepNestedCategoriesAndProductsTest.php
@@ -69,35 +69,26 @@ public function testDispatchForCacheHeadersOnDeepNestedQueries(): void
$productIdsFromCategory = $category->getProductCollection()->getAllIds();
foreach ($productIdsFromCategory as $productId) {
- // phpcs:ignore Magento2.Performance.ForeachArrayMerge
- $resolvedCategoryIds = array_merge(
- $resolvedCategoryIds,
- $productRepository->getById($productId)->getCategoryIds()
- );
+ $resolvedCategoryIds[] = $productRepository->getById($productId)->getCategoryIds();
}
- // phpcs:ignore Magento2.Performance.ForeachArrayMerge
- $resolvedCategoryIds = array_merge($resolvedCategoryIds, [$baseCategoryId]);
+ $productIdsFromCategory = [$productIdsFromCategory];
+ $resolvedCategoryIds = array_merge(array_merge([], ...$resolvedCategoryIds), [$baseCategoryId]);
foreach ($resolvedCategoryIds as $categoryId) {
$category = $categoryRepository->get($categoryId);
- // phpcs:ignore Magento2.Performance.ForeachArrayMerge
- $productIdsFromCategory= array_merge(
- $productIdsFromCategory,
- $category->getProductCollection()->getAllIds()
- );
+ $productIdsFromCategory[] = $category->getProductCollection()->getAllIds();
}
- $uniqueProductIds = array_unique($productIdsFromCategory);
+ $uniqueProductIds = array_unique(array_merge([], ...$productIdsFromCategory));
$uniqueCategoryIds = array_unique($resolvedCategoryIds);
- $expectedCacheTags = ['cat_c', 'cat_p', 'FPC'];
+ $expectedCacheTags = [];
foreach ($uniqueProductIds as $uniqueProductId) {
- // phpcs:ignore Magento2.Performance.ForeachArrayMerge
- $expectedCacheTags = array_merge($expectedCacheTags, ['cat_p_' . $uniqueProductId]);
+ $expectedCacheTags[] = ['cat_p_' . $uniqueProductId];
}
foreach ($uniqueCategoryIds as $uniqueCategoryId) {
- // phpcs:ignore Magento2.Performance.ForeachArrayMerge
- $expectedCacheTags = array_merge($expectedCacheTags, ['cat_c_' . $uniqueCategoryId]);
+ $expectedCacheTags[] = ['cat_c_' . $uniqueCategoryId];
}
+ $expectedCacheTags = array_merge(['cat_c', 'cat_p', 'FPC'], ...$expectedCacheTags);
$response = $this->dispatchGraphQlGETRequest(['query' => $query]);
$this->assertEquals('MISS', $response->getHeader('X-Magento-Cache-Debug')->getFieldValue());
diff --git a/dev/tests/static/framework/Magento/TestFramework/Dependency/Route/RouteMapper.php b/dev/tests/static/framework/Magento/TestFramework/Dependency/Route/RouteMapper.php
index 6cc55b49edcca..aa2989137de63 100644
--- a/dev/tests/static/framework/Magento/TestFramework/Dependency/Route/RouteMapper.php
+++ b/dev/tests/static/framework/Magento/TestFramework/Dependency/Route/RouteMapper.php
@@ -174,13 +174,10 @@ public function getDependencyByRoutePath(
$dependencies = [];
foreach ($this->getRouterTypes() as $routerId) {
if (isset($this->getActionsMap()[$routerId][$routeId][$controllerName][$actionName])) {
- //phpcs:ignore Magento2.Performance.ForeachArrayMerge
- $dependencies = array_merge(
- $dependencies,
- $this->getActionsMap()[$routerId][$routeId][$controllerName][$actionName]
- );
+ $dependencies[] = $this->getActionsMap()[$routerId][$routeId][$controllerName][$actionName];
}
}
+ $dependencies = array_merge([], ...$dependencies);
if (empty($dependencies)) {
throw new NoSuchActionException(implode('/', [$routeId, $controllerName, $actionName]));
@@ -278,6 +275,7 @@ private function getActionsMap(): array
$files = Files::init()->getPhpFiles(Files::INCLUDE_APP_CODE);
$actionsMap = [];
foreach ($this->getRoutersMap() as $routerId => $routes) {
+ $actionsMapPerArea = [];
foreach ($routes as $routeId => $dependencies) {
$actionsMapPerArea[$routeId] = [];
foreach ($dependencies as $module) {
diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/ComposerTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/ComposerTest.php
index 277736ef434aa..1c0f451de71dc 100644
--- a/dev/tests/static/testsuite/Magento/Test/Integrity/ComposerTest.php
+++ b/dev/tests/static/testsuite/Magento/Test/Integrity/ComposerTest.php
@@ -73,10 +73,9 @@ public static function getBlacklist(string $pattern)
{
$blacklist = [];
foreach (glob($pattern) as $list) {
- //phpcs:ignore Magento2.Performance.ForeachArrayMerge
- $blacklist = array_merge($blacklist, file($list, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES));
+ $blacklist[] = file($list, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
}
- return $blacklist;
+ return array_merge([], ...$blacklist);
}
public function testValidComposerJson()
@@ -150,8 +149,16 @@ private function validateComposerJsonFile($path)
*/
private function assertCodingStyle($contents)
{
- $this->assertDoesNotMatchRegularExpression('/" :\s*["{]/', $contents, 'Coding style: there should be no space before colon.');
- $this->assertDoesNotMatchRegularExpression('/":["{]/', $contents, 'Coding style: a space is necessary after colon.');
+ $this->assertDoesNotMatchRegularExpression(
+ '/" :\s*["{]/',
+ $contents,
+ 'Coding style: there should be no space before colon.'
+ );
+ $this->assertDoesNotMatchRegularExpression(
+ '/":["{]/',
+ $contents,
+ 'Coding style: a space is necessary after colon.'
+ );
}
/**
@@ -188,13 +195,19 @@ private function assertMagentoConventions($dir, $packageType, \StdClass $json)
$this->assertNoVersionSpecified($json);
break;
case 'magento2-language':
- $this->assertMatchesRegularExpression('/^magento\/language\-[a-z]{2}_([a-z]{4}_)?[a-z]{2}$/', $json->name);
+ $this->assertMatchesRegularExpression(
+ '/^magento\/language\-[a-z]{2}_([a-z]{4}_)?[a-z]{2}$/',
+ $json->name
+ );
$this->assertDependsOnFramework($json->require);
$this->assertRequireInSync($json);
$this->assertNoVersionSpecified($json);
break;
case 'magento2-theme':
- $this->assertMatchesRegularExpression('/^magento\/theme-(?:adminhtml|frontend)(\-[a-z0-9_]+)+$/', $json->name);
+ $this->assertMatchesRegularExpression(
+ '/^magento\/theme-(?:adminhtml|frontend)(\-[a-z0-9_]+)+$/',
+ $json->name
+ );
$this->assertDependsOnPhp($json->require);
$this->assertPhpVersionInSync($json->name, $json->require->php);
$this->assertDependsOnFramework($json->require);
diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/Dependency/DeclarativeSchemaDependencyProvider.php b/dev/tests/static/testsuite/Magento/Test/Integrity/Dependency/DeclarativeSchemaDependencyProvider.php
index e1d35431c5e1d..8da62df528eb0 100644
--- a/dev/tests/static/testsuite/Magento/Test/Integrity/Dependency/DeclarativeSchemaDependencyProvider.php
+++ b/dev/tests/static/testsuite/Magento/Test/Integrity/Dependency/DeclarativeSchemaDependencyProvider.php
@@ -85,12 +85,11 @@ public function getDeclaredExistingModuleDependencies(string $moduleName): array
foreach ($dependencies as $dependency) {
$checkResult = array_intersect($declared, $dependency);
if ($checkResult) {
- //phpcs:ignore Magento2.Performance.ForeachArrayMerge
- $existingDeclared = array_merge($existingDeclared, array_values($checkResult));
+ $existingDeclared[] = array_values($checkResult);
}
}
- return array_unique($existingDeclared);
+ return array_unique(array_merge([], ...$existingDeclared));
}
/**
@@ -179,13 +178,10 @@ private function filterComplexDependency(string $moduleName, array $modules): ar
} else {
foreach ($modules as $dependencySet) {
if (array_search($moduleName, $dependencySet) === false) {
- //phpcs:ignore Magento2.Performance.ForeachArrayMerge
- $resultDependencies = array_merge(
- $resultDependencies,
- $dependencySet
- );
+ $resultDependencies[] = $dependencySet;
}
}
+ $resultDependencies = array_merge([], ...$resultDependencies);
}
return array_values(array_unique($resultDependencies));
diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/DependencyTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/DependencyTest.php
index d79e94af2bc01..85f6a0aabfee0 100644
--- a/dev/tests/static/testsuite/Magento/Test/Integrity/DependencyTest.php
+++ b/dev/tests/static/testsuite/Magento/Test/Integrity/DependencyTest.php
@@ -243,10 +243,9 @@ private static function getRedundantDependenciesWhiteLists(): array
realpath(__DIR__) . '/_files/dependency_test/whitelist/redundant_dependencies_*.php';
$redundantDependenciesWhitelist = [];
foreach (glob($redundantDependenciesWhitelistFilePattern) as $fileName) {
- //phpcs:ignore Magento2.Performance.ForeachArrayMerge
- $redundantDependenciesWhitelist = array_merge($redundantDependenciesWhitelist, include $fileName);
+ $redundantDependenciesWhitelist[] = include $fileName;
}
- self::$redundantDependenciesWhitelist = $redundantDependenciesWhitelist;
+ self::$redundantDependenciesWhitelist = array_merge([], ...$redundantDependenciesWhitelist);
}
return self::$redundantDependenciesWhitelist;
}
@@ -310,10 +309,9 @@ private static function getRoutesWhitelist(): array
$routesWhitelistFilePattern = realpath(__DIR__) . '/_files/dependency_test/whitelist/routes_*.php';
$routesWhitelist = [];
foreach (glob($routesWhitelistFilePattern) as $fileName) {
- //phpcs:ignore Magento2.Performance.ForeachArrayMerge
- $routesWhitelist = array_merge($routesWhitelist, include $fileName);
+ $routesWhitelist[] = include $fileName;
}
- self::$routesWhitelist = $routesWhitelist;
+ self::$routesWhitelist = array_merge([], ...$routesWhitelist);
}
return self::$routesWhitelist;
}
@@ -678,9 +676,9 @@ protected function getDependenciesFromFiles($module, $fileType, $file, $contents
foreach (self::$_rulesInstances as $rule) {
/** @var \Magento\TestFramework\Dependency\RuleInterface $rule */
$newDependencies = $rule->getDependencyInfo($module, $fileType, $file, $contents);
- //phpcs:ignore Magento2.Performance.ForeachArrayMerge
- $dependencies = array_merge($dependencies, $newDependencies);
+ $dependencies[] = $newDependencies;
}
+ $dependencies = array_merge([], ...$dependencies);
foreach ($dependencies as $dependencyKey => $dependency) {
foreach (self::$whiteList as $namespace) {
diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Api/ExtensibleInterfacesTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Api/ExtensibleInterfacesTest.php
index 9076c16981a49..fd87d02e2246a 100644
--- a/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Api/ExtensibleInterfacesTest.php
+++ b/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Api/ExtensibleInterfacesTest.php
@@ -239,12 +239,11 @@ public function getPhpFiles()
*/
protected function getFiles($dir, $pattern)
{
- $files = glob($dir . '/' . $pattern, GLOB_NOSORT);
+ $files = [glob($dir . '/' . $pattern, GLOB_NOSORT)];
foreach (glob($dir . '/*', GLOB_ONLYDIR | GLOB_NOSORT) as $newDir) {
- // phpcs:ignore Magento2.Performance.ForeachArrayMerge
- $files = array_merge($files, $this->getFiles($newDir, $pattern));
+ $files[] = $this->getFiles($newDir, $pattern);
}
- return $files;
+ return array_merge([], ...$files);
}
/**
diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/PublicCodeTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/PublicCodeTest.php
index 246ccc5732674..29ac58f39d89b 100644
--- a/dev/tests/static/testsuite/Magento/Test/Integrity/PublicCodeTest.php
+++ b/dev/tests/static/testsuite/Magento/Test/Integrity/PublicCodeTest.php
@@ -42,13 +42,9 @@ private function getWhitelist(): array
);
$whiteListItems = [];
foreach (glob($whiteListFiles) as $fileName) {
- // phpcs:ignore Magento2.Performance.ForeachArrayMerge
- $whiteListItems = array_merge(
- $whiteListItems,
- file($fileName, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES)
- );
+ $whiteListItems[] = file($fileName, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
}
- $this->blockWhitelist = $whiteListItems;
+ $this->blockWhitelist = array_merge([], ...$whiteListItems);
}
return $this->blockWhitelist;
}
diff --git a/dev/tests/static/testsuite/Magento/Test/Php/LiveCodeTest.php b/dev/tests/static/testsuite/Magento/Test/Php/LiveCodeTest.php
index ad91025448579..aa1f8b1c259a4 100644
--- a/dev/tests/static/testsuite/Magento/Test/Php/LiveCodeTest.php
+++ b/dev/tests/static/testsuite/Magento/Test/Php/LiveCodeTest.php
@@ -346,9 +346,9 @@ public function testCopyPaste()
$blackList = [];
foreach (glob(__DIR__ . '/_files/phpcpd/blacklist/*.txt') as $list) {
- // phpcs:ignore Magento2.Performance.ForeachArrayMerge.ForeachArrayMerge
- $blackList = array_merge($blackList, file($list, FILE_IGNORE_NEW_LINES));
+ $blackList[] = file($list, FILE_IGNORE_NEW_LINES);
}
+ $blackList = array_merge([], ...$blackList);
$copyPasteDetector->setBlackList($blackList);
diff --git a/lib/internal/Magento/Framework/App/Utility/Files.php b/lib/internal/Magento/Framework/App/Utility/Files.php
index 4298577f3147b..2c3fbad4b9aaf 100644
--- a/lib/internal/Magento/Framework/App/Utility/Files.php
+++ b/lib/internal/Magento/Framework/App/Utility/Files.php
@@ -644,23 +644,19 @@ private function collectModuleLayoutFiles(array $params, $location)
$regex = '#^' . $modulePath . '/view/(?P[a-z]+)/layout/(?P.+)$#i';
if (preg_match($regex, $moduleFile, $matches)) {
$files[] = [
- $matches['area'],
- '',
- $moduleName,
- $matches['path'],
- $moduleFile,
+ [$matches['area'], '', $moduleName, $matches['path'], $moduleFile]
];
} else {
throw new \UnexpectedValueException("Could not parse modular layout file '$moduleFile'");
}
}
} else {
- // phpcs:ignore Magento2.Performance.ForeachArrayMerge
- $files = array_merge($files, $moduleFiles);
+ $files[] = $moduleFiles;
}
}
}
- return $files;
+
+ return array_merge([], ...$files);
}
/**
@@ -691,14 +687,14 @@ private function collectThemeLayoutFiles(array $params, $location)
if ($params['with_metainfo']) {
// phpcs:ignore Magento2.Performance.ForeachArrayMerge
- $files = array_merge($this->parseThemeFiles($themeFiles, $currentThemePath, $theme));
+ $files[] = [array_merge($this->parseThemeFiles($themeFiles, $currentThemePath, $theme))];
} else {
- // phpcs:ignore Magento2.Performance.ForeachArrayMerge
- $files = array_merge($files, $themeFiles);
+ $files[] = $themeFiles;
}
}
}
- return $files;
+
+ return array_merge([], ...$files);
}
/**
diff --git a/lib/internal/Magento/Framework/Composer/ComposerInformation.php b/lib/internal/Magento/Framework/Composer/ComposerInformation.php
index 9808b8d60ab0e..0b796da73452c 100644
--- a/lib/internal/Magento/Framework/Composer/ComposerInformation.php
+++ b/lib/internal/Magento/Framework/Composer/ComposerInformation.php
@@ -144,16 +144,16 @@ public function getRequiredPhpVersion()
public function getRequiredExtensions()
{
$requiredExtensions = [];
- $allPlatformReqs = array_keys($this->getLocker()->getPlatformRequirements(true));
+ $allPlatformReqs = [array_keys($this->getLocker()->getPlatformRequirements(true))];
if (!$this->isMagentoRoot()) {
/** @var CompletePackageInterface $package */
foreach ($this->getLocker()->getLockedRepository()->getPackages() as $package) {
$requires = array_keys($package->getRequires());
- // phpcs:ignore Magento2.Performance.ForeachArrayMerge
- $allPlatformReqs = array_merge($allPlatformReqs, $requires);
+ $allPlatformReqs[] = $requires;
}
}
+ $allPlatformReqs = array_merge([], ...$allPlatformReqs);
foreach ($allPlatformReqs as $reqIndex) {
if (substr($reqIndex, 0, 4) === 'ext-') {
$requiredExtensions[] = substr($reqIndex, 4);
diff --git a/lib/internal/Magento/Framework/Console/Cli.php b/lib/internal/Magento/Framework/Console/Cli.php
index 6aab9c03ff7b2..f22c452549a78 100644
--- a/lib/internal/Magento/Framework/Console/Cli.php
+++ b/lib/internal/Magento/Framework/Console/Cli.php
@@ -224,15 +224,11 @@ protected function getVendorCommands($objectManager)
$commands = [];
foreach (CommandLocator::getCommands() as $commandListClass) {
if (class_exists($commandListClass)) {
- // phpcs:ignore Magento2.Performance.ForeachArrayMerge
- $commands = array_merge(
- $commands,
- $objectManager->create($commandListClass)->getCommands()
- );
+ $commands[] = $objectManager->create($commandListClass)->getCommands();
}
}
- return $commands;
+ return array_merge([], ...$commands);
}
/**
diff --git a/lib/internal/Magento/Framework/Search/Dynamic/Algorithm.php b/lib/internal/Magento/Framework/Search/Dynamic/Algorithm.php
index baee7221a7f17..4f044ddddd48a 100644
--- a/lib/internal/Magento/Framework/Search/Dynamic/Algorithm.php
+++ b/lib/internal/Magento/Framework/Search/Dynamic/Algorithm.php
@@ -502,7 +502,7 @@ protected function _mergeRoundValues(&$oldRoundValues, &$newRoundValues)
foreach ($newRoundValues as $roundingFactor => $roundValueValues) {
if (array_key_exists($roundingFactor, $oldRoundValues)) {
$oldRoundValues[$roundingFactor] = array_unique(
- // phpcs:ignore Magento2.Performance.ForeachArrayMerge
+ // phpcs:ignore Magento2.Performance.ForeachArrayMerge
array_merge($oldRoundValues[$roundingFactor], $roundValueValues)
);
} else {
diff --git a/setup/src/Magento/Setup/Model/ConfigGenerator.php b/setup/src/Magento/Setup/Model/ConfigGenerator.php
index 09d15489812e2..57f462c747ee4 100644
--- a/setup/src/Magento/Setup/Model/ConfigGenerator.php
+++ b/setup/src/Magento/Setup/Model/ConfigGenerator.php
@@ -140,7 +140,7 @@ public function createSessionConfig(array $data)
* Creates definitions config data
*
* @param array $data
- * @return ConfigData
+ * @return ConfigData|null
* @deprecated 2.2.0
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
diff --git a/setup/src/Magento/Setup/Model/ConfigOptionsList.php b/setup/src/Magento/Setup/Model/ConfigOptionsList.php
index a8d0a8591f539..f2135d8bf5202 100644
--- a/setup/src/Magento/Setup/Model/ConfigOptionsList.php
+++ b/setup/src/Magento/Setup/Model/ConfigOptionsList.php
@@ -205,12 +205,12 @@ public function getOptions()
),
];
+ $options = [$options];
foreach ($this->configOptionsCollection as $configOptionsList) {
- // phpcs:ignore Magento2.Performance.ForeachArrayMerge
- $options = array_merge($options, $configOptionsList->getOptions());
+ $options[] = $configOptionsList->getOptions();
}
- return $options;
+ return array_merge([], ...$options);
}
/**
@@ -245,34 +245,24 @@ public function validate(array $options, DeploymentConfig $deploymentConfig)
$errors = [];
if (isset($options[ConfigOptionsListConstants::INPUT_KEY_CACHE_HOSTS])) {
- $errors = array_merge(
- $errors,
- $this->validateHttpCacheHosts($options[ConfigOptionsListConstants::INPUT_KEY_CACHE_HOSTS])
- );
+ $errors[] = $this->validateHttpCacheHosts($options[ConfigOptionsListConstants::INPUT_KEY_CACHE_HOSTS]);
}
if (isset($options[ConfigOptionsListConstants::INPUT_KEY_DB_PREFIX])) {
- $errors = array_merge(
- $errors,
- $this->validateDbPrefix($options[ConfigOptionsListConstants::INPUT_KEY_DB_PREFIX])
- );
+ $errors[] = $this->validateDbPrefix($options[ConfigOptionsListConstants::INPUT_KEY_DB_PREFIX]);
}
if (!$options[ConfigOptionsListConstants::INPUT_KEY_SKIP_DB_VALIDATION]) {
- $errors = array_merge($errors, $this->validateDbSettings($options, $deploymentConfig));
+ $errors[] = $this->validateDbSettings($options, $deploymentConfig);
}
foreach ($this->configOptionsCollection as $configOptionsList) {
- // phpcs:ignore Magento2.Performance.ForeachArrayMerge
- $errors = array_merge($errors, $configOptionsList->validate($options, $deploymentConfig));
+ $errors[] = $configOptionsList->validate($options, $deploymentConfig);
}
- $errors = array_merge(
- $errors,
- $this->validateEncryptionKey($options)
- );
+ $errors[] = $this->validateEncryptionKey($options);
- return $errors;
+ return array_merge([], ...$errors);
}
/**