Skip to content

Commit

Permalink
Merge branch 'main' into rector-2-cq
Browse files Browse the repository at this point in the history
# Conflicts:
#	composer.lock
#	errors/report.php
  • Loading branch information
sreichel committed Sep 9, 2024
2 parents fb3621a + e75e940 commit e20935e
Show file tree
Hide file tree
Showing 74 changed files with 144 additions and 143 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ['7.4', '8.3']
php-versions: ['7.4', '8.4']

steps:
- name: Setup PHP
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/syntax-php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

strategy:
matrix:
php: ['7.4', '8.3']
php: ['7.4', '8.4']

name: PHP Syntax ${{ matrix.php }}

Expand Down
1 change: 1 addition & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
PhpCsFixer\Finder::create()
->in([
'app/code/core/Mage/',
'errors/',
'lib/Mage/',
'lib/Magento/',
'lib/Varien/',
Expand Down
5 changes: 5 additions & 0 deletions .phpcs.ecg.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<file>install.php</file>
<file>app/Mage.php</file>
<file>app/code/core/Mage/</file>
<file>errors/</file>
<file>lib/Mage/</file>
<file>lib/Magento/</file>
<file>lib/Varien/</file>
Expand Down Expand Up @@ -66,6 +67,7 @@
<exclude-pattern>*/core/Mage/Catalog/Model/Resource/Product/Compare/Item.php*</exclude-pattern>
<exclude-pattern>*/core/Mage/Catalog/Model/Resource/Product/Indexer/Price.php*</exclude-pattern>
<exclude-pattern>*/core/Mage/Catalog/Model/Resource/Product/Option/Value.php*</exclude-pattern>
<exclude-pattern>*/core/Mage/Catalog/Model/Resource/Product/Type/Configurable/Attribute.php*</exclude-pattern>
<exclude-pattern>*/core/Mage/CatalogIndex/Model/Indexer.php*</exclude-pattern>
<exclude-pattern>*/core/Mage/CatalogInventory/Model/Observer.php*</exclude-pattern>
<exclude-pattern>*/core/Mage/CatalogInventory/Model/Api2/Stock/Item/Rest.php*</exclude-pattern>
Expand Down Expand Up @@ -111,6 +113,7 @@
<exclude-pattern>*/core/Mage/ImportExport/Model/Import/Entity/Product/Type/Grouped.php*</exclude-pattern>
<exclude-pattern>*/core/Mage/ImportExport/Model/Import/Proxy/Product/Resource.php*</exclude-pattern>
<exclude-pattern>*/core/Mage/Index/controllers/Adminhtml/ProcessController.php*</exclude-pattern>
<exclude-pattern>*/core/Mage/Index/Model/Observer.php*</exclude-pattern>
<exclude-pattern>*/core/Mage/Index/Model/Process.php*</exclude-pattern>
<exclude-pattern>*/core/Mage/Index/Model/Resource/Event.php*</exclude-pattern>
<exclude-pattern>*/core/Mage/Log/Model/Resource/Log.php*</exclude-pattern>
Expand Down Expand Up @@ -148,6 +151,7 @@
<exclude-pattern>*/core/Mage/Sales/Model/Order/Shipment.php*</exclude-pattern>
<exclude-pattern>*/core/Mage/SalesRule/Model/Observer.php*</exclude-pattern>
<exclude-pattern>*/core/Mage/SalesRule/Model/Rule.php*</exclude-pattern>
<exclude-pattern>*/core/Mage/SalesRule/Model/Coupon/Massgenerator.php*</exclude-pattern>
<exclude-pattern>*/core/Mage/Tag/controllers/IndexController.php*</exclude-pattern>
<exclude-pattern>*/core/Mage/Tag/Model/Api.php*</exclude-pattern>
<exclude-pattern>*/core/Mage/Tag/Model/Resource/Product/Collection.php*</exclude-pattern>
Expand All @@ -163,6 +167,7 @@
<exclude-pattern>*/lib/Varien/Cache/Backend/Memcached.php*</exclude-pattern>
<exclude-pattern>*/lib/Varien/Convert/Parser/Csv.php*</exclude-pattern>
<exclude-pattern>*/lib/Varien/Object/Cache.php*</exclude-pattern>
<exclude-pattern>*/shell/indexer.php*</exclude-pattern>
<exclude-pattern>*/core/Mage/*/data/*</exclude-pattern>
<exclude-pattern>*/core/Mage/*/sql/*</exclude-pattern>
</rule>
Expand Down
1 change: 1 addition & 0 deletions .phpcs.php.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<file>install.php</file>
<file>app/Mage.php</file>
<file>app/code/core/Mage/</file>
<file>errors/</file>
<file>lib/Mage/</file>
<file>lib/Magento/</file>
<file>lib/Varien/</file>
Expand Down
1 change: 1 addition & 0 deletions .phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<file>install.php</file>
<file>app/Mage.php</file>
<file>app/code/core/Mage/</file>
<file>errors/</file>
<file>lib/Mage/</file>
<file>lib/Magento/</file>
<file>lib/Varien/</file>
Expand Down
5 changes: 0 additions & 5 deletions .phpstan.dist.baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3290,11 +3290,6 @@ parameters:
count: 1
path: app/code/core/Mage/ImportExport/Model/Export/Entity/Product.php

-
message: "#^Offset int\\|string on non\\-empty\\-array\\<int\\|string, 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
Expand Down
1 change: 1 addition & 0 deletions .phpstan.dist.neon
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ parameters:
- install.php
- app/Mage.php
- app/code/core/Mage
- errors
- lib/Mage
- lib/Magento
- lib/Varien
Expand Down
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 ($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 {
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 ($this->_axisLabels as $idx => $labels) {
foreach (array_keys($this->_axisLabels) as $idx) {
if ($idx === 'x') {
/**
* Format date
Expand Down
6 changes: 2 additions & 4 deletions app/code/core/Mage/Adminhtml/Block/Page/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,8 @@ protected function _buildMenuArray(Varien_Simplexml_Element $parent, $path = '',

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

foreach ($parentArr as $key => $value) {
$last = $key;
}
if (isset($last)) {
$last = array_key_last($parentArr);
if (!is_null($last)) {
$parentArr[$last]['last'] = true;
}

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 ($data as $name => $value) {
foreach (array_keys($data) as $name) {
$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 ($this->_columns as $key => $value) {
foreach (array_keys($this->_columns) as $key) {
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 ($websites as $websiteId => $website) {
foreach (array_keys($websites) as $websiteId) {
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 ($stores as $storeId => $store) {
foreach (array_keys($stores) as $storeId) {
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 ($this->_children as $alias => $child) {
foreach (array_keys($this->_children) as $alias) {
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 ($formValues as $key => $value) {
foreach (array_keys($formValues) as $key) {
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 ($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)
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 ($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);
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 ($this->_tabPositions as $tabId => $position) {
foreach (array_keys($this->_tabPositions) as $tabId) {
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,10 +109,8 @@ protected function _buildMenuArray(?Varien_Simplexml_Element $parent = null, $pa

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

foreach ($parentArr as $key => $value) {
$last = $key;
}
if (isset($last)) {
$last = array_key_last($parentArr);
if (!is_null($last)) {
$parentArr[$last]['last'] = true;
}

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 ($data as $attribute => $value) {
foreach (array_keys($data) as $attribute) {
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 ($operations as $operation => $operationLabel) {
foreach (array_keys($operations) as $operation) {
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 ($attributes as $code => $label) {
foreach (array_keys($attributes) as $code) {
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 ($result as $k => $a) {
foreach (array_keys($result) as $k) {
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 ($price as $index => $value) {
foreach (array_keys($price) as $index) {
$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 ($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]);
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 ($checkout->getStepData() as $step => $data) {
foreach (array_keys($checkout->getStepData()) as $step) {
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 ($mapping as $key => $value) {
foreach (array_keys($mapping) as $key) {
$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 as $key => $value) {
foreach (array_keys($array) as $key) {
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 ($types as $type => $flag) {
foreach (array_keys($types) as $type) {
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 ($disallowedBlockConfig as $blockName => $value) {
foreach (array_keys($disallowedBlockConfig) as $blockName) {
$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 ($locales as $code => $active) {
foreach (array_keys($locales) as $code) {
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 ($debugData as $key => $value) {
foreach (array_keys($debugData) as $key) {
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 ($queryParams as $key => $value) {
foreach (array_keys($queryParams) as $key) {
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 ($queryParams as $key => $value) {
foreach (array_keys($queryParams) as $key) {
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 ($this->getAllowedAttributes($address) as $attributeCode => $attribute) {
foreach (array_keys($this->getAllowedAttributes($address)) as $attributeCode) {
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 ($this->getAllowedAttributes($address) as $attributeCode => $attribute) {
foreach (array_keys($this->getAllowedAttributes($address)) as $attributeCode) {
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 ($this->getAllowedAttributes($address) as $attributeCode => $attribute) {
foreach (array_keys($this->getAllowedAttributes($address)) as $attributeCode) {
$result[$attributeCode] = $address->getData($attributeCode);
}

Expand Down Expand Up @@ -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]);
}
Expand Down
Loading

0 comments on commit e20935e

Please sign in to comment.