Skip to content

Commit 03e1514

Browse files
committed
Rector: CQ - UnusedForeachValueToArrayKeysRector
See Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector
1 parent fae22f5 commit 03e1514

File tree

71 files changed

+91
-91
lines changed

Some content is hidden

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

71 files changed

+91
-91
lines changed

app/code/core/Mage/Adminhtml/Block/Dashboard/Graph.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ public function getChartUrl($directUrl = true)
215215
$dateStart->addMonth(1);
216216
break;
217217
}
218-
foreach ($this->getAllSeries() as $index => $serie) {
218+
foreach (array_keys($this->getAllSeries()) as $index) {
219219
if (in_array($d, $this->_axisLabels['x'])) {
220220
$datas[$index][] = (float)array_shift($this->_allSeries[$index]);
221221
} else {
@@ -328,7 +328,7 @@ public function getChartUrl($directUrl = true)
328328
if (count($this->_axisLabels)) {
329329
$params['chxt'] = implode(',', array_keys($this->_axisLabels));
330330
$indexid = 0;
331-
foreach ($this->_axisLabels as $idx => $labels) {
331+
foreach (array_keys($this->_axisLabels) as $idx) {
332332
if ($idx === 'x') {
333333
/**
334334
* Format date

app/code/core/Mage/Adminhtml/Block/Page/Menu.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ protected function _buildMenuArray(Varien_Simplexml_Element $parent, $path = '',
164164

165165
uasort($parentArr, [$this, '_sortMenu']);
166166

167-
foreach ($parentArr as $key => $value) {
167+
foreach (array_keys($parentArr) as $key) {
168168
$last = $key;
169169
}
170170
if (isset($last)) {

app/code/core/Mage/Adminhtml/Block/Report/Grid.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ protected function _prepareCollection()
207207
*/
208208
protected function _setFilterValues($data)
209209
{
210-
foreach ($data as $name => $value) {
210+
foreach (array_keys($data) as $name) {
211211
$this->setFilter($name, $data[$name]);
212212
}
213213
return $this;

app/code/core/Mage/Adminhtml/Block/Sales/Transactions/Child/Grid.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ protected function _prepareColumns()
6262
{
6363
$result = parent::_prepareColumns();
6464

65-
foreach ($this->_columns as $key => $value) {
65+
foreach (array_keys($this->_columns) as $key) {
6666
if (in_array($key, $this->_columnsToRemove)) {
6767
unset($this->_columns[$key]);
6868
} else {

app/code/core/Mage/Adminhtml/Block/Store/Switcher.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function getWebsites()
7373
{
7474
$websites = Mage::app()->getWebsites();
7575
if ($websiteIds = $this->getWebsiteIds()) {
76-
foreach ($websites as $websiteId => $website) {
76+
foreach (array_keys($websites) as $websiteId) {
7777
if (!in_array($websiteId, $websiteIds)) {
7878
unset($websites[$websiteId]);
7979
}
@@ -140,7 +140,7 @@ public function getStores($group)
140140
}
141141
$stores = $group->getStores();
142142
if ($storeIds = $this->getStoreIds()) {
143-
foreach ($stores as $storeId => $store) {
143+
foreach (array_keys($stores) as $storeId) {
144144
if (!in_array($storeId, $storeIds)) {
145145
unset($stores[$storeId]);
146146
}

app/code/core/Mage/Adminhtml/Block/Urlrewrite/Edit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ public function getButtonsHtml($area = null)
194194
{
195195
if ($this->_buttonsHtml === null) {
196196
$this->_buttonsHtml = parent::getButtonsHtml();
197-
foreach ($this->_children as $alias => $child) {
197+
foreach (array_keys($this->_children) as $alias) {
198198
if (str_contains($alias, '_button')) {
199199
$this->unsetChild($alias);
200200
}

app/code/core/Mage/Adminhtml/Block/Urlrewrite/Edit/Form.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ protected function _prepareForm()
6161
'description' => $model->getDescription(),
6262
];
6363
if ($sessionData = Mage::getSingleton('adminhtml/session')->getData('urlrewrite_data', true)) {
64-
foreach ($formValues as $key => $value) {
64+
foreach (array_keys($formValues) as $key) {
6565
if (isset($sessionData[$key])) {
6666
$formValues[$key] = $sessionData[$key];
6767
}

app/code/core/Mage/Adminhtml/Block/Widget/Grid.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ public function getColumns()
481481
*/
482482
protected function _setFilterValues($data)
483483
{
484-
foreach ($data as $columnId => $value) {
484+
foreach (array_keys($data) as $columnId) {
485485
$column = $this->getColumn($columnId);
486486
if ($column instanceof Mage_Adminhtml_Block_Widget_Grid_Column
487487
&& (!empty($data[$columnId]) || strlen($data[$columnId]) > 0)

app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Action.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ protected function _toLinkHtml($action, Varien_Object $row)
109109
*/
110110
protected function _transformActionData(&$action, &$actionCaption, Varien_Object $row)
111111
{
112-
foreach ($action as $attribute => $value) {
112+
foreach (array_keys($action) as $attribute) {
113113
if (isset($action[$attribute]) && !is_array($action[$attribute])) {
114114
$this->getColumn()->setFormat($action[$attribute]);
115115
$action[$attribute] = parent::render($row);

app/code/core/Mage/Adminhtml/Block/Widget/Tabs.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ protected function _reorderTabs()
256256
asort($this->_tabPositions);
257257

258258
$ordered = [];
259-
foreach ($this->_tabPositions as $tabId => $position) {
259+
foreach (array_keys($this->_tabPositions) as $tabId) {
260260
if (isset($this->_tabs[$tabId])) {
261261
$tab = $this->_tabs[$tabId];
262262
$ordered[$tabId] = $tab;

app/code/core/Mage/Adminhtml/Model/System/Config/Source/Admin/Page.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ protected function _buildMenuArray(?Varien_Simplexml_Element $parent = null, $pa
109109

110110
uasort($parentArr, [$this, '_sortMenu']);
111111

112-
foreach ($parentArr as $key => $value) {
112+
foreach (array_keys($parentArr) as $key) {
113113
$last = $key;
114114
}
115115
if (isset($last)) {

app/code/core/Mage/Api2/Model/Acl/Filter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function __construct(Mage_Api2_Model_Resource $resource)
6161
*/
6262
protected function _filter(array $allowedAttributes, array $data)
6363
{
64-
foreach ($data as $attribute => $value) {
64+
foreach (array_keys($data) as $attribute) {
6565
if (!in_array($attribute, $allowedAttributes)) {
6666
unset($data[$attribute]);
6767
}

app/code/core/Mage/Api2/Model/Acl/Filter/Attribute/ResourcePermission.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function getResourcesPermissions()
103103
$resourceModel->setResourceType($resource)
104104
->setUserType($this->_userType);
105105

106-
foreach ($operations as $operation => $operationLabel) {
106+
foreach (array_keys($operations) as $operation) {
107107
if (!$this->_hasEntityOnlyAttributes
108108
&& $config->getResourceEntityOnlyAttributes($resource, $this->_userType, $operation)
109109
) {

app/code/core/Mage/Catalog/Model/Api2/Product.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function getAvailableAttributes($userType, $operation)
4242
}
4343
$excludedAttrs = $this->getExcludedAttributes($userType, $operation);
4444
$includedAttrs = $this->getIncludedAttributes($userType, $operation);
45-
foreach ($attributes as $code => $label) {
45+
foreach (array_keys($attributes) as $code) {
4646
if (in_array($code, $excludedAttrs) || ($includedAttrs && !in_array($code, $includedAttrs))) {
4747
unset($attributes[$code]);
4848
}

app/code/core/Mage/Catalog/Model/Category.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ public function getAttributes($noDesignAttributes = false)
346346
->getSortedAttributes();
347347

348348
if ($noDesignAttributes) {
349-
foreach ($result as $k => $a) {
349+
foreach (array_keys($result) as $k) {
350350
if (in_array($k, $this->_designAttributes)) {
351351
unset($result[$k]);
352352
}

app/code/core/Mage/Catalog/Model/Product/Type/Price.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ public function getFormatedTierPrice($qty, $product)
300300
{
301301
$price = $product->getTierPrice($qty);
302302
if (is_array($price)) {
303-
foreach ($price as $index => $value) {
303+
foreach (array_keys($price) as $index) {
304304
$price[$index]['formated_price'] = Mage::app()->getStore()->convertPrice(
305305
$price[$index]['website_price'],
306306
true

app/code/core/Mage/Catalog/Model/Resource/Category/Flat.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1152,7 +1152,7 @@ protected function _prepareDataForAllFields($category, $replaceFields = [])
11521152
$table = $this->_getReadAdapter()->describeTable($table);
11531153
$data = [];
11541154
$idFieldName = Mage::getSingleton('catalog/category')->getIdFieldName();
1155-
foreach ($table as $column => $columnData) {
1155+
foreach (array_keys($table) as $column) {
11561156
if ($column != $idFieldName || $category->getData($column) !== null) {
11571157
if (array_key_exists($column, $replaceFields)) {
11581158
$value = $category->getData($replaceFields[$column]);

app/code/core/Mage/Checkout/Model/Type/Onepage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public function initCheckout()
119119
$checkout = $this->getCheckout();
120120
$customerSession = $this->getCustomerSession();
121121
if (is_array($checkout->getStepData())) {
122-
foreach ($checkout->getStepData() as $step => $data) {
122+
foreach (array_keys($checkout->getStepData()) as $step) {
123123
if (!($step === 'login' || $customerSession->isLoggedIn() && $step === 'billing')) {
124124
$checkout->setStepData($step, 'allow', false);
125125
}

app/code/core/Mage/ConfigurableSwatches/Helper/Mediafallback.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public function attachProductChildrenAttributeMapping(array $parentProducts, $st
136136
} // end looping child products
137137
} // end looping attributes
138138

139-
foreach ($mapping as $key => $value) {
139+
foreach (array_keys($mapping) as $key) {
140140
$mapping[$key]['product_ids'] = array_unique($mapping[$key]['product_ids']);
141141
}
142142

app/code/core/Mage/Core/Helper/Data.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ public function assocToXml(array $array, $rootName = '_')
603603
<$rootName></$rootName>
604604
XML;
605605
$xml = new SimpleXMLElement($xmlstr);
606-
foreach ($array as $key => $value) {
606+
foreach (array_keys($array) as $key) {
607607
if (is_numeric($key)) {
608608
throw new Exception('Array root keys must not be numeric.');
609609
}

app/code/core/Mage/Core/Model/Cache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ public function getInvalidatedTypes()
625625
$types = $this->_getInvalidatedTypes();
626626
if ($types) {
627627
$allTypes = $this->getTypes();
628-
foreach ($types as $type => $flag) {
628+
foreach (array_keys($types) as $type) {
629629
if (isset($allTypes[$type]) && $this->canUse($type)) {
630630
$invalidatedTypes[$type] = $allTypes[$type];
631631
}

app/code/core/Mage/Core/Model/Date.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ public function parseDateTime($dateTimeString, $dateTimeFormat)
250250
'm/d/y' => ['/^([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{1,2})/', ['y' => 3, 'm' => 1, 'd' => 2]],
251251
];
252252

253-
foreach ($formats as $supportedFormat => $regRule) {
253+
foreach (array_keys($formats) as $supportedFormat) {
254254
if (strpos($dateTimeFormat, $supportedFormat, 0) !== false) {
255255
$isSupportedFormatFound = true;
256256
break;

app/code/core/Mage/Core/Model/Layout/Validator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public function getDisallowedBlocks()
108108
if (!count($this->_disallowedBlock)) {
109109
$disallowedBlockConfig = $this->_getDisallowedBlockConfigValue();
110110
if (is_array($disallowedBlockConfig)) {
111-
foreach ($disallowedBlockConfig as $blockName => $value) {
111+
foreach (array_keys($disallowedBlockConfig) as $blockName) {
112112
$this->_disallowedBlock[] = $blockName;
113113
}
114114
}

app/code/core/Mage/Core/Model/Locale.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ protected function _getOptionLocales($translatedName = false)
247247
}
248248
}
249249

250-
foreach ($locales as $code => $active) {
250+
foreach (array_keys($locales) as $code) {
251251
if (strstr($code, '_')) {
252252
if (!in_array($code, $allowed)) {
253253
continue;

app/code/core/Mage/Core/Model/Log/Adapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public function setFilterDataKeys($keys)
115115
protected function _filterDebugData($debugData)
116116
{
117117
if (is_array($debugData) && is_array($this->_debugReplacePrivateDataKeys)) {
118-
foreach ($debugData as $key => $value) {
118+
foreach (array_keys($debugData) as $key) {
119119
if (in_array($key, $this->_debugReplacePrivateDataKeys)) {
120120
$debugData[$key] = '****';
121121
} else {

app/code/core/Mage/Core/Model/Url/Rewrite.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ protected function _getQueryString()
319319
$queryParams = [];
320320
parse_str($_SERVER['QUERY_STRING'], $queryParams);
321321
$hasChanges = false;
322-
foreach ($queryParams as $key => $value) {
322+
foreach (array_keys($queryParams) as $key) {
323323
if (substr($key, 0, 3) === '___') {
324324
unset($queryParams[$key]);
325325
$hasChanges = true;

app/code/core/Mage/Core/Model/Url/Rewrite/Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ protected function _getQueryString()
306306
$queryParams = [];
307307
parse_str($_SERVER['QUERY_STRING'], $queryParams);
308308
$hasChanges = false;
309-
foreach ($queryParams as $key => $value) {
309+
foreach (array_keys($queryParams) as $key) {
310310
if (substr($key, 0, 3) === '___') {
311311
unset($queryParams[$key]);
312312
$hasChanges = true;

app/code/core/Mage/Customer/Model/Address/Api.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function items($customerId)
5555
$row[$attributeAlias] = $data[$attributeCode] ?? null;
5656
}
5757

58-
foreach ($this->getAllowedAttributes($address) as $attributeCode => $attribute) {
58+
foreach (array_keys($this->getAllowedAttributes($address)) as $attributeCode) {
5959
if (isset($data[$attributeCode])) {
6060
$row[$attributeCode] = $data[$attributeCode];
6161
}
@@ -89,7 +89,7 @@ public function create($customerId, $addressData)
8989

9090
$address = Mage::getModel('customer/address');
9191

92-
foreach ($this->getAllowedAttributes($address) as $attributeCode => $attribute) {
92+
foreach (array_keys($this->getAllowedAttributes($address)) as $attributeCode) {
9393
if (isset($addressData[$attributeCode])) {
9494
$address->setData($attributeCode, $addressData[$attributeCode]);
9595
}
@@ -141,7 +141,7 @@ public function info($addressId)
141141
$result[$attributeAlias] = $address->getData($attributeCode);
142142
}
143143

144-
foreach ($this->getAllowedAttributes($address) as $attributeCode => $attribute) {
144+
foreach (array_keys($this->getAllowedAttributes($address)) as $attributeCode) {
145145
$result[$attributeCode] = $address->getData($attributeCode);
146146
}
147147

@@ -169,7 +169,7 @@ public function update($addressId, $addressData)
169169
$this->_fault('not_exists');
170170
}
171171

172-
foreach ($this->getAllowedAttributes($address) as $attributeCode => $attribute) {
172+
foreach (array_keys($this->getAllowedAttributes($address)) as $attributeCode) {
173173
if (isset($addressData[$attributeCode])) {
174174
$address->setData($attributeCode, $addressData[$attributeCode]);
175175
}

app/code/core/Mage/Customer/Model/Address/Api/V2.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function create($customerId, $addressData)
4040

4141
$address = Mage::getModel('customer/address');
4242

43-
foreach ($this->getAllowedAttributes($address) as $attributeCode => $attribute) {
43+
foreach (array_keys($this->getAllowedAttributes($address)) as $attributeCode) {
4444
if (isset($addressData->$attributeCode)) {
4545
$address->setData($attributeCode, $addressData->$attributeCode);
4646
}
@@ -92,7 +92,7 @@ public function info($addressId)
9292
$result[$attributeAlias] = $address->getData($attributeCode);
9393
}
9494

95-
foreach ($this->getAllowedAttributes($address) as $attributeCode => $attribute) {
95+
foreach (array_keys($this->getAllowedAttributes($address)) as $attributeCode) {
9696
$result[$attributeCode] = $address->getData($attributeCode);
9797
}
9898

@@ -120,7 +120,7 @@ public function update($addressId, $addressData)
120120
$this->_fault('not_exists');
121121
}
122122

123-
foreach ($this->getAllowedAttributes($address) as $attributeCode => $attribute) {
123+
foreach (array_keys($this->getAllowedAttributes($address)) as $attributeCode) {
124124
if (isset($addressData->$attributeCode)) {
125125
$address->setData($attributeCode, $addressData->$attributeCode);
126126
}

app/code/core/Mage/Customer/Model/Customer/Api.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function info($customerId, $attributes = null)
8787
$result[$attributeAlias] = $customer->getData($attributeCode);
8888
}
8989

90-
foreach ($this->getAllowedAttributes($customer, $attributes) as $attributeCode => $attribute) {
90+
foreach (array_keys($this->getAllowedAttributes($customer, $attributes)) as $attributeCode) {
9191
$result[$attributeCode] = $customer->getData($attributeCode);
9292
}
9393

@@ -121,7 +121,7 @@ public function items($filters)
121121
foreach ($this->_mapAttributes as $attributeAlias => $attributeCode) {
122122
$row[$attributeAlias] = $data[$attributeCode] ?? null;
123123
}
124-
foreach ($this->getAllowedAttributes($customer) as $attributeCode => $attribute) {
124+
foreach (array_keys($this->getAllowedAttributes($customer)) as $attributeCode) {
125125
if (isset($data[$attributeCode])) {
126126
$row[$attributeCode] = $data[$attributeCode];
127127
}
@@ -149,7 +149,7 @@ public function update($customerId, $customerData)
149149
$this->_fault('not_exists');
150150
}
151151

152-
foreach ($this->getAllowedAttributes($customer) as $attributeCode => $attribute) {
152+
foreach (array_keys($this->getAllowedAttributes($customer)) as $attributeCode) {
153153
if (isset($customerData[$attributeCode])) {
154154
$customer->setData($attributeCode, $customerData[$attributeCode]);
155155
}

app/code/core/Mage/Dataflow/Model/Batch.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public function getFieldList()
9292
*/
9393
public function parseFieldList($row)
9494
{
95-
foreach ($row as $fieldName => $value) {
95+
foreach (array_keys($row) as $fieldName) {
9696
if (!in_array($fieldName, $this->_fieldList)) {
9797
$this->_fieldList[$fieldName] = $fieldName;
9898
}

app/code/core/Mage/Dataflow/Model/Session/Parser/Csv.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function parse()
4747
$fields = $line;
4848
continue;
4949
} else {
50-
foreach ($line as $j => $f) {
50+
foreach (array_keys($line) as $j) {
5151
$fields[$j] = 'column' . ($j + 1);
5252
}
5353
}

app/code/core/Mage/Eav/Model/Entity/Abstract.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1594,7 +1594,7 @@ public function delete($object)
15941594
];
15951595
$this->_getWriteAdapter()->delete($this->getEntityTable(), $where);
15961596
$this->loadAllAttributes($object);
1597-
foreach ($this->getAttributesByTable() as $table => $attributes) {
1597+
foreach (array_keys($this->getAttributesByTable()) as $table) {
15981598
$this->_getWriteAdapter()->delete($table, $where);
15991599
}
16001600
} catch (Exception $e) {

0 commit comments

Comments
 (0)