From 3d7eaf63f2211a9e1a8defe8c29e8f6da889ab2e Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 22 Jul 2024 14:01:39 +0200 Subject: [PATCH 1/3] Rector: CQ - UnusedForeachValueToArrayKeysRector (#1) * Rector: CQ - UnusedForeachValueToArrayKeysRector See Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector * fixes + phpstan See fix at rector: https://github.com/rectorphp/rector-src/pull/6164 --- app/code/core/Mage/Adminhtml/Block/Dashboard/Graph.php | 4 ++-- app/code/core/Mage/Adminhtml/Block/Page/Menu.php | 2 +- app/code/core/Mage/Adminhtml/Block/Report/Grid.php | 2 +- .../Adminhtml/Block/Sales/Transactions/Child/Grid.php | 2 +- app/code/core/Mage/Adminhtml/Block/Store/Switcher.php | 4 ++-- app/code/core/Mage/Adminhtml/Block/Urlrewrite/Edit.php | 2 +- .../core/Mage/Adminhtml/Block/Urlrewrite/Edit/Form.php | 2 +- app/code/core/Mage/Adminhtml/Block/Widget/Grid.php | 2 +- .../Block/Widget/Grid/Column/Renderer/Action.php | 2 +- app/code/core/Mage/Adminhtml/Block/Widget/Tabs.php | 2 +- .../Adminhtml/Model/System/Config/Source/Admin/Page.php | 2 +- app/code/core/Mage/Api2/Model/Acl/Filter.php | 2 +- .../Model/Acl/Filter/Attribute/ResourcePermission.php | 2 +- app/code/core/Mage/Catalog/Model/Api2/Product.php | 2 +- app/code/core/Mage/Catalog/Model/Category.php | 2 +- app/code/core/Mage/Catalog/Model/Product/Type/Price.php | 2 +- .../core/Mage/Catalog/Model/Resource/Category/Flat.php | 2 +- app/code/core/Mage/Checkout/Model/Type/Onepage.php | 2 +- .../Mage/ConfigurableSwatches/Helper/Mediafallback.php | 2 +- app/code/core/Mage/Core/Helper/Data.php | 2 +- app/code/core/Mage/Core/Model/Cache.php | 2 +- app/code/core/Mage/Core/Model/Layout/Validator.php | 2 +- app/code/core/Mage/Core/Model/Locale.php | 2 +- app/code/core/Mage/Core/Model/Log/Adapter.php | 2 +- app/code/core/Mage/Core/Model/Url/Rewrite.php | 2 +- app/code/core/Mage/Core/Model/Url/Rewrite/Request.php | 2 +- app/code/core/Mage/Customer/Model/Address/Api.php | 8 ++++---- app/code/core/Mage/Customer/Model/Address/Api/V2.php | 6 +++--- app/code/core/Mage/Customer/Model/Customer/Api.php | 6 +++--- app/code/core/Mage/Dataflow/Model/Batch.php | 4 ++-- app/code/core/Mage/Dataflow/Model/Session/Parser/Csv.php | 2 +- app/code/core/Mage/Eav/Model/Entity/Abstract.php | 2 +- .../Mage/ImportExport/Model/Export/Entity/Product.php | 6 +++--- .../Mage/ImportExport/Model/Import/Entity/Customer.php | 2 +- .../Mage/ImportExport/Model/Import/Entity/Product.php | 2 +- app/code/core/Mage/Index/Model/Event.php | 2 +- app/code/core/Mage/Install/Block/Db/Main.php | 2 +- app/code/core/Mage/Install/Model/Installer/Console.php | 2 +- .../core/Mage/Install/Model/Installer/Db/Abstract.php | 2 +- app/code/core/Mage/Page/Block/Template/Links.php | 2 +- app/code/core/Mage/Paygate/Model/Authorizenet.php | 2 +- app/code/core/Mage/Payment/Block/Form/Cc.php | 2 +- app/code/core/Mage/Payment/Helper/Data.php | 6 +++--- .../core/Mage/Paypal/Model/Resource/Report/Settlement.php | 2 +- app/code/core/Mage/Reports/Model/Totals.php | 2 +- app/code/core/Mage/Rule/Model/Action/Abstract.php | 4 ++-- app/code/core/Mage/Rule/Model/Condition/Abstract.php | 6 +++--- app/code/core/Mage/Rule/Model/Condition/Combine.php | 2 +- .../Sales/Block/Adminhtml/Customer/Edit/Tab/Agreement.php | 2 +- .../Mage/Sales/Model/Resource/Report/Order/Createdat.php | 2 +- .../core/Mage/Sales/Model/Resource/Sale/Collection.php | 2 +- .../sql/sales_setup/mysql4-upgrade-0.8.13-0.8.14.php | 2 +- .../sql/sales_setup/mysql4-upgrade-0.9.50-0.9.51.php | 2 +- app/code/core/Mage/Shipping/Model/Rate/Result.php | 2 +- app/code/core/Mage/Tag/Helper/Data.php | 2 +- app/code/core/Mage/Tag/controllers/IndexController.php | 2 +- .../core/Mage/Weee/Model/Attribute/Backend/Weee/Tax.php | 2 +- .../Catalog/Product/Attribute/Edit/AttributeForm.php | 2 +- .../Test/Block/Catalog/Product/Edit/Tab/Prices.php | 4 ++-- .../Adminhtml/Test/Block/Catalog/Product/ProductForm.php | 2 +- .../app/Mage/Adminhtml/Test/Block/Widget/FormTabs.php | 4 ++-- .../tests/app/Mage/Bundle/Test/Handler/Curl.php | 4 ++-- .../DeleteOptionsSubStep.php | 2 +- .../app/Mage/Customer/Test/Handler/Customer/Curl.php | 2 +- .../app/Mage/Weee/Test/Constraint/AssertFptApplied.php | 2 +- lib/Varien/Convert/Parser/Csv.php | 4 ++-- lib/Varien/Db/Statement/Pdo/Mysql.php | 2 +- lib/Varien/Http/Adapter/Curl.php | 2 +- lib/Varien/Object.php | 2 +- lib/Varien/Object/Cache.php | 2 +- phpstan.dist.baseline.neon | 5 ----- 71 files changed, 91 insertions(+), 96 deletions(-) diff --git a/app/code/core/Mage/Adminhtml/Block/Dashboard/Graph.php b/app/code/core/Mage/Adminhtml/Block/Dashboard/Graph.php index 700d3b3b17d..afc5f13938c 100644 --- a/app/code/core/Mage/Adminhtml/Block/Dashboard/Graph.php +++ b/app/code/core/Mage/Adminhtml/Block/Dashboard/Graph.php @@ -215,7 +215,7 @@ public function getChartUrl($directUrl = true) $dateStart->addMonth(1); break; } - foreach ($this->getAllSeries() as $index => $serie) { + foreach (array_keys($this->getAllSeries()) as $index) { if (in_array($d, $this->_axisLabels['x'])) { $datas[$index][] = (float)array_shift($this->_allSeries[$index]); } else { @@ -328,7 +328,7 @@ public function getChartUrl($directUrl = true) if (count($this->_axisLabels)) { $params['chxt'] = implode(',', array_keys($this->_axisLabels)); $indexid = 0; - foreach ($this->_axisLabels as $idx => $labels) { + foreach (array_keys($this->_axisLabels) as $idx) { if ($idx === 'x') { /** * Format date diff --git a/app/code/core/Mage/Adminhtml/Block/Page/Menu.php b/app/code/core/Mage/Adminhtml/Block/Page/Menu.php index d4872f9158d..20bb44f96f4 100644 --- a/app/code/core/Mage/Adminhtml/Block/Page/Menu.php +++ b/app/code/core/Mage/Adminhtml/Block/Page/Menu.php @@ -164,7 +164,7 @@ protected function _buildMenuArray(Varien_Simplexml_Element $parent, $path = '', uasort($parentArr, [$this, '_sortMenu']); - foreach ($parentArr as $key => $value) { + foreach (array_keys($parentArr) as $key) { $last = $key; } if (isset($last)) { diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Grid.php b/app/code/core/Mage/Adminhtml/Block/Report/Grid.php index 180a228a288..efc441c2365 100644 --- a/app/code/core/Mage/Adminhtml/Block/Report/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Report/Grid.php @@ -207,7 +207,7 @@ protected function _prepareCollection() */ protected function _setFilterValues($data) { - foreach ($data as $name => $value) { + foreach (array_keys($data) as $name) { $this->setFilter($name, $data[$name]); } return $this; diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Transactions/Child/Grid.php b/app/code/core/Mage/Adminhtml/Block/Sales/Transactions/Child/Grid.php index 1e8e12f3dd4..2a585eb5b7d 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Transactions/Child/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Transactions/Child/Grid.php @@ -62,7 +62,7 @@ protected function _prepareColumns() { $result = parent::_prepareColumns(); - foreach ($this->_columns as $key => $value) { + foreach (array_keys($this->_columns) as $key) { if (in_array($key, $this->_columnsToRemove)) { unset($this->_columns[$key]); } else { diff --git a/app/code/core/Mage/Adminhtml/Block/Store/Switcher.php b/app/code/core/Mage/Adminhtml/Block/Store/Switcher.php index d0c60a17406..33442aa26b1 100644 --- a/app/code/core/Mage/Adminhtml/Block/Store/Switcher.php +++ b/app/code/core/Mage/Adminhtml/Block/Store/Switcher.php @@ -73,7 +73,7 @@ public function getWebsites() { $websites = Mage::app()->getWebsites(); if ($websiteIds = $this->getWebsiteIds()) { - foreach ($websites as $websiteId => $website) { + foreach (array_keys($websites) as $websiteId) { if (!in_array($websiteId, $websiteIds)) { unset($websites[$websiteId]); } @@ -140,7 +140,7 @@ public function getStores($group) } $stores = $group->getStores(); if ($storeIds = $this->getStoreIds()) { - foreach ($stores as $storeId => $store) { + foreach (array_keys($stores) as $storeId) { if (!in_array($storeId, $storeIds)) { unset($stores[$storeId]); } diff --git a/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Edit.php b/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Edit.php index 9e369a45972..fc959e184ff 100644 --- a/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Edit.php @@ -194,7 +194,7 @@ public function getButtonsHtml($area = null) { if ($this->_buttonsHtml === null) { $this->_buttonsHtml = parent::getButtonsHtml(); - foreach ($this->_children as $alias => $child) { + foreach (array_keys($this->_children) as $alias) { if (str_contains($alias, '_button')) { $this->unsetChild($alias); } diff --git a/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Edit/Form.php b/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Edit/Form.php index a91f22b905a..955c2f871b0 100644 --- a/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Edit/Form.php +++ b/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Edit/Form.php @@ -61,7 +61,7 @@ protected function _prepareForm() 'description' => $model->getDescription(), ]; if ($sessionData = Mage::getSingleton('adminhtml/session')->getData('urlrewrite_data', true)) { - foreach ($formValues as $key => $value) { + foreach (array_keys($formValues) as $key) { if (isset($sessionData[$key])) { $formValues[$key] = $sessionData[$key]; } diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php b/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php index af36a237924..5b701ae5133 100644 --- a/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php @@ -481,7 +481,7 @@ public function getColumns() */ protected function _setFilterValues($data) { - foreach ($data as $columnId => $value) { + foreach (array_keys($data) as $columnId) { $column = $this->getColumn($columnId); if ($column instanceof Mage_Adminhtml_Block_Widget_Grid_Column && (!empty($data[$columnId]) || strlen($data[$columnId]) > 0) diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Action.php b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Action.php index 1fe5f9905b6..9bdad27dbbf 100644 --- a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Action.php +++ b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Action.php @@ -109,7 +109,7 @@ protected function _toLinkHtml($action, Varien_Object $row) */ protected function _transformActionData(&$action, &$actionCaption, Varien_Object $row) { - foreach ($action as $attribute => $value) { + foreach (array_keys($action) as $attribute) { if (isset($action[$attribute]) && !is_array($action[$attribute])) { $this->getColumn()->setFormat($action[$attribute]); $action[$attribute] = parent::render($row); diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Tabs.php b/app/code/core/Mage/Adminhtml/Block/Widget/Tabs.php index 94e9fae48a6..ca58c8f7fc6 100644 --- a/app/code/core/Mage/Adminhtml/Block/Widget/Tabs.php +++ b/app/code/core/Mage/Adminhtml/Block/Widget/Tabs.php @@ -256,7 +256,7 @@ protected function _reorderTabs() asort($this->_tabPositions); $ordered = []; - foreach ($this->_tabPositions as $tabId => $position) { + foreach (array_keys($this->_tabPositions) as $tabId) { if (isset($this->_tabs[$tabId])) { $tab = $this->_tabs[$tabId]; $ordered[$tabId] = $tab; diff --git a/app/code/core/Mage/Adminhtml/Model/System/Config/Source/Admin/Page.php b/app/code/core/Mage/Adminhtml/Model/System/Config/Source/Admin/Page.php index e79b3daedc4..92bfd9d0639 100644 --- a/app/code/core/Mage/Adminhtml/Model/System/Config/Source/Admin/Page.php +++ b/app/code/core/Mage/Adminhtml/Model/System/Config/Source/Admin/Page.php @@ -109,7 +109,7 @@ protected function _buildMenuArray(?Varien_Simplexml_Element $parent = null, $pa uasort($parentArr, [$this, '_sortMenu']); - foreach ($parentArr as $key => $value) { + foreach (array_keys($parentArr) as $key) { $last = $key; } if (isset($last)) { diff --git a/app/code/core/Mage/Api2/Model/Acl/Filter.php b/app/code/core/Mage/Api2/Model/Acl/Filter.php index 3494dfceb14..cefef4dd4f6 100644 --- a/app/code/core/Mage/Api2/Model/Acl/Filter.php +++ b/app/code/core/Mage/Api2/Model/Acl/Filter.php @@ -61,7 +61,7 @@ public function __construct(Mage_Api2_Model_Resource $resource) */ protected function _filter(array $allowedAttributes, array $data) { - foreach ($data as $attribute => $value) { + foreach (array_keys($data) as $attribute) { if (!in_array($attribute, $allowedAttributes)) { unset($data[$attribute]); } diff --git a/app/code/core/Mage/Api2/Model/Acl/Filter/Attribute/ResourcePermission.php b/app/code/core/Mage/Api2/Model/Acl/Filter/Attribute/ResourcePermission.php index 1016b87c227..f58a244ca00 100644 --- a/app/code/core/Mage/Api2/Model/Acl/Filter/Attribute/ResourcePermission.php +++ b/app/code/core/Mage/Api2/Model/Acl/Filter/Attribute/ResourcePermission.php @@ -103,7 +103,7 @@ public function getResourcesPermissions() $resourceModel->setResourceType($resource) ->setUserType($this->_userType); - foreach ($operations as $operation => $operationLabel) { + foreach (array_keys($operations) as $operation) { if (!$this->_hasEntityOnlyAttributes && $config->getResourceEntityOnlyAttributes($resource, $this->_userType, $operation) ) { diff --git a/app/code/core/Mage/Catalog/Model/Api2/Product.php b/app/code/core/Mage/Catalog/Model/Api2/Product.php index 586f1db4acd..f757413be4b 100644 --- a/app/code/core/Mage/Catalog/Model/Api2/Product.php +++ b/app/code/core/Mage/Catalog/Model/Api2/Product.php @@ -42,7 +42,7 @@ public function getAvailableAttributes($userType, $operation) } $excludedAttrs = $this->getExcludedAttributes($userType, $operation); $includedAttrs = $this->getIncludedAttributes($userType, $operation); - foreach ($attributes as $code => $label) { + foreach (array_keys($attributes) as $code) { if (in_array($code, $excludedAttrs) || ($includedAttrs && !in_array($code, $includedAttrs))) { unset($attributes[$code]); } diff --git a/app/code/core/Mage/Catalog/Model/Category.php b/app/code/core/Mage/Catalog/Model/Category.php index 58cd0b2c7c9..5ff10b609dc 100644 --- a/app/code/core/Mage/Catalog/Model/Category.php +++ b/app/code/core/Mage/Catalog/Model/Category.php @@ -346,7 +346,7 @@ public function getAttributes($noDesignAttributes = false) ->getSortedAttributes(); if ($noDesignAttributes) { - foreach ($result as $k => $a) { + foreach (array_keys($result) as $k) { if (in_array($k, $this->_designAttributes)) { unset($result[$k]); } diff --git a/app/code/core/Mage/Catalog/Model/Product/Type/Price.php b/app/code/core/Mage/Catalog/Model/Product/Type/Price.php index 62e6d7f86ae..df7d7f731c9 100644 --- a/app/code/core/Mage/Catalog/Model/Product/Type/Price.php +++ b/app/code/core/Mage/Catalog/Model/Product/Type/Price.php @@ -300,7 +300,7 @@ public function getFormatedTierPrice($qty, $product) { $price = $product->getTierPrice($qty); if (is_array($price)) { - foreach ($price as $index => $value) { + foreach (array_keys($price) as $index) { $price[$index]['formated_price'] = Mage::app()->getStore()->convertPrice( $price[$index]['website_price'], true diff --git a/app/code/core/Mage/Catalog/Model/Resource/Category/Flat.php b/app/code/core/Mage/Catalog/Model/Resource/Category/Flat.php index 3a03e409ef5..7e962fb0b72 100644 --- a/app/code/core/Mage/Catalog/Model/Resource/Category/Flat.php +++ b/app/code/core/Mage/Catalog/Model/Resource/Category/Flat.php @@ -1152,7 +1152,7 @@ protected function _prepareDataForAllFields($category, $replaceFields = []) $table = $this->_getReadAdapter()->describeTable($table); $data = []; $idFieldName = Mage::getSingleton('catalog/category')->getIdFieldName(); - foreach ($table as $column => $columnData) { + foreach (array_keys($table) as $column) { if ($column != $idFieldName || $category->getData($column) !== null) { if (array_key_exists($column, $replaceFields)) { $value = $category->getData($replaceFields[$column]); diff --git a/app/code/core/Mage/Checkout/Model/Type/Onepage.php b/app/code/core/Mage/Checkout/Model/Type/Onepage.php index f1d8d4a5ced..2cdbe2eec65 100644 --- a/app/code/core/Mage/Checkout/Model/Type/Onepage.php +++ b/app/code/core/Mage/Checkout/Model/Type/Onepage.php @@ -119,7 +119,7 @@ public function initCheckout() $checkout = $this->getCheckout(); $customerSession = $this->getCustomerSession(); if (is_array($checkout->getStepData())) { - foreach ($checkout->getStepData() as $step => $data) { + foreach (array_keys($checkout->getStepData()) as $step) { if (!($step === 'login' || $customerSession->isLoggedIn() && $step === 'billing')) { $checkout->setStepData($step, 'allow', false); } diff --git a/app/code/core/Mage/ConfigurableSwatches/Helper/Mediafallback.php b/app/code/core/Mage/ConfigurableSwatches/Helper/Mediafallback.php index db49ed16933..da23ea014ad 100644 --- a/app/code/core/Mage/ConfigurableSwatches/Helper/Mediafallback.php +++ b/app/code/core/Mage/ConfigurableSwatches/Helper/Mediafallback.php @@ -136,7 +136,7 @@ public function attachProductChildrenAttributeMapping(array $parentProducts, $st } // end looping child products } // end looping attributes - foreach ($mapping as $key => $value) { + foreach (array_keys($mapping) as $key) { $mapping[$key]['product_ids'] = array_unique($mapping[$key]['product_ids']); } diff --git a/app/code/core/Mage/Core/Helper/Data.php b/app/code/core/Mage/Core/Helper/Data.php index 73029d7952c..d3c9a73ac45 100644 --- a/app/code/core/Mage/Core/Helper/Data.php +++ b/app/code/core/Mage/Core/Helper/Data.php @@ -603,7 +603,7 @@ public function assocToXml(array $array, $rootName = '_') <$rootName> XML; $xml = new SimpleXMLElement($xmlstr); - foreach ($array as $key => $value) { + foreach (array_keys($array) as $key) { if (is_numeric($key)) { throw new Exception('Array root keys must not be numeric.'); } diff --git a/app/code/core/Mage/Core/Model/Cache.php b/app/code/core/Mage/Core/Model/Cache.php index fe97c2c491f..9965019bf1e 100644 --- a/app/code/core/Mage/Core/Model/Cache.php +++ b/app/code/core/Mage/Core/Model/Cache.php @@ -625,7 +625,7 @@ public function getInvalidatedTypes() $types = $this->_getInvalidatedTypes(); if ($types) { $allTypes = $this->getTypes(); - foreach ($types as $type => $flag) { + foreach (array_keys($types) as $type) { if (isset($allTypes[$type]) && $this->canUse($type)) { $invalidatedTypes[$type] = $allTypes[$type]; } diff --git a/app/code/core/Mage/Core/Model/Layout/Validator.php b/app/code/core/Mage/Core/Model/Layout/Validator.php index 9bedeaf8621..2d14731992b 100644 --- a/app/code/core/Mage/Core/Model/Layout/Validator.php +++ b/app/code/core/Mage/Core/Model/Layout/Validator.php @@ -108,7 +108,7 @@ public function getDisallowedBlocks() if (!count($this->_disallowedBlock)) { $disallowedBlockConfig = $this->_getDisallowedBlockConfigValue(); if (is_array($disallowedBlockConfig)) { - foreach ($disallowedBlockConfig as $blockName => $value) { + foreach (array_keys($disallowedBlockConfig) as $blockName) { $this->_disallowedBlock[] = $blockName; } } diff --git a/app/code/core/Mage/Core/Model/Locale.php b/app/code/core/Mage/Core/Model/Locale.php index d3b70a7c1cd..2a0c44563c3 100644 --- a/app/code/core/Mage/Core/Model/Locale.php +++ b/app/code/core/Mage/Core/Model/Locale.php @@ -247,7 +247,7 @@ protected function _getOptionLocales($translatedName = false) } } - foreach ($locales as $code => $active) { + foreach (array_keys($locales) as $code) { if (strstr($code, '_')) { if (!in_array($code, $allowed)) { continue; diff --git a/app/code/core/Mage/Core/Model/Log/Adapter.php b/app/code/core/Mage/Core/Model/Log/Adapter.php index 3bc190114c0..1a173c94d99 100644 --- a/app/code/core/Mage/Core/Model/Log/Adapter.php +++ b/app/code/core/Mage/Core/Model/Log/Adapter.php @@ -115,7 +115,7 @@ public function setFilterDataKeys($keys) protected function _filterDebugData($debugData) { if (is_array($debugData) && is_array($this->_debugReplacePrivateDataKeys)) { - foreach ($debugData as $key => $value) { + foreach (array_keys($debugData) as $key) { if (in_array($key, $this->_debugReplacePrivateDataKeys)) { $debugData[$key] = '****'; } else { diff --git a/app/code/core/Mage/Core/Model/Url/Rewrite.php b/app/code/core/Mage/Core/Model/Url/Rewrite.php index a9bae5f2912..929f39be12c 100644 --- a/app/code/core/Mage/Core/Model/Url/Rewrite.php +++ b/app/code/core/Mage/Core/Model/Url/Rewrite.php @@ -319,7 +319,7 @@ protected function _getQueryString() $queryParams = []; parse_str($_SERVER['QUERY_STRING'], $queryParams); $hasChanges = false; - foreach ($queryParams as $key => $value) { + foreach (array_keys($queryParams) as $key) { if (substr($key, 0, 3) === '___') { unset($queryParams[$key]); $hasChanges = true; diff --git a/app/code/core/Mage/Core/Model/Url/Rewrite/Request.php b/app/code/core/Mage/Core/Model/Url/Rewrite/Request.php index 80bf9ce24de..f6c14bf4b9a 100644 --- a/app/code/core/Mage/Core/Model/Url/Rewrite/Request.php +++ b/app/code/core/Mage/Core/Model/Url/Rewrite/Request.php @@ -306,7 +306,7 @@ protected function _getQueryString() $queryParams = []; parse_str($_SERVER['QUERY_STRING'], $queryParams); $hasChanges = false; - foreach ($queryParams as $key => $value) { + foreach (array_keys($queryParams) as $key) { if (substr($key, 0, 3) === '___') { unset($queryParams[$key]); $hasChanges = true; diff --git a/app/code/core/Mage/Customer/Model/Address/Api.php b/app/code/core/Mage/Customer/Model/Address/Api.php index 63120a58f38..9f779558882 100644 --- a/app/code/core/Mage/Customer/Model/Address/Api.php +++ b/app/code/core/Mage/Customer/Model/Address/Api.php @@ -55,7 +55,7 @@ public function items($customerId) $row[$attributeAlias] = $data[$attributeCode] ?? null; } - foreach ($this->getAllowedAttributes($address) as $attributeCode => $attribute) { + foreach (array_keys($this->getAllowedAttributes($address)) as $attributeCode) { if (isset($data[$attributeCode])) { $row[$attributeCode] = $data[$attributeCode]; } @@ -89,7 +89,7 @@ public function create($customerId, $addressData) $address = Mage::getModel('customer/address'); - foreach ($this->getAllowedAttributes($address) as $attributeCode => $attribute) { + foreach (array_keys($this->getAllowedAttributes($address)) as $attributeCode) { if (isset($addressData[$attributeCode])) { $address->setData($attributeCode, $addressData[$attributeCode]); } @@ -141,7 +141,7 @@ public function info($addressId) $result[$attributeAlias] = $address->getData($attributeCode); } - foreach ($this->getAllowedAttributes($address) as $attributeCode => $attribute) { + foreach (array_keys($this->getAllowedAttributes($address)) as $attributeCode) { $result[$attributeCode] = $address->getData($attributeCode); } @@ -169,7 +169,7 @@ public function update($addressId, $addressData) $this->_fault('not_exists'); } - foreach ($this->getAllowedAttributes($address) as $attributeCode => $attribute) { + foreach (array_keys($this->getAllowedAttributes($address)) as $attributeCode) { if (isset($addressData[$attributeCode])) { $address->setData($attributeCode, $addressData[$attributeCode]); } diff --git a/app/code/core/Mage/Customer/Model/Address/Api/V2.php b/app/code/core/Mage/Customer/Model/Address/Api/V2.php index 8616fec57a1..901b932eef7 100644 --- a/app/code/core/Mage/Customer/Model/Address/Api/V2.php +++ b/app/code/core/Mage/Customer/Model/Address/Api/V2.php @@ -40,7 +40,7 @@ public function create($customerId, $addressData) $address = Mage::getModel('customer/address'); - foreach ($this->getAllowedAttributes($address) as $attributeCode => $attribute) { + foreach (array_keys($this->getAllowedAttributes($address)) as $attributeCode) { if (isset($addressData->$attributeCode)) { $address->setData($attributeCode, $addressData->$attributeCode); } @@ -92,7 +92,7 @@ public function info($addressId) $result[$attributeAlias] = $address->getData($attributeCode); } - foreach ($this->getAllowedAttributes($address) as $attributeCode => $attribute) { + foreach (array_keys($this->getAllowedAttributes($address)) as $attributeCode) { $result[$attributeCode] = $address->getData($attributeCode); } @@ -120,7 +120,7 @@ public function update($addressId, $addressData) $this->_fault('not_exists'); } - foreach ($this->getAllowedAttributes($address) as $attributeCode => $attribute) { + foreach (array_keys($this->getAllowedAttributes($address)) as $attributeCode) { if (isset($addressData->$attributeCode)) { $address->setData($attributeCode, $addressData->$attributeCode); } diff --git a/app/code/core/Mage/Customer/Model/Customer/Api.php b/app/code/core/Mage/Customer/Model/Customer/Api.php index 16853c6c60e..f8daaa27a89 100644 --- a/app/code/core/Mage/Customer/Model/Customer/Api.php +++ b/app/code/core/Mage/Customer/Model/Customer/Api.php @@ -87,7 +87,7 @@ public function info($customerId, $attributes = null) $result[$attributeAlias] = $customer->getData($attributeCode); } - foreach ($this->getAllowedAttributes($customer, $attributes) as $attributeCode => $attribute) { + foreach (array_keys($this->getAllowedAttributes($customer, $attributes)) as $attributeCode) { $result[$attributeCode] = $customer->getData($attributeCode); } @@ -121,7 +121,7 @@ public function items($filters) foreach ($this->_mapAttributes as $attributeAlias => $attributeCode) { $row[$attributeAlias] = $data[$attributeCode] ?? null; } - foreach ($this->getAllowedAttributes($customer) as $attributeCode => $attribute) { + foreach (array_keys($this->getAllowedAttributes($customer)) as $attributeCode) { if (isset($data[$attributeCode])) { $row[$attributeCode] = $data[$attributeCode]; } @@ -149,7 +149,7 @@ public function update($customerId, $customerData) $this->_fault('not_exists'); } - foreach ($this->getAllowedAttributes($customer) as $attributeCode => $attribute) { + foreach (array_keys($this->getAllowedAttributes($customer)) as $attributeCode) { if (isset($customerData[$attributeCode])) { $customer->setData($attributeCode, $customerData[$attributeCode]); } diff --git a/app/code/core/Mage/Dataflow/Model/Batch.php b/app/code/core/Mage/Dataflow/Model/Batch.php index 1f727062e73..1235b8f468f 100644 --- a/app/code/core/Mage/Dataflow/Model/Batch.php +++ b/app/code/core/Mage/Dataflow/Model/Batch.php @@ -92,12 +92,12 @@ public function getFieldList() */ public function parseFieldList($row) { - foreach ($row as $fieldName => $value) { + foreach (array_keys($row) as $fieldName) { if (!in_array($fieldName, $this->_fieldList)) { $this->_fieldList[$fieldName] = $fieldName; } } - unset($fieldName, $value, $row); + unset($fieldName, $row); } /** diff --git a/app/code/core/Mage/Dataflow/Model/Session/Parser/Csv.php b/app/code/core/Mage/Dataflow/Model/Session/Parser/Csv.php index 1a15c400f15..fdf30b8c5f6 100644 --- a/app/code/core/Mage/Dataflow/Model/Session/Parser/Csv.php +++ b/app/code/core/Mage/Dataflow/Model/Session/Parser/Csv.php @@ -47,7 +47,7 @@ public function parse() $fields = $line; continue; } else { - foreach ($line as $j => $f) { + foreach (array_keys($line) as $j) { $fields[$j] = 'column' . ($j + 1); } } diff --git a/app/code/core/Mage/Eav/Model/Entity/Abstract.php b/app/code/core/Mage/Eav/Model/Entity/Abstract.php index 25c93a56c2e..01c39e4c918 100644 --- a/app/code/core/Mage/Eav/Model/Entity/Abstract.php +++ b/app/code/core/Mage/Eav/Model/Entity/Abstract.php @@ -1594,7 +1594,7 @@ public function delete($object) ]; $this->_getWriteAdapter()->delete($this->getEntityTable(), $where); $this->loadAllAttributes($object); - foreach ($this->getAttributesByTable() as $table => $attributes) { + foreach (array_keys($this->getAttributesByTable()) as $table) { $this->_getWriteAdapter()->delete($table, $where); } } catch (Exception $e) { diff --git a/app/code/core/Mage/ImportExport/Model/Export/Entity/Product.php b/app/code/core/Mage/ImportExport/Model/Export/Entity/Product.php index 91b578e810a..1ecb2e87b92 100644 --- a/app/code/core/Mage/ImportExport/Model/Export/Entity/Product.php +++ b/app/code/core/Mage/ImportExport/Model/Export/Entity/Product.php @@ -790,7 +790,7 @@ protected function _prepareExport() '_custom_option_row_sku', '_custom_option_row_sort' ]; - foreach ($this->_storeIdToCode as $storeId => &$storeCode) { + foreach (array_keys($this->_storeIdToCode) as &$storeId) { $skip = false; $options = Mage::getResourceModel('catalog/product_option_collection') ->reset() @@ -961,7 +961,7 @@ protected function _prepareExport() $dataRow = array_merge($dataRow, array_shift($configurableData[$productId])); } if (!empty($rowMultiselects[$productId][$storeId])) { - foreach ($rowMultiselects[$productId][$storeId] as $attrKey => $attrVal) { + foreach (array_keys($rowMultiselects[$productId][$storeId]) as $attrKey) { if (isset($rowMultiselects[$productId][$storeId][$attrKey])) { $dataRow[$attrKey] = array_shift($rowMultiselects[$productId][$storeId][$attrKey]); } @@ -1039,7 +1039,7 @@ protected function _prepareExport() $dataRow = array_merge($dataRow, array_shift($configurableData[$productId])); } if (!empty($rowMultiselects[$productId][$storeId])) { - foreach ($rowMultiselects[$productId][$storeId] as $attrKey => $attrVal) { + foreach (array_keys($rowMultiselects[$productId][$storeId]) as $attrKey) { if (isset($rowMultiselects[$productId][$storeId][$attrKey])) { $dataRow[$attrKey] = array_shift($rowMultiselects[$productId][$storeId][$attrKey]); } diff --git a/app/code/core/Mage/ImportExport/Model/Import/Entity/Customer.php b/app/code/core/Mage/ImportExport/Model/Import/Entity/Customer.php index 6c1771b734e..5fc9083546d 100644 --- a/app/code/core/Mage/ImportExport/Model/Import/Entity/Customer.php +++ b/app/code/core/Mage/ImportExport/Model/Import/Entity/Customer.php @@ -547,7 +547,7 @@ public function getEntityTypeCode() public function getRowScope(array $rowData) { $foundOptions = false; - foreach ($this->_multiSelectAttributes as $attrCode => $attribute) { + foreach (array_keys($this->_multiSelectAttributes) as $attrCode) { if ($rowData[$attrCode]) { $foundOptions = true; } diff --git a/app/code/core/Mage/ImportExport/Model/Import/Entity/Product.php b/app/code/core/Mage/ImportExport/Model/Import/Entity/Product.php index 0a4cf80d21e..914c5be124f 100644 --- a/app/code/core/Mage/ImportExport/Model/Import/Entity/Product.php +++ b/app/code/core/Mage/ImportExport/Model/Import/Entity/Product.php @@ -1099,7 +1099,7 @@ protected function _saveCustomOptions() if ($productIds) { // update product entity table to show that product has options $customOptionsProducts = $customOptions['product_id']; - foreach ($customOptionsProducts as $key => $value) { + foreach (array_keys($customOptionsProducts) as $key) { if (!in_array($key, $productIds)) { unset($customOptionsProducts[$key]); } diff --git a/app/code/core/Mage/Index/Model/Event.php b/app/code/core/Mage/Index/Model/Event.php index 2035a5be359..d4dc4468a17 100644 --- a/app/code/core/Mage/Index/Model/Event.php +++ b/app/code/core/Mage/Index/Model/Event.php @@ -157,7 +157,7 @@ protected function _mergeNewDataRecursive($previous, $current) return $previous; } - foreach ($previous as $key => $value) { + foreach (array_keys($previous) as $key) { if (array_key_exists($key, $current) && !is_null($current[$key]) && is_array($previous[$key])) { if (!is_string($key) || is_array($current[$key])) { $current[$key] = $this->_mergeNewDataRecursive($previous[$key], $current[$key]); diff --git a/app/code/core/Mage/Install/Block/Db/Main.php b/app/code/core/Mage/Install/Block/Db/Main.php index 9f0789c1ea3..25791d2f5f8 100644 --- a/app/code/core/Mage/Install/Block/Db/Main.php +++ b/app/code/core/Mage/Install/Block/Db/Main.php @@ -77,7 +77,7 @@ public function getDatabaseBlock($type) public function getDatabaseBlocks() { $databases = []; - foreach ($this->_databases as $type => $blockData) { + foreach (array_keys($this->_databases) as $type) { $databases[] = $this->getDatabaseBlock($type); } return $databases; diff --git a/app/code/core/Mage/Install/Model/Installer/Console.php b/app/code/core/Mage/Install/Model/Installer/Console.php index 033d8db36a4..7c31a5007ab 100644 --- a/app/code/core/Mage/Install/Model/Installer/Console.php +++ b/app/code/core/Mage/Install/Model/Installer/Console.php @@ -155,7 +155,7 @@ public function setArgs($args = null) /** * Set args values */ - foreach ($this->_getOptions() as $name => $option) { + foreach (array_keys($this->_getOptions()) as $name) { $this->_args[$name] = $args[$name] ?? ''; } diff --git a/app/code/core/Mage/Install/Model/Installer/Db/Abstract.php b/app/code/core/Mage/Install/Model/Installer/Db/Abstract.php index 40155d07e4a..33b6de0c2ea 100644 --- a/app/code/core/Mage/Install/Model/Installer/Db/Abstract.php +++ b/app/code/core/Mage/Install/Model/Installer/Db/Abstract.php @@ -136,7 +136,7 @@ public function getRequiredExtensions() { $extensions = []; $configExt = (array)Mage::getConfig()->getNode(sprintf('install/databases/%s/extensions', $this->getModel())); - foreach ($configExt as $name => $value) { + foreach (array_keys($configExt) as $name) { $extensions[] = $name; } return $extensions; diff --git a/app/code/core/Mage/Page/Block/Template/Links.php b/app/code/core/Mage/Page/Block/Template/Links.php index b52e2f367eb..aacfd69b27e 100644 --- a/app/code/core/Mage/Page/Block/Template/Links.php +++ b/app/code/core/Mage/Page/Block/Template/Links.php @@ -242,7 +242,7 @@ protected function _getNewPosition($position = 0) } } else { $position = 0; - foreach ($this->_links as $k => $v) { + foreach (array_keys($this->_links) as $k) { $position = $k; } $position += 10; diff --git a/app/code/core/Mage/Paygate/Model/Authorizenet.php b/app/code/core/Mage/Paygate/Model/Authorizenet.php index 5659e2caac3..c32a8b69385 100644 --- a/app/code/core/Mage/Paygate/Model/Authorizenet.php +++ b/app/code/core/Mage/Paygate/Model/Authorizenet.php @@ -1475,7 +1475,7 @@ protected function _addTransaction( $payment->setTransactionAdditionalInfo($key, $value); } $transaction = $payment->addTransaction($transactionType, null, false, $message); - foreach ($transactionDetails as $key => $value) { + foreach (array_keys($transactionDetails) as $key) { $payment->unsetData($key); } $payment->unsLastTransId(); diff --git a/app/code/core/Mage/Payment/Block/Form/Cc.php b/app/code/core/Mage/Payment/Block/Form/Cc.php index 5435e7f4a75..08a12b4c037 100644 --- a/app/code/core/Mage/Payment/Block/Form/Cc.php +++ b/app/code/core/Mage/Payment/Block/Form/Cc.php @@ -47,7 +47,7 @@ public function getCcAvailableTypes() $availableTypes = $method->getConfigData('cctypes'); if ($availableTypes) { $availableTypes = explode(',', $availableTypes); - foreach ($types as $code => $name) { + foreach (array_keys($types) as $code) { if (!in_array($code, $availableTypes)) { unset($types[$code]); } diff --git a/app/code/core/Mage/Payment/Helper/Data.php b/app/code/core/Mage/Payment/Helper/Data.php index a7f9071c590..fed881ddeae 100644 --- a/app/code/core/Mage/Payment/Helper/Data.php +++ b/app/code/core/Mage/Payment/Helper/Data.php @@ -67,7 +67,7 @@ public function getMethodInstance($code) public function getStoreMethods($store = null, $quote = null) { $res = []; - foreach ($this->getPaymentMethods($store) as $code => $methodConfig) { + foreach (array_keys($this->getPaymentMethods($store)) as $code) { $prefix = self::XML_PATH_PAYMENT_METHODS . '/' . $code . '/'; if (!$model = Mage::getStoreConfig($prefix . 'model', $store)) { continue; @@ -166,7 +166,7 @@ public function getBillingAgreementMethods($store = null, $quote = null) public function getRecurringProfileMethods($store = null) { $result = []; - foreach ($this->getPaymentMethods($store) as $code => $data) { + foreach (array_keys($this->getPaymentMethods($store)) as $code) { $paymentMethodModelClassName = $this->getMethodModelClassName($code); if (!$paymentMethodModelClassName) { continue; @@ -244,7 +244,7 @@ public function getPaymentMethodList($sorted = true, $asLabelValue = false, $wit } if ($asLabelValue) { $labelValues = []; - foreach ($methods as $code => $title) { + foreach (array_keys($methods) as $code) { $labelValues[$code] = []; } foreach ($methods as $code => $title) { diff --git a/app/code/core/Mage/Paypal/Model/Resource/Report/Settlement.php b/app/code/core/Mage/Paypal/Model/Resource/Report/Settlement.php index ec75245e7e2..fca1a3d661e 100644 --- a/app/code/core/Mage/Paypal/Model/Resource/Report/Settlement.php +++ b/app/code/core/Mage/Paypal/Model/Resource/Report/Settlement.php @@ -58,7 +58,7 @@ protected function _afterSave(Mage_Core_Model_Abstract $object) /** @var Mage_Core_Model_Date $date */ $date = Mage::getSingleton('core/date'); - foreach ($rows as $key => $row) { + foreach (array_keys($rows) as $key) { /* * Converting dates */ diff --git a/app/code/core/Mage/Reports/Model/Totals.php b/app/code/core/Mage/Reports/Model/Totals.php index 33f899cc705..6b98422fdee 100644 --- a/app/code/core/Mage/Reports/Model/Totals.php +++ b/app/code/core/Mage/Reports/Model/Totals.php @@ -47,7 +47,7 @@ public function countTotals($grid, $from, $to) } $data = $item->getData(); - foreach ($columns as $field => $a) { + foreach (array_keys($columns) as $field) { if ($field !== '') { $columns[$field]['value'] += $data[$field] ?? 0; } diff --git a/app/code/core/Mage/Rule/Model/Action/Abstract.php b/app/code/core/Mage/Rule/Model/Action/Abstract.php index a810922d2f7..d8cb87fb7f4 100644 --- a/app/code/core/Mage/Rule/Model/Action/Abstract.php +++ b/app/code/core/Mage/Rule/Model/Action/Abstract.php @@ -52,11 +52,11 @@ public function __construct() parent::__construct(); $this->loadAttributeOptions()->loadOperatorOptions()->loadValueOptions(); - foreach ($this->getAttributeOption() as $attr => $dummy) { + foreach (array_keys($this->getAttributeOption()) as $attr) { $this->setAttribute($attr); break; } - foreach ($this->getOperatorOption() as $operator => $dummy) { + foreach (array_keys($this->getOperatorOption()) as $operator) { $this->setOperator($operator); break; } diff --git a/app/code/core/Mage/Rule/Model/Condition/Abstract.php b/app/code/core/Mage/Rule/Model/Condition/Abstract.php index d2e67c86270..e31fbdda29c 100644 --- a/app/code/core/Mage/Rule/Model/Condition/Abstract.php +++ b/app/code/core/Mage/Rule/Model/Condition/Abstract.php @@ -92,13 +92,13 @@ public function __construct() $this->loadAttributeOptions()->loadOperatorOptions()->loadValueOptions(); if ($options = $this->getAttributeOptions()) { - foreach ($options as $attr => $dummy) { + foreach (array_keys($options) as $attr) { $this->setAttribute($attr); break; } } if ($options = $this->getOperatorOptions()) { - foreach ($options as $operator => $dummy) { + foreach (array_keys($options) as $operator) { $this->setOperator($operator); break; } @@ -503,7 +503,7 @@ public function getTypeElementHtml() public function getAttributeElement() { if (is_null($this->getAttribute())) { - foreach ($this->getAttributeOption() as $k => $v) { + foreach (array_keys($this->getAttributeOption()) as $k) { $this->setAttribute($k); break; } diff --git a/app/code/core/Mage/Rule/Model/Condition/Combine.php b/app/code/core/Mage/Rule/Model/Condition/Combine.php index 79d4e693c38..1d9b0093d13 100644 --- a/app/code/core/Mage/Rule/Model/Condition/Combine.php +++ b/app/code/core/Mage/Rule/Model/Condition/Combine.php @@ -95,7 +95,7 @@ public function __construct() $this->loadAggregatorOptions(); if ($options = $this->getAggregatorOptions()) { - foreach ($options as $aggregator => $dummy) { + foreach (array_keys($options) as $aggregator) { $this->setAggregator($aggregator); break; } diff --git a/app/code/core/Mage/Sales/Block/Adminhtml/Customer/Edit/Tab/Agreement.php b/app/code/core/Mage/Sales/Block/Adminhtml/Customer/Edit/Tab/Agreement.php index 52bf6a9b347..713bee21bab 100644 --- a/app/code/core/Mage/Sales/Block/Adminhtml/Customer/Edit/Tab/Agreement.php +++ b/app/code/core/Mage/Sales/Block/Adminhtml/Customer/Edit/Tab/Agreement.php @@ -125,7 +125,7 @@ protected function _prepareColumns() { $result = parent::_prepareColumns(); - foreach ($this->_columns as $key => $value) { + foreach (array_keys($this->_columns) as $key) { if (in_array($key, $this->_columnsToRemove)) { unset($this->_columns[$key]); } diff --git a/app/code/core/Mage/Sales/Model/Resource/Report/Order/Createdat.php b/app/code/core/Mage/Sales/Model/Resource/Report/Order/Createdat.php index 323ce47e00f..a9971351972 100644 --- a/app/code/core/Mage/Sales/Model/Resource/Report/Order/Createdat.php +++ b/app/code/core/Mage/Sales/Model/Resource/Report/Order/Createdat.php @@ -230,7 +230,7 @@ protected function _aggregateByField($aggregationField, $from, $to) $adapter->query($select->insertFromSelect($this->getMainTable(), array_keys($columns))); // setup all columns to select SUM() except period, store_id and order_status - foreach ($columns as $k => $v) { + foreach (array_keys($columns) as $k) { $columns[$k] = new Zend_Db_Expr('SUM(' . $k . ')'); } $columns['period'] = 'period'; diff --git a/app/code/core/Mage/Sales/Model/Resource/Sale/Collection.php b/app/code/core/Mage/Sales/Model/Resource/Sale/Collection.php index 1bf6ed99bf1..f2972e84cc9 100644 --- a/app/code/core/Mage/Sales/Model/Resource/Sale/Collection.php +++ b/app/code/core/Mage/Sales/Model/Resource/Sale/Collection.php @@ -182,7 +182,7 @@ public function load($printQuery = false, $logQuery = false) ->setWebsiteId(Mage::app()->getStore($storeId)->getWebsiteId()) ->setAvgNormalized($v['avgsale'] * $v['num_orders']); $this->_items[$storeId] = $storeObject; - foreach ($this->_totals as $key => $value) { + foreach (array_keys($this->_totals) as $key) { $this->_totals[$key] += $storeObject->getData($key); } } diff --git a/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.8.13-0.8.14.php b/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.8.13-0.8.14.php index 43d089aa854..9525a968c57 100644 --- a/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.8.13-0.8.14.php +++ b/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.8.13-0.8.14.php @@ -183,7 +183,7 @@ $select->from(['e' => $this->getTable('sales_order_entity')]); $attributeIds = []; -foreach ($attributes as $code => $params) { +foreach (array_keys($attributes) as $code) { $attributes[$code] = $installer->getAttribute($orderEntityTypeId, $code); if ($attributes[$code]['backend_type'] != 'static') { $select->joinLeft( diff --git a/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.50-0.9.51.php b/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.50-0.9.51.php index 3e9e34ea693..69722481f54 100644 --- a/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.50-0.9.51.php +++ b/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.50-0.9.51.php @@ -46,7 +46,7 @@ "); /* get order_payment attribute codes*/ -foreach ($attributesIds as $attributeCode => $attributeId) { +foreach (array_keys($attributesIds) as $attributeCode) { $attributesIds[$attributeCode] = $connection->fetchOne(" SELECT attribute_id FROM {$this->getTable('eav_attribute')} diff --git a/app/code/core/Mage/Shipping/Model/Rate/Result.php b/app/code/core/Mage/Shipping/Model/Rate/Result.php index fa06daacb29..bc7ad148a12 100644 --- a/app/code/core/Mage/Shipping/Model/Rate/Result.php +++ b/app/code/core/Mage/Shipping/Model/Rate/Result.php @@ -180,7 +180,7 @@ public function sortRatesByPrice() natsort($tmp); - foreach ($tmp as $i => $price) { + foreach (array_keys($tmp) as $i) { $result[] = $this->_rates[$i]; } diff --git a/app/code/core/Mage/Tag/Helper/Data.php b/app/code/core/Mage/Tag/Helper/Data.php index c86d4d5eee1..a2de68080cc 100644 --- a/app/code/core/Mage/Tag/Helper/Data.php +++ b/app/code/core/Mage/Tag/Helper/Data.php @@ -73,7 +73,7 @@ public function extractTags($tagNamesInString) */ public function cleanTags(array $tagNamesArr) { - foreach ($tagNamesArr as $key => $tagName) { + foreach (array_keys($tagNamesArr) as $key) { $tagNamesArr[$key] = trim($tagNamesArr[$key], '\''); $tagNamesArr[$key] = trim($tagNamesArr[$key]); if ($tagNamesArr[$key] == '') { diff --git a/app/code/core/Mage/Tag/controllers/IndexController.php b/app/code/core/Mage/Tag/controllers/IndexController.php index 54b26c441f7..833837c75b6 100644 --- a/app/code/core/Mage/Tag/controllers/IndexController.php +++ b/app/code/core/Mage/Tag/controllers/IndexController.php @@ -99,7 +99,7 @@ protected function _extractTags($tagNamesInString) */ protected function _cleanTags(array $tagNamesArr) { - foreach ($tagNamesArr as $key => $tagName) { + foreach (array_keys($tagNamesArr) as $key) { $tagNamesArr[$key] = trim($tagNamesArr[$key], '\''); $tagNamesArr[$key] = trim($tagNamesArr[$key]); if ($tagNamesArr[$key] == '') { diff --git a/app/code/core/Mage/Weee/Model/Attribute/Backend/Weee/Tax.php b/app/code/core/Mage/Weee/Model/Attribute/Backend/Weee/Tax.php index ed49099010c..f6ed065e028 100644 --- a/app/code/core/Mage/Weee/Model/Attribute/Backend/Weee/Tax.php +++ b/app/code/core/Mage/Weee/Model/Attribute/Backend/Weee/Tax.php @@ -74,7 +74,7 @@ public function afterLoad($object) { $data = $this->_getResource()->loadProductData($object, $this->getAttribute()); - foreach ($data as $i => $row) { + foreach (array_keys($data) as $i) { if ($data[$i]['website_id'] == 0) { $rate = Mage::app()->getStore()->getBaseCurrency()->getRate(Mage::app()->getBaseCurrencyCode()); if ($rate) { diff --git a/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Catalog/Product/Attribute/Edit/AttributeForm.php b/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Catalog/Product/Attribute/Edit/AttributeForm.php index 9683e4322cd..1344cfc1a92 100644 --- a/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Catalog/Product/Attribute/Edit/AttributeForm.php +++ b/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Catalog/Product/Attribute/Edit/AttributeForm.php @@ -45,7 +45,7 @@ public function getData(FixtureInterface $fixture = null, Element $element = nul { $data = []; if ($fixture === null) { - foreach ($this->tabs as $tabName => $tab) { + foreach (array_keys($this->tabs) as $tabName) { $this->openTab($tabName); $tabData = $this->getTabElement($tabName)->getDataFormTab(); $data = array_merge($data, $tabData); diff --git a/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Catalog/Product/Edit/Tab/Prices.php b/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Catalog/Product/Edit/Tab/Prices.php index 3346dcc17a8..657f84a8239 100644 --- a/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Catalog/Product/Edit/Tab/Prices.php +++ b/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Catalog/Product/Edit/Tab/Prices.php @@ -54,7 +54,7 @@ class Prices extends Tab public function fillFormTab(array $fields, Element $element = null) { $context = $element ? $element : $this->_rootElement; - foreach ($this->childrenForm as $key => $value) { + foreach (array_keys($this->childrenForm) as $key) { if (isset($fields[$key])) { $this->fillOptionsPrices([$key => $fields[$key]], $context); unset($fields[$key]); @@ -91,7 +91,7 @@ public function getDataFormTab($fields = null, Element $element = null) { $result = []; $context = $element ? $element : $this->_rootElement; - foreach ($this->childrenForm as $key => $value) { + foreach (array_keys($this->childrenForm) as $key) { if (isset($fields[$key])) { $result[$key] = $this->getOptionsPrices([$key => $fields[$key]], $context); unset($fields[$key]); diff --git a/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Catalog/Product/ProductForm.php b/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Catalog/Product/ProductForm.php index 584a8f25fbc..565b823b7c5 100644 --- a/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Catalog/Product/ProductForm.php +++ b/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Catalog/Product/ProductForm.php @@ -341,7 +341,7 @@ public function getRequireNoticeAttributes(FixtureInterface $product) { $data = []; $tabs = $this->getFieldsByTabs($product); - foreach ($tabs as $tabName => $fields) { + foreach (array_keys($tabs) as $tabName) { $tab = $this->getTabElement($tabName); $this->openTab($tabName); $errors = $tab->getRequireNoticeMessages(); diff --git a/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Widget/FormTabs.php b/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Widget/FormTabs.php index 8d9596cda76..a0c24f0c42d 100644 --- a/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Widget/FormTabs.php +++ b/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Widget/FormTabs.php @@ -135,7 +135,7 @@ protected function fillTabs(array $tabs, Element $element = null) */ protected function fillMissedFields() { - foreach ($this->tabs as $tabName => $tabData) { + foreach (array_keys($this->tabs) as $tabName) { $tabElement = $this->getTabElement($tabName); if ($this->openTab($tabName)) { $mapping = $tabElement->dataMapping($this->unassignedFields); @@ -174,7 +174,7 @@ public function getData(FixtureInterface $fixture = null, Element $element = nul $data = []; if (null === $fixture) { - foreach ($this->tabs as $tabName => $tab) { + foreach (array_keys($this->tabs) as $tabName) { $this->openTab($tabName); $tabData = $this->getTabElement($tabName)->getDataFormTab(); $data = array_merge($data, $tabData); diff --git a/dev/tests/functional/tests/app/Mage/Bundle/Test/Handler/Curl.php b/dev/tests/functional/tests/app/Mage/Bundle/Test/Handler/Curl.php index e4777d9f973..eb79bfc90ef 100644 --- a/dev/tests/functional/tests/app/Mage/Bundle/Test/Handler/Curl.php +++ b/dev/tests/functional/tests/app/Mage/Bundle/Test/Handler/Curl.php @@ -146,7 +146,7 @@ protected function prepareBundleSelections(array $bundleData) */ protected function prepareItemSelectionData(array $selections, array $products) { - foreach ($selections as $key => $selection) { + foreach (array_keys($selections) as $key) { $selections[$key]['product_id'] = $products[$key]->getId(); unset($selections[$key]['sku']); $selections[$key]['delete'] = ''; @@ -163,7 +163,7 @@ protected function prepareItemSelectionData(array $selections, array $products) */ protected function prepareBundleOptions(array $bundleData) { - foreach ($bundleData as $key => $option) { + foreach (array_keys($bundleData) as $key) { $bundleData[$key] = array_intersect_key($bundleData[$key], array_flip($this->optionsFields)); $bundleData[$key]['delete'] = ''; } diff --git a/dev/tests/functional/tests/app/Mage/Catalog/Test/TestStep/UpdateConfigurableProductStep/DeleteOptionsSubStep.php b/dev/tests/functional/tests/app/Mage/Catalog/Test/TestStep/UpdateConfigurableProductStep/DeleteOptionsSubStep.php index 6b18d2b8ea3..16d05ab359c 100644 --- a/dev/tests/functional/tests/app/Mage/Catalog/Test/TestStep/UpdateConfigurableProductStep/DeleteOptionsSubStep.php +++ b/dev/tests/functional/tests/app/Mage/Catalog/Test/TestStep/UpdateConfigurableProductStep/DeleteOptionsSubStep.php @@ -86,7 +86,7 @@ protected function searchKeysForOption($optionIndex) { $keys = []; $originalProductAssignedProducts = $this->getOriginalProductAssignedProducts(); - foreach ($originalProductAssignedProducts as $key => $product) { + foreach (array_keys($originalProductAssignedProducts) as $key) { if (strpos($key, 'option_key_' . $optionIndex) !== false) { $keys[] = $key; } diff --git a/dev/tests/functional/tests/app/Mage/Customer/Test/Handler/Customer/Curl.php b/dev/tests/functional/tests/app/Mage/Customer/Test/Handler/Customer/Curl.php index 68f2f85b69a..23d27ff801b 100644 --- a/dev/tests/functional/tests/app/Mage/Customer/Test/Handler/Customer/Curl.php +++ b/dev/tests/functional/tests/app/Mage/Customer/Test/Handler/Customer/Curl.php @@ -131,7 +131,7 @@ public function persist(FixtureInterface $customer = null) */ protected function checkForUpdateData(array $data) { - foreach ($data as $key => $field) { + foreach (array_keys($data) as $key) { if (in_array($key, $this->updatingFields)) { return true; } diff --git a/dev/tests/functional/tests/app/Mage/Weee/Test/Constraint/AssertFptApplied.php b/dev/tests/functional/tests/app/Mage/Weee/Test/Constraint/AssertFptApplied.php index c1b61df6d23..baf99e0e016 100644 --- a/dev/tests/functional/tests/app/Mage/Weee/Test/Constraint/AssertFptApplied.php +++ b/dev/tests/functional/tests/app/Mage/Weee/Test/Constraint/AssertFptApplied.php @@ -145,7 +145,7 @@ protected function clearShoppingCart() protected function getPrices() { $actualPrices = []; - foreach ($this->expectedPrices as $priceType => $prices) { + foreach (array_keys($this->expectedPrices) as $priceType) { $actualPrices[$priceType] = $this->{'get' . ucfirst($priceType) . 'Price'}(); } diff --git a/lib/Varien/Convert/Parser/Csv.php b/lib/Varien/Convert/Parser/Csv.php index f857c3b85a8..4550d155691 100644 --- a/lib/Varien/Convert/Parser/Csv.php +++ b/lib/Varien/Convert/Parser/Csv.php @@ -44,7 +44,7 @@ public function parse() $fields = $line; continue; } else { - foreach ($line as $j => $f) { + foreach (array_keys($line) as $j) { $fields[$j] = 'column' . ($j + 1); } } @@ -87,7 +87,7 @@ public function parseTest() $fields = $line; continue; } else { - foreach ($line as $j => $f) { + foreach (array_keys($line) as $j) { $fields[$j] = 'column' . ($j + 1); } } diff --git a/lib/Varien/Db/Statement/Pdo/Mysql.php b/lib/Varien/Db/Statement/Pdo/Mysql.php index b23cb8435fa..d5f83882237 100644 --- a/lib/Varien/Db/Statement/Pdo/Mysql.php +++ b/lib/Varien/Db/Statement/Pdo/Mysql.php @@ -33,7 +33,7 @@ public function _executeWithBinding(array $params) { // Check whether we deal with named bind $isPositionalBind = true; - foreach ($params as $k => $v) { + foreach (array_keys($params) as $k) { if (!is_int($k)) { $isPositionalBind = false; break; diff --git a/lib/Varien/Http/Adapter/Curl.php b/lib/Varien/Http/Adapter/Curl.php index 56e9359a23f..1e9fd81f16b 100644 --- a/lib/Varien/Http/Adapter/Curl.php +++ b/lib/Varien/Http/Adapter/Curl.php @@ -75,7 +75,7 @@ protected function _applyConfig() $verifyHost = isset($this->_config['verifyhost']) ? $this->_config['verifyhost'] : 0; curl_setopt($this->_getResource(), CURLOPT_SSL_VERIFYHOST, $verifyHost); - foreach ($this->_config as $param => $curlOption) { + foreach (array_keys($this->_config) as $param) { if (array_key_exists($param, $this->_allowedParams)) { curl_setopt($this->_getResource(), $this->_allowedParams[$param], $this->_config[$param]); } diff --git a/lib/Varien/Object.php b/lib/Varien/Object.php index bfd0f11bcff..968d5b0fc02 100644 --- a/lib/Varien/Object.php +++ b/lib/Varien/Object.php @@ -292,7 +292,7 @@ public function unsetData($key = null) public function unsetOldData($key = null) { if (is_null($key)) { - foreach ($this->_oldFieldsMap as $key => $newFieldName) { + foreach (array_keys($this->_oldFieldsMap) as $key) { unset($this->_data[$key]); } } else { diff --git a/lib/Varien/Object/Cache.php b/lib/Varien/Object/Cache.php index 11b6cc23775..24047b87356 100644 --- a/lib/Varien/Object/Cache.php +++ b/lib/Varien/Object/Cache.php @@ -241,7 +241,7 @@ public function delete($idx) } if (isset($this->_objectReferences[$idx])) { - foreach ($this->_references as $r => $dummy) { + foreach (array_keys($this->_references) as $r) { unset($this->_references[$r]); } unset($this->_objectReferences[$idx]); diff --git a/phpstan.dist.baseline.neon b/phpstan.dist.baseline.neon index 8fd0d3944fa..21489364a42 100644 --- a/phpstan.dist.baseline.neon +++ b/phpstan.dist.baseline.neon @@ -3400,11 +3400,6 @@ parameters: count: 1 path: app/code/core/Mage/ImportExport/Model/Export/Entity/Product.php - - - message: "#^Offset int\\|string on non\\-empty\\-array\\ in isset\\(\\) always exists and is not nullable\\.$#" - count: 2 - path: app/code/core/Mage/ImportExport/Model/Export/Entity/Product.php - - message: "#^Variable \\$collection might not be defined\\.$#" count: 1 From 0340c9f17cdb9d8a9da6f4245198d5c49a289c55 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 21 Aug 2024 03:42:21 +0200 Subject: [PATCH 2/3] Updated phpstan to 1.11.11 --- composer.lock | 10 +++++----- phpstan.dist.baseline.neon | 5 ----- phpstan.dist.neon | 3 --- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/composer.lock b/composer.lock index 8fdf520b2b4..2e0dc2c7fcb 100644 --- a/composer.lock +++ b/composer.lock @@ -3486,16 +3486,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.11.7", + "version": "1.11.11", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "52d2bbfdcae7f895915629e4694e9497d0f8e28d" + "reference": "707c2aed5d8d0075666e673a5e71440c1d01a5a3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/52d2bbfdcae7f895915629e4694e9497d0f8e28d", - "reference": "52d2bbfdcae7f895915629e4694e9497d0f8e28d", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/707c2aed5d8d0075666e673a5e71440c1d01a5a3", + "reference": "707c2aed5d8d0075666e673a5e71440c1d01a5a3", "shasum": "" }, "require": { @@ -3540,7 +3540,7 @@ "type": "github" } ], - "time": "2024-07-06T11:17:41+00:00" + "time": "2024-08-19T14:37:29+00:00" }, { "name": "phpunit/php-code-coverage", diff --git a/phpstan.dist.baseline.neon b/phpstan.dist.baseline.neon index 52c437a2709..40723ea0e61 100644 --- a/phpstan.dist.baseline.neon +++ b/phpstan.dist.baseline.neon @@ -3560,11 +3560,6 @@ parameters: count: 1 path: app/code/core/Mage/Payment/Model/Method/Abstract.php - - - message: "#^Loose comparison using \\!\\= between ''\\|'OT' and 'SS' will always evaluate to true\\.$#" - count: 1 - path: app/code/core/Mage/Payment/Model/Method/Cc.php - - message: "#^Method Mage_Payment_Model_Recurring_Profile\\:\\:exportStartDatetime\\(\\) should return string\\|Zend_Date but empty return statement found\\.$#" count: 1 diff --git a/phpstan.dist.neon b/phpstan.dist.neon index d82c837f678..30cc67196a7 100644 --- a/phpstan.dist.neon +++ b/phpstan.dist.neon @@ -50,9 +50,6 @@ parameters: - app/code/core/Mage/Paypal/Model/Report/Settlement.php - lib/Varien/Io/Sftp.php - # Class backup/db was not found while trying to analyse it - - app/code/core/Mage/Adminhtml/controllers/System/BackupController.php - # Dataflow/Model/Convert/Iterator.php - app/code/core/Mage/Dataflow/Model/Convert/Iterator.php From 76e773b306511d7946837f8a9f54416460d6a862 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 21 Aug 2024 03:42:36 +0200 Subject: [PATCH 3/3] Revert "Rector: CQ - UnusedForeachValueToArrayKeysRector (#1)" This reverts commit 3d7eaf63f2211a9e1a8defe8c29e8f6da889ab2e. --- app/code/core/Mage/Adminhtml/Block/Dashboard/Graph.php | 4 ++-- app/code/core/Mage/Adminhtml/Block/Page/Menu.php | 2 +- app/code/core/Mage/Adminhtml/Block/Report/Grid.php | 2 +- .../Adminhtml/Block/Sales/Transactions/Child/Grid.php | 2 +- app/code/core/Mage/Adminhtml/Block/Store/Switcher.php | 4 ++-- app/code/core/Mage/Adminhtml/Block/Urlrewrite/Edit.php | 2 +- .../core/Mage/Adminhtml/Block/Urlrewrite/Edit/Form.php | 2 +- app/code/core/Mage/Adminhtml/Block/Widget/Grid.php | 2 +- .../Block/Widget/Grid/Column/Renderer/Action.php | 2 +- app/code/core/Mage/Adminhtml/Block/Widget/Tabs.php | 2 +- .../Adminhtml/Model/System/Config/Source/Admin/Page.php | 2 +- app/code/core/Mage/Api2/Model/Acl/Filter.php | 2 +- .../Model/Acl/Filter/Attribute/ResourcePermission.php | 2 +- app/code/core/Mage/Catalog/Model/Api2/Product.php | 2 +- app/code/core/Mage/Catalog/Model/Category.php | 2 +- app/code/core/Mage/Catalog/Model/Product/Type/Price.php | 2 +- .../core/Mage/Catalog/Model/Resource/Category/Flat.php | 2 +- app/code/core/Mage/Checkout/Model/Type/Onepage.php | 2 +- .../Mage/ConfigurableSwatches/Helper/Mediafallback.php | 2 +- app/code/core/Mage/Core/Helper/Data.php | 2 +- app/code/core/Mage/Core/Model/Cache.php | 2 +- app/code/core/Mage/Core/Model/Layout/Validator.php | 2 +- app/code/core/Mage/Core/Model/Locale.php | 2 +- app/code/core/Mage/Core/Model/Log/Adapter.php | 2 +- app/code/core/Mage/Core/Model/Url/Rewrite.php | 2 +- app/code/core/Mage/Core/Model/Url/Rewrite/Request.php | 2 +- app/code/core/Mage/Customer/Model/Address/Api.php | 8 ++++---- app/code/core/Mage/Customer/Model/Address/Api/V2.php | 6 +++--- app/code/core/Mage/Customer/Model/Customer/Api.php | 6 +++--- app/code/core/Mage/Dataflow/Model/Batch.php | 4 ++-- app/code/core/Mage/Dataflow/Model/Session/Parser/Csv.php | 2 +- app/code/core/Mage/Eav/Model/Entity/Abstract.php | 2 +- .../Mage/ImportExport/Model/Export/Entity/Product.php | 6 +++--- .../Mage/ImportExport/Model/Import/Entity/Customer.php | 2 +- .../Mage/ImportExport/Model/Import/Entity/Product.php | 2 +- app/code/core/Mage/Index/Model/Event.php | 2 +- app/code/core/Mage/Install/Block/Db/Main.php | 2 +- app/code/core/Mage/Install/Model/Installer/Console.php | 2 +- .../core/Mage/Install/Model/Installer/Db/Abstract.php | 2 +- app/code/core/Mage/Page/Block/Template/Links.php | 2 +- app/code/core/Mage/Paygate/Model/Authorizenet.php | 2 +- app/code/core/Mage/Payment/Block/Form/Cc.php | 2 +- app/code/core/Mage/Payment/Helper/Data.php | 6 +++--- .../core/Mage/Paypal/Model/Resource/Report/Settlement.php | 2 +- app/code/core/Mage/Reports/Model/Totals.php | 2 +- app/code/core/Mage/Rule/Model/Action/Abstract.php | 4 ++-- app/code/core/Mage/Rule/Model/Condition/Abstract.php | 6 +++--- app/code/core/Mage/Rule/Model/Condition/Combine.php | 2 +- .../Sales/Block/Adminhtml/Customer/Edit/Tab/Agreement.php | 2 +- .../Mage/Sales/Model/Resource/Report/Order/Createdat.php | 2 +- .../core/Mage/Sales/Model/Resource/Sale/Collection.php | 2 +- .../sql/sales_setup/mysql4-upgrade-0.8.13-0.8.14.php | 2 +- .../sql/sales_setup/mysql4-upgrade-0.9.50-0.9.51.php | 2 +- app/code/core/Mage/Shipping/Model/Rate/Result.php | 2 +- app/code/core/Mage/Tag/Helper/Data.php | 2 +- app/code/core/Mage/Tag/controllers/IndexController.php | 2 +- .../core/Mage/Weee/Model/Attribute/Backend/Weee/Tax.php | 2 +- .../Catalog/Product/Attribute/Edit/AttributeForm.php | 2 +- .../Test/Block/Catalog/Product/Edit/Tab/Prices.php | 4 ++-- .../Adminhtml/Test/Block/Catalog/Product/ProductForm.php | 2 +- .../app/Mage/Adminhtml/Test/Block/Widget/FormTabs.php | 4 ++-- .../tests/app/Mage/Bundle/Test/Handler/Curl.php | 4 ++-- .../DeleteOptionsSubStep.php | 2 +- .../app/Mage/Customer/Test/Handler/Customer/Curl.php | 2 +- .../app/Mage/Weee/Test/Constraint/AssertFptApplied.php | 2 +- lib/Varien/Convert/Parser/Csv.php | 4 ++-- lib/Varien/Db/Statement/Pdo/Mysql.php | 2 +- lib/Varien/Http/Adapter/Curl.php | 2 +- lib/Varien/Object.php | 2 +- lib/Varien/Object/Cache.php | 2 +- phpstan.dist.baseline.neon | 5 +++++ 71 files changed, 96 insertions(+), 91 deletions(-) diff --git a/app/code/core/Mage/Adminhtml/Block/Dashboard/Graph.php b/app/code/core/Mage/Adminhtml/Block/Dashboard/Graph.php index afc5f13938c..700d3b3b17d 100644 --- a/app/code/core/Mage/Adminhtml/Block/Dashboard/Graph.php +++ b/app/code/core/Mage/Adminhtml/Block/Dashboard/Graph.php @@ -215,7 +215,7 @@ public function getChartUrl($directUrl = true) $dateStart->addMonth(1); break; } - foreach (array_keys($this->getAllSeries()) as $index) { + foreach ($this->getAllSeries() as $index => $serie) { if (in_array($d, $this->_axisLabels['x'])) { $datas[$index][] = (float)array_shift($this->_allSeries[$index]); } else { @@ -328,7 +328,7 @@ public function getChartUrl($directUrl = true) if (count($this->_axisLabels)) { $params['chxt'] = implode(',', array_keys($this->_axisLabels)); $indexid = 0; - foreach (array_keys($this->_axisLabels) as $idx) { + foreach ($this->_axisLabels as $idx => $labels) { if ($idx === 'x') { /** * Format date diff --git a/app/code/core/Mage/Adminhtml/Block/Page/Menu.php b/app/code/core/Mage/Adminhtml/Block/Page/Menu.php index 20bb44f96f4..d4872f9158d 100644 --- a/app/code/core/Mage/Adminhtml/Block/Page/Menu.php +++ b/app/code/core/Mage/Adminhtml/Block/Page/Menu.php @@ -164,7 +164,7 @@ protected function _buildMenuArray(Varien_Simplexml_Element $parent, $path = '', uasort($parentArr, [$this, '_sortMenu']); - foreach (array_keys($parentArr) as $key) { + foreach ($parentArr as $key => $value) { $last = $key; } if (isset($last)) { diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Grid.php b/app/code/core/Mage/Adminhtml/Block/Report/Grid.php index efc441c2365..180a228a288 100644 --- a/app/code/core/Mage/Adminhtml/Block/Report/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Report/Grid.php @@ -207,7 +207,7 @@ protected function _prepareCollection() */ protected function _setFilterValues($data) { - foreach (array_keys($data) as $name) { + foreach ($data as $name => $value) { $this->setFilter($name, $data[$name]); } return $this; diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Transactions/Child/Grid.php b/app/code/core/Mage/Adminhtml/Block/Sales/Transactions/Child/Grid.php index 2a585eb5b7d..1e8e12f3dd4 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Transactions/Child/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Transactions/Child/Grid.php @@ -62,7 +62,7 @@ protected function _prepareColumns() { $result = parent::_prepareColumns(); - foreach (array_keys($this->_columns) as $key) { + foreach ($this->_columns as $key => $value) { if (in_array($key, $this->_columnsToRemove)) { unset($this->_columns[$key]); } else { diff --git a/app/code/core/Mage/Adminhtml/Block/Store/Switcher.php b/app/code/core/Mage/Adminhtml/Block/Store/Switcher.php index 33442aa26b1..d0c60a17406 100644 --- a/app/code/core/Mage/Adminhtml/Block/Store/Switcher.php +++ b/app/code/core/Mage/Adminhtml/Block/Store/Switcher.php @@ -73,7 +73,7 @@ public function getWebsites() { $websites = Mage::app()->getWebsites(); if ($websiteIds = $this->getWebsiteIds()) { - foreach (array_keys($websites) as $websiteId) { + foreach ($websites as $websiteId => $website) { if (!in_array($websiteId, $websiteIds)) { unset($websites[$websiteId]); } @@ -140,7 +140,7 @@ public function getStores($group) } $stores = $group->getStores(); if ($storeIds = $this->getStoreIds()) { - foreach (array_keys($stores) as $storeId) { + foreach ($stores as $storeId => $store) { if (!in_array($storeId, $storeIds)) { unset($stores[$storeId]); } diff --git a/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Edit.php b/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Edit.php index fc959e184ff..9e369a45972 100644 --- a/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Edit.php @@ -194,7 +194,7 @@ public function getButtonsHtml($area = null) { if ($this->_buttonsHtml === null) { $this->_buttonsHtml = parent::getButtonsHtml(); - foreach (array_keys($this->_children) as $alias) { + foreach ($this->_children as $alias => $child) { if (str_contains($alias, '_button')) { $this->unsetChild($alias); } diff --git a/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Edit/Form.php b/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Edit/Form.php index 955c2f871b0..a91f22b905a 100644 --- a/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Edit/Form.php +++ b/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Edit/Form.php @@ -61,7 +61,7 @@ protected function _prepareForm() 'description' => $model->getDescription(), ]; if ($sessionData = Mage::getSingleton('adminhtml/session')->getData('urlrewrite_data', true)) { - foreach (array_keys($formValues) as $key) { + foreach ($formValues as $key => $value) { if (isset($sessionData[$key])) { $formValues[$key] = $sessionData[$key]; } diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php b/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php index 5b701ae5133..af36a237924 100644 --- a/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php @@ -481,7 +481,7 @@ public function getColumns() */ protected function _setFilterValues($data) { - foreach (array_keys($data) as $columnId) { + foreach ($data as $columnId => $value) { $column = $this->getColumn($columnId); if ($column instanceof Mage_Adminhtml_Block_Widget_Grid_Column && (!empty($data[$columnId]) || strlen($data[$columnId]) > 0) diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Action.php b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Action.php index 9bdad27dbbf..1fe5f9905b6 100644 --- a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Action.php +++ b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Action.php @@ -109,7 +109,7 @@ protected function _toLinkHtml($action, Varien_Object $row) */ protected function _transformActionData(&$action, &$actionCaption, Varien_Object $row) { - foreach (array_keys($action) as $attribute) { + foreach ($action as $attribute => $value) { if (isset($action[$attribute]) && !is_array($action[$attribute])) { $this->getColumn()->setFormat($action[$attribute]); $action[$attribute] = parent::render($row); diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Tabs.php b/app/code/core/Mage/Adminhtml/Block/Widget/Tabs.php index ca58c8f7fc6..94e9fae48a6 100644 --- a/app/code/core/Mage/Adminhtml/Block/Widget/Tabs.php +++ b/app/code/core/Mage/Adminhtml/Block/Widget/Tabs.php @@ -256,7 +256,7 @@ protected function _reorderTabs() asort($this->_tabPositions); $ordered = []; - foreach (array_keys($this->_tabPositions) as $tabId) { + foreach ($this->_tabPositions as $tabId => $position) { if (isset($this->_tabs[$tabId])) { $tab = $this->_tabs[$tabId]; $ordered[$tabId] = $tab; diff --git a/app/code/core/Mage/Adminhtml/Model/System/Config/Source/Admin/Page.php b/app/code/core/Mage/Adminhtml/Model/System/Config/Source/Admin/Page.php index 92bfd9d0639..e79b3daedc4 100644 --- a/app/code/core/Mage/Adminhtml/Model/System/Config/Source/Admin/Page.php +++ b/app/code/core/Mage/Adminhtml/Model/System/Config/Source/Admin/Page.php @@ -109,7 +109,7 @@ protected function _buildMenuArray(?Varien_Simplexml_Element $parent = null, $pa uasort($parentArr, [$this, '_sortMenu']); - foreach (array_keys($parentArr) as $key) { + foreach ($parentArr as $key => $value) { $last = $key; } if (isset($last)) { diff --git a/app/code/core/Mage/Api2/Model/Acl/Filter.php b/app/code/core/Mage/Api2/Model/Acl/Filter.php index cefef4dd4f6..3494dfceb14 100644 --- a/app/code/core/Mage/Api2/Model/Acl/Filter.php +++ b/app/code/core/Mage/Api2/Model/Acl/Filter.php @@ -61,7 +61,7 @@ public function __construct(Mage_Api2_Model_Resource $resource) */ protected function _filter(array $allowedAttributes, array $data) { - foreach (array_keys($data) as $attribute) { + foreach ($data as $attribute => $value) { if (!in_array($attribute, $allowedAttributes)) { unset($data[$attribute]); } diff --git a/app/code/core/Mage/Api2/Model/Acl/Filter/Attribute/ResourcePermission.php b/app/code/core/Mage/Api2/Model/Acl/Filter/Attribute/ResourcePermission.php index f58a244ca00..1016b87c227 100644 --- a/app/code/core/Mage/Api2/Model/Acl/Filter/Attribute/ResourcePermission.php +++ b/app/code/core/Mage/Api2/Model/Acl/Filter/Attribute/ResourcePermission.php @@ -103,7 +103,7 @@ public function getResourcesPermissions() $resourceModel->setResourceType($resource) ->setUserType($this->_userType); - foreach (array_keys($operations) as $operation) { + foreach ($operations as $operation => $operationLabel) { if (!$this->_hasEntityOnlyAttributes && $config->getResourceEntityOnlyAttributes($resource, $this->_userType, $operation) ) { diff --git a/app/code/core/Mage/Catalog/Model/Api2/Product.php b/app/code/core/Mage/Catalog/Model/Api2/Product.php index f757413be4b..586f1db4acd 100644 --- a/app/code/core/Mage/Catalog/Model/Api2/Product.php +++ b/app/code/core/Mage/Catalog/Model/Api2/Product.php @@ -42,7 +42,7 @@ public function getAvailableAttributes($userType, $operation) } $excludedAttrs = $this->getExcludedAttributes($userType, $operation); $includedAttrs = $this->getIncludedAttributes($userType, $operation); - foreach (array_keys($attributes) as $code) { + foreach ($attributes as $code => $label) { if (in_array($code, $excludedAttrs) || ($includedAttrs && !in_array($code, $includedAttrs))) { unset($attributes[$code]); } diff --git a/app/code/core/Mage/Catalog/Model/Category.php b/app/code/core/Mage/Catalog/Model/Category.php index 5ff10b609dc..58cd0b2c7c9 100644 --- a/app/code/core/Mage/Catalog/Model/Category.php +++ b/app/code/core/Mage/Catalog/Model/Category.php @@ -346,7 +346,7 @@ public function getAttributes($noDesignAttributes = false) ->getSortedAttributes(); if ($noDesignAttributes) { - foreach (array_keys($result) as $k) { + foreach ($result as $k => $a) { if (in_array($k, $this->_designAttributes)) { unset($result[$k]); } diff --git a/app/code/core/Mage/Catalog/Model/Product/Type/Price.php b/app/code/core/Mage/Catalog/Model/Product/Type/Price.php index df7d7f731c9..62e6d7f86ae 100644 --- a/app/code/core/Mage/Catalog/Model/Product/Type/Price.php +++ b/app/code/core/Mage/Catalog/Model/Product/Type/Price.php @@ -300,7 +300,7 @@ public function getFormatedTierPrice($qty, $product) { $price = $product->getTierPrice($qty); if (is_array($price)) { - foreach (array_keys($price) as $index) { + foreach ($price as $index => $value) { $price[$index]['formated_price'] = Mage::app()->getStore()->convertPrice( $price[$index]['website_price'], true diff --git a/app/code/core/Mage/Catalog/Model/Resource/Category/Flat.php b/app/code/core/Mage/Catalog/Model/Resource/Category/Flat.php index 7e962fb0b72..3a03e409ef5 100644 --- a/app/code/core/Mage/Catalog/Model/Resource/Category/Flat.php +++ b/app/code/core/Mage/Catalog/Model/Resource/Category/Flat.php @@ -1152,7 +1152,7 @@ protected function _prepareDataForAllFields($category, $replaceFields = []) $table = $this->_getReadAdapter()->describeTable($table); $data = []; $idFieldName = Mage::getSingleton('catalog/category')->getIdFieldName(); - foreach (array_keys($table) as $column) { + foreach ($table as $column => $columnData) { if ($column != $idFieldName || $category->getData($column) !== null) { if (array_key_exists($column, $replaceFields)) { $value = $category->getData($replaceFields[$column]); diff --git a/app/code/core/Mage/Checkout/Model/Type/Onepage.php b/app/code/core/Mage/Checkout/Model/Type/Onepage.php index 2cdbe2eec65..f1d8d4a5ced 100644 --- a/app/code/core/Mage/Checkout/Model/Type/Onepage.php +++ b/app/code/core/Mage/Checkout/Model/Type/Onepage.php @@ -119,7 +119,7 @@ public function initCheckout() $checkout = $this->getCheckout(); $customerSession = $this->getCustomerSession(); if (is_array($checkout->getStepData())) { - foreach (array_keys($checkout->getStepData()) as $step) { + foreach ($checkout->getStepData() as $step => $data) { if (!($step === 'login' || $customerSession->isLoggedIn() && $step === 'billing')) { $checkout->setStepData($step, 'allow', false); } diff --git a/app/code/core/Mage/ConfigurableSwatches/Helper/Mediafallback.php b/app/code/core/Mage/ConfigurableSwatches/Helper/Mediafallback.php index da23ea014ad..db49ed16933 100644 --- a/app/code/core/Mage/ConfigurableSwatches/Helper/Mediafallback.php +++ b/app/code/core/Mage/ConfigurableSwatches/Helper/Mediafallback.php @@ -136,7 +136,7 @@ public function attachProductChildrenAttributeMapping(array $parentProducts, $st } // end looping child products } // end looping attributes - foreach (array_keys($mapping) as $key) { + foreach ($mapping as $key => $value) { $mapping[$key]['product_ids'] = array_unique($mapping[$key]['product_ids']); } diff --git a/app/code/core/Mage/Core/Helper/Data.php b/app/code/core/Mage/Core/Helper/Data.php index d3c9a73ac45..73029d7952c 100644 --- a/app/code/core/Mage/Core/Helper/Data.php +++ b/app/code/core/Mage/Core/Helper/Data.php @@ -603,7 +603,7 @@ public function assocToXml(array $array, $rootName = '_') <$rootName> XML; $xml = new SimpleXMLElement($xmlstr); - foreach (array_keys($array) as $key) { + foreach ($array as $key => $value) { if (is_numeric($key)) { throw new Exception('Array root keys must not be numeric.'); } diff --git a/app/code/core/Mage/Core/Model/Cache.php b/app/code/core/Mage/Core/Model/Cache.php index 9965019bf1e..fe97c2c491f 100644 --- a/app/code/core/Mage/Core/Model/Cache.php +++ b/app/code/core/Mage/Core/Model/Cache.php @@ -625,7 +625,7 @@ public function getInvalidatedTypes() $types = $this->_getInvalidatedTypes(); if ($types) { $allTypes = $this->getTypes(); - foreach (array_keys($types) as $type) { + foreach ($types as $type => $flag) { if (isset($allTypes[$type]) && $this->canUse($type)) { $invalidatedTypes[$type] = $allTypes[$type]; } diff --git a/app/code/core/Mage/Core/Model/Layout/Validator.php b/app/code/core/Mage/Core/Model/Layout/Validator.php index 2d14731992b..9bedeaf8621 100644 --- a/app/code/core/Mage/Core/Model/Layout/Validator.php +++ b/app/code/core/Mage/Core/Model/Layout/Validator.php @@ -108,7 +108,7 @@ public function getDisallowedBlocks() if (!count($this->_disallowedBlock)) { $disallowedBlockConfig = $this->_getDisallowedBlockConfigValue(); if (is_array($disallowedBlockConfig)) { - foreach (array_keys($disallowedBlockConfig) as $blockName) { + foreach ($disallowedBlockConfig as $blockName => $value) { $this->_disallowedBlock[] = $blockName; } } diff --git a/app/code/core/Mage/Core/Model/Locale.php b/app/code/core/Mage/Core/Model/Locale.php index 2a0c44563c3..d3b70a7c1cd 100644 --- a/app/code/core/Mage/Core/Model/Locale.php +++ b/app/code/core/Mage/Core/Model/Locale.php @@ -247,7 +247,7 @@ protected function _getOptionLocales($translatedName = false) } } - foreach (array_keys($locales) as $code) { + foreach ($locales as $code => $active) { if (strstr($code, '_')) { if (!in_array($code, $allowed)) { continue; diff --git a/app/code/core/Mage/Core/Model/Log/Adapter.php b/app/code/core/Mage/Core/Model/Log/Adapter.php index 1a173c94d99..3bc190114c0 100644 --- a/app/code/core/Mage/Core/Model/Log/Adapter.php +++ b/app/code/core/Mage/Core/Model/Log/Adapter.php @@ -115,7 +115,7 @@ public function setFilterDataKeys($keys) protected function _filterDebugData($debugData) { if (is_array($debugData) && is_array($this->_debugReplacePrivateDataKeys)) { - foreach (array_keys($debugData) as $key) { + foreach ($debugData as $key => $value) { if (in_array($key, $this->_debugReplacePrivateDataKeys)) { $debugData[$key] = '****'; } else { diff --git a/app/code/core/Mage/Core/Model/Url/Rewrite.php b/app/code/core/Mage/Core/Model/Url/Rewrite.php index 929f39be12c..a9bae5f2912 100644 --- a/app/code/core/Mage/Core/Model/Url/Rewrite.php +++ b/app/code/core/Mage/Core/Model/Url/Rewrite.php @@ -319,7 +319,7 @@ protected function _getQueryString() $queryParams = []; parse_str($_SERVER['QUERY_STRING'], $queryParams); $hasChanges = false; - foreach (array_keys($queryParams) as $key) { + foreach ($queryParams as $key => $value) { if (substr($key, 0, 3) === '___') { unset($queryParams[$key]); $hasChanges = true; diff --git a/app/code/core/Mage/Core/Model/Url/Rewrite/Request.php b/app/code/core/Mage/Core/Model/Url/Rewrite/Request.php index f6c14bf4b9a..80bf9ce24de 100644 --- a/app/code/core/Mage/Core/Model/Url/Rewrite/Request.php +++ b/app/code/core/Mage/Core/Model/Url/Rewrite/Request.php @@ -306,7 +306,7 @@ protected function _getQueryString() $queryParams = []; parse_str($_SERVER['QUERY_STRING'], $queryParams); $hasChanges = false; - foreach (array_keys($queryParams) as $key) { + foreach ($queryParams as $key => $value) { if (substr($key, 0, 3) === '___') { unset($queryParams[$key]); $hasChanges = true; diff --git a/app/code/core/Mage/Customer/Model/Address/Api.php b/app/code/core/Mage/Customer/Model/Address/Api.php index 9f779558882..63120a58f38 100644 --- a/app/code/core/Mage/Customer/Model/Address/Api.php +++ b/app/code/core/Mage/Customer/Model/Address/Api.php @@ -55,7 +55,7 @@ public function items($customerId) $row[$attributeAlias] = $data[$attributeCode] ?? null; } - foreach (array_keys($this->getAllowedAttributes($address)) as $attributeCode) { + foreach ($this->getAllowedAttributes($address) as $attributeCode => $attribute) { if (isset($data[$attributeCode])) { $row[$attributeCode] = $data[$attributeCode]; } @@ -89,7 +89,7 @@ public function create($customerId, $addressData) $address = Mage::getModel('customer/address'); - foreach (array_keys($this->getAllowedAttributes($address)) as $attributeCode) { + foreach ($this->getAllowedAttributes($address) as $attributeCode => $attribute) { if (isset($addressData[$attributeCode])) { $address->setData($attributeCode, $addressData[$attributeCode]); } @@ -141,7 +141,7 @@ public function info($addressId) $result[$attributeAlias] = $address->getData($attributeCode); } - foreach (array_keys($this->getAllowedAttributes($address)) as $attributeCode) { + foreach ($this->getAllowedAttributes($address) as $attributeCode => $attribute) { $result[$attributeCode] = $address->getData($attributeCode); } @@ -169,7 +169,7 @@ public function update($addressId, $addressData) $this->_fault('not_exists'); } - foreach (array_keys($this->getAllowedAttributes($address)) as $attributeCode) { + foreach ($this->getAllowedAttributes($address) as $attributeCode => $attribute) { if (isset($addressData[$attributeCode])) { $address->setData($attributeCode, $addressData[$attributeCode]); } diff --git a/app/code/core/Mage/Customer/Model/Address/Api/V2.php b/app/code/core/Mage/Customer/Model/Address/Api/V2.php index 901b932eef7..8616fec57a1 100644 --- a/app/code/core/Mage/Customer/Model/Address/Api/V2.php +++ b/app/code/core/Mage/Customer/Model/Address/Api/V2.php @@ -40,7 +40,7 @@ public function create($customerId, $addressData) $address = Mage::getModel('customer/address'); - foreach (array_keys($this->getAllowedAttributes($address)) as $attributeCode) { + foreach ($this->getAllowedAttributes($address) as $attributeCode => $attribute) { if (isset($addressData->$attributeCode)) { $address->setData($attributeCode, $addressData->$attributeCode); } @@ -92,7 +92,7 @@ public function info($addressId) $result[$attributeAlias] = $address->getData($attributeCode); } - foreach (array_keys($this->getAllowedAttributes($address)) as $attributeCode) { + foreach ($this->getAllowedAttributes($address) as $attributeCode => $attribute) { $result[$attributeCode] = $address->getData($attributeCode); } @@ -120,7 +120,7 @@ public function update($addressId, $addressData) $this->_fault('not_exists'); } - foreach (array_keys($this->getAllowedAttributes($address)) as $attributeCode) { + foreach ($this->getAllowedAttributes($address) as $attributeCode => $attribute) { if (isset($addressData->$attributeCode)) { $address->setData($attributeCode, $addressData->$attributeCode); } diff --git a/app/code/core/Mage/Customer/Model/Customer/Api.php b/app/code/core/Mage/Customer/Model/Customer/Api.php index f8daaa27a89..16853c6c60e 100644 --- a/app/code/core/Mage/Customer/Model/Customer/Api.php +++ b/app/code/core/Mage/Customer/Model/Customer/Api.php @@ -87,7 +87,7 @@ public function info($customerId, $attributes = null) $result[$attributeAlias] = $customer->getData($attributeCode); } - foreach (array_keys($this->getAllowedAttributes($customer, $attributes)) as $attributeCode) { + foreach ($this->getAllowedAttributes($customer, $attributes) as $attributeCode => $attribute) { $result[$attributeCode] = $customer->getData($attributeCode); } @@ -121,7 +121,7 @@ public function items($filters) foreach ($this->_mapAttributes as $attributeAlias => $attributeCode) { $row[$attributeAlias] = $data[$attributeCode] ?? null; } - foreach (array_keys($this->getAllowedAttributes($customer)) as $attributeCode) { + foreach ($this->getAllowedAttributes($customer) as $attributeCode => $attribute) { if (isset($data[$attributeCode])) { $row[$attributeCode] = $data[$attributeCode]; } @@ -149,7 +149,7 @@ public function update($customerId, $customerData) $this->_fault('not_exists'); } - foreach (array_keys($this->getAllowedAttributes($customer)) as $attributeCode) { + foreach ($this->getAllowedAttributes($customer) as $attributeCode => $attribute) { if (isset($customerData[$attributeCode])) { $customer->setData($attributeCode, $customerData[$attributeCode]); } diff --git a/app/code/core/Mage/Dataflow/Model/Batch.php b/app/code/core/Mage/Dataflow/Model/Batch.php index 1235b8f468f..1f727062e73 100644 --- a/app/code/core/Mage/Dataflow/Model/Batch.php +++ b/app/code/core/Mage/Dataflow/Model/Batch.php @@ -92,12 +92,12 @@ public function getFieldList() */ public function parseFieldList($row) { - foreach (array_keys($row) as $fieldName) { + foreach ($row as $fieldName => $value) { if (!in_array($fieldName, $this->_fieldList)) { $this->_fieldList[$fieldName] = $fieldName; } } - unset($fieldName, $row); + unset($fieldName, $value, $row); } /** diff --git a/app/code/core/Mage/Dataflow/Model/Session/Parser/Csv.php b/app/code/core/Mage/Dataflow/Model/Session/Parser/Csv.php index fdf30b8c5f6..1a15c400f15 100644 --- a/app/code/core/Mage/Dataflow/Model/Session/Parser/Csv.php +++ b/app/code/core/Mage/Dataflow/Model/Session/Parser/Csv.php @@ -47,7 +47,7 @@ public function parse() $fields = $line; continue; } else { - foreach (array_keys($line) as $j) { + foreach ($line as $j => $f) { $fields[$j] = 'column' . ($j + 1); } } diff --git a/app/code/core/Mage/Eav/Model/Entity/Abstract.php b/app/code/core/Mage/Eav/Model/Entity/Abstract.php index 01c39e4c918..25c93a56c2e 100644 --- a/app/code/core/Mage/Eav/Model/Entity/Abstract.php +++ b/app/code/core/Mage/Eav/Model/Entity/Abstract.php @@ -1594,7 +1594,7 @@ public function delete($object) ]; $this->_getWriteAdapter()->delete($this->getEntityTable(), $where); $this->loadAllAttributes($object); - foreach (array_keys($this->getAttributesByTable()) as $table) { + foreach ($this->getAttributesByTable() as $table => $attributes) { $this->_getWriteAdapter()->delete($table, $where); } } catch (Exception $e) { diff --git a/app/code/core/Mage/ImportExport/Model/Export/Entity/Product.php b/app/code/core/Mage/ImportExport/Model/Export/Entity/Product.php index 1ecb2e87b92..91b578e810a 100644 --- a/app/code/core/Mage/ImportExport/Model/Export/Entity/Product.php +++ b/app/code/core/Mage/ImportExport/Model/Export/Entity/Product.php @@ -790,7 +790,7 @@ protected function _prepareExport() '_custom_option_row_sku', '_custom_option_row_sort' ]; - foreach (array_keys($this->_storeIdToCode) as &$storeId) { + foreach ($this->_storeIdToCode as $storeId => &$storeCode) { $skip = false; $options = Mage::getResourceModel('catalog/product_option_collection') ->reset() @@ -961,7 +961,7 @@ protected function _prepareExport() $dataRow = array_merge($dataRow, array_shift($configurableData[$productId])); } if (!empty($rowMultiselects[$productId][$storeId])) { - foreach (array_keys($rowMultiselects[$productId][$storeId]) as $attrKey) { + foreach ($rowMultiselects[$productId][$storeId] as $attrKey => $attrVal) { if (isset($rowMultiselects[$productId][$storeId][$attrKey])) { $dataRow[$attrKey] = array_shift($rowMultiselects[$productId][$storeId][$attrKey]); } @@ -1039,7 +1039,7 @@ protected function _prepareExport() $dataRow = array_merge($dataRow, array_shift($configurableData[$productId])); } if (!empty($rowMultiselects[$productId][$storeId])) { - foreach (array_keys($rowMultiselects[$productId][$storeId]) as $attrKey) { + foreach ($rowMultiselects[$productId][$storeId] as $attrKey => $attrVal) { if (isset($rowMultiselects[$productId][$storeId][$attrKey])) { $dataRow[$attrKey] = array_shift($rowMultiselects[$productId][$storeId][$attrKey]); } diff --git a/app/code/core/Mage/ImportExport/Model/Import/Entity/Customer.php b/app/code/core/Mage/ImportExport/Model/Import/Entity/Customer.php index a80445efc8b..3ad37c5afb3 100644 --- a/app/code/core/Mage/ImportExport/Model/Import/Entity/Customer.php +++ b/app/code/core/Mage/ImportExport/Model/Import/Entity/Customer.php @@ -548,7 +548,7 @@ public function getEntityTypeCode() public function getRowScope(array $rowData) { $foundOptions = false; - foreach (array_keys($this->_multiSelectAttributes) as $attrCode) { + foreach ($this->_multiSelectAttributes as $attrCode => $attribute) { if ($rowData[$attrCode]) { $foundOptions = true; } diff --git a/app/code/core/Mage/ImportExport/Model/Import/Entity/Product.php b/app/code/core/Mage/ImportExport/Model/Import/Entity/Product.php index ce5f1e8327f..2acd52bbc58 100644 --- a/app/code/core/Mage/ImportExport/Model/Import/Entity/Product.php +++ b/app/code/core/Mage/ImportExport/Model/Import/Entity/Product.php @@ -1101,7 +1101,7 @@ protected function _saveCustomOptions() if ($productIds) { // update product entity table to show that product has options $customOptionsProducts = $customOptions['product_id']; - foreach (array_keys($customOptionsProducts) as $key) { + foreach ($customOptionsProducts as $key => $value) { if (!in_array($key, $productIds)) { unset($customOptionsProducts[$key]); } diff --git a/app/code/core/Mage/Index/Model/Event.php b/app/code/core/Mage/Index/Model/Event.php index d4dc4468a17..2035a5be359 100644 --- a/app/code/core/Mage/Index/Model/Event.php +++ b/app/code/core/Mage/Index/Model/Event.php @@ -157,7 +157,7 @@ protected function _mergeNewDataRecursive($previous, $current) return $previous; } - foreach (array_keys($previous) as $key) { + foreach ($previous as $key => $value) { if (array_key_exists($key, $current) && !is_null($current[$key]) && is_array($previous[$key])) { if (!is_string($key) || is_array($current[$key])) { $current[$key] = $this->_mergeNewDataRecursive($previous[$key], $current[$key]); diff --git a/app/code/core/Mage/Install/Block/Db/Main.php b/app/code/core/Mage/Install/Block/Db/Main.php index 25791d2f5f8..9f0789c1ea3 100644 --- a/app/code/core/Mage/Install/Block/Db/Main.php +++ b/app/code/core/Mage/Install/Block/Db/Main.php @@ -77,7 +77,7 @@ public function getDatabaseBlock($type) public function getDatabaseBlocks() { $databases = []; - foreach (array_keys($this->_databases) as $type) { + foreach ($this->_databases as $type => $blockData) { $databases[] = $this->getDatabaseBlock($type); } return $databases; diff --git a/app/code/core/Mage/Install/Model/Installer/Console.php b/app/code/core/Mage/Install/Model/Installer/Console.php index 7c31a5007ab..033d8db36a4 100644 --- a/app/code/core/Mage/Install/Model/Installer/Console.php +++ b/app/code/core/Mage/Install/Model/Installer/Console.php @@ -155,7 +155,7 @@ public function setArgs($args = null) /** * Set args values */ - foreach (array_keys($this->_getOptions()) as $name) { + foreach ($this->_getOptions() as $name => $option) { $this->_args[$name] = $args[$name] ?? ''; } diff --git a/app/code/core/Mage/Install/Model/Installer/Db/Abstract.php b/app/code/core/Mage/Install/Model/Installer/Db/Abstract.php index 33b6de0c2ea..40155d07e4a 100644 --- a/app/code/core/Mage/Install/Model/Installer/Db/Abstract.php +++ b/app/code/core/Mage/Install/Model/Installer/Db/Abstract.php @@ -136,7 +136,7 @@ public function getRequiredExtensions() { $extensions = []; $configExt = (array)Mage::getConfig()->getNode(sprintf('install/databases/%s/extensions', $this->getModel())); - foreach (array_keys($configExt) as $name) { + foreach ($configExt as $name => $value) { $extensions[] = $name; } return $extensions; diff --git a/app/code/core/Mage/Page/Block/Template/Links.php b/app/code/core/Mage/Page/Block/Template/Links.php index aacfd69b27e..b52e2f367eb 100644 --- a/app/code/core/Mage/Page/Block/Template/Links.php +++ b/app/code/core/Mage/Page/Block/Template/Links.php @@ -242,7 +242,7 @@ protected function _getNewPosition($position = 0) } } else { $position = 0; - foreach (array_keys($this->_links) as $k) { + foreach ($this->_links as $k => $v) { $position = $k; } $position += 10; diff --git a/app/code/core/Mage/Paygate/Model/Authorizenet.php b/app/code/core/Mage/Paygate/Model/Authorizenet.php index c32a8b69385..5659e2caac3 100644 --- a/app/code/core/Mage/Paygate/Model/Authorizenet.php +++ b/app/code/core/Mage/Paygate/Model/Authorizenet.php @@ -1475,7 +1475,7 @@ protected function _addTransaction( $payment->setTransactionAdditionalInfo($key, $value); } $transaction = $payment->addTransaction($transactionType, null, false, $message); - foreach (array_keys($transactionDetails) as $key) { + foreach ($transactionDetails as $key => $value) { $payment->unsetData($key); } $payment->unsLastTransId(); diff --git a/app/code/core/Mage/Payment/Block/Form/Cc.php b/app/code/core/Mage/Payment/Block/Form/Cc.php index 08a12b4c037..5435e7f4a75 100644 --- a/app/code/core/Mage/Payment/Block/Form/Cc.php +++ b/app/code/core/Mage/Payment/Block/Form/Cc.php @@ -47,7 +47,7 @@ public function getCcAvailableTypes() $availableTypes = $method->getConfigData('cctypes'); if ($availableTypes) { $availableTypes = explode(',', $availableTypes); - foreach (array_keys($types) as $code) { + foreach ($types as $code => $name) { if (!in_array($code, $availableTypes)) { unset($types[$code]); } diff --git a/app/code/core/Mage/Payment/Helper/Data.php b/app/code/core/Mage/Payment/Helper/Data.php index fed881ddeae..a7f9071c590 100644 --- a/app/code/core/Mage/Payment/Helper/Data.php +++ b/app/code/core/Mage/Payment/Helper/Data.php @@ -67,7 +67,7 @@ public function getMethodInstance($code) public function getStoreMethods($store = null, $quote = null) { $res = []; - foreach (array_keys($this->getPaymentMethods($store)) as $code) { + foreach ($this->getPaymentMethods($store) as $code => $methodConfig) { $prefix = self::XML_PATH_PAYMENT_METHODS . '/' . $code . '/'; if (!$model = Mage::getStoreConfig($prefix . 'model', $store)) { continue; @@ -166,7 +166,7 @@ public function getBillingAgreementMethods($store = null, $quote = null) public function getRecurringProfileMethods($store = null) { $result = []; - foreach (array_keys($this->getPaymentMethods($store)) as $code) { + foreach ($this->getPaymentMethods($store) as $code => $data) { $paymentMethodModelClassName = $this->getMethodModelClassName($code); if (!$paymentMethodModelClassName) { continue; @@ -244,7 +244,7 @@ public function getPaymentMethodList($sorted = true, $asLabelValue = false, $wit } if ($asLabelValue) { $labelValues = []; - foreach (array_keys($methods) as $code) { + foreach ($methods as $code => $title) { $labelValues[$code] = []; } foreach ($methods as $code => $title) { diff --git a/app/code/core/Mage/Paypal/Model/Resource/Report/Settlement.php b/app/code/core/Mage/Paypal/Model/Resource/Report/Settlement.php index fca1a3d661e..ec75245e7e2 100644 --- a/app/code/core/Mage/Paypal/Model/Resource/Report/Settlement.php +++ b/app/code/core/Mage/Paypal/Model/Resource/Report/Settlement.php @@ -58,7 +58,7 @@ protected function _afterSave(Mage_Core_Model_Abstract $object) /** @var Mage_Core_Model_Date $date */ $date = Mage::getSingleton('core/date'); - foreach (array_keys($rows) as $key) { + foreach ($rows as $key => $row) { /* * Converting dates */ diff --git a/app/code/core/Mage/Reports/Model/Totals.php b/app/code/core/Mage/Reports/Model/Totals.php index 6b98422fdee..33f899cc705 100644 --- a/app/code/core/Mage/Reports/Model/Totals.php +++ b/app/code/core/Mage/Reports/Model/Totals.php @@ -47,7 +47,7 @@ public function countTotals($grid, $from, $to) } $data = $item->getData(); - foreach (array_keys($columns) as $field) { + foreach ($columns as $field => $a) { if ($field !== '') { $columns[$field]['value'] += $data[$field] ?? 0; } diff --git a/app/code/core/Mage/Rule/Model/Action/Abstract.php b/app/code/core/Mage/Rule/Model/Action/Abstract.php index d8cb87fb7f4..a810922d2f7 100644 --- a/app/code/core/Mage/Rule/Model/Action/Abstract.php +++ b/app/code/core/Mage/Rule/Model/Action/Abstract.php @@ -52,11 +52,11 @@ public function __construct() parent::__construct(); $this->loadAttributeOptions()->loadOperatorOptions()->loadValueOptions(); - foreach (array_keys($this->getAttributeOption()) as $attr) { + foreach ($this->getAttributeOption() as $attr => $dummy) { $this->setAttribute($attr); break; } - foreach (array_keys($this->getOperatorOption()) as $operator) { + foreach ($this->getOperatorOption() as $operator => $dummy) { $this->setOperator($operator); break; } diff --git a/app/code/core/Mage/Rule/Model/Condition/Abstract.php b/app/code/core/Mage/Rule/Model/Condition/Abstract.php index e31fbdda29c..d2e67c86270 100644 --- a/app/code/core/Mage/Rule/Model/Condition/Abstract.php +++ b/app/code/core/Mage/Rule/Model/Condition/Abstract.php @@ -92,13 +92,13 @@ public function __construct() $this->loadAttributeOptions()->loadOperatorOptions()->loadValueOptions(); if ($options = $this->getAttributeOptions()) { - foreach (array_keys($options) as $attr) { + foreach ($options as $attr => $dummy) { $this->setAttribute($attr); break; } } if ($options = $this->getOperatorOptions()) { - foreach (array_keys($options) as $operator) { + foreach ($options as $operator => $dummy) { $this->setOperator($operator); break; } @@ -503,7 +503,7 @@ public function getTypeElementHtml() public function getAttributeElement() { if (is_null($this->getAttribute())) { - foreach (array_keys($this->getAttributeOption()) as $k) { + foreach ($this->getAttributeOption() as $k => $v) { $this->setAttribute($k); break; } diff --git a/app/code/core/Mage/Rule/Model/Condition/Combine.php b/app/code/core/Mage/Rule/Model/Condition/Combine.php index 1d9b0093d13..79d4e693c38 100644 --- a/app/code/core/Mage/Rule/Model/Condition/Combine.php +++ b/app/code/core/Mage/Rule/Model/Condition/Combine.php @@ -95,7 +95,7 @@ public function __construct() $this->loadAggregatorOptions(); if ($options = $this->getAggregatorOptions()) { - foreach (array_keys($options) as $aggregator) { + foreach ($options as $aggregator => $dummy) { $this->setAggregator($aggregator); break; } diff --git a/app/code/core/Mage/Sales/Block/Adminhtml/Customer/Edit/Tab/Agreement.php b/app/code/core/Mage/Sales/Block/Adminhtml/Customer/Edit/Tab/Agreement.php index 713bee21bab..52bf6a9b347 100644 --- a/app/code/core/Mage/Sales/Block/Adminhtml/Customer/Edit/Tab/Agreement.php +++ b/app/code/core/Mage/Sales/Block/Adminhtml/Customer/Edit/Tab/Agreement.php @@ -125,7 +125,7 @@ protected function _prepareColumns() { $result = parent::_prepareColumns(); - foreach (array_keys($this->_columns) as $key) { + foreach ($this->_columns as $key => $value) { if (in_array($key, $this->_columnsToRemove)) { unset($this->_columns[$key]); } diff --git a/app/code/core/Mage/Sales/Model/Resource/Report/Order/Createdat.php b/app/code/core/Mage/Sales/Model/Resource/Report/Order/Createdat.php index a9971351972..323ce47e00f 100644 --- a/app/code/core/Mage/Sales/Model/Resource/Report/Order/Createdat.php +++ b/app/code/core/Mage/Sales/Model/Resource/Report/Order/Createdat.php @@ -230,7 +230,7 @@ protected function _aggregateByField($aggregationField, $from, $to) $adapter->query($select->insertFromSelect($this->getMainTable(), array_keys($columns))); // setup all columns to select SUM() except period, store_id and order_status - foreach (array_keys($columns) as $k) { + foreach ($columns as $k => $v) { $columns[$k] = new Zend_Db_Expr('SUM(' . $k . ')'); } $columns['period'] = 'period'; diff --git a/app/code/core/Mage/Sales/Model/Resource/Sale/Collection.php b/app/code/core/Mage/Sales/Model/Resource/Sale/Collection.php index f2972e84cc9..1bf6ed99bf1 100644 --- a/app/code/core/Mage/Sales/Model/Resource/Sale/Collection.php +++ b/app/code/core/Mage/Sales/Model/Resource/Sale/Collection.php @@ -182,7 +182,7 @@ public function load($printQuery = false, $logQuery = false) ->setWebsiteId(Mage::app()->getStore($storeId)->getWebsiteId()) ->setAvgNormalized($v['avgsale'] * $v['num_orders']); $this->_items[$storeId] = $storeObject; - foreach (array_keys($this->_totals) as $key) { + foreach ($this->_totals as $key => $value) { $this->_totals[$key] += $storeObject->getData($key); } } diff --git a/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.8.13-0.8.14.php b/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.8.13-0.8.14.php index 9525a968c57..43d089aa854 100644 --- a/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.8.13-0.8.14.php +++ b/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.8.13-0.8.14.php @@ -183,7 +183,7 @@ $select->from(['e' => $this->getTable('sales_order_entity')]); $attributeIds = []; -foreach (array_keys($attributes) as $code) { +foreach ($attributes as $code => $params) { $attributes[$code] = $installer->getAttribute($orderEntityTypeId, $code); if ($attributes[$code]['backend_type'] != 'static') { $select->joinLeft( diff --git a/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.50-0.9.51.php b/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.50-0.9.51.php index 69722481f54..3e9e34ea693 100644 --- a/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.50-0.9.51.php +++ b/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.50-0.9.51.php @@ -46,7 +46,7 @@ "); /* get order_payment attribute codes*/ -foreach (array_keys($attributesIds) as $attributeCode) { +foreach ($attributesIds as $attributeCode => $attributeId) { $attributesIds[$attributeCode] = $connection->fetchOne(" SELECT attribute_id FROM {$this->getTable('eav_attribute')} diff --git a/app/code/core/Mage/Shipping/Model/Rate/Result.php b/app/code/core/Mage/Shipping/Model/Rate/Result.php index bc7ad148a12..fa06daacb29 100644 --- a/app/code/core/Mage/Shipping/Model/Rate/Result.php +++ b/app/code/core/Mage/Shipping/Model/Rate/Result.php @@ -180,7 +180,7 @@ public function sortRatesByPrice() natsort($tmp); - foreach (array_keys($tmp) as $i) { + foreach ($tmp as $i => $price) { $result[] = $this->_rates[$i]; } diff --git a/app/code/core/Mage/Tag/Helper/Data.php b/app/code/core/Mage/Tag/Helper/Data.php index a2de68080cc..c86d4d5eee1 100644 --- a/app/code/core/Mage/Tag/Helper/Data.php +++ b/app/code/core/Mage/Tag/Helper/Data.php @@ -73,7 +73,7 @@ public function extractTags($tagNamesInString) */ public function cleanTags(array $tagNamesArr) { - foreach (array_keys($tagNamesArr) as $key) { + foreach ($tagNamesArr as $key => $tagName) { $tagNamesArr[$key] = trim($tagNamesArr[$key], '\''); $tagNamesArr[$key] = trim($tagNamesArr[$key]); if ($tagNamesArr[$key] == '') { diff --git a/app/code/core/Mage/Tag/controllers/IndexController.php b/app/code/core/Mage/Tag/controllers/IndexController.php index 833837c75b6..54b26c441f7 100644 --- a/app/code/core/Mage/Tag/controllers/IndexController.php +++ b/app/code/core/Mage/Tag/controllers/IndexController.php @@ -99,7 +99,7 @@ protected function _extractTags($tagNamesInString) */ protected function _cleanTags(array $tagNamesArr) { - foreach (array_keys($tagNamesArr) as $key) { + foreach ($tagNamesArr as $key => $tagName) { $tagNamesArr[$key] = trim($tagNamesArr[$key], '\''); $tagNamesArr[$key] = trim($tagNamesArr[$key]); if ($tagNamesArr[$key] == '') { diff --git a/app/code/core/Mage/Weee/Model/Attribute/Backend/Weee/Tax.php b/app/code/core/Mage/Weee/Model/Attribute/Backend/Weee/Tax.php index f6ed065e028..ed49099010c 100644 --- a/app/code/core/Mage/Weee/Model/Attribute/Backend/Weee/Tax.php +++ b/app/code/core/Mage/Weee/Model/Attribute/Backend/Weee/Tax.php @@ -74,7 +74,7 @@ public function afterLoad($object) { $data = $this->_getResource()->loadProductData($object, $this->getAttribute()); - foreach (array_keys($data) as $i) { + foreach ($data as $i => $row) { if ($data[$i]['website_id'] == 0) { $rate = Mage::app()->getStore()->getBaseCurrency()->getRate(Mage::app()->getBaseCurrencyCode()); if ($rate) { diff --git a/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Catalog/Product/Attribute/Edit/AttributeForm.php b/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Catalog/Product/Attribute/Edit/AttributeForm.php index 1344cfc1a92..9683e4322cd 100644 --- a/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Catalog/Product/Attribute/Edit/AttributeForm.php +++ b/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Catalog/Product/Attribute/Edit/AttributeForm.php @@ -45,7 +45,7 @@ public function getData(FixtureInterface $fixture = null, Element $element = nul { $data = []; if ($fixture === null) { - foreach (array_keys($this->tabs) as $tabName) { + foreach ($this->tabs as $tabName => $tab) { $this->openTab($tabName); $tabData = $this->getTabElement($tabName)->getDataFormTab(); $data = array_merge($data, $tabData); diff --git a/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Catalog/Product/Edit/Tab/Prices.php b/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Catalog/Product/Edit/Tab/Prices.php index 657f84a8239..3346dcc17a8 100644 --- a/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Catalog/Product/Edit/Tab/Prices.php +++ b/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Catalog/Product/Edit/Tab/Prices.php @@ -54,7 +54,7 @@ class Prices extends Tab public function fillFormTab(array $fields, Element $element = null) { $context = $element ? $element : $this->_rootElement; - foreach (array_keys($this->childrenForm) as $key) { + foreach ($this->childrenForm as $key => $value) { if (isset($fields[$key])) { $this->fillOptionsPrices([$key => $fields[$key]], $context); unset($fields[$key]); @@ -91,7 +91,7 @@ public function getDataFormTab($fields = null, Element $element = null) { $result = []; $context = $element ? $element : $this->_rootElement; - foreach (array_keys($this->childrenForm) as $key) { + foreach ($this->childrenForm as $key => $value) { if (isset($fields[$key])) { $result[$key] = $this->getOptionsPrices([$key => $fields[$key]], $context); unset($fields[$key]); diff --git a/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Catalog/Product/ProductForm.php b/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Catalog/Product/ProductForm.php index 565b823b7c5..584a8f25fbc 100644 --- a/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Catalog/Product/ProductForm.php +++ b/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Catalog/Product/ProductForm.php @@ -341,7 +341,7 @@ public function getRequireNoticeAttributes(FixtureInterface $product) { $data = []; $tabs = $this->getFieldsByTabs($product); - foreach (array_keys($tabs) as $tabName) { + foreach ($tabs as $tabName => $fields) { $tab = $this->getTabElement($tabName); $this->openTab($tabName); $errors = $tab->getRequireNoticeMessages(); diff --git a/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Widget/FormTabs.php b/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Widget/FormTabs.php index a0c24f0c42d..8d9596cda76 100644 --- a/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Widget/FormTabs.php +++ b/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Widget/FormTabs.php @@ -135,7 +135,7 @@ protected function fillTabs(array $tabs, Element $element = null) */ protected function fillMissedFields() { - foreach (array_keys($this->tabs) as $tabName) { + foreach ($this->tabs as $tabName => $tabData) { $tabElement = $this->getTabElement($tabName); if ($this->openTab($tabName)) { $mapping = $tabElement->dataMapping($this->unassignedFields); @@ -174,7 +174,7 @@ public function getData(FixtureInterface $fixture = null, Element $element = nul $data = []; if (null === $fixture) { - foreach (array_keys($this->tabs) as $tabName) { + foreach ($this->tabs as $tabName => $tab) { $this->openTab($tabName); $tabData = $this->getTabElement($tabName)->getDataFormTab(); $data = array_merge($data, $tabData); diff --git a/dev/tests/functional/tests/app/Mage/Bundle/Test/Handler/Curl.php b/dev/tests/functional/tests/app/Mage/Bundle/Test/Handler/Curl.php index eb79bfc90ef..e4777d9f973 100644 --- a/dev/tests/functional/tests/app/Mage/Bundle/Test/Handler/Curl.php +++ b/dev/tests/functional/tests/app/Mage/Bundle/Test/Handler/Curl.php @@ -146,7 +146,7 @@ protected function prepareBundleSelections(array $bundleData) */ protected function prepareItemSelectionData(array $selections, array $products) { - foreach (array_keys($selections) as $key) { + foreach ($selections as $key => $selection) { $selections[$key]['product_id'] = $products[$key]->getId(); unset($selections[$key]['sku']); $selections[$key]['delete'] = ''; @@ -163,7 +163,7 @@ protected function prepareItemSelectionData(array $selections, array $products) */ protected function prepareBundleOptions(array $bundleData) { - foreach (array_keys($bundleData) as $key) { + foreach ($bundleData as $key => $option) { $bundleData[$key] = array_intersect_key($bundleData[$key], array_flip($this->optionsFields)); $bundleData[$key]['delete'] = ''; } diff --git a/dev/tests/functional/tests/app/Mage/Catalog/Test/TestStep/UpdateConfigurableProductStep/DeleteOptionsSubStep.php b/dev/tests/functional/tests/app/Mage/Catalog/Test/TestStep/UpdateConfigurableProductStep/DeleteOptionsSubStep.php index 16d05ab359c..6b18d2b8ea3 100644 --- a/dev/tests/functional/tests/app/Mage/Catalog/Test/TestStep/UpdateConfigurableProductStep/DeleteOptionsSubStep.php +++ b/dev/tests/functional/tests/app/Mage/Catalog/Test/TestStep/UpdateConfigurableProductStep/DeleteOptionsSubStep.php @@ -86,7 +86,7 @@ protected function searchKeysForOption($optionIndex) { $keys = []; $originalProductAssignedProducts = $this->getOriginalProductAssignedProducts(); - foreach (array_keys($originalProductAssignedProducts) as $key) { + foreach ($originalProductAssignedProducts as $key => $product) { if (strpos($key, 'option_key_' . $optionIndex) !== false) { $keys[] = $key; } diff --git a/dev/tests/functional/tests/app/Mage/Customer/Test/Handler/Customer/Curl.php b/dev/tests/functional/tests/app/Mage/Customer/Test/Handler/Customer/Curl.php index 23d27ff801b..68f2f85b69a 100644 --- a/dev/tests/functional/tests/app/Mage/Customer/Test/Handler/Customer/Curl.php +++ b/dev/tests/functional/tests/app/Mage/Customer/Test/Handler/Customer/Curl.php @@ -131,7 +131,7 @@ public function persist(FixtureInterface $customer = null) */ protected function checkForUpdateData(array $data) { - foreach (array_keys($data) as $key) { + foreach ($data as $key => $field) { if (in_array($key, $this->updatingFields)) { return true; } diff --git a/dev/tests/functional/tests/app/Mage/Weee/Test/Constraint/AssertFptApplied.php b/dev/tests/functional/tests/app/Mage/Weee/Test/Constraint/AssertFptApplied.php index baf99e0e016..c1b61df6d23 100644 --- a/dev/tests/functional/tests/app/Mage/Weee/Test/Constraint/AssertFptApplied.php +++ b/dev/tests/functional/tests/app/Mage/Weee/Test/Constraint/AssertFptApplied.php @@ -145,7 +145,7 @@ protected function clearShoppingCart() protected function getPrices() { $actualPrices = []; - foreach (array_keys($this->expectedPrices) as $priceType) { + foreach ($this->expectedPrices as $priceType => $prices) { $actualPrices[$priceType] = $this->{'get' . ucfirst($priceType) . 'Price'}(); } diff --git a/lib/Varien/Convert/Parser/Csv.php b/lib/Varien/Convert/Parser/Csv.php index 4550d155691..f857c3b85a8 100644 --- a/lib/Varien/Convert/Parser/Csv.php +++ b/lib/Varien/Convert/Parser/Csv.php @@ -44,7 +44,7 @@ public function parse() $fields = $line; continue; } else { - foreach (array_keys($line) as $j) { + foreach ($line as $j => $f) { $fields[$j] = 'column' . ($j + 1); } } @@ -87,7 +87,7 @@ public function parseTest() $fields = $line; continue; } else { - foreach (array_keys($line) as $j) { + foreach ($line as $j => $f) { $fields[$j] = 'column' . ($j + 1); } } diff --git a/lib/Varien/Db/Statement/Pdo/Mysql.php b/lib/Varien/Db/Statement/Pdo/Mysql.php index d5f83882237..b23cb8435fa 100644 --- a/lib/Varien/Db/Statement/Pdo/Mysql.php +++ b/lib/Varien/Db/Statement/Pdo/Mysql.php @@ -33,7 +33,7 @@ public function _executeWithBinding(array $params) { // Check whether we deal with named bind $isPositionalBind = true; - foreach (array_keys($params) as $k) { + foreach ($params as $k => $v) { if (!is_int($k)) { $isPositionalBind = false; break; diff --git a/lib/Varien/Http/Adapter/Curl.php b/lib/Varien/Http/Adapter/Curl.php index 1e9fd81f16b..56e9359a23f 100644 --- a/lib/Varien/Http/Adapter/Curl.php +++ b/lib/Varien/Http/Adapter/Curl.php @@ -75,7 +75,7 @@ protected function _applyConfig() $verifyHost = isset($this->_config['verifyhost']) ? $this->_config['verifyhost'] : 0; curl_setopt($this->_getResource(), CURLOPT_SSL_VERIFYHOST, $verifyHost); - foreach (array_keys($this->_config) as $param) { + foreach ($this->_config as $param => $curlOption) { if (array_key_exists($param, $this->_allowedParams)) { curl_setopt($this->_getResource(), $this->_allowedParams[$param], $this->_config[$param]); } diff --git a/lib/Varien/Object.php b/lib/Varien/Object.php index 968d5b0fc02..bfd0f11bcff 100644 --- a/lib/Varien/Object.php +++ b/lib/Varien/Object.php @@ -292,7 +292,7 @@ public function unsetData($key = null) public function unsetOldData($key = null) { if (is_null($key)) { - foreach (array_keys($this->_oldFieldsMap) as $key) { + foreach ($this->_oldFieldsMap as $key => $newFieldName) { unset($this->_data[$key]); } } else { diff --git a/lib/Varien/Object/Cache.php b/lib/Varien/Object/Cache.php index 24047b87356..11b6cc23775 100644 --- a/lib/Varien/Object/Cache.php +++ b/lib/Varien/Object/Cache.php @@ -241,7 +241,7 @@ public function delete($idx) } if (isset($this->_objectReferences[$idx])) { - foreach (array_keys($this->_references) as $r) { + foreach ($this->_references as $r => $dummy) { unset($this->_references[$r]); } unset($this->_objectReferences[$idx]); diff --git a/phpstan.dist.baseline.neon b/phpstan.dist.baseline.neon index 40723ea0e61..bf2f4ca58bd 100644 --- a/phpstan.dist.baseline.neon +++ b/phpstan.dist.baseline.neon @@ -3365,6 +3365,11 @@ parameters: count: 1 path: app/code/core/Mage/ImportExport/Model/Export/Entity/Product.php + - + message: "#^Offset int\\|string on non\\-empty\\-array\\ in isset\\(\\) always exists and is not nullable\\.$#" + count: 2 + path: app/code/core/Mage/ImportExport/Model/Export/Entity/Product.php + - message: "#^Variable \\$collection might not be defined\\.$#" count: 1