Skip to content

Commit

Permalink
Revert "Rector: CQ - UnusedForeachValueToArrayKeysRector (#1)"
Browse files Browse the repository at this point in the history
This reverts commit 3d7eaf6.
  • Loading branch information
sreichel committed Aug 21, 2024
1 parent c7d6aeb commit 63108c1
Show file tree
Hide file tree
Showing 71 changed files with 96 additions and 91 deletions.
4 changes: 2 additions & 2 deletions app/code/core/Mage/Adminhtml/Block/Dashboard/Graph.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Adminhtml/Block/Page/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Adminhtml/Block/Report/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions app/code/core/Mage/Adminhtml/Block/Store/Switcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
Expand Down Expand Up @@ -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]);
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Adminhtml/Block/Urlrewrite/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Adminhtml/Block/Widget/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Adminhtml/Block/Widget/Tabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Api2/Model/Acl/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
) {
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Catalog/Model/Api2/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Catalog/Model/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Catalog/Model/Product/Type/Price.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Checkout/Model/Type/Onepage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}

Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Core/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ public function assocToXml(array $array, $rootName = '_')
<$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.');
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Core/Model/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Core/Model/Layout/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Core/Model/Locale.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Core/Model/Log/Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Core/Model/Url/Rewrite.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Core/Model/Url/Rewrite/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions app/code/core/Mage/Customer/Model/Address/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down Expand Up @@ -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]);
}
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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]);
}
Expand Down
6 changes: 3 additions & 3 deletions app/code/core/Mage/Customer/Model/Address/Api/V2.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}
Expand Down
6 changes: 3 additions & 3 deletions app/code/core/Mage/Customer/Model/Customer/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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];
}
Expand Down Expand Up @@ -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]);
}
Expand Down
4 changes: 2 additions & 2 deletions app/code/core/Mage/Dataflow/Model/Batch.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Dataflow/Model/Session/Parser/Csv.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Eav/Model/Entity/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading

0 comments on commit 63108c1

Please sign in to comment.