From 3d7eaf63f2211a9e1a8defe8c29e8f6da889ab2e Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 22 Jul 2024 14:01:39 +0200 Subject: [PATCH 01/16] 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 30fb790667431d3485b7de99654b91b200a31dde Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 12 Aug 2024 02:30:28 +0200 Subject: [PATCH 02/16] Added rector to composer dev requirements --- composer.json | 1 + composer.lock | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index a63c329cfb3..3213b88d537 100644 --- a/composer.json +++ b/composer.json @@ -46,6 +46,7 @@ "phpmd/phpmd": "^2.13", "phpstan/phpstan": "^1.11", "phpunit/phpunit": "^9.5", + "rector/rector": "^1.2", "squizlabs/php_codesniffer": "^3.7", "symplify/vendor-patches": "^11.1" }, diff --git a/composer.lock b/composer.lock index 8fdf520b2b4..d218d024cc8 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "40e9d3cfc444bb72b7cf7754c735f694", + "content-hash": "9d58f2d5fb3e68e59321d8d00118b47f", "packages": [ { "name": "colinmollenhour/cache-backend-redis", @@ -4594,6 +4594,65 @@ ], "time": "2024-06-11T12:45:25+00:00" }, + { + "name": "rector/rector", + "version": "1.2.2", + "source": { + "type": "git", + "url": "https://github.com/rectorphp/rector.git", + "reference": "044e6364017882d1e346da8690eeabc154da5495" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/rectorphp/rector/zipball/044e6364017882d1e346da8690eeabc154da5495", + "reference": "044e6364017882d1e346da8690eeabc154da5495", + "shasum": "" + }, + "require": { + "php": "^7.2|^8.0", + "phpstan/phpstan": "^1.11" + }, + "conflict": { + "rector/rector-doctrine": "*", + "rector/rector-downgrade-php": "*", + "rector/rector-phpunit": "*", + "rector/rector-symfony": "*" + }, + "suggest": { + "ext-dom": "To manipulate phpunit.xml via the custom-rule command" + }, + "bin": [ + "bin/rector" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Instant Upgrade and Automated Refactoring of any PHP code", + "keywords": [ + "automation", + "dev", + "migration", + "refactoring" + ], + "support": { + "issues": "https://github.com/rectorphp/rector/issues", + "source": "https://github.com/rectorphp/rector/tree/1.2.2" + }, + "funding": [ + { + "url": "https://github.com/tomasvotruba", + "type": "github" + } + ], + "time": "2024-07-25T07:44:34+00:00" + }, { "name": "sebastian/cli-parser", "version": "1.0.2", From 3904b0f90df401b494d99f38e0d26230c9d3b415 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 12 Aug 2024 02:31:02 +0200 Subject: [PATCH 03/16] Updated DDEV command --- .ddev/commands/web/rector | 1 - 1 file changed, 1 deletion(-) diff --git a/.ddev/commands/web/rector b/.ddev/commands/web/rector index 05ec4689d58..1189ce12807 100755 --- a/.ddev/commands/web/rector +++ b/.ddev/commands/web/rector @@ -4,5 +4,4 @@ ## Usage: rector ## Example: ddev rector -cp -n vendor/sreichel/openmage-rector/rector.php rector.php php vendor/bin/rector process "$@" From f76521ed5be008421500e9fe5927da9ea4558898 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 12 Aug 2024 02:31:51 +0200 Subject: [PATCH 04/16] Added rector.php with first rule --- rector.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 rector.php diff --git a/rector.php b/rector.php new file mode 100644 index 00000000000..0b0d4c0ab7c --- /dev/null +++ b/rector.php @@ -0,0 +1,20 @@ +withPaths([ + __DIR__ . '/app', + __DIR__ . '/dev', + __DIR__ . '/errors', + __DIR__ . '/lib', + __DIR__ . '/pub', + __DIR__ . '/shell', + ]) + ->withSkipPath(__DIR__ . '/vendor') + ->withRules([ + SimplifyIfReturnBoolRector::class + ]); From 14468be8a670033c08239ad1fa8ea7895540fc86 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 12 Aug 2024 02:48:41 +0200 Subject: [PATCH 05/16] Updated labeler [skip ci] --- .github/labeler.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/labeler.yml b/.github/labeler.yml index 61d73ee8dba..40f137f80ec 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -897,6 +897,7 @@ dev/test/*, dev/phpunit*, dev/sonar*, + phpunit*, .github/workflows/phpunit.yml, .github/workflows/sonar.yml ] @@ -907,3 +908,10 @@ .ddev/*, .ddev/**/* ] + +'rector': + - changed-files: + - any-glob-to-any-file: [ + rector.php, + .github/workflows/rector.yml + ] From e788ea764ac1585315a9cde86db86c69d4610968 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 12 Aug 2024 02:49:22 +0200 Subject: [PATCH 06/16] Added rector to workflow --- .github/workflows/check-files.yml | 1 + .github/workflows/rector.yml | 37 +++++++++++++++++++++++++++++++ .github/workflows/workflow.yml | 8 +++++++ 3 files changed, 46 insertions(+) create mode 100644 .github/workflows/rector.yml diff --git a/.github/workflows/check-files.yml b/.github/workflows/check-files.yml index 1c463234dbd..9453a1de2eb 100644 --- a/.github/workflows/check-files.yml +++ b/.github/workflows/check-files.yml @@ -87,6 +87,7 @@ jobs: **phpcs** **php-cs-fixer** **phpstan** + rector.php dev/tests/ dev/phpunit* dev/sonar* diff --git a/.github/workflows/rector.yml b/.github/workflows/rector.yml new file mode 100644 index 00000000000..f5d1d18466c --- /dev/null +++ b/.github/workflows/rector.yml @@ -0,0 +1,37 @@ +name: Rector + +on: + workflow_call: + # Allow manually triggering the workflow. + workflow_dispatch: + +jobs: + rector: + name: Validation + runs-on: [ubuntu-latest] + + steps: + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 7.4 + + - name: Checkout code + uses: actions/checkout@v4 + + - name: Get composer cache directory + id: composer-cache + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: Cache dependencies + uses: actions/cache@v4 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install dependencies + run: composer install --prefer-dist --no-progress --ignore-platform-req=ext-* + + - name: Rector + run: php vendor/bin/rector fix --dry-run diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 68400099a6c..549eb04251d 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -106,6 +106,14 @@ jobs: if: needs.check.outputs.xml > 0 uses: ./.github/workflows/syntax-xml.yml + rector: + name: Rector + needs: [check, phpcs, php-cs-fixer] + if: | + needs.check.outputs.php > 0 || + needs.check.outputs.workflow > 0 + uses: ./.github/workflows/rector.yml + # DOES NOT run by default # runs on schedule or when worklfow or unit tests changed sonar: From 28f12c8b5009942098d9e2d8a9807c523cb2abeb Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 12 Aug 2024 02:51:12 +0200 Subject: [PATCH 07/16] 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 52c437a2709..58d3dfd945d 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 From 3fd569d98f0102ae0eb5c612839f0516108d5f80 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 12 Aug 2024 02:59:34 +0200 Subject: [PATCH 08/16] Typo --- .github/workflows/rector.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rector.yml b/.github/workflows/rector.yml index f5d1d18466c..9314962d057 100644 --- a/.github/workflows/rector.yml +++ b/.github/workflows/rector.yml @@ -34,4 +34,4 @@ jobs: run: composer install --prefer-dist --no-progress --ignore-platform-req=ext-* - name: Rector - run: php vendor/bin/rector fix --dry-run + run: php vendor/bin/rector process --dry-run From 954fcdde9eb132d75c22667b5d8f4687f649316d Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 12 Aug 2024 03:17:41 +0200 Subject: [PATCH 09/16] Applied rule --- app/code/core/Mage/Admin/Model/User.php | 6 +-- .../Block/Catalog/Category/Abstract.php | 5 +-- .../Mage/Adminhtml/Block/Catalog/Product.php | 5 +-- .../Catalog/Product/Edit/Tab/Inventory.php | 5 +-- .../Product/Edit/Tab/Price/Group/Abstract.php | 10 +---- .../Catalog/Product/Helper/Form/Gallery.php | 13 +----- .../Block/Customer/Edit/Tab/View.php | 10 +---- app/code/core/Mage/Adminhtml/Block/Denied.php | 5 +-- .../Adminhtml/Block/Notification/Toolbar.php | 9 +--- .../Adminhtml/Block/Sales/Items/Abstract.php | 15 ++----- .../Order/Create/Billing/Method/Form.php | 10 +---- .../Block/Sales/Order/Create/Comment.php | 5 +-- .../Block/Sales/Order/Invoice/Create/Form.php | 5 +-- .../Block/Sales/Order/Shipment/Packaging.php | 5 +-- .../Sales/Order/Shipment/Packaging/Grid.php | 5 +-- .../Adminhtml/Block/System/Config/Form.php | 10 +---- .../core/Mage/Adminhtml/Block/Widget/Grid.php | 10 +---- .../core/Mage/Adminhtml/Controller/Action.php | 14 ++---- .../Sales/Order/CreditmemoController.php | 8 +--- .../Sales/Order/InvoiceController.php | 15 ++----- .../Sales/Order/ShipmentController.php | 8 +--- .../Mage/Api2/Model/Acl/Global/Rule/Tree.php | 5 +-- .../Authorizenet/Model/Directpost/Session.php | 5 +-- .../Adminhtml/Sales/Order/Items/Renderer.php | 8 +--- .../Sales/Order/View/Items/Renderer.php | 8 +--- .../Catalog/Product/View/Type/Bundle.php | 5 +-- .../Block/Sales/Order/Items/Renderer.php | 8 +--- .../core/Mage/Bundle/Model/Product/Type.php | 7 +-- .../Model/Sales/Order/Pdf/Items/Abstract.php | 8 +--- .../Mage/Catalog/Block/Product/Abstract.php | 5 +-- .../core/Mage/Catalog/Block/Product/View.php | 5 +-- .../Catalog/Block/Product/View/Options.php | 5 +-- .../Block/Product/View/Type/Configurable.php | 11 +---- .../core/Mage/Catalog/Helper/Category.php | 6 +-- app/code/core/Mage/Catalog/Helper/Data.php | 5 +-- .../Mage/Catalog/Model/Product/Option/Api.php | 6 +-- .../Model/Product/Option/Type/File.php | 5 +-- .../Catalog/Model/Product/Type/Abstract.php | 10 +---- .../Mage/Catalog/Model/Resource/Category.php | 6 +-- .../Catalog/Model/Resource/Category/Tree.php | 5 +-- .../Mage/CatalogIndex/Model/Data/Abstract.php | 5 +-- .../Model/Indexer/Minimalprice.php | 6 +-- .../Mage/CatalogIndex/Model/Indexer/Price.php | 6 +-- .../CatalogIndex/Model/Indexer/Tierprice.php | 6 +-- .../CatalogInventory/Model/Stock/Item.php | 5 +-- .../Model/Resource/Search/Collection.php | 17 ++----- .../core/Mage/Centinel/Model/State/Jcb.php | 15 ++----- .../Mage/Centinel/Model/State/Mastercard.php | 15 ++----- .../core/Mage/Centinel/Model/State/Visa.php | 15 ++----- .../Checkout/Block/Cart/Item/Renderer.php | 5 +-- .../core/Mage/Checkout/Block/Cart/Totals.php | 5 +-- .../Mage/Checkout/Block/Onepage/Billing.php | 8 +--- .../core/Mage/Checkout/Model/Api/Resource.php | 10 +---- .../Mage/Checkout/Model/Cart/Payment/Api.php | 7 +-- .../core/Mage/Cms/Model/Resource/Block.php | 7 +-- .../core/Mage/Cms/Model/Resource/Page.php | 7 +-- .../Mage/Core/Controller/Request/Http.php | 5 +-- .../Controller/Varien/Router/Standard.php | 10 +---- app/code/core/Mage/Core/Helper/Abstract.php | 11 +---- app/code/core/Mage/Core/Helper/String.php | 5 +-- app/code/core/Mage/Core/Helper/Url.php | 8 +--- app/code/core/Mage/Core/Model/Cookie.php | 5 +-- .../core/Mage/Core/Model/Resource/Session.php | 6 +-- .../Core/Model/Session/Abstract/Varien.php | 9 +--- app/code/core/Mage/Core/Model/Url.php | 5 +-- .../Mage/Cron/Model/Resource/Schedule.php | 5 +-- .../Customer/Block/Account/Navigation.php | 5 +-- app/code/core/Mage/Customer/Model/Group.php | 5 +-- .../Mage/Customer/Model/Resource/Customer.php | 5 +-- .../core/Mage/Downloadable/Helper/Data.php | 5 +-- .../Mage/Downloadable/Model/Product/Type.php | 5 +-- .../core/Mage/Eav/Model/Entity/Abstract.php | 6 +-- .../Eav/Model/Entity/Attribute/Abstract.php | 16 ++----- app/code/core/Mage/Eav/Model/Form.php | 5 +-- app/code/core/Mage/Media/Model/File/Image.php | 6 +-- .../core/Mage/Newsletter/Model/Subscriber.php | 6 +-- .../core/Mage/Paygate/Model/Authorizenet.php | 5 +-- app/code/core/Mage/Payment/Block/Form/Cc.php | 5 +-- .../core/Mage/Payment/Model/Method/Cc.php | 8 +--- app/code/core/Mage/Paypal/Block/Iframe.php | 9 +--- app/code/core/Mage/Paypal/Model/Config.php | 18 ++------ app/code/core/Mage/Paypal/Model/Direct.php | 5 +-- app/code/core/Mage/Paypal/Model/Express.php | 12 +---- .../core/Mage/Paypal/Model/Payflowlink.php | 5 +-- .../core/Mage/Paypal/Model/Payflowpro.php | 10 +---- app/code/core/Mage/Paypal/Model/Standard.php | 5 +-- app/code/core/Mage/PaypalUk/Model/Direct.php | 5 +-- .../core/Mage/ProductAlert/Block/Price.php | 6 +-- app/code/core/Mage/Rss/Helper/Order.php | 5 +-- .../core/Mage/Sales/Controller/Abstract.php | 8 +--- app/code/core/Mage/Sales/Helper/Reorder.php | 5 +-- .../core/Mage/Sales/Model/Api/Resource.php | 10 +---- app/code/core/Mage/Sales/Model/Order.php | 45 +++++-------------- .../Mage/Sales/Model/Order/Creditmemo.php | 8 +--- .../Sales/Model/Order/Creditmemo/Item.php | 8 +--- .../core/Mage/Sales/Model/Order/Invoice.php | 5 +-- .../Mage/Sales/Model/Order/Invoice/Item.php | 5 +-- app/code/core/Mage/Sales/Model/Order/Item.php | 18 ++------ .../Sales/Model/Order/Payment/Transaction.php | 5 +-- .../core/Mage/Sales/Model/Quote/Address.php | 5 +-- .../Model/Quote/Address/Total/Abstract.php | 5 +-- app/code/core/Mage/Sales/Model/Quote/Item.php | 5 +-- .../Mage/Sales/Model/Quote/Item/Abstract.php | 15 ++----- .../core/Mage/Sales/Model/Resource/Quote.php | 6 +-- .../Sales/controllers/GuestController.php | 5 +-- .../Mage/SalesRule/Model/Resource/Coupon.php | 6 +-- .../Tax/Model/Sales/Total/Quote/Shipping.php | 5 +-- .../Tax/Model/Sales/Total/Quote/Subtotal.php | 10 +---- .../Widget/Instance/Edit/Chooser/Block.php | 5 +-- .../Widget/Instance/Edit/Chooser/Layout.php | 5 +-- app/code/core/Mage/Wishlist/Helper/Data.php | 5 +-- app/code/core/Mage/Wishlist/Model/Item.php | 10 +---- .../Mage/Adminhtml/Test/Block/Widget/Grid.php | 5 +-- .../app/Mage/Paypal/Test/Block/Login.php | 6 +-- .../app/Mage/Paypal/Test/Block/NewLogin.php | 6 +-- lib/Mage/Archive.php | 10 +---- lib/Magento/Db/Object/Trigger.php | 7 +-- lib/Varien/Data/Form/Element/Editor.php | 5 +-- lib/Varien/Db/Adapter/Pdo/Mysql.php | 6 +-- lib/Varien/Object.php | 5 +-- 120 files changed, 187 insertions(+), 738 deletions(-) diff --git a/app/code/core/Mage/Admin/Model/User.php b/app/code/core/Mage/Admin/Model/User.php index 10ce60260a1..8cbf0913b35 100644 --- a/app/code/core/Mage/Admin/Model/User.php +++ b/app/code/core/Mage/Admin/Model/User.php @@ -696,11 +696,7 @@ public function isResetPasswordLinkTokenExpired() } $hoursDifference = floor(($currentTimestamp - $tokenTimestamp) / (60 * 60)); - if ($hoursDifference >= $tokenExpirationPeriod) { - return true; - } - - return false; + return $hoursDifference >= $tokenExpirationPeriod; } /** diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php index 94ce3400af7..1b483c21676 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php @@ -55,10 +55,7 @@ public function getCategoryPath() public function hasStoreRootCategory() { $root = $this->getRoot(); - if ($root && $root->getId()) { - return true; - } - return false; + return $root && $root->getId(); } public function getStore() diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product.php index 8d1efdf0c67..a25606c3cd6 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product.php @@ -73,9 +73,6 @@ public function getGridHtml() */ public function isSingleStoreMode() { - if (!Mage::app()->isSingleStoreMode()) { - return false; - } - return true; + return Mage::app()->isSingleStoreMode(); } } diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Inventory.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Inventory.php index 458fecf1609..897529b6341 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Inventory.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Inventory.php @@ -112,10 +112,7 @@ public function isReadonly() public function isNew() { - if ($this->getProduct()->getId()) { - return false; - } - return true; + return !$this->getProduct()->getId(); } public function getFieldSuffix() diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Group/Abstract.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Group/Abstract.php index e189e7362be..6c863d731ba 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Group/Abstract.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Group/Abstract.php @@ -309,10 +309,7 @@ public function isScopeGlobal() */ public function isShowWebsiteColumn() { - if ($this->isScopeGlobal() || Mage::app()->isSingleStoreMode()) { - return false; - } - return true; + return !($this->isScopeGlobal() || Mage::app()->isSingleStoreMode()); } /** @@ -322,9 +319,6 @@ public function isShowWebsiteColumn() */ public function isAllowChangeWebsite() { - if (!$this->isShowWebsiteColumn() || $this->getProduct()->getStoreId()) { - return false; - } - return true; + return !(!$this->isShowWebsiteColumn() || $this->getProduct()->getStoreId()); } } diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Gallery.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Gallery.php index 4f865355dc8..459a926560c 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Gallery.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Gallery.php @@ -56,11 +56,7 @@ public function getLabel() */ public function canDisplayUseDefault($attribute) { - if (!$attribute->isScopeGlobal() && $this->getDataObject()->getStoreId()) { - return true; - } - - return false; + return !$attribute->isScopeGlobal() && $this->getDataObject()->getStoreId(); } /** @@ -161,12 +157,7 @@ public function getAttributeReadonly($attribute) if (is_object($attribute)) { $attribute = $attribute->getAttributeCode(); } - - if ($this->getDataObject()->isLockedAttribute($attribute)) { - return true; - } - - return false; + return $this->getDataObject()->isLockedAttribute($attribute); } public function toHtml() diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View.php b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View.php index a9b62ec3161..9348e97b039 100644 --- a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View.php +++ b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View.php @@ -224,10 +224,7 @@ public function getTabTitle() */ public function canShowTab() { - if (Mage::registry('current_customer')->getId()) { - return true; - } - return false; + return (bool) Mage::registry('current_customer')->getId(); } /** @@ -235,10 +232,7 @@ public function canShowTab() */ public function isHidden() { - if (Mage::registry('current_customer')->getId()) { - return false; - } - return true; + return !Mage::registry('current_customer')->getId(); } /** diff --git a/app/code/core/Mage/Adminhtml/Block/Denied.php b/app/code/core/Mage/Adminhtml/Block/Denied.php index ced0e58af99..f147ca04275 100644 --- a/app/code/core/Mage/Adminhtml/Block/Denied.php +++ b/app/code/core/Mage/Adminhtml/Block/Denied.php @@ -22,9 +22,6 @@ class Mage_Adminhtml_Block_Denied extends Mage_Adminhtml_Block_Template public function hasAvailaleResources() { $user = Mage::getSingleton('admin/session')->getUser(); - if ($user && $user->hasAvailableResources()) { - return true; - } - return false; + return $user && $user->hasAvailableResources(); } } diff --git a/app/code/core/Mage/Adminhtml/Block/Notification/Toolbar.php b/app/code/core/Mage/Adminhtml/Block/Notification/Toolbar.php index 3d1e245e68a..6c84ef7a53a 100644 --- a/app/code/core/Mage/Adminhtml/Block/Notification/Toolbar.php +++ b/app/code/core/Mage/Adminhtml/Block/Notification/Toolbar.php @@ -53,13 +53,8 @@ public function isShow() if ($this->getRequest()->getControllerName() === 'notification') { return false; } - if ($this->getCriticalCount() == 0 && $this->getMajorCount() == 0 && $this->getMinorCount() == 0 - && $this->getNoticeCount() == 0 - ) { - return false; - } - - return true; + return !($this->getCriticalCount() == 0 && $this->getMajorCount() == 0 && $this->getMinorCount() == 0 + && $this->getNoticeCount() == 0); } /** diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Items/Abstract.php b/app/code/core/Mage/Adminhtml/Block/Sales/Items/Abstract.php index e60828bc845..2b17aa249ec 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Items/Abstract.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Items/Abstract.php @@ -562,10 +562,7 @@ public function canShipPartially($order = null) $order = Mage::registry('current_shipment')->getOrder(); } $value = $order->getCanShipPartially(); - if (!is_null($value) && !$value) { - return false; - } - return true; + return !(!is_null($value) && !$value); } /** @@ -580,17 +577,11 @@ public function canShipPartiallyItem($order = null) $order = Mage::registry('current_shipment')->getOrder(); } $value = $order->getCanShipPartiallyItem(); - if (!is_null($value) && !$value) { - return false; - } - return true; + return !(!is_null($value) && !$value); } public function isShipmentRegular() { - if (!$this->canShipPartiallyItem() || !$this->canShipPartially()) { - return false; - } - return true; + return !(!$this->canShipPartiallyItem() || !$this->canShipPartially()); } } diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Billing/Method/Form.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Billing/Method/Form.php index a75ce46685b..3035c854fa9 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Billing/Method/Form.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Billing/Method/Form.php @@ -40,10 +40,7 @@ protected function _canUseMethod($method) public function hasMethods() { $methods = $this->getMethods(); - if (is_array($methods) && count($methods)) { - return true; - } - return false; + return is_array($methods) && count($methods); } /** @@ -86,9 +83,6 @@ public function hasSsCardType() { $availableTypes = explode(',', $this->getQuote()->getPayment()->getMethod()->getConfigData('cctypes')); $ssPresenations = array_intersect(['SS', 'SM', 'SO'], $availableTypes); - if ($availableTypes && count($ssPresenations) > 0) { - return true; - } - return false; + return $availableTypes && count($ssPresenations) > 0; } } diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Comment.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Comment.php index c9a6c69eaf5..e4f7f3426d4 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Comment.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Comment.php @@ -53,9 +53,6 @@ public function getCommentNote() public function getNoteNotify() { $notify = $this->getQuote()->getCustomerNoteNotify(); - if (is_null($notify) || $notify) { - return true; - } - return false; + return is_null($notify) || $notify; } } diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/Create/Form.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/Create/Form.php index 49242734b60..ad3a7a82b21 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/Create/Form.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/Create/Form.php @@ -102,10 +102,7 @@ public function hasInvoiceShipmentTypeMismatch() public function canShipPartiallyItem() { $value = $this->getOrder()->getCanShipPartiallyItem(); - if (!is_null($value) && !$value) { - return false; - } - return true; + return !(!is_null($value) && !$value); } /** diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Packaging.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Packaging.php index b7443c55e43..7e4662b8f00 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Packaging.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Packaging.php @@ -231,10 +231,7 @@ public function displayCustomsValue() $storeId ); $recipientAddressCountryCode = $address->getCountryId(); - if ($shipperAddressCountryCode != $recipientAddressCountryCode) { - return true; - } - return false; + return $shipperAddressCountryCode != $recipientAddressCountryCode; } /** diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Packaging/Grid.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Packaging/Grid.php index b1e8da187a5..3c39888da52 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Packaging/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Packaging/Grid.php @@ -68,10 +68,7 @@ public function displayCustomsValue() $storeId ); $recipientAddressCountryCode = $address->getCountryId(); - if ($shipperAddressCountryCode != $recipientAddressCountryCode) { - return true; - } - return false; + return $shipperAddressCountryCode != $recipientAddressCountryCode; } /** diff --git a/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php b/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php index a38a7d8db43..3bc9d13909f 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php @@ -565,10 +565,7 @@ public function canUseDefaultValue($field) if ($this->getScope() == self::SCOPE_STORES && $field) { return true; } - if ($this->getScope() == self::SCOPE_WEBSITES && $field) { - return true; - } - return false; + return $this->getScope() == self::SCOPE_WEBSITES && $field; } /** @@ -577,10 +574,7 @@ public function canUseDefaultValue($field) */ public function canUseWebsiteValue($field) { - if ($this->getScope() == self::SCOPE_STORES && $field) { - return true; - } - return false; + return $this->getScope() == self::SCOPE_STORES && $field; } /** diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php b/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php index af36a237924..3150f4b00d9 100644 --- a/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php @@ -1395,10 +1395,7 @@ public function getExcel($filename = '') */ public function canDisplayContainer() { - if ($this->getRequest()->getQuery('ajax')) { - return false; - } - return true; + return !$this->getRequest()->getQuery('ajax'); } /** @@ -1817,10 +1814,7 @@ public function shouldRenderCell($item, $column) if ($this->isColumnGrouped($column) && $item->getIsEmpty()) { return true; } - if (!$item->getIsEmpty()) { - return true; - } - return false; + return !$item->getIsEmpty(); } /** diff --git a/app/code/core/Mage/Adminhtml/Controller/Action.php b/app/code/core/Mage/Adminhtml/Controller/Action.php index ec3fd52958d..20b819f4fad 100644 --- a/app/code/core/Mage/Adminhtml/Controller/Action.php +++ b/app/code/core/Mage/Adminhtml/Controller/Action.php @@ -395,13 +395,8 @@ protected function _validateSecretKey() if (is_array($this->_publicActions) && in_array($this->getRequest()->getActionName(), $this->_publicActions)) { return true; } - - if (!($secretKey = $this->getRequest()->getParam(Mage_Adminhtml_Model_Url::SECRET_KEY_PARAM_NAME, null)) - || !hash_equals(Mage::getSingleton('adminhtml/url')->getSecretKey(), $secretKey) - ) { - return false; - } - return true; + return !(!($secretKey = $this->getRequest()->getParam(Mage_Adminhtml_Model_Url::SECRET_KEY_PARAM_NAME, null)) + || !hash_equals(Mage::getSingleton('adminhtml/url')->getSecretKey(), $secretKey)); } /** @@ -456,10 +451,7 @@ protected function _setForcedFormKeyActions($actionNames) protected function _validateRequestParam($param, $pattern = '') { $pattern = empty($pattern) ? '/^[a-z0-9\-\_\/]*$/si' : $pattern; - if (preg_match($pattern, $param)) { - return true; - } - return false; + return (bool) preg_match($pattern, $param); } /** diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreditmemoController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreditmemoController.php index 8ad63eb97ae..0948ae00907 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreditmemoController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreditmemoController.php @@ -429,13 +429,9 @@ protected function _needToAddDummy($item, $qtys) } if ($item->getParentItem()) { - if (isset($qtys[$item->getParentItem()->getId()]) + return isset($qtys[$item->getParentItem()->getId()]) && isset($qtys[$item->getParentItem()->getId()]['qty']) - && $qtys[$item->getParentItem()->getId()]['qty'] > 0 - ) { - return true; - } - return false; + && $qtys[$item->getParentItem()->getId()]['qty'] > 0; } return false; diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/InvoiceController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/InvoiceController.php index f382469a91c..15dbf0f3f28 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/InvoiceController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/InvoiceController.php @@ -420,10 +420,7 @@ protected function _needToAddDummy($item, $qtys) } if ($item->getParentItem()) { - if (isset($qtys[$item->getParentItem()->getId()]) && $qtys[$item->getParentItem()->getId()] > 0) { - return true; - } - return false; + return isset($qtys[$item->getParentItem()->getId()]) && $qtys[$item->getParentItem()->getId()] > 0; } return false; @@ -450,20 +447,14 @@ protected function _needToAddDummyForShipment($item, $qtys) return true; } } - if ($item->isShipSeparately()) { - return true; - } - return false; + return $item->isShipSeparately(); } if ($item->getParentItem()) { if ($item->getIsVirtual()) { return false; } - if (isset($qtys[$item->getParentItem()->getId()]) && $qtys[$item->getParentItem()->getId()] > 0) { - return true; - } - return false; + return isset($qtys[$item->getParentItem()->getId()]) && $qtys[$item->getParentItem()->getId()] > 0; } return false; diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php index dd803294b5a..29c927c1149 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php @@ -478,12 +478,8 @@ protected function _needToAddDummy($item, $qtys) if ($item->getIsVirtual()) { return false; } - if ((isset($qtys[$item->getParentItem()->getId()]) && $qtys[$item->getParentItem()->getId()] > 0) - || (!isset($qtys[$item->getParentItem()->getId()]) && $item->getParentItem()->getQtyToShip()) - ) { - return true; - } - return false; + return (isset($qtys[$item->getParentItem()->getId()]) && $qtys[$item->getParentItem()->getId()] > 0) + || (!isset($qtys[$item->getParentItem()->getId()]) && $item->getParentItem()->getQtyToShip()); } return false; diff --git a/app/code/core/Mage/Api2/Model/Acl/Global/Rule/Tree.php b/app/code/core/Mage/Api2/Model/Acl/Global/Rule/Tree.php index cc657634070..d64148abcf5 100644 --- a/app/code/core/Mage/Api2/Model/Acl/Global/Rule/Tree.php +++ b/app/code/core/Mage/Api2/Model/Acl/Global/Rule/Tree.php @@ -415,10 +415,7 @@ protected function _addOperations(&$item, Varien_Simplexml_Element $node, $name) } $item[self::NAME_CHILDREN][] = $subItem; } - if (!$cnt) { - return false; - } - return true; + return (bool) $cnt; } /** diff --git a/app/code/core/Mage/Authorizenet/Model/Directpost/Session.php b/app/code/core/Mage/Authorizenet/Model/Directpost/Session.php index c8964a4627a..4c856e12553 100644 --- a/app/code/core/Mage/Authorizenet/Model/Directpost/Session.php +++ b/app/code/core/Mage/Authorizenet/Model/Directpost/Session.php @@ -72,9 +72,6 @@ public function removeCheckoutOrderIncrementId($orderIncrementId) public function isCheckoutOrderIncrementIdExist($orderIncrementId) { $orderIncIds = $this->getDirectPostOrderIncrementIds(); - if (is_array($orderIncIds) && isset($orderIncIds[$orderIncrementId])) { - return true; - } - return false; + return is_array($orderIncIds) && isset($orderIncIds[$orderIncrementId]); } } diff --git a/app/code/core/Mage/Bundle/Block/Adminhtml/Sales/Order/Items/Renderer.php b/app/code/core/Mage/Bundle/Block/Adminhtml/Sales/Order/Items/Renderer.php index 65e49b59c28..3526876b3f6 100644 --- a/app/code/core/Mage/Bundle/Block/Adminhtml/Sales/Order/Items/Renderer.php +++ b/app/code/core/Mage/Bundle/Block/Adminhtml/Sales/Order/Items/Renderer.php @@ -213,11 +213,7 @@ public function getValueHtml($item) */ public function canShowPriceInfo($item) { - if (($item->getOrderItem()->getParentItem() && $this->isChildCalculated()) - || (!$item->getOrderItem()->getParentItem() && !$this->isChildCalculated()) - ) { - return true; - } - return false; + return ($item->getOrderItem()->getParentItem() && $this->isChildCalculated()) + || (!$item->getOrderItem()->getParentItem() && !$this->isChildCalculated()); } } diff --git a/app/code/core/Mage/Bundle/Block/Adminhtml/Sales/Order/View/Items/Renderer.php b/app/code/core/Mage/Bundle/Block/Adminhtml/Sales/Order/View/Items/Renderer.php index 58f8390e5c0..42d93c31c32 100644 --- a/app/code/core/Mage/Bundle/Block/Adminhtml/Sales/Order/View/Items/Renderer.php +++ b/app/code/core/Mage/Bundle/Block/Adminhtml/Sales/Order/View/Items/Renderer.php @@ -164,11 +164,7 @@ public function getValueHtml($item) */ public function canShowPriceInfo($item) { - if (($item->getParentItem() && $this->isChildCalculated()) - || (!$item->getParentItem() && !$this->isChildCalculated()) - ) { - return true; - } - return false; + return ($item->getParentItem() && $this->isChildCalculated()) + || (!$item->getParentItem() && !$this->isChildCalculated()); } } diff --git a/app/code/core/Mage/Bundle/Block/Catalog/Product/View/Type/Bundle.php b/app/code/core/Mage/Bundle/Block/Catalog/Product/View/Type/Bundle.php index 97b5b47f658..73ca64c96ea 100644 --- a/app/code/core/Mage/Bundle/Block/Catalog/Product/View/Type/Bundle.php +++ b/app/code/core/Mage/Bundle/Block/Catalog/Product/View/Type/Bundle.php @@ -89,10 +89,7 @@ public function getOptions() public function hasOptions() { $this->getOptions(); - if (empty($this->_options) || !$this->getProduct()->isSalable()) { - return false; - } - return true; + return !(empty($this->_options) || !$this->getProduct()->isSalable()); } /** diff --git a/app/code/core/Mage/Bundle/Block/Sales/Order/Items/Renderer.php b/app/code/core/Mage/Bundle/Block/Sales/Order/Items/Renderer.php index 40f501cd4b4..f327d4a2f10 100644 --- a/app/code/core/Mage/Bundle/Block/Sales/Order/Items/Renderer.php +++ b/app/code/core/Mage/Bundle/Block/Sales/Order/Items/Renderer.php @@ -176,11 +176,7 @@ public function getChilds($item) */ public function canShowPriceInfo($item) { - if (($item->getOrderItem()->getParentItem() && $this->isChildCalculated()) - || (!$item->getOrderItem()->getParentItem() && !$this->isChildCalculated()) - ) { - return true; - } - return false; + return ($item->getOrderItem()->getParentItem() && $this->isChildCalculated()) + || (!$item->getOrderItem()->getParentItem() && !$this->isChildCalculated()); } } diff --git a/app/code/core/Mage/Bundle/Model/Product/Type.php b/app/code/core/Mage/Bundle/Model/Product/Type.php index d72b304e9d6..5fd82c69a4c 100644 --- a/app/code/core/Mage/Bundle/Model/Product/Type.php +++ b/app/code/core/Mage/Bundle/Model/Product/Type.php @@ -873,12 +873,7 @@ public function hasOptions($product = null) $this->setStoreFilter($product->getStoreId(), $product); $optionIds = $this->getOptionsCollection($product)->getAllIds(); $collection = $this->getSelectionsCollection($optionIds, $product); - - if (count($collection) > 0 || $product->getOptions()) { - return true; - } - - return false; + return count($collection) > 0 || $product->getOptions(); } /** diff --git a/app/code/core/Mage/Bundle/Model/Sales/Order/Pdf/Items/Abstract.php b/app/code/core/Mage/Bundle/Model/Sales/Order/Pdf/Items/Abstract.php index 62cb3dfa7fc..169cb8d9bfc 100644 --- a/app/code/core/Mage/Bundle/Model/Sales/Order/Pdf/Items/Abstract.php +++ b/app/code/core/Mage/Bundle/Model/Sales/Order/Pdf/Items/Abstract.php @@ -257,11 +257,7 @@ public function getValueHtml($item) */ public function canShowPriceInfo($item) { - if (($item->getOrderItem()->getParentItem() && $this->isChildCalculated()) - || (!$item->getOrderItem()->getParentItem() && !$this->isChildCalculated()) - ) { - return true; - } - return false; + return ($item->getOrderItem()->getParentItem() && $this->isChildCalculated()) + || (!$item->getOrderItem()->getParentItem() && !$this->isChildCalculated()); } } diff --git a/app/code/core/Mage/Catalog/Block/Product/Abstract.php b/app/code/core/Mage/Catalog/Block/Product/Abstract.php index d156b682def..8be957cc674 100644 --- a/app/code/core/Mage/Catalog/Block/Product/Abstract.php +++ b/app/code/core/Mage/Catalog/Block/Product/Abstract.php @@ -513,10 +513,7 @@ public function getProductUrl($product, $additional = []) */ public function hasProductUrl($product) { - if ($product->getVisibleInSiteVisibilities()) { - return true; - } - return false; + return (bool) $product->getVisibleInSiteVisibilities(); } /** diff --git a/app/code/core/Mage/Catalog/Block/Product/View.php b/app/code/core/Mage/Catalog/Block/Product/View.php index 23e1cab33c5..25fb7f301e2 100644 --- a/app/code/core/Mage/Catalog/Block/Product/View.php +++ b/app/code/core/Mage/Catalog/Block/Product/View.php @@ -158,10 +158,7 @@ public function getJsonConfig() */ public function hasOptions() { - if ($this->getProduct()->getTypeInstance(true)->hasOptions($this->getProduct())) { - return true; - } - return false; + return $this->getProduct()->getTypeInstance(true)->hasOptions($this->getProduct()); } /** diff --git a/app/code/core/Mage/Catalog/Block/Product/View/Options.php b/app/code/core/Mage/Catalog/Block/Product/View/Options.php index ab9cecd8499..e5f65f7d454 100644 --- a/app/code/core/Mage/Catalog/Block/Product/View/Options.php +++ b/app/code/core/Mage/Catalog/Block/Product/View/Options.php @@ -122,10 +122,7 @@ public function getOptions() */ public function hasOptions() { - if ($this->getOptions()) { - return true; - } - return false; + return (bool) $this->getOptions(); } /** diff --git a/app/code/core/Mage/Catalog/Block/Product/View/Type/Configurable.php b/app/code/core/Mage/Catalog/Block/Product/View/Type/Configurable.php index 6201403b42a..c9a4007e692 100644 --- a/app/code/core/Mage/Catalog/Block/Product/View/Type/Configurable.php +++ b/app/code/core/Mage/Catalog/Block/Product/View/Type/Configurable.php @@ -288,11 +288,7 @@ public function getJsonConfig() */ protected function _validateAttributeValue($attributeId, &$value, &$options) { - if (isset($options[$attributeId][$value['value_index']])) { - return true; - } - - return false; + return isset($options[$attributeId][$value['value_index']]); } /** @@ -303,10 +299,7 @@ protected function _validateAttributeValue($attributeId, &$value, &$options) */ protected function _validateAttributeInfo(&$info) { - if (count($info['options']) > 0) { - return true; - } - return false; + return count($info['options']) > 0; } /** diff --git a/app/code/core/Mage/Catalog/Helper/Category.php b/app/code/core/Mage/Catalog/Helper/Category.php index 5ec837a85b1..4ac39126e78 100644 --- a/app/code/core/Mage/Catalog/Helper/Category.php +++ b/app/code/core/Mage/Catalog/Helper/Category.php @@ -112,11 +112,7 @@ public function canShow($category) if (!$category->getIsActive()) { return false; } - if (!$category->isInRootCategoryList()) { - return false; - } - - return true; + return (bool) $category->isInRootCategoryList(); } /** diff --git a/app/code/core/Mage/Catalog/Helper/Data.php b/app/code/core/Mage/Catalog/Helper/Data.php index 79b39545d28..b8a122021a6 100644 --- a/app/code/core/Mage/Catalog/Helper/Data.php +++ b/app/code/core/Mage/Catalog/Helper/Data.php @@ -121,10 +121,7 @@ protected function _isCategoryLink($categoryId) if ($this->getProduct()) { return true; } - if ($categoryId != $this->getCategory()->getId()) { - return true; - } - return false; + return $categoryId != $this->getCategory()->getId(); } /** diff --git a/app/code/core/Mage/Catalog/Model/Product/Option/Api.php b/app/code/core/Mage/Catalog/Model/Product/Option/Api.php index a73be8f33cd..1b926a49d95 100644 --- a/app/code/core/Mage/Catalog/Model/Product/Option/Api.php +++ b/app/code/core/Mage/Catalog/Model/Product/Option/Api.php @@ -305,10 +305,6 @@ protected function _isTypeAllowed($type) foreach ($this->types() as $optionType) { $allowedTypes[] = $optionType['value']; } - - if (!in_array($type, $allowedTypes)) { - return false; - } - return true; + return in_array($type, $allowedTypes); } } diff --git a/app/code/core/Mage/Catalog/Model/Product/Option/Type/File.php b/app/code/core/Mage/Catalog/Model/Product/Option/Type/File.php index 5b08b5ca993..6af6fec5bad 100644 --- a/app/code/core/Mage/Catalog/Model/Product/Option/Type/File.php +++ b/app/code/core/Mage/Catalog/Model/Product/Option/Type/File.php @@ -773,10 +773,7 @@ protected function _isImage($fileInfo) return false; } $imageInfo = getimagesize($fileInfo); - if (!$imageInfo) { - return false; - } - return true; + return (bool) $imageInfo; } /** diff --git a/app/code/core/Mage/Catalog/Model/Product/Type/Abstract.php b/app/code/core/Mage/Catalog/Model/Product/Type/Abstract.php index 5773d9f4cf0..638014be90b 100644 --- a/app/code/core/Mage/Catalog/Model/Product/Type/Abstract.php +++ b/app/code/core/Mage/Catalog/Model/Product/Type/Abstract.php @@ -778,10 +778,7 @@ public function hasOptions($product = null) if ($this->getProduct($product)->getHasOptions()) { return true; } - if ($this->getProduct($product)->isRecurring()) { - return true; - } - return false; + return $this->getProduct($product)->isRecurring(); } /** @@ -809,10 +806,7 @@ public function updateQtyOption($options, Varien_Object $option, $value, $produc */ public function hasRequiredOptions($product = null) { - if ($this->getProduct($product)->getRequiredOptions()) { - return true; - } - return false; + return $this->getProduct($product)->getRequiredOptions(); } /** diff --git a/app/code/core/Mage/Catalog/Model/Resource/Category.php b/app/code/core/Mage/Catalog/Model/Resource/Category.php index c3201921c2f..af3dfe2c2a9 100644 --- a/app/code/core/Mage/Catalog/Model/Resource/Category.php +++ b/app/code/core/Mage/Catalog/Model/Resource/Category.php @@ -763,11 +763,7 @@ public function isForbiddenToDelete($categoryId) ->from($this->getTable('core/store_group'), ['group_id']) ->where('root_category_id = :root_category_id'); $result = $this->_getReadAdapter()->fetchOne($select, ['root_category_id' => $categoryId]); - - if ($result) { - return true; - } - return false; + return (bool) $result; } /** diff --git a/app/code/core/Mage/Catalog/Model/Resource/Category/Tree.php b/app/code/core/Mage/Catalog/Model/Resource/Category/Tree.php index 6ee9bafc0d9..e432e41916a 100644 --- a/app/code/core/Mage/Catalog/Model/Resource/Category/Tree.php +++ b/app/code/core/Mage/Catalog/Model/Resource/Category/Tree.php @@ -317,10 +317,7 @@ protected function _getInactiveItemIds($collection, $storeId) */ protected function _getItemIsActive($id) { - if (!in_array($id, $this->_inactiveItems)) { - return true; - } - return false; + return !in_array($id, $this->_inactiveItems); } /** diff --git a/app/code/core/Mage/CatalogIndex/Model/Data/Abstract.php b/app/code/core/Mage/CatalogIndex/Model/Data/Abstract.php index 2b9c65102de..3f37fb8a252 100644 --- a/app/code/core/Mage/CatalogIndex/Model/Data/Abstract.php +++ b/app/code/core/Mage/CatalogIndex/Model/Data/Abstract.php @@ -270,10 +270,7 @@ protected function _getLinkSettings() */ public function areChildrenIndexable($type) { - if (!$this->_haveChildren || !isset($this->_haveChildren[$type]) || !$this->_haveChildren[$type]) { - return false; - } - return true; + return !(!$this->_haveChildren || !isset($this->_haveChildren[$type]) || !$this->_haveChildren[$type]); } /** diff --git a/app/code/core/Mage/CatalogIndex/Model/Indexer/Minimalprice.php b/app/code/core/Mage/CatalogIndex/Model/Indexer/Minimalprice.php index 07fd53d56d0..0cc492244db 100644 --- a/app/code/core/Mage/CatalogIndex/Model/Indexer/Minimalprice.php +++ b/app/code/core/Mage/CatalogIndex/Model/Indexer/Minimalprice.php @@ -149,10 +149,6 @@ public function isAttributeIdUsed() */ protected function _isAttributeIndexable(Mage_Eav_Model_Entity_Attribute_Abstract $attribute) { - if ($attribute->getAttributeCode() != 'minimal_price') { - return false; - } - - return true; + return $attribute->getAttributeCode() == 'minimal_price'; } } diff --git a/app/code/core/Mage/CatalogIndex/Model/Indexer/Price.php b/app/code/core/Mage/CatalogIndex/Model/Indexer/Price.php index 04715b9e455..58afd70dc34 100644 --- a/app/code/core/Mage/CatalogIndex/Model/Indexer/Price.php +++ b/app/code/core/Mage/CatalogIndex/Model/Indexer/Price.php @@ -92,11 +92,7 @@ protected function _isAttributeIndexable(Mage_Eav_Model_Entity_Attribute_Abstrac if ($attribute->getAttributeCode() == 'tier_price') { return false; } - if ($attribute->getAttributeCode() == 'minimal_price') { - return false; - } - - return true; + return $attribute->getAttributeCode() != 'minimal_price'; } /** diff --git a/app/code/core/Mage/CatalogIndex/Model/Indexer/Tierprice.php b/app/code/core/Mage/CatalogIndex/Model/Indexer/Tierprice.php index f3f4fd3edb7..5fd7f9b5994 100644 --- a/app/code/core/Mage/CatalogIndex/Model/Indexer/Tierprice.php +++ b/app/code/core/Mage/CatalogIndex/Model/Indexer/Tierprice.php @@ -110,11 +110,7 @@ public function createIndexData(Mage_Catalog_Model_Product $object, ?Mage_Eav_Mo */ protected function _isAttributeIndexable(Mage_Eav_Model_Entity_Attribute_Abstract $attribute) { - if ($attribute->getAttributeCode() != 'tier_price') { - return false; - } - - return true; + return $attribute->getAttributeCode() == 'tier_price'; } /** diff --git a/app/code/core/Mage/CatalogInventory/Model/Stock/Item.php b/app/code/core/Mage/CatalogInventory/Model/Stock/Item.php index abc109a3bd4..8e4f033f67c 100644 --- a/app/code/core/Mage/CatalogInventory/Model/Stock/Item.php +++ b/app/code/core/Mage/CatalogInventory/Model/Stock/Item.php @@ -794,10 +794,7 @@ public function verifyStock($qty = null) if ($qty === null) { $qty = $this->getQty(); } - if ($this->getBackorders() == Mage_CatalogInventory_Model_Stock::BACKORDERS_NO && $qty <= $this->getMinQty()) { - return false; - } - return true; + return !($this->getBackorders() == Mage_CatalogInventory_Model_Stock::BACKORDERS_NO && $qty <= $this->getMinQty()); } /** diff --git a/app/code/core/Mage/CatalogSearch/Model/Resource/Search/Collection.php b/app/code/core/Mage/CatalogSearch/Model/Resource/Search/Collection.php index 7862c441895..46fefd19ffd 100644 --- a/app/code/core/Mage/CatalogSearch/Model/Resource/Search/Collection.php +++ b/app/code/core/Mage/CatalogSearch/Model/Resource/Search/Collection.php @@ -74,14 +74,10 @@ protected function _getAttributesCollection() */ protected function _isAttributeTextAndSearchable($attribute) { - if (($attribute->getIsSearchable() + return ($attribute->getIsSearchable() && !in_array($attribute->getFrontendInput(), ['select', 'multiselect'])) && (in_array($attribute->getBackendType(), ['varchar', 'text']) - || $attribute->getBackendType() == 'static') - ) { - return true; - } - return false; + || $attribute->getBackendType() == 'static'); } /** @@ -92,13 +88,8 @@ protected function _isAttributeTextAndSearchable($attribute) */ protected function _hasAttributeOptionsAndSearchable($attribute) { - if ($attribute->getIsSearchable() - && in_array($attribute->getFrontendInput(), ['select', 'multiselect']) - ) { - return true; - } - - return false; + return $attribute->getIsSearchable() + && in_array($attribute->getFrontendInput(), ['select', 'multiselect']); } /** diff --git a/app/code/core/Mage/Centinel/Model/State/Jcb.php b/app/code/core/Mage/Centinel/Model/State/Jcb.php index 5d92fa9e7e8..074f5ce02f4 100644 --- a/app/code/core/Mage/Centinel/Model/State/Jcb.php +++ b/app/code/core/Mage/Centinel/Model/State/Jcb.php @@ -119,14 +119,10 @@ public function isAuthenticateSuccessful() protected function _isLookupStrictSuccessful() { //Test cases 1-4, 6, 10-11 - if ($this->getLookupEnrolled() == 'Y' && + return $this->getLookupEnrolled() == 'Y' && $this->getLookupAcsUrl() != '' && $this->getLookupPayload() != '' && - $this->getLookupErrorNo() == '0' - ) { - return true; - } - return false; + $this->getLookupErrorNo() == '0'; } /** @@ -150,12 +146,7 @@ protected function _isLookupSoftSuccessful() if ($enrolled == 'U' && $acsUrl == '' && $payload == '' && $errorNo == '0') { return true; } - //Test cases 8,9 - if ($enrolled == 'U' && $acsUrl == '' && $payload == '' && $errorNo != '0') { - return true; - } - - return false; + return $enrolled == 'U' && $acsUrl == '' && $payload == '' && $errorNo != '0'; } } diff --git a/app/code/core/Mage/Centinel/Model/State/Mastercard.php b/app/code/core/Mage/Centinel/Model/State/Mastercard.php index 5579c059d03..39bff8e0bef 100644 --- a/app/code/core/Mage/Centinel/Model/State/Mastercard.php +++ b/app/code/core/Mage/Centinel/Model/State/Mastercard.php @@ -109,14 +109,10 @@ public function isAuthenticateSuccessful() protected function _isLookupStrictSuccessful() { //Test cases 1-4, 10 - if ($this->getLookupEnrolled() == 'Y' && + return $this->getLookupEnrolled() == 'Y' && $this->getLookupAcsUrl() != '' && $this->getLookupPayload() != '' && - $this->getLookupErrorNo() == '0' - ) { - return true; - } - return false; + $this->getLookupErrorNo() == '0'; } /** @@ -140,12 +136,7 @@ protected function _isLookupSoftSuccessful() if ($enrolled == '' && $acsUrl == '' && $payload == '' && $errorNo == 'Timeout number') { return true; } - //Test cases 8,9 - if ($enrolled == 'U' && $acsUrl == '' && $payload == '' && $errorNo == '1001') { - return true; - } - - return false; + return $enrolled == 'U' && $acsUrl == '' && $payload == '' && $errorNo == '1001'; } } diff --git a/app/code/core/Mage/Centinel/Model/State/Visa.php b/app/code/core/Mage/Centinel/Model/State/Visa.php index 23723799192..11e05af8697 100644 --- a/app/code/core/Mage/Centinel/Model/State/Visa.php +++ b/app/code/core/Mage/Centinel/Model/State/Visa.php @@ -124,14 +124,10 @@ public function isAuthenticateSuccessful() protected function _isLookupStrictSuccessful() { //Test cases 1-5, 11 - if ($this->getLookupEnrolled() == 'Y' && + return $this->getLookupEnrolled() == 'Y' && $this->getLookupAcsUrl() != '' && $this->getLookupPayload() != '' && - $this->getLookupErrorNo() == '0' - ) { - return true; - } - return false; + $this->getLookupErrorNo() == '0'; } /** @@ -155,12 +151,7 @@ protected function _isLookupSoftSuccessful() if ($enrolled == '' && $acsUrl == '' && $payload == '' && $errorNo == 'Timeout number') { return true; } - //Test cases 9,10 - if ($enrolled == 'U' && $acsUrl == '' && $payload == '' && $errorNo == '1001') { - return true; - } - - return false; + return $enrolled == 'U' && $acsUrl == '' && $payload == '' && $errorNo == '1001'; } } diff --git a/app/code/core/Mage/Checkout/Block/Cart/Item/Renderer.php b/app/code/core/Mage/Checkout/Block/Cart/Item/Renderer.php index 6be51c7ce34..0940103d2ff 100644 --- a/app/code/core/Mage/Checkout/Block/Cart/Item/Renderer.php +++ b/app/code/core/Mage/Checkout/Block/Cart/Item/Renderer.php @@ -134,10 +134,7 @@ public function hasProductUrl() if ($option) { $product = $option->getProduct(); } - if ($product->isVisibleInSiteVisibility()) { - return true; - } - return false; + return $product->isVisibleInSiteVisibility(); } /** diff --git a/app/code/core/Mage/Checkout/Block/Cart/Totals.php b/app/code/core/Mage/Checkout/Block/Cart/Totals.php index 1fb8b714cc3..903facf8cbf 100644 --- a/app/code/core/Mage/Checkout/Block/Cart/Totals.php +++ b/app/code/core/Mage/Checkout/Block/Cart/Totals.php @@ -114,10 +114,7 @@ public function renderTotals($area = null, $colspan = 1) public function needDisplayBaseGrandtotal() { $quote = $this->getQuote(); - if ($quote->getBaseCurrencyCode() != $quote->getQuoteCurrencyCode()) { - return true; - } - return false; + return $quote->getBaseCurrencyCode() != $quote->getQuoteCurrencyCode(); } /** diff --git a/app/code/core/Mage/Checkout/Block/Onepage/Billing.php b/app/code/core/Mage/Checkout/Block/Onepage/Billing.php index c8aea60c55e..ea0fb2fe38b 100644 --- a/app/code/core/Mage/Checkout/Block/Onepage/Billing.php +++ b/app/code/core/Mage/Checkout/Block/Onepage/Billing.php @@ -57,12 +57,8 @@ protected function _construct() */ public function isUseBillingAddressForShipping() { - if (($this->getQuote()->getIsVirtual()) - || !$this->getQuote()->getShippingAddress()->getSameAsBilling() - ) { - return false; - } - return true; + return !(($this->getQuote()->getIsVirtual()) + || !$this->getQuote()->getShippingAddress()->getSameAsBilling()); } /** diff --git a/app/code/core/Mage/Checkout/Model/Api/Resource.php b/app/code/core/Mage/Checkout/Model/Api/Resource.php index 510c821ae51..47d9a1eb32c 100644 --- a/app/code/core/Mage/Checkout/Model/Api/Resource.php +++ b/app/code/core/Mage/Checkout/Model/Api/Resource.php @@ -213,13 +213,7 @@ protected function _isAllowedAttribute($attributeCode, $type, ?array $attributes if (in_array($attributeCode, $this->_ignoredAttributeCodes['global'])) { return false; } - - if (isset($this->_ignoredAttributeCodes[$type]) - && in_array($attributeCode, $this->_ignoredAttributeCodes[$type]) - ) { - return false; - } - - return true; + return !(isset($this->_ignoredAttributeCodes[$type]) + && in_array($attributeCode, $this->_ignoredAttributeCodes[$type])); } } diff --git a/app/code/core/Mage/Checkout/Model/Cart/Payment/Api.php b/app/code/core/Mage/Checkout/Model/Cart/Payment/Api.php index d858dee6246..3fffca407c2 100644 --- a/app/code/core/Mage/Checkout/Model/Cart/Payment/Api.php +++ b/app/code/core/Mage/Checkout/Model/Cart/Payment/Api.php @@ -59,12 +59,7 @@ protected function _canUsePaymentMethod($method, $quote) $total = $quote->getBaseGrandTotal(); $minTotal = $method->getConfigData('min_order_total'); $maxTotal = $method->getConfigData('max_order_total'); - - if ((!empty($minTotal) && ($total < $minTotal)) || (!empty($maxTotal) && ($total > $maxTotal))) { - return false; - } - - return true; + return !((!empty($minTotal) && ($total < $minTotal)) || (!empty($maxTotal) && ($total > $maxTotal))); } /** diff --git a/app/code/core/Mage/Cms/Model/Resource/Block.php b/app/code/core/Mage/Cms/Model/Resource/Block.php index f3ca4f85938..42221c24837 100644 --- a/app/code/core/Mage/Cms/Model/Resource/Block.php +++ b/app/code/core/Mage/Cms/Model/Resource/Block.php @@ -180,12 +180,7 @@ public function getIsUniqueBlockToStores(Mage_Core_Model_Abstract $object) if ($object->getId()) { $select->where('cb.block_id <> ?', $object->getId()); } - - if ($this->_getReadAdapter()->fetchRow($select)) { - return false; - } - - return true; + return !$this->_getReadAdapter()->fetchRow($select); } /** diff --git a/app/code/core/Mage/Cms/Model/Resource/Page.php b/app/code/core/Mage/Cms/Model/Resource/Page.php index 4bc973e4b83..d447538ed51 100644 --- a/app/code/core/Mage/Cms/Model/Resource/Page.php +++ b/app/code/core/Mage/Cms/Model/Resource/Page.php @@ -229,12 +229,7 @@ public function getIsUniquePageToStores(Mage_Core_Model_Abstract $object) if ($object->getId()) { $select->where('cps.page_id <> ?', $object->getId()); } - - if ($this->_getWriteAdapter()->fetchRow($select)) { - return false; - } - - return true; + return !$this->_getWriteAdapter()->fetchRow($select); } /** diff --git a/app/code/core/Mage/Core/Controller/Request/Http.php b/app/code/core/Mage/Core/Controller/Request/Http.php index f3442146f75..e7dc05754c6 100644 --- a/app/code/core/Mage/Core/Controller/Request/Http.php +++ b/app/code/core/Mage/Core/Controller/Request/Http.php @@ -562,10 +562,7 @@ public function isAjax() if ($this->isXmlHttpRequest()) { return true; } - if ($this->getParam('ajax') || $this->getParam('isAjax')) { - return true; - } - return false; + return $this->getParam('ajax') || $this->getParam('isAjax'); } /** diff --git a/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php b/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php index a1c9aece874..08b3d6146af 100644 --- a/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php +++ b/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php @@ -83,10 +83,7 @@ public function fetchDefault() */ protected function _beforeModuleMatch() { - if (Mage::app()->getStore()->isAdmin()) { - return false; - } - return true; + return !Mage::app()->getStore()->isAdmin(); } /** @@ -431,10 +428,7 @@ public function getControllerFileName($realModule, $controller) */ public function validateControllerFileName($fileName) { - if ($fileName && is_readable($fileName) && !str_contains($fileName, '//')) { - return true; - } - return false; + return $fileName && is_readable($fileName) && !str_contains($fileName, '//'); } /** diff --git a/app/code/core/Mage/Core/Helper/Abstract.php b/app/code/core/Mage/Core/Helper/Abstract.php index fc0580855c7..50bf0a3a8e5 100644 --- a/app/code/core/Mage/Core/Helper/Abstract.php +++ b/app/code/core/Mage/Core/Helper/Abstract.php @@ -134,11 +134,7 @@ public function isModuleOutputEnabled($moduleName = null) if (!$this->isModuleEnabled($moduleName)) { return false; } - - if (Mage::getStoreConfigFlag('advanced/modules_disable_output/' . $moduleName)) { - return false; - } - return true; + return !Mage::getStoreConfigFlag('advanced/modules_disable_output/' . $moduleName); } /** @@ -158,10 +154,7 @@ public function isModuleEnabled($moduleName = null) } $isActive = Mage::getConfig()->getNode('modules/' . $moduleName . '/active'); - if (!$isActive || !in_array((string)$isActive, ['true', '1'])) { - return false; - } - return true; + return !(!$isActive || !in_array((string)$isActive, ['true', '1'])); } /** diff --git a/app/code/core/Mage/Core/Helper/String.php b/app/code/core/Mage/Core/Helper/String.php index 74b8aca84a5..dd9ec89dc0f 100644 --- a/app/code/core/Mage/Core/Helper/String.php +++ b/app/code/core/Mage/Core/Helper/String.php @@ -350,10 +350,7 @@ public function parseQueryStr($str) */ protected function _validateQueryStr($str) { - if (!$str || !str_contains($str, '=')) { - return false; - } - return true; + return !(!$str || !str_contains($str, '=')); } /** diff --git a/app/code/core/Mage/Core/Helper/Url.php b/app/code/core/Mage/Core/Helper/Url.php index 39636722c05..cd836282db6 100644 --- a/app/code/core/Mage/Core/Helper/Url.php +++ b/app/code/core/Mage/Core/Helper/Url.php @@ -199,11 +199,7 @@ public function decodePunycode($url) */ private function _isPunycode($host) { - if (str_starts_with($host, 'xn--') || str_contains($host, '.xn--') - || str_starts_with($host, 'XN--') || str_contains($host, '.XN--') - ) { - return true; - } - return false; + return str_starts_with($host, 'xn--') || str_contains($host, '.xn--') + || str_starts_with($host, 'XN--') || str_contains($host, '.XN--'); } } diff --git a/app/code/core/Mage/Core/Model/Cookie.php b/app/code/core/Mage/Core/Model/Cookie.php index d9330737899..514ba78bcbf 100644 --- a/app/code/core/Mage/Core/Model/Cookie.php +++ b/app/code/core/Mage/Core/Model/Cookie.php @@ -189,10 +189,7 @@ public function isSecure() return $this->_getRequest()->isSecure(); } // Use secure cookie if unsecure base url is actually secure - if (preg_match('/^https:/', $this->getStore()->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, false))) { - return true; - } - return false; + return (bool) preg_match('/^https:/', $this->getStore()->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, false)); } /** diff --git a/app/code/core/Mage/Core/Model/Resource/Session.php b/app/code/core/Mage/Core/Model/Resource/Session.php index 56d246f80f4..7bb2d046622 100644 --- a/app/code/core/Mage/Core/Model/Resource/Session.php +++ b/app/code/core/Mage/Core/Model/Resource/Session.php @@ -117,11 +117,7 @@ public function hasConnection() if (!$this->_read) { return false; } - if (!$this->_read->isTableExists($this->_sessionTable)) { - return false; - } - - return true; + return $this->_read->isTableExists($this->_sessionTable); } /** diff --git a/app/code/core/Mage/Core/Model/Session/Abstract/Varien.php b/app/code/core/Mage/Core/Model/Session/Abstract/Varien.php index 0c6b7b3e2c3..4d09d4f7f40 100644 --- a/app/code/core/Mage/Core/Model/Session/Abstract/Varien.php +++ b/app/code/core/Mage/Core/Model/Session/Abstract/Varien.php @@ -549,16 +549,11 @@ protected function _validate() ) { return false; } - if ($this->useValidateSessionPasswordTimestamp() + return !($this->useValidateSessionPasswordTimestamp() && isset($validatorData[self::VALIDATOR_PASSWORD_CREATE_TIMESTAMP]) && isset($sessionData[self::VALIDATOR_SESSION_RENEW_TIMESTAMP]) && $validatorData[self::VALIDATOR_PASSWORD_CREATE_TIMESTAMP] - > $sessionData[self::VALIDATOR_SESSION_RENEW_TIMESTAMP] - ) { - return false; - } - - return true; + > $sessionData[self::VALIDATOR_SESSION_RENEW_TIMESTAMP]); } /** diff --git a/app/code/core/Mage/Core/Model/Url.php b/app/code/core/Mage/Core/Model/Url.php index 0ee085048eb..2a466dfe24c 100644 --- a/app/code/core/Mage/Core/Model/Url.php +++ b/app/code/core/Mage/Core/Model/Url.php @@ -1222,10 +1222,7 @@ public function isOwnOriginUrl() $storeDomains[] = parse_url($store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, true), PHP_URL_HOST); } $storeDomains = array_unique($storeDomains); - if (in_array($referer, $storeDomains)) { - return true; - } - return false; + return in_array($referer, $storeDomains); } /** diff --git a/app/code/core/Mage/Cron/Model/Resource/Schedule.php b/app/code/core/Mage/Cron/Model/Resource/Schedule.php index 462a417b64a..980c515ba97 100644 --- a/app/code/core/Mage/Cron/Model/Resource/Schedule.php +++ b/app/code/core/Mage/Cron/Model/Resource/Schedule.php @@ -48,9 +48,6 @@ public function trySetJobStatusAtomic($scheduleId, $newStatus, $currentStatus) ['status' => $newStatus], ['schedule_id = ?' => $scheduleId, 'status = ?' => $currentStatus] ); - if ($result == 1) { - return true; - } - return false; + return $result == 1; } } diff --git a/app/code/core/Mage/Customer/Block/Account/Navigation.php b/app/code/core/Mage/Customer/Block/Account/Navigation.php index 8baf0e8d6a7..60bc693bfb3 100644 --- a/app/code/core/Mage/Customer/Block/Account/Navigation.php +++ b/app/code/core/Mage/Customer/Block/Account/Navigation.php @@ -90,10 +90,7 @@ public function isActive($link) if (empty($this->_activeLink)) { $this->_activeLink = $this->getAction()->getFullActionName('/'); } - if ($this->_completePath($link->getPath()) == $this->_activeLink) { - return true; - } - return false; + return $this->_completePath($link->getPath()) == $this->_activeLink; } /** diff --git a/app/code/core/Mage/Customer/Model/Group.php b/app/code/core/Mage/Customer/Model/Group.php index 8d1ba82ecda..8653dedec82 100644 --- a/app/code/core/Mage/Customer/Model/Group.php +++ b/app/code/core/Mage/Customer/Model/Group.php @@ -108,10 +108,7 @@ public function getTaxClassId($groupId = null) public function usesAsDefault() { $data = Mage::getConfig()->getStoresConfigByPath(self::XML_PATH_DEFAULT_ID); - if (in_array($this->getId(), $data)) { - return true; - } - return false; + return in_array($this->getId(), $data); } /** diff --git a/app/code/core/Mage/Customer/Model/Resource/Customer.php b/app/code/core/Mage/Customer/Model/Resource/Customer.php index 9d89a366940..203bd9a9aa8 100644 --- a/app/code/core/Mage/Customer/Model/Resource/Customer.php +++ b/app/code/core/Mage/Customer/Model/Resource/Customer.php @@ -271,10 +271,7 @@ public function checkCustomerId($customerId) ->limit(1); $result = $adapter->fetchOne($select, $bind); - if ($result) { - return true; - } - return false; + return (bool) $result; } /** diff --git a/app/code/core/Mage/Downloadable/Helper/Data.php b/app/code/core/Mage/Downloadable/Helper/Data.php index c74945cb47e..0b87910f923 100644 --- a/app/code/core/Mage/Downloadable/Helper/Data.php +++ b/app/code/core/Mage/Downloadable/Helper/Data.php @@ -53,9 +53,6 @@ public function getIsShareable($link) public function getIsPriceWebsiteScope() { $scope = (int) Mage::app()->getStore()->getConfig(Mage_Core_Model_Store::XML_PATH_PRICE_SCOPE); - if ($scope == Mage_Core_Model_Store::PRICE_SCOPE_WEBSITE) { - return true; - } - return false; + return $scope == Mage_Core_Model_Store::PRICE_SCOPE_WEBSITE; } } diff --git a/app/code/core/Mage/Downloadable/Model/Product/Type.php b/app/code/core/Mage/Downloadable/Model/Product/Type.php index 32efc635dba..b4b179a9e7d 100644 --- a/app/code/core/Mage/Downloadable/Model/Product/Type.php +++ b/app/code/core/Mage/Downloadable/Model/Product/Type.php @@ -83,10 +83,7 @@ public function hasOptions($product = null) */ public function hasRequiredOptions($product = null) { - if (parent::hasRequiredOptions($product) || $this->getProduct($product)->getLinksPurchasedSeparately()) { - return true; - } - return false; + return parent::hasRequiredOptions($product) || $this->getProduct($product)->getLinksPurchasedSeparately(); } /** diff --git a/app/code/core/Mage/Eav/Model/Entity/Abstract.php b/app/code/core/Mage/Eav/Model/Entity/Abstract.php index 25c93a56c2e..18fdf7dd84d 100644 --- a/app/code/core/Mage/Eav/Model/Entity/Abstract.php +++ b/app/code/core/Mage/Eav/Model/Entity/Abstract.php @@ -660,11 +660,7 @@ public function walkAttributes($partMethod, array $args = []) */ protected function _isCallableAttributeInstance($instance, $method, $args) { - if (!is_object($instance) || !method_exists($instance, $method)) { - return false; - } - - return true; + return !(!is_object($instance) || !method_exists($instance, $method)); } /** diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute/Abstract.php b/app/code/core/Mage/Eav/Model/Entity/Attribute/Abstract.php index dc83e413615..74b4f050a61 100644 --- a/app/code/core/Mage/Eav/Model/Entity/Attribute/Abstract.php +++ b/app/code/core/Mage/Eav/Model/Entity/Attribute/Abstract.php @@ -564,14 +564,8 @@ public function isInSet($setId) ) { return true; } - - if (!is_array($setId) - && array_key_exists($setId, $this->getAttributeSetInfo()) - ) { - return true; - } - - return false; + return !is_array($setId) + && array_key_exists($setId, $this->getAttributeSetInfo()); } /** @@ -584,11 +578,7 @@ public function isInSet($setId) public function isInGroup($setId, $groupId) { $dataPath = sprintf('attribute_set_info/%s/group_id', $setId); - if ($this->isInSet($setId) && $this->getData($dataPath) == $groupId) { - return true; - } - - return false; + return $this->isInSet($setId) && $this->getData($dataPath) == $groupId; } /** diff --git a/app/code/core/Mage/Eav/Model/Form.php b/app/code/core/Mage/Eav/Model/Form.php index a8bd9d95605..6fb450dd7a2 100644 --- a/app/code/core/Mage/Eav/Model/Form.php +++ b/app/code/core/Mage/Eav/Model/Form.php @@ -532,9 +532,6 @@ public function ignoreInvisible($setValue = null) */ protected function _isAttributeOmitted($attribute) { - if ($this->_ignoreInvisible && !$attribute->getIsVisible()) { - return true; - } - return false; + return $this->_ignoreInvisible && !$attribute->getIsVisible(); } } diff --git a/app/code/core/Mage/Media/Model/File/Image.php b/app/code/core/Mage/Media/Model/File/Image.php index 298d3c0ab98..66190e4bec7 100644 --- a/app/code/core/Mage/Media/Model/File/Image.php +++ b/app/code/core/Mage/Media/Model/File/Image.php @@ -237,10 +237,6 @@ public function destroyResource(&$resource) */ public function hasSpecialImage(Mage_Media_Model_Image $object) { - if (file_exists($object->getFilePath(true))) { - return true; - } - - return false; + return file_exists($object->getFilePath(true)); } } diff --git a/app/code/core/Mage/Newsletter/Model/Subscriber.php b/app/code/core/Mage/Newsletter/Model/Subscriber.php index 53edf443619..a0841e8145b 100644 --- a/app/code/core/Mage/Newsletter/Model/Subscriber.php +++ b/app/code/core/Mage/Newsletter/Model/Subscriber.php @@ -239,11 +239,7 @@ public function getIsStatusChanged() */ public function isSubscribed() { - if ($this->getId() && $this->getStatus() == self::STATUS_SUBSCRIBED) { - return true; - } - - return false; + return $this->getId() && $this->getStatus() == self::STATUS_SUBSCRIBED; } /** diff --git a/app/code/core/Mage/Paygate/Model/Authorizenet.php b/app/code/core/Mage/Paygate/Model/Authorizenet.php index 5659e2caac3..8beb8dd346e 100644 --- a/app/code/core/Mage/Paygate/Model/Authorizenet.php +++ b/app/code/core/Mage/Paygate/Model/Authorizenet.php @@ -191,10 +191,7 @@ class Mage_Paygate_Model_Authorizenet extends Mage_Payment_Model_Method_Cc */ public function canUseForCurrency($currencyCode) { - if (!in_array($currencyCode, $this->getAcceptedCurrencyCodes())) { - return false; - } - return true; + return in_array($currencyCode, $this->getAcceptedCurrencyCodes()); } /** diff --git a/app/code/core/Mage/Payment/Block/Form/Cc.php b/app/code/core/Mage/Payment/Block/Form/Cc.php index 5435e7f4a75..67bc4213d26 100644 --- a/app/code/core/Mage/Payment/Block/Form/Cc.php +++ b/app/code/core/Mage/Payment/Block/Form/Cc.php @@ -116,10 +116,7 @@ public function hasSsCardType() { $availableTypes = explode(',', $this->getMethod()->getConfigData('cctypes')); $ssPresenations = array_intersect(['SS', 'SM', 'SO'], $availableTypes); - if ($availableTypes && count($ssPresenations) > 0) { - return true; - } - return false; + return $availableTypes && count($ssPresenations) > 0; } /* diff --git a/app/code/core/Mage/Payment/Model/Method/Cc.php b/app/code/core/Mage/Payment/Model/Method/Cc.php index 82301bf5b76..7bc2934c19c 100644 --- a/app/code/core/Mage/Payment/Model/Method/Cc.php +++ b/app/code/core/Mage/Payment/Model/Method/Cc.php @@ -205,12 +205,8 @@ public function getVerificationRegEx() protected function _validateExpDate($expYear, $expMonth) { $date = Mage::app()->getLocale()->date(); - if (!$expYear || !$expMonth || ($date->compareYear($expYear) == 1) - || ($date->compareYear($expYear) == 0 && ($date->compareMonth($expMonth) == 1)) - ) { - return false; - } - return true; + return !(!$expYear || !$expMonth || ($date->compareYear($expYear) == 1) + || ($date->compareYear($expYear) == 0 && ($date->compareMonth($expMonth) == 1))); } /** diff --git a/app/code/core/Mage/Paypal/Block/Iframe.php b/app/code/core/Mage/Paypal/Block/Iframe.php index 9b286a533bc..9d6c81a8243 100644 --- a/app/code/core/Mage/Paypal/Block/Iframe.php +++ b/app/code/core/Mage/Paypal/Block/Iframe.php @@ -166,15 +166,10 @@ protected function _toHtml() protected function _isAfterPaymentSave() { $quote = $this->_getCheckout()->getQuote(); - if ($quote->getPayment()->getMethod() == $this->_paymentMethodCode && + return $quote->getPayment()->getMethod() == $this->_paymentMethodCode && $quote->getIsActive() && $this->getTemplate() && - $this->getRequest()->getActionName() == 'savePayment' - ) { - return true; - } - - return false; + $this->getRequest()->getActionName() == 'savePayment'; } /** diff --git a/app/code/core/Mage/Paypal/Model/Config.php b/app/code/core/Mage/Paypal/Model/Config.php index af3cb556d9c..1292c4e6e4c 100644 --- a/app/code/core/Mage/Paypal/Model/Config.php +++ b/app/code/core/Mage/Paypal/Model/Config.php @@ -689,12 +689,8 @@ public function setStoreId($storeId) */ public function isMethodActive($method) { - if ($this->isMethodSupportedForCountry($method) - && Mage::getStoreConfigFlag("payment/{$method}/active", $this->_storeId) - ) { - return true; - } - return false; + return $this->isMethodSupportedForCountry($method) + && Mage::getStoreConfigFlag("payment/{$method}/active", $this->_storeId); } /** @@ -865,10 +861,7 @@ public function isMethodSupportedForCountry($method = null, $countryCode = null) $countryCode = $this->getMerchantCountry(); } $countryMethods = $this->getCountryMethods($countryCode); - if (in_array($method, $countryMethods)) { - return true; - } - return false; + return in_array($method, $countryMethods); } /** @@ -1533,10 +1526,7 @@ public function isCurrencyCodeSupported($code) if ($this->getMerchantCountry() == 'BR' && $code == 'BRL') { return true; } - if ($this->getMerchantCountry() == 'MY' && $code == 'MYR') { - return true; - } - return false; + return $this->getMerchantCountry() == 'MY' && $code == 'MYR'; } /** diff --git a/app/code/core/Mage/Paypal/Model/Direct.php b/app/code/core/Mage/Paypal/Model/Direct.php index ad1190ffd45..2ee86272e80 100644 --- a/app/code/core/Mage/Paypal/Model/Direct.php +++ b/app/code/core/Mage/Paypal/Model/Direct.php @@ -131,10 +131,7 @@ public function getAllowedCcTypes() */ public function isAvailable($quote = null) { - if (parent::isAvailable($quote) && $this->_pro->getConfig()->isMethodAvailable()) { - return true; - } - return false; + return parent::isAvailable($quote) && $this->_pro->getConfig()->isMethodAvailable(); } /** diff --git a/app/code/core/Mage/Paypal/Model/Express.php b/app/code/core/Mage/Paypal/Model/Express.php index 0ff0eeab18c..c4e5e890f03 100644 --- a/app/code/core/Mage/Paypal/Model/Express.php +++ b/app/code/core/Mage/Paypal/Model/Express.php @@ -162,10 +162,7 @@ public function getConfigPaymentAction() */ public function isAvailable($quote = null) { - if (parent::isAvailable($quote) && $this->_pro->getConfig()->isMethodAvailable()) { - return true; - } - return false; + return parent::isAvailable($quote) && $this->_pro->getConfig()->isMethodAvailable(); } /** @@ -718,11 +715,6 @@ protected function _isTransactionExpired(Mage_Sales_Model_Order_Payment_Transact $transactionClosingDate->modify('+' . $period . ' days'); $currentTime = new DateTime(null, new DateTimeZone('US/Pacific')); - - if ($currentTime > $transactionClosingDate) { - return true; - } - - return false; + return $currentTime > $transactionClosingDate; } } diff --git a/app/code/core/Mage/Paypal/Model/Payflowlink.php b/app/code/core/Mage/Paypal/Model/Payflowlink.php index 3df873ac52b..34c98879140 100644 --- a/app/code/core/Mage/Paypal/Model/Payflowlink.php +++ b/app/code/core/Mage/Paypal/Model/Payflowlink.php @@ -127,10 +127,7 @@ public function isAvailable($quote = null) { $storeId = Mage::app()->getStore($this->getStore())->getId(); $config = Mage::getModel('paypal/config')->setStoreId($storeId); - if (Mage_Payment_Model_Method_Abstract::isAvailable($quote) && $config->isMethodAvailable($this->getCode())) { - return true; - } - return false; + return Mage_Payment_Model_Method_Abstract::isAvailable($quote) && $config->isMethodAvailable($this->getCode()); } /** diff --git a/app/code/core/Mage/Paypal/Model/Payflowpro.php b/app/code/core/Mage/Paypal/Model/Payflowpro.php index c40b3ba2e17..669f887b698 100644 --- a/app/code/core/Mage/Paypal/Model/Payflowpro.php +++ b/app/code/core/Mage/Paypal/Model/Payflowpro.php @@ -112,10 +112,7 @@ public function isAvailable($quote = null) { $storeId = Mage::app()->getStore($this->getStore())->getId(); $config = Mage::getModel('paypal/config')->setStoreId($storeId); - if (parent::isAvailable($quote) && $config->isMethodAvailable($this->getCode())) { - return true; - } - return false; + return parent::isAvailable($quote) && $config->isMethodAvailable($this->getCode()); } /** @@ -337,10 +334,7 @@ public function fetchTransactionInfo(Mage_Payment_Model_Info $payment, $transact */ protected static function _isTransactionUnderReview($status) { - if (in_array($status, [self::RESPONSE_CODE_APPROVED, self::RESPONSE_CODE_DECLINED_BY_MERCHANT])) { - return false; - } - return true; + return !in_array($status, [self::RESPONSE_CODE_APPROVED, self::RESPONSE_CODE_DECLINED_BY_MERCHANT]); } /** diff --git a/app/code/core/Mage/Paypal/Model/Standard.php b/app/code/core/Mage/Paypal/Model/Standard.php index dd58a6c1be1..8d17648c9dd 100644 --- a/app/code/core/Mage/Paypal/Model/Standard.php +++ b/app/code/core/Mage/Paypal/Model/Standard.php @@ -173,10 +173,7 @@ public function getConfig() */ public function isAvailable($quote = null) { - if (parent::isAvailable($quote) && $this->getConfig()->isMethodAvailable()) { - return true; - } - return false; + return parent::isAvailable($quote) && $this->getConfig()->isMethodAvailable(); } /** diff --git a/app/code/core/Mage/PaypalUk/Model/Direct.php b/app/code/core/Mage/PaypalUk/Model/Direct.php index 812182d1f52..13df9f7dc7d 100644 --- a/app/code/core/Mage/PaypalUk/Model/Direct.php +++ b/app/code/core/Mage/PaypalUk/Model/Direct.php @@ -56,10 +56,7 @@ public function getIsCentinelValidationEnabled() return false; } // available only for US and UK merchants - if (in_array($this->_pro->getConfig()->getMerchantCountry(), ['US', 'GB'])) { - return true; - } - return false; + return in_array($this->_pro->getConfig()->getMerchantCountry(), ['US', 'GB']); } /** diff --git a/app/code/core/Mage/ProductAlert/Block/Price.php b/app/code/core/Mage/ProductAlert/Block/Price.php index 8e034a4341f..26a234574c7 100644 --- a/app/code/core/Mage/ProductAlert/Block/Price.php +++ b/app/code/core/Mage/ProductAlert/Block/Price.php @@ -33,11 +33,7 @@ public function __construct() */ public function isShow() { - if (!Mage::getStoreConfig('catalog/productalert/allow_price')) { - return false; - } - - return true; + return (bool) Mage::getStoreConfig('catalog/productalert/allow_price'); } /** diff --git a/app/code/core/Mage/Rss/Helper/Order.php b/app/code/core/Mage/Rss/Helper/Order.php index c35a5b39e1e..9fdbd760d86 100644 --- a/app/code/core/Mage/Rss/Helper/Order.php +++ b/app/code/core/Mage/Rss/Helper/Order.php @@ -30,10 +30,7 @@ class Mage_Rss_Helper_Order extends Mage_Core_Helper_Abstract */ public function isStatusNotificationAllow() { - if (Mage::getStoreConfig('rss/order/status_notified')) { - return true; - } - return false; + return (bool) Mage::getStoreConfig('rss/order/status_notified'); } /** diff --git a/app/code/core/Mage/Sales/Controller/Abstract.php b/app/code/core/Mage/Sales/Controller/Abstract.php index e0d804b68a2..ad75dbf67d3 100644 --- a/app/code/core/Mage/Sales/Controller/Abstract.php +++ b/app/code/core/Mage/Sales/Controller/Abstract.php @@ -31,12 +31,8 @@ protected function _canViewOrder($order) { $customerId = Mage::getSingleton('customer/session')->getCustomerId(); $availableStates = Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates(); - if ($order->getId() && $order->getCustomerId() && ($order->getCustomerId() == $customerId) - && in_array($order->getState(), $availableStates, $strict = true) - ) { - return true; - } - return false; + return $order->getId() && $order->getCustomerId() && ($order->getCustomerId() == $customerId) + && in_array($order->getState(), $availableStates, $strict = true); } /** diff --git a/app/code/core/Mage/Sales/Helper/Reorder.php b/app/code/core/Mage/Sales/Helper/Reorder.php index 59b831de524..b22a8f534ac 100644 --- a/app/code/core/Mage/Sales/Helper/Reorder.php +++ b/app/code/core/Mage/Sales/Helper/Reorder.php @@ -41,10 +41,7 @@ public function isAllow() */ public function isAllowed($store = null) { - if (Mage::getStoreConfig(self::XML_PATH_SALES_REORDER_ALLOW, $store)) { - return true; - } - return false; + return (bool) Mage::getStoreConfig(self::XML_PATH_SALES_REORDER_ALLOW, $store); } /** diff --git a/app/code/core/Mage/Sales/Model/Api/Resource.php b/app/code/core/Mage/Sales/Model/Api/Resource.php index 9e1617c2086..f42a1ed6d15 100644 --- a/app/code/core/Mage/Sales/Model/Api/Resource.php +++ b/app/code/core/Mage/Sales/Model/Api/Resource.php @@ -115,13 +115,7 @@ protected function _isAllowedAttribute($attributeCode, $type, ?array $attributes if (in_array($attributeCode, $this->_ignoredAttributeCodes['global'])) { return false; } - - if (isset($this->_ignoredAttributeCodes[$type]) - && in_array($attributeCode, $this->_ignoredAttributeCodes[$type]) - ) { - return false; - } - - return true; + return !(isset($this->_ignoredAttributeCodes[$type]) + && in_array($attributeCode, $this->_ignoredAttributeCodes[$type])); } } diff --git a/app/code/core/Mage/Sales/Model/Order.php b/app/code/core/Mage/Sales/Model/Order.php index ec00ea9bd88..6d3a81cec00 100644 --- a/app/code/core/Mage/Sales/Model/Order.php +++ b/app/code/core/Mage/Sales/Model/Order.php @@ -648,20 +648,16 @@ public function canCancel() if ($this->isCanceled() || $state === self::STATE_COMPLETE || $state === self::STATE_CLOSED) { return false; } - - if ($this->getActionFlag(self::ACTION_FLAG_CANCEL) === false) { - return false; - } /** * Use only state for availability detect */ /*foreach ($this->getAllItems() as $item) { - if ($item->getQtyToCancel()>0) { - return true; - } - } - return false;*/ - return true; + if ($item->getQtyToCancel()>0) { + return true; + } + } + return false;*/ + return $this->getActionFlag(self::ACTION_FLAG_CANCEL) !== false; } /** @@ -681,10 +677,7 @@ public function canVoidPayment() */ protected function _canVoidOrder() { - if ($this->canUnhold() || $this->isPaymentReview()) { - return false; - } - return true; + return !($this->canUnhold() || $this->isPaymentReview()); } /** @@ -741,11 +734,7 @@ public function canCreditmemo() if (abs($this->getStore()->roundPrice($this->getTotalPaid()) - $this->getTotalRefunded()) < .0001) { return false; } - - if ($this->getActionFlag(self::ACTION_FLAG_EDIT) === false) { - return false; - } - return true; + return $this->getActionFlag(self::ACTION_FLAG_EDIT) !== false; } /** @@ -761,11 +750,7 @@ public function canHold() ) { return false; } - - if ($this->getActionFlag(self::ACTION_FLAG_HOLD) === false) { - return false; - } - return true; + return $this->getActionFlag(self::ACTION_FLAG_HOLD) !== false; } /** @@ -788,10 +773,7 @@ public function canUnhold() */ public function canComment() { - if ($this->getActionFlag(self::ACTION_FLAG_COMMENT) === false) { - return false; - } - return true; + return $this->getActionFlag(self::ACTION_FLAG_COMMENT) !== false; } /** @@ -844,12 +826,7 @@ public function canEdit() if (!$this->getPayment()->getMethodInstance()->canEdit()) { return false; } - - if ($this->getActionFlag(self::ACTION_FLAG_EDIT) === false) { - return false; - } - - return true; + return $this->getActionFlag(self::ACTION_FLAG_EDIT) !== false; } /** diff --git a/app/code/core/Mage/Sales/Model/Order/Creditmemo.php b/app/code/core/Mage/Sales/Model/Order/Creditmemo.php index f1cfe339c9c..146a1166688 100644 --- a/app/code/core/Mage/Sales/Model/Order/Creditmemo.php +++ b/app/code/core/Mage/Sales/Model/Order/Creditmemo.php @@ -398,13 +398,9 @@ public function roundPrice($price, $type = 'regular', $negative = false) */ public function canRefund() { - if ($this->getState() != self::STATE_CANCELED + return $this->getState() != self::STATE_CANCELED && $this->getState() != self::STATE_REFUNDED - && $this->getOrder()->getPayment()->canRefund() - ) { - return true; - } - return false; + && $this->getOrder()->getPayment()->canRefund(); } /** diff --git a/app/code/core/Mage/Sales/Model/Order/Creditmemo/Item.php b/app/code/core/Mage/Sales/Model/Order/Creditmemo/Item.php index 88177437351..fe76c1217b1 100644 --- a/app/code/core/Mage/Sales/Model/Order/Creditmemo/Item.php +++ b/app/code/core/Mage/Sales/Model/Order/Creditmemo/Item.php @@ -298,12 +298,8 @@ public function calcRowTotal() public function isLast() { $orderItem = $this->getOrderItem(); - if ((string)(float)$this->getQty() == (string)(float)$orderItem->getQtyToRefund() - && !$orderItem->getQtyToInvoice() - ) { - return true; - } - return false; + return (string)(float)$this->getQty() == (string)(float)$orderItem->getQtyToRefund() + && !$orderItem->getQtyToInvoice(); } /** diff --git a/app/code/core/Mage/Sales/Model/Order/Invoice.php b/app/code/core/Mage/Sales/Model/Order/Invoice.php index 812f614da9d..4f8dbcb3176 100644 --- a/app/code/core/Mage/Sales/Model/Order/Invoice.php +++ b/app/code/core/Mage/Sales/Model/Order/Invoice.php @@ -376,10 +376,7 @@ public function canRefund() if ($this->getState() != self::STATE_PAID) { return false; } - if (abs($this->getBaseGrandTotal() - $this->getBaseTotalRefunded()) < .0001) { - return false; - } - return true; + return !(abs($this->getBaseGrandTotal() - $this->getBaseTotalRefunded()) < .0001); } /** diff --git a/app/code/core/Mage/Sales/Model/Order/Invoice/Item.php b/app/code/core/Mage/Sales/Model/Order/Invoice/Item.php index f88b39f3d28..41e1538c0aa 100644 --- a/app/code/core/Mage/Sales/Model/Order/Invoice/Item.php +++ b/app/code/core/Mage/Sales/Model/Order/Invoice/Item.php @@ -287,10 +287,7 @@ public function calcRowTotal() */ public function isLast() { - if ((string)(float)$this->getQty() == (string)(float)$this->getOrderItem()->getQtyToInvoice()) { - return true; - } - return false; + return (string)(float)$this->getQty() == (string)(float)$this->getOrderItem()->getQtyToInvoice(); } /** diff --git a/app/code/core/Mage/Sales/Model/Order/Item.php b/app/code/core/Mage/Sales/Model/Order/Item.php index c55c7a80917..f89a7afdc46 100644 --- a/app/code/core/Mage/Sales/Model/Order/Item.php +++ b/app/code/core/Mage/Sales/Model/Order/Item.php @@ -690,13 +690,8 @@ public function isChildrenCalculated() } else { $options = $this->getProductOptions(); } - - if (isset($options['product_calculations']) && - $options['product_calculations'] == Mage_Catalog_Model_Product_Type_Abstract::CALCULATE_CHILD - ) { - return true; - } - return false; + return isset($options['product_calculations']) && + $options['product_calculations'] == Mage_Catalog_Model_Product_Type_Abstract::CALCULATE_CHILD; } /** * Check if discount has to be applied to parent item @@ -727,13 +722,8 @@ public function isShipSeparately() } else { $options = $this->getProductOptions(); } - - if (isset($options['shipment_type']) && - $options['shipment_type'] == Mage_Catalog_Model_Product_Type_Abstract::SHIPMENT_SEPARATELY - ) { - return true; - } - return false; + return isset($options['shipment_type']) && + $options['shipment_type'] == Mage_Catalog_Model_Product_Type_Abstract::SHIPMENT_SEPARATELY; } /** diff --git a/app/code/core/Mage/Sales/Model/Order/Payment/Transaction.php b/app/code/core/Mage/Sales/Model/Order/Payment/Transaction.php index 6927359620a..b2bf223756b 100644 --- a/app/code/core/Mage/Sales/Model/Order/Payment/Transaction.php +++ b/app/code/core/Mage/Sales/Model/Order/Payment/Transaction.php @@ -357,10 +357,7 @@ public function canVoidAuthorizationCompletely() { try { $authTransaction = $this->closeAuthorization('', true); - if ($authTransaction->hasChildTransaction() || $this->_children) { - return false; - } - return true; + return !($authTransaction->hasChildTransaction() || $this->_children); } catch (Mage_Core_Exception $e) { // jam all logical exceptions, fallback to false } diff --git a/app/code/core/Mage/Sales/Model/Quote/Address.php b/app/code/core/Mage/Sales/Model/Quote/Address.php index beeabfbdb31..b6f7f9974a4 100644 --- a/app/code/core/Mage/Sales/Model/Quote/Address.php +++ b/app/code/core/Mage/Sales/Model/Quote/Address.php @@ -1157,10 +1157,7 @@ public function validateMinimumAmount() } $amount = Mage::getStoreConfig('sales/minimum_order/amount', $storeId); - if ($this->getBaseSubtotalWithDiscount() < $amount) { - return false; - } - return true; + return !($this->getBaseSubtotalWithDiscount() < $amount); } /** diff --git a/app/code/core/Mage/Sales/Model/Quote/Address/Total/Abstract.php b/app/code/core/Mage/Sales/Model/Quote/Address/Total/Abstract.php index a61546dad4f..f6a01434f3a 100644 --- a/app/code/core/Mage/Sales/Model/Quote/Address/Total/Abstract.php +++ b/app/code/core/Mage/Sales/Model/Quote/Address/Total/Abstract.php @@ -239,10 +239,7 @@ public function getItemBaseRowTotal(Mage_Sales_Model_Quote_Item_Abstract $item) */ public function getIsItemRowTotalCompoundable(Mage_Sales_Model_Quote_Item_Abstract $item) { - if ($item->getData("skip_compound_{$this->_itemRowTotalKey}")) { - return false; - } - return true; + return !$item->getData("skip_compound_{$this->_itemRowTotalKey}"); } /** diff --git a/app/code/core/Mage/Sales/Model/Quote/Item.php b/app/code/core/Mage/Sales/Model/Quote/Item.php index 212a78f0ce2..f40bdae8baf 100644 --- a/app/code/core/Mage/Sales/Model/Quote/Item.php +++ b/app/code/core/Mage/Sales/Model/Quote/Item.php @@ -460,10 +460,7 @@ public function representProduct($product) if (!$this->compareOptions($itemOptions, $productOptions)) { return false; } - if (!$this->compareOptions($productOptions, $itemOptions)) { - return false; - } - return true; + return $this->compareOptions($productOptions, $itemOptions); } /** diff --git a/app/code/core/Mage/Sales/Model/Quote/Item/Abstract.php b/app/code/core/Mage/Sales/Model/Quote/Item/Abstract.php index 9886867755f..de4f53d8487 100644 --- a/app/code/core/Mage/Sales/Model/Quote/Item/Abstract.php +++ b/app/code/core/Mage/Sales/Model/Quote/Item/Abstract.php @@ -713,11 +713,7 @@ public function isChildrenCalculated() } else { $calculate = $this->getProduct()->getPriceType(); } - - if (($calculate !== null) && (int)$calculate === Mage_Catalog_Model_Product_Type_Abstract::CALCULATE_CHILD) { - return true; - } - return false; + return ($calculate !== null) && (int)$calculate === Mage_Catalog_Model_Product_Type_Abstract::CALCULATE_CHILD; } /** @@ -733,13 +729,8 @@ public function isShipSeparately() } else { $shipmentType = $this->getProduct()->getShipmentType(); } - - if (($shipmentType !== null) && - (int)$shipmentType === Mage_Catalog_Model_Product_Type_Abstract::SHIPMENT_SEPARATELY - ) { - return true; - } - return false; + return ($shipmentType !== null) && + (int)$shipmentType === Mage_Catalog_Model_Product_Type_Abstract::SHIPMENT_SEPARATELY; } /** diff --git a/app/code/core/Mage/Sales/Model/Resource/Quote.php b/app/code/core/Mage/Sales/Model/Resource/Quote.php index b4d24f99ad7..a96082d7c01 100644 --- a/app/code/core/Mage/Sales/Model/Resource/Quote.php +++ b/app/code/core/Mage/Sales/Model/Resource/Quote.php @@ -155,11 +155,7 @@ public function isOrderIncrementIdUsed($orderIncrementId) $select->from($this->getTable('sales/order'), 'entity_id') ->where('increment_id = :increment_id'); $entity_id = $adapter->fetchOne($select, $bind); - if ($entity_id > 0) { - return true; - } - - return false; + return $entity_id > 0; } /** diff --git a/app/code/core/Mage/Sales/controllers/GuestController.php b/app/code/core/Mage/Sales/controllers/GuestController.php index b19310334cc..c37b52d8c25 100644 --- a/app/code/core/Mage/Sales/controllers/GuestController.php +++ b/app/code/core/Mage/Sales/controllers/GuestController.php @@ -41,10 +41,7 @@ protected function _loadValidOrder($orderId = null) protected function _canViewOrder($order) { $currentOrder = Mage::registry('current_order'); - if ($order->getId() && ($order->getId() === $currentOrder->getId())) { - return true; - } - return false; + return $order->getId() && ($order->getId() === $currentOrder->getId()); } protected function _viewAction() diff --git a/app/code/core/Mage/SalesRule/Model/Resource/Coupon.php b/app/code/core/Mage/SalesRule/Model/Resource/Coupon.php index 2d04d99ef85..a7ce63c7d2f 100644 --- a/app/code/core/Mage/SalesRule/Model/Resource/Coupon.php +++ b/app/code/core/Mage/SalesRule/Model/Resource/Coupon.php @@ -96,11 +96,7 @@ public function exists($code) $select = $read->select(); $select->from($this->getMainTable(), 'code'); $select->where('code = :code'); - - if ($read->fetchOne($select, ['code' => $code]) === false) { - return false; - } - return true; + return $read->fetchOne($select, ['code' => $code]) !== false; } /** diff --git a/app/code/core/Mage/Tax/Model/Sales/Total/Quote/Shipping.php b/app/code/core/Mage/Tax/Model/Sales/Total/Quote/Shipping.php index e70c3996304..0b9a7d72199 100644 --- a/app/code/core/Mage/Tax/Model/Sales/Total/Quote/Shipping.php +++ b/app/code/core/Mage/Tax/Model/Sales/Total/Quote/Shipping.php @@ -244,10 +244,7 @@ protected function _getAddressTaxRequest($address) protected function _needSubtractShippingTax($address) { $store = $address->getQuote()->getStore(); - if ($this->_config->shippingPriceIncludesTax($store) || $this->_config->getNeedUseShippingExcludeTax()) { - return true; - } - return false; + return $this->_config->shippingPriceIncludesTax($store) || $this->_config->getNeedUseShippingExcludeTax(); } /** diff --git a/app/code/core/Mage/Tax/Model/Sales/Total/Quote/Subtotal.php b/app/code/core/Mage/Tax/Model/Sales/Total/Quote/Subtotal.php index d0a63646805..59cd1c7f357 100644 --- a/app/code/core/Mage/Tax/Model/Sales/Total/Quote/Subtotal.php +++ b/app/code/core/Mage/Tax/Model/Sales/Total/Quote/Subtotal.php @@ -935,10 +935,7 @@ protected function _recollectItem($address, Mage_Sales_Model_Quote_Item_Abstract protected function _needSubtractTax($address) { $store = $address->getQuote()->getStore(); - if ($this->_config->priceIncludesTax($store) || $this->_config->getNeedUsePriceExcludeTax()) { - return true; - } - return false; + return $this->_config->priceIncludesTax($store) || $this->_config->getNeedUsePriceExcludeTax(); } /** @@ -953,9 +950,6 @@ protected function _needSubtractTax($address) protected function _needSubtractShippingTax($address) { $store = $address->getQuote()->getStore(); - if ($this->_config->shippingPriceIncludesTax($store) || $this->_config->getNeedUseShippingExcludeTax()) { - return true; - } - return false; + return $this->_config->shippingPriceIncludesTax($store) || $this->_config->getNeedUseShippingExcludeTax(); } } diff --git a/app/code/core/Mage/Widget/Block/Adminhtml/Widget/Instance/Edit/Chooser/Block.php b/app/code/core/Mage/Widget/Block/Adminhtml/Widget/Instance/Edit/Chooser/Block.php index 31efd2ea750..351207b913a 100644 --- a/app/code/core/Mage/Widget/Block/Adminhtml/Widget/Instance/Edit/Chooser/Block.php +++ b/app/code/core/Mage/Widget/Block/Adminhtml/Widget/Instance/Edit/Chooser/Block.php @@ -242,9 +242,6 @@ protected function _filterBlock($block) if (!$this->getAllowedBlocks()) { return true; } - if (in_array((string)$block->getAttribute('name'), $this->getAllowedBlocks())) { - return true; - } - return false; + return in_array((string)$block->getAttribute('name'), $this->getAllowedBlocks()); } } diff --git a/app/code/core/Mage/Widget/Block/Adminhtml/Widget/Instance/Edit/Chooser/Layout.php b/app/code/core/Mage/Widget/Block/Adminhtml/Widget/Instance/Edit/Chooser/Layout.php index 4098902fe42..b40d1478136 100644 --- a/app/code/core/Mage/Widget/Block/Adminhtml/Widget/Instance/Edit/Chooser/Layout.php +++ b/app/code/core/Mage/Widget/Block/Adminhtml/Widget/Instance/Edit/Chooser/Layout.php @@ -171,9 +171,6 @@ protected function _collectLayoutHandles($layoutHandles) protected function _filterLayoutHandle($layoutHandle) { $wildCard = '/(' . implode(')|(', $this->getLayoutHandlePatterns()) . ')/'; - if (preg_match($wildCard, $layoutHandle)) { - return false; - } - return true; + return !preg_match($wildCard, $layoutHandle); } } diff --git a/app/code/core/Mage/Wishlist/Helper/Data.php b/app/code/core/Mage/Wishlist/Helper/Data.php index 1e6fb11a99f..b89fb59a89f 100644 --- a/app/code/core/Mage/Wishlist/Helper/Data.php +++ b/app/code/core/Mage/Wishlist/Helper/Data.php @@ -428,10 +428,7 @@ public function getListUrl($wishlistId = null) */ public function isAllow() { - if ($this->isModuleOutputEnabled() && Mage::getStoreConfig('wishlist/general/active')) { - return true; - } - return false; + return $this->isModuleOutputEnabled() && Mage::getStoreConfig('wishlist/general/active'); } /** diff --git a/app/code/core/Mage/Wishlist/Model/Item.php b/app/code/core/Mage/Wishlist/Model/Item.php index d56354c811b..8ff9219cfe3 100644 --- a/app/code/core/Mage/Wishlist/Model/Item.php +++ b/app/code/core/Mage/Wishlist/Model/Item.php @@ -498,10 +498,7 @@ public function isRepresent($product, $buyRequest) if (!$this->_compareOptions($requestArray, $selfOptions)) { return false; } - if (!$this->_compareOptions($selfOptions, $requestArray)) { - return false; - } - return true; + return $this->_compareOptions($selfOptions, $requestArray); } /** @@ -523,10 +520,7 @@ public function representProduct($product) if (!$this->compareOptions($itemOptions, $productOptions)) { return false; } - if (!$this->compareOptions($productOptions, $itemOptions)) { - return false; - } - return true; + return $this->compareOptions($productOptions, $itemOptions); } /** diff --git a/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Widget/Grid.php b/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Widget/Grid.php index d1401e08a1c..7fab818ba31 100644 --- a/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Widget/Grid.php +++ b/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Widget/Grid.php @@ -517,10 +517,7 @@ public function isSelect(array $filter) try { $this->search($filter); $checkValue = $this->_rootElement->find($this->selectedItem, Locator::SELECTOR_CSS, 'checkbox')->getValue(); - if ($checkValue == 'Yes') { - return true; - } - return false; + return $checkValue == 'Yes'; } catch (\Exception $e) { throw new \Exception("Searched item was not found. \n $e"); } diff --git a/dev/tests/functional/tests/app/Mage/Paypal/Test/Block/Login.php b/dev/tests/functional/tests/app/Mage/Paypal/Test/Block/Login.php index f3e8fbeb46b..f4e47875493 100644 --- a/dev/tests/functional/tests/app/Mage/Paypal/Test/Block/Login.php +++ b/dev/tests/functional/tests/app/Mage/Paypal/Test/Block/Login.php @@ -120,10 +120,6 @@ public function fill(FixtureInterface $customer, Element $element = null) */ public function isBlockActive() { - if ($this->browser->find($this->mapping['password']['selector'])->isVisible()) { - return true; - } - - return false; + return (bool) $this->browser->find($this->mapping['password']['selector'])->isVisible(); } } diff --git a/dev/tests/functional/tests/app/Mage/Paypal/Test/Block/NewLogin.php b/dev/tests/functional/tests/app/Mage/Paypal/Test/Block/NewLogin.php index 3030342d0c8..d4e09b62ef9 100644 --- a/dev/tests/functional/tests/app/Mage/Paypal/Test/Block/NewLogin.php +++ b/dev/tests/functional/tests/app/Mage/Paypal/Test/Block/NewLogin.php @@ -82,11 +82,7 @@ public function clickToElement($selector) */ public function isBlockActive() { - if (!$this->browser->find($this->mapping['password']['selector'])->isVisible()) { - return true; - } - - return false; + return !$this->browser->find($this->mapping['password']['selector'])->isVisible(); } /** diff --git a/lib/Mage/Archive.php b/lib/Mage/Archive.php index 548fd32a8c2..1389a8a0442 100644 --- a/lib/Mage/Archive.php +++ b/lib/Mage/Archive.php @@ -184,10 +184,7 @@ public function extract($file, $source, $destination = '.') public function isArchive($file) { $archivers = $this->_getArchivers($file); - if (count($archivers)) { - return true; - } - return false; + return (bool) count($archivers); } /** @@ -199,9 +196,6 @@ public function isArchive($file) public function isTar($file) { $archivers = $this->_getArchivers($file); - if (count($archivers) == 1 && $archivers[0] == self::TAPE_ARCHIVER) { - return true; - } - return false; + return count($archivers) == 1 && $archivers[0] == self::TAPE_ARCHIVER; } } diff --git a/lib/Magento/Db/Object/Trigger.php b/lib/Magento/Db/Object/Trigger.php index 100292d7a36..12210470cf9 100644 --- a/lib/Magento/Db/Object/Trigger.php +++ b/lib/Magento/Db/Object/Trigger.php @@ -39,12 +39,7 @@ public function isExists() if (!isset($this->_data['triggers'][$this->_schemaName])) { $this->describe(); } - - if (isset($this->_data['triggers'][$this->_schemaName][$this->_objectName])) { - return true; - } - - return false; + return isset($this->_data['triggers'][$this->_schemaName][$this->_objectName]); } public function describe() diff --git a/lib/Varien/Data/Form/Element/Editor.php b/lib/Varien/Data/Form/Element/Editor.php index 43d40074109..bfdb99123c8 100644 --- a/lib/Varien/Data/Form/Element/Editor.php +++ b/lib/Varien/Data/Form/Element/Editor.php @@ -259,10 +259,7 @@ protected function _prepareButtonOptions($options) */ protected function _checkPluginButtonOptions($pluginOptions) { - if (!isset($pluginOptions['title'])) { - return false; - } - return true; + return isset($pluginOptions['title']); } /** diff --git a/lib/Varien/Db/Adapter/Pdo/Mysql.php b/lib/Varien/Db/Adapter/Pdo/Mysql.php index 93412dad7c6..e473f3058da 100644 --- a/lib/Varien/Db/Adapter/Pdo/Mysql.php +++ b/lib/Varien/Db/Adapter/Pdo/Mysql.php @@ -2679,11 +2679,7 @@ public function isTableExists($tableName, $schemaName = null) $fromDbName ); $ddl = $this->raw_fetchRow($sql, 'tbl_exists'); - if ($ddl) { - return true; - } - - return false; + return $ddl; } /** diff --git a/lib/Varien/Object.php b/lib/Varien/Object.php index bfd0f11bcff..21b75bbbf91 100644 --- a/lib/Varien/Object.php +++ b/lib/Varien/Object.php @@ -669,10 +669,7 @@ public function __set($var, $value) */ public function isEmpty() { - if (empty($this->_data)) { - return true; - } - return false; + return empty($this->_data); } /** From 4fe6c68e0eb9623504cedc9c91e9f78d63746ee0 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 12 Aug 2024 04:57:54 +0200 Subject: [PATCH 10/16] Added SimplifyDeMorganBinaryRector rule --- .../Block/Catalog/Product/Edit/Tab/Price/Group/Abstract.php | 4 ++-- app/code/core/Mage/Adminhtml/Block/Sales/Items/Abstract.php | 2 +- .../core/Mage/Adminhtml/Block/System/Variable/Edit/Form.php | 5 +---- app/code/core/Mage/Adminhtml/Controller/Action.php | 3 +-- .../Mage/Adminhtml/Model/System/Config/Backend/Sitemap.php | 2 +- .../Mage/Bundle/Block/Catalog/Product/View/Type/Bundle.php | 2 +- app/code/core/Mage/Catalog/Model/Api/Resource.php | 3 +-- .../core/Mage/Catalog/Model/Api2/Product/Rest/Admin/V1.php | 3 +-- app/code/core/Mage/Checkout/Block/Onepage/Billing.php | 3 +-- app/code/core/Mage/Checkout/Model/Api/Resource.php | 2 +- app/code/core/Mage/Checkout/Model/Cart/Payment/Api.php | 4 ++-- app/code/core/Mage/Checkout/Model/Type/Onepage.php | 2 +- app/code/core/Mage/Core/Helper/Abstract.php | 2 +- app/code/core/Mage/Core/Helper/Data.php | 6 +++--- app/code/core/Mage/Core/Helper/String.php | 2 +- app/code/core/Mage/Customer/Model/Api/Resource.php | 3 +-- app/code/core/Mage/Eav/Model/Entity/Abstract.php | 2 +- app/code/core/Mage/Paypal/Model/Express/Checkout.php | 3 +-- app/code/core/Mage/Sales/Model/Order.php | 2 +- .../core/Mage/Sales/Model/Order/Payment/Transaction.php | 2 +- lib/Varien/File/Uploader.php | 2 +- rector.php | 2 ++ 22 files changed, 27 insertions(+), 34 deletions(-) diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Group/Abstract.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Group/Abstract.php index 6c863d731ba..bebb82bfe65 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Group/Abstract.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Group/Abstract.php @@ -309,7 +309,7 @@ public function isScopeGlobal() */ public function isShowWebsiteColumn() { - return !($this->isScopeGlobal() || Mage::app()->isSingleStoreMode()); + return !$this->isScopeGlobal() && !Mage::app()->isSingleStoreMode(); } /** @@ -319,6 +319,6 @@ public function isShowWebsiteColumn() */ public function isAllowChangeWebsite() { - return !(!$this->isShowWebsiteColumn() || $this->getProduct()->getStoreId()); + return $this->isShowWebsiteColumn() && !$this->getProduct()->getStoreId(); } } diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Items/Abstract.php b/app/code/core/Mage/Adminhtml/Block/Sales/Items/Abstract.php index 2b17aa249ec..d18226b1b63 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Items/Abstract.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Items/Abstract.php @@ -582,6 +582,6 @@ public function canShipPartiallyItem($order = null) public function isShipmentRegular() { - return !(!$this->canShipPartiallyItem() || !$this->canShipPartially()); + return $this->canShipPartiallyItem() && $this->canShipPartially(); } } diff --git a/app/code/core/Mage/Adminhtml/Block/System/Variable/Edit/Form.php b/app/code/core/Mage/Adminhtml/Block/System/Variable/Edit/Form.php index 2d4eaa41226..c676108c685 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Variable/Edit/Form.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Variable/Edit/Form.php @@ -66,10 +66,7 @@ protected function _prepareForm() $useDefault = false; if ($this->getVariable()->getId() && $this->getVariable()->getStoreId()) { - $useDefault = !( - (bool)$this->getVariable()->getStoreHtmlValue() - || (bool)$this->getVariable()->getStorePlainValue() - ); + $useDefault = !(bool)$this->getVariable()->getStoreHtmlValue() && !(bool)$this->getVariable()->getStorePlainValue(); $this->getVariable()->setUseDefaultValue((int)$useDefault); $fieldset->addField('use_default_value', 'select', [ 'name' => 'use_default_value', diff --git a/app/code/core/Mage/Adminhtml/Controller/Action.php b/app/code/core/Mage/Adminhtml/Controller/Action.php index 20b819f4fad..b3da64f2fbd 100644 --- a/app/code/core/Mage/Adminhtml/Controller/Action.php +++ b/app/code/core/Mage/Adminhtml/Controller/Action.php @@ -395,8 +395,7 @@ protected function _validateSecretKey() if (is_array($this->_publicActions) && in_array($this->getRequest()->getActionName(), $this->_publicActions)) { return true; } - return !(!($secretKey = $this->getRequest()->getParam(Mage_Adminhtml_Model_Url::SECRET_KEY_PARAM_NAME, null)) - || !hash_equals(Mage::getSingleton('adminhtml/url')->getSecretKey(), $secretKey)); + return ($secretKey = $this->getRequest()->getParam(Mage_Adminhtml_Model_Url::SECRET_KEY_PARAM_NAME, null)) && hash_equals(Mage::getSingleton('adminhtml/url')->getSecretKey(), $secretKey); } /** diff --git a/app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Sitemap.php b/app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Sitemap.php index 89e63186fa4..a4967f90f10 100644 --- a/app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Sitemap.php +++ b/app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Sitemap.php @@ -24,7 +24,7 @@ protected function _beforeSave() $value = $this->getValue(); if ($value < 0 || $value > 1) { throw new Exception(Mage::helper('sitemap')->__('The priority must be between 0 and 1.')); - } elseif (($value == 0) && !($value === '0' || $value === '0.0')) { + } elseif (($value == 0) && ($value !== '0' && $value !== '0.0')) { throw new Exception(Mage::helper('sitemap')->__('The priority must be between 0 and 1.')); } return $this; diff --git a/app/code/core/Mage/Bundle/Block/Catalog/Product/View/Type/Bundle.php b/app/code/core/Mage/Bundle/Block/Catalog/Product/View/Type/Bundle.php index 73ca64c96ea..48cc44161e9 100644 --- a/app/code/core/Mage/Bundle/Block/Catalog/Product/View/Type/Bundle.php +++ b/app/code/core/Mage/Bundle/Block/Catalog/Product/View/Type/Bundle.php @@ -89,7 +89,7 @@ public function getOptions() public function hasOptions() { $this->getOptions(); - return !(empty($this->_options) || !$this->getProduct()->isSalable()); + return !empty($this->_options) && $this->getProduct()->isSalable(); } /** diff --git a/app/code/core/Mage/Catalog/Model/Api/Resource.php b/app/code/core/Mage/Catalog/Model/Api/Resource.php index 2d2bd39a464..871914bd1ef 100644 --- a/app/code/core/Mage/Catalog/Model/Api/Resource.php +++ b/app/code/core/Mage/Catalog/Model/Api/Resource.php @@ -63,8 +63,7 @@ protected function _isAllowedAttribute($attribute, $attributes = null) } if (is_array($attributes) - && !(in_array($attribute->getAttributeCode(), $attributes) - || in_array($attribute->getAttributeId(), $attributes)) + && (!in_array($attribute->getAttributeCode(), $attributes) && !in_array($attribute->getAttributeId(), $attributes)) ) { return false; } diff --git a/app/code/core/Mage/Catalog/Model/Api2/Product/Rest/Admin/V1.php b/app/code/core/Mage/Catalog/Model/Api2/Product/Rest/Admin/V1.php index 9b9d0a7c3fe..2dfae68a163 100644 --- a/app/code/core/Mage/Catalog/Model/Api2/Product/Rest/Admin/V1.php +++ b/app/code/core/Mage/Catalog/Model/Api2/Product/Rest/Admin/V1.php @@ -383,8 +383,7 @@ protected function _isAllowedAttribute($attribute, $attributes = null) { $isAllowed = true; if (is_array($attributes) - && !(in_array($attribute->getAttributeCode(), $attributes) - || in_array($attribute->getAttributeId(), $attributes)) + && (!in_array($attribute->getAttributeCode(), $attributes) && !in_array($attribute->getAttributeId(), $attributes)) ) { $isAllowed = false; } diff --git a/app/code/core/Mage/Checkout/Block/Onepage/Billing.php b/app/code/core/Mage/Checkout/Block/Onepage/Billing.php index ea0fb2fe38b..e1fcacd4ea5 100644 --- a/app/code/core/Mage/Checkout/Block/Onepage/Billing.php +++ b/app/code/core/Mage/Checkout/Block/Onepage/Billing.php @@ -57,8 +57,7 @@ protected function _construct() */ public function isUseBillingAddressForShipping() { - return !(($this->getQuote()->getIsVirtual()) - || !$this->getQuote()->getShippingAddress()->getSameAsBilling()); + return !$this->getQuote()->getIsVirtual() && $this->getQuote()->getShippingAddress()->getSameAsBilling(); } /** diff --git a/app/code/core/Mage/Checkout/Model/Api/Resource.php b/app/code/core/Mage/Checkout/Model/Api/Resource.php index 47d9a1eb32c..471119618c9 100644 --- a/app/code/core/Mage/Checkout/Model/Api/Resource.php +++ b/app/code/core/Mage/Checkout/Model/Api/Resource.php @@ -105,7 +105,7 @@ protected function _getQuote($quoteId, $store = null) /** @var Mage_Sales_Model_Quote $quote */ $quote = Mage::getModel("sales/quote"); - if (!(is_string($store) || is_int($store))) { + if (!is_string($store) && !is_int($store)) { $quote->loadByIdWithoutStore($quoteId); } else { $storeId = $this->_getStoreId($store); diff --git a/app/code/core/Mage/Checkout/Model/Cart/Payment/Api.php b/app/code/core/Mage/Checkout/Model/Cart/Payment/Api.php index 3fffca407c2..48234d5b9d1 100644 --- a/app/code/core/Mage/Checkout/Model/Cart/Payment/Api.php +++ b/app/code/core/Mage/Checkout/Model/Cart/Payment/Api.php @@ -41,7 +41,7 @@ protected function _preparePaymentData($data) */ protected function _canUsePaymentMethod($method, $quote) { - if (!($method->isGateway() || $method->canUseInternal())) { + if (!$method->isGateway() && !$method->canUseInternal()) { return false; } @@ -59,7 +59,7 @@ protected function _canUsePaymentMethod($method, $quote) $total = $quote->getBaseGrandTotal(); $minTotal = $method->getConfigData('min_order_total'); $maxTotal = $method->getConfigData('max_order_total'); - return !((!empty($minTotal) && ($total < $minTotal)) || (!empty($maxTotal) && ($total > $maxTotal))); + return !(!empty($minTotal) && ($total < $minTotal)) && !(!empty($maxTotal) && ($total > $maxTotal)); } /** diff --git a/app/code/core/Mage/Checkout/Model/Type/Onepage.php b/app/code/core/Mage/Checkout/Model/Type/Onepage.php index f1d8d4a5ced..e63523ce65e 100644 --- a/app/code/core/Mage/Checkout/Model/Type/Onepage.php +++ b/app/code/core/Mage/Checkout/Model/Type/Onepage.php @@ -120,7 +120,7 @@ public function initCheckout() $customerSession = $this->getCustomerSession(); if (is_array($checkout->getStepData())) { foreach ($checkout->getStepData() as $step => $data) { - if (!($step === 'login' || $customerSession->isLoggedIn() && $step === 'billing')) { + if ($step !== 'login' && !($customerSession->isLoggedIn() && $step === 'billing')) { $checkout->setStepData($step, 'allow', false); } } diff --git a/app/code/core/Mage/Core/Helper/Abstract.php b/app/code/core/Mage/Core/Helper/Abstract.php index 50bf0a3a8e5..6d5d9147aed 100644 --- a/app/code/core/Mage/Core/Helper/Abstract.php +++ b/app/code/core/Mage/Core/Helper/Abstract.php @@ -154,7 +154,7 @@ public function isModuleEnabled($moduleName = null) } $isActive = Mage::getConfig()->getNode('modules/' . $moduleName . '/active'); - return !(!$isActive || !in_array((string)$isActive, ['true', '1'])); + return $isActive && in_array((string)$isActive, ['true', '1']); } /** diff --git a/app/code/core/Mage/Core/Helper/Data.php b/app/code/core/Mage/Core/Helper/Data.php index 73029d7952c..515e1826cb8 100644 --- a/app/code/core/Mage/Core/Helper/Data.php +++ b/app/code/core/Mage/Core/Helper/Data.php @@ -455,8 +455,8 @@ public function getCacheBetaTypes() */ public function copyFieldset($fieldset, $aspect, $source, $target, $root = 'global') { - if (!(is_array($source) || $source instanceof Varien_Object) - || !(is_array($target) || $target instanceof Varien_Object) + if (!is_array($source) && !$source instanceof Varien_Object + || !is_array($target) && !$target instanceof Varien_Object ) { return false; } @@ -525,7 +525,7 @@ public function copyFieldset($fieldset, $aspect, $source, $target, $root = 'glob public function decorateArray($array, $prefix = 'decorated_', $forceSetAll = false) { // check if array or an object to be iterated given - if (!(is_array($array) || is_object($array))) { + if (!is_array($array) && !is_object($array)) { return $array; } diff --git a/app/code/core/Mage/Core/Helper/String.php b/app/code/core/Mage/Core/Helper/String.php index dd9ec89dc0f..2c474029177 100644 --- a/app/code/core/Mage/Core/Helper/String.php +++ b/app/code/core/Mage/Core/Helper/String.php @@ -350,7 +350,7 @@ public function parseQueryStr($str) */ protected function _validateQueryStr($str) { - return !(!$str || !str_contains($str, '=')); + return $str && str_contains($str, '='); } /** diff --git a/app/code/core/Mage/Customer/Model/Api/Resource.php b/app/code/core/Mage/Customer/Model/Api/Resource.php index 4c684a1fcf7..67daa20796b 100644 --- a/app/code/core/Mage/Customer/Model/Api/Resource.php +++ b/app/code/core/Mage/Customer/Model/Api/Resource.php @@ -45,8 +45,7 @@ class Mage_Customer_Model_Api_Resource extends Mage_Api_Model_Resource_Abstract protected function _isAllowedAttribute($attribute, ?array $filter = null) { if (!is_null($filter) - && !(in_array($attribute->getAttributeCode(), $filter) - || in_array($attribute->getAttributeId(), $filter)) + && (!in_array($attribute->getAttributeCode(), $filter) && !in_array($attribute->getAttributeId(), $filter)) ) { return false; } diff --git a/app/code/core/Mage/Eav/Model/Entity/Abstract.php b/app/code/core/Mage/Eav/Model/Entity/Abstract.php index 18fdf7dd84d..97eb67592c1 100644 --- a/app/code/core/Mage/Eav/Model/Entity/Abstract.php +++ b/app/code/core/Mage/Eav/Model/Entity/Abstract.php @@ -660,7 +660,7 @@ public function walkAttributes($partMethod, array $args = []) */ protected function _isCallableAttributeInstance($instance, $method, $args) { - return !(!is_object($instance) || !method_exists($instance, $method)); + return is_object($instance) && method_exists($instance, $method); } /** diff --git a/app/code/core/Mage/Paypal/Model/Express/Checkout.php b/app/code/core/Mage/Paypal/Model/Express/Checkout.php index 979feaa7817..94d437c4dbc 100644 --- a/app/code/core/Mage/Paypal/Model/Express/Checkout.php +++ b/app/code/core/Mage/Paypal/Model/Express/Checkout.php @@ -755,8 +755,7 @@ protected function _setBillingAgreementRequest() $isRequested = $this->_isBARequested || $this->_quote->getPayment() ->getAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT); - if (!($this->_config->allow_ba_signup == Mage_Paypal_Model_Config::EC_BA_SIGNUP_AUTO - || $isRequested && $this->_config->shouldAskToCreateBillingAgreement()) + if ($this->_config->allow_ba_signup != Mage_Paypal_Model_Config::EC_BA_SIGNUP_AUTO && !($isRequested && $this->_config->shouldAskToCreateBillingAgreement()) ) { return $this; } diff --git a/app/code/core/Mage/Sales/Model/Order.php b/app/code/core/Mage/Sales/Model/Order.php index 6d3a81cec00..fe82fda3f8e 100644 --- a/app/code/core/Mage/Sales/Model/Order.php +++ b/app/code/core/Mage/Sales/Model/Order.php @@ -677,7 +677,7 @@ public function canVoidPayment() */ protected function _canVoidOrder() { - return !($this->canUnhold() || $this->isPaymentReview()); + return !$this->canUnhold() && !$this->isPaymentReview(); } /** diff --git a/app/code/core/Mage/Sales/Model/Order/Payment/Transaction.php b/app/code/core/Mage/Sales/Model/Order/Payment/Transaction.php index b2bf223756b..c47abfa6529 100644 --- a/app/code/core/Mage/Sales/Model/Order/Payment/Transaction.php +++ b/app/code/core/Mage/Sales/Model/Order/Payment/Transaction.php @@ -357,7 +357,7 @@ public function canVoidAuthorizationCompletely() { try { $authTransaction = $this->closeAuthorization('', true); - return !($authTransaction->hasChildTransaction() || $this->_children); + return !$authTransaction->hasChildTransaction() && !$this->_children; } catch (Mage_Core_Exception $e) { // jam all logical exceptions, fallback to false } diff --git a/lib/Varien/File/Uploader.php b/lib/Varien/File/Uploader.php index 0acc053944b..cb3ea36ff60 100644 --- a/lib/Varien/File/Uploader.php +++ b/lib/Varien/File/Uploader.php @@ -546,7 +546,7 @@ private function _createDestinationFolder($destinationFolder) $destinationFolder = substr($destinationFolder, 0, -1); } - if (!(@is_dir($destinationFolder) || @mkdir($destinationFolder, 0777, true))) { + if (!@is_dir($destinationFolder) && !@mkdir($destinationFolder, 0777, true)) { throw new Exception("Unable to create directory '{$destinationFolder}'."); } return $this; diff --git a/rector.php b/rector.php index 0b0d4c0ab7c..56e18efa3f2 100644 --- a/rector.php +++ b/rector.php @@ -2,6 +2,7 @@ declare(strict_types=1); +use Rector\CodeQuality\Rector\BooleanNot\SimplifyDeMorganBinaryRector; use Rector\CodeQuality\Rector\If_\SimplifyIfReturnBoolRector; use Rector\Config\RectorConfig; @@ -16,5 +17,6 @@ ]) ->withSkipPath(__DIR__ . '/vendor') ->withRules([ + SimplifyDeMorganBinaryRector::class, SimplifyIfReturnBoolRector::class ]); From 392d0a88c2a8c68854106c79288e727fa2c1660c Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 13 Aug 2024 01:22:33 +0200 Subject: [PATCH 11/16] Revert "Added SimplifyDeMorganBinaryRector rule" This reverts commit 4fe6c68e0eb9623504cedc9c91e9f78d63746ee0. --- .../Block/Catalog/Product/Edit/Tab/Price/Group/Abstract.php | 4 ++-- app/code/core/Mage/Adminhtml/Block/Sales/Items/Abstract.php | 2 +- .../core/Mage/Adminhtml/Block/System/Variable/Edit/Form.php | 5 ++++- app/code/core/Mage/Adminhtml/Controller/Action.php | 3 ++- .../Mage/Adminhtml/Model/System/Config/Backend/Sitemap.php | 2 +- .../Mage/Bundle/Block/Catalog/Product/View/Type/Bundle.php | 2 +- app/code/core/Mage/Catalog/Model/Api/Resource.php | 3 ++- .../core/Mage/Catalog/Model/Api2/Product/Rest/Admin/V1.php | 3 ++- app/code/core/Mage/Checkout/Block/Onepage/Billing.php | 3 ++- app/code/core/Mage/Checkout/Model/Api/Resource.php | 2 +- app/code/core/Mage/Checkout/Model/Cart/Payment/Api.php | 4 ++-- app/code/core/Mage/Checkout/Model/Type/Onepage.php | 2 +- app/code/core/Mage/Core/Helper/Abstract.php | 2 +- app/code/core/Mage/Core/Helper/Data.php | 6 +++--- app/code/core/Mage/Core/Helper/String.php | 2 +- app/code/core/Mage/Customer/Model/Api/Resource.php | 3 ++- app/code/core/Mage/Eav/Model/Entity/Abstract.php | 2 +- app/code/core/Mage/Paypal/Model/Express/Checkout.php | 3 ++- app/code/core/Mage/Sales/Model/Order.php | 2 +- .../core/Mage/Sales/Model/Order/Payment/Transaction.php | 2 +- lib/Varien/File/Uploader.php | 2 +- rector.php | 2 -- 22 files changed, 34 insertions(+), 27 deletions(-) diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Group/Abstract.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Group/Abstract.php index bebb82bfe65..6c863d731ba 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Group/Abstract.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Group/Abstract.php @@ -309,7 +309,7 @@ public function isScopeGlobal() */ public function isShowWebsiteColumn() { - return !$this->isScopeGlobal() && !Mage::app()->isSingleStoreMode(); + return !($this->isScopeGlobal() || Mage::app()->isSingleStoreMode()); } /** @@ -319,6 +319,6 @@ public function isShowWebsiteColumn() */ public function isAllowChangeWebsite() { - return $this->isShowWebsiteColumn() && !$this->getProduct()->getStoreId(); + return !(!$this->isShowWebsiteColumn() || $this->getProduct()->getStoreId()); } } diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Items/Abstract.php b/app/code/core/Mage/Adminhtml/Block/Sales/Items/Abstract.php index d18226b1b63..2b17aa249ec 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Items/Abstract.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Items/Abstract.php @@ -582,6 +582,6 @@ public function canShipPartiallyItem($order = null) public function isShipmentRegular() { - return $this->canShipPartiallyItem() && $this->canShipPartially(); + return !(!$this->canShipPartiallyItem() || !$this->canShipPartially()); } } diff --git a/app/code/core/Mage/Adminhtml/Block/System/Variable/Edit/Form.php b/app/code/core/Mage/Adminhtml/Block/System/Variable/Edit/Form.php index c676108c685..2d4eaa41226 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Variable/Edit/Form.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Variable/Edit/Form.php @@ -66,7 +66,10 @@ protected function _prepareForm() $useDefault = false; if ($this->getVariable()->getId() && $this->getVariable()->getStoreId()) { - $useDefault = !(bool)$this->getVariable()->getStoreHtmlValue() && !(bool)$this->getVariable()->getStorePlainValue(); + $useDefault = !( + (bool)$this->getVariable()->getStoreHtmlValue() + || (bool)$this->getVariable()->getStorePlainValue() + ); $this->getVariable()->setUseDefaultValue((int)$useDefault); $fieldset->addField('use_default_value', 'select', [ 'name' => 'use_default_value', diff --git a/app/code/core/Mage/Adminhtml/Controller/Action.php b/app/code/core/Mage/Adminhtml/Controller/Action.php index b3da64f2fbd..20b819f4fad 100644 --- a/app/code/core/Mage/Adminhtml/Controller/Action.php +++ b/app/code/core/Mage/Adminhtml/Controller/Action.php @@ -395,7 +395,8 @@ protected function _validateSecretKey() if (is_array($this->_publicActions) && in_array($this->getRequest()->getActionName(), $this->_publicActions)) { return true; } - return ($secretKey = $this->getRequest()->getParam(Mage_Adminhtml_Model_Url::SECRET_KEY_PARAM_NAME, null)) && hash_equals(Mage::getSingleton('adminhtml/url')->getSecretKey(), $secretKey); + return !(!($secretKey = $this->getRequest()->getParam(Mage_Adminhtml_Model_Url::SECRET_KEY_PARAM_NAME, null)) + || !hash_equals(Mage::getSingleton('adminhtml/url')->getSecretKey(), $secretKey)); } /** diff --git a/app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Sitemap.php b/app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Sitemap.php index a4967f90f10..89e63186fa4 100644 --- a/app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Sitemap.php +++ b/app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Sitemap.php @@ -24,7 +24,7 @@ protected function _beforeSave() $value = $this->getValue(); if ($value < 0 || $value > 1) { throw new Exception(Mage::helper('sitemap')->__('The priority must be between 0 and 1.')); - } elseif (($value == 0) && ($value !== '0' && $value !== '0.0')) { + } elseif (($value == 0) && !($value === '0' || $value === '0.0')) { throw new Exception(Mage::helper('sitemap')->__('The priority must be between 0 and 1.')); } return $this; diff --git a/app/code/core/Mage/Bundle/Block/Catalog/Product/View/Type/Bundle.php b/app/code/core/Mage/Bundle/Block/Catalog/Product/View/Type/Bundle.php index 48cc44161e9..73ca64c96ea 100644 --- a/app/code/core/Mage/Bundle/Block/Catalog/Product/View/Type/Bundle.php +++ b/app/code/core/Mage/Bundle/Block/Catalog/Product/View/Type/Bundle.php @@ -89,7 +89,7 @@ public function getOptions() public function hasOptions() { $this->getOptions(); - return !empty($this->_options) && $this->getProduct()->isSalable(); + return !(empty($this->_options) || !$this->getProduct()->isSalable()); } /** diff --git a/app/code/core/Mage/Catalog/Model/Api/Resource.php b/app/code/core/Mage/Catalog/Model/Api/Resource.php index 871914bd1ef..2d2bd39a464 100644 --- a/app/code/core/Mage/Catalog/Model/Api/Resource.php +++ b/app/code/core/Mage/Catalog/Model/Api/Resource.php @@ -63,7 +63,8 @@ protected function _isAllowedAttribute($attribute, $attributes = null) } if (is_array($attributes) - && (!in_array($attribute->getAttributeCode(), $attributes) && !in_array($attribute->getAttributeId(), $attributes)) + && !(in_array($attribute->getAttributeCode(), $attributes) + || in_array($attribute->getAttributeId(), $attributes)) ) { return false; } diff --git a/app/code/core/Mage/Catalog/Model/Api2/Product/Rest/Admin/V1.php b/app/code/core/Mage/Catalog/Model/Api2/Product/Rest/Admin/V1.php index 2dfae68a163..9b9d0a7c3fe 100644 --- a/app/code/core/Mage/Catalog/Model/Api2/Product/Rest/Admin/V1.php +++ b/app/code/core/Mage/Catalog/Model/Api2/Product/Rest/Admin/V1.php @@ -383,7 +383,8 @@ protected function _isAllowedAttribute($attribute, $attributes = null) { $isAllowed = true; if (is_array($attributes) - && (!in_array($attribute->getAttributeCode(), $attributes) && !in_array($attribute->getAttributeId(), $attributes)) + && !(in_array($attribute->getAttributeCode(), $attributes) + || in_array($attribute->getAttributeId(), $attributes)) ) { $isAllowed = false; } diff --git a/app/code/core/Mage/Checkout/Block/Onepage/Billing.php b/app/code/core/Mage/Checkout/Block/Onepage/Billing.php index e1fcacd4ea5..ea0fb2fe38b 100644 --- a/app/code/core/Mage/Checkout/Block/Onepage/Billing.php +++ b/app/code/core/Mage/Checkout/Block/Onepage/Billing.php @@ -57,7 +57,8 @@ protected function _construct() */ public function isUseBillingAddressForShipping() { - return !$this->getQuote()->getIsVirtual() && $this->getQuote()->getShippingAddress()->getSameAsBilling(); + return !(($this->getQuote()->getIsVirtual()) + || !$this->getQuote()->getShippingAddress()->getSameAsBilling()); } /** diff --git a/app/code/core/Mage/Checkout/Model/Api/Resource.php b/app/code/core/Mage/Checkout/Model/Api/Resource.php index 471119618c9..47d9a1eb32c 100644 --- a/app/code/core/Mage/Checkout/Model/Api/Resource.php +++ b/app/code/core/Mage/Checkout/Model/Api/Resource.php @@ -105,7 +105,7 @@ protected function _getQuote($quoteId, $store = null) /** @var Mage_Sales_Model_Quote $quote */ $quote = Mage::getModel("sales/quote"); - if (!is_string($store) && !is_int($store)) { + if (!(is_string($store) || is_int($store))) { $quote->loadByIdWithoutStore($quoteId); } else { $storeId = $this->_getStoreId($store); diff --git a/app/code/core/Mage/Checkout/Model/Cart/Payment/Api.php b/app/code/core/Mage/Checkout/Model/Cart/Payment/Api.php index 48234d5b9d1..3fffca407c2 100644 --- a/app/code/core/Mage/Checkout/Model/Cart/Payment/Api.php +++ b/app/code/core/Mage/Checkout/Model/Cart/Payment/Api.php @@ -41,7 +41,7 @@ protected function _preparePaymentData($data) */ protected function _canUsePaymentMethod($method, $quote) { - if (!$method->isGateway() && !$method->canUseInternal()) { + if (!($method->isGateway() || $method->canUseInternal())) { return false; } @@ -59,7 +59,7 @@ protected function _canUsePaymentMethod($method, $quote) $total = $quote->getBaseGrandTotal(); $minTotal = $method->getConfigData('min_order_total'); $maxTotal = $method->getConfigData('max_order_total'); - return !(!empty($minTotal) && ($total < $minTotal)) && !(!empty($maxTotal) && ($total > $maxTotal)); + return !((!empty($minTotal) && ($total < $minTotal)) || (!empty($maxTotal) && ($total > $maxTotal))); } /** diff --git a/app/code/core/Mage/Checkout/Model/Type/Onepage.php b/app/code/core/Mage/Checkout/Model/Type/Onepage.php index e63523ce65e..f1d8d4a5ced 100644 --- a/app/code/core/Mage/Checkout/Model/Type/Onepage.php +++ b/app/code/core/Mage/Checkout/Model/Type/Onepage.php @@ -120,7 +120,7 @@ public function initCheckout() $customerSession = $this->getCustomerSession(); if (is_array($checkout->getStepData())) { foreach ($checkout->getStepData() as $step => $data) { - if ($step !== 'login' && !($customerSession->isLoggedIn() && $step === 'billing')) { + if (!($step === 'login' || $customerSession->isLoggedIn() && $step === 'billing')) { $checkout->setStepData($step, 'allow', false); } } diff --git a/app/code/core/Mage/Core/Helper/Abstract.php b/app/code/core/Mage/Core/Helper/Abstract.php index 6d5d9147aed..50bf0a3a8e5 100644 --- a/app/code/core/Mage/Core/Helper/Abstract.php +++ b/app/code/core/Mage/Core/Helper/Abstract.php @@ -154,7 +154,7 @@ public function isModuleEnabled($moduleName = null) } $isActive = Mage::getConfig()->getNode('modules/' . $moduleName . '/active'); - return $isActive && in_array((string)$isActive, ['true', '1']); + return !(!$isActive || !in_array((string)$isActive, ['true', '1'])); } /** diff --git a/app/code/core/Mage/Core/Helper/Data.php b/app/code/core/Mage/Core/Helper/Data.php index 515e1826cb8..73029d7952c 100644 --- a/app/code/core/Mage/Core/Helper/Data.php +++ b/app/code/core/Mage/Core/Helper/Data.php @@ -455,8 +455,8 @@ public function getCacheBetaTypes() */ public function copyFieldset($fieldset, $aspect, $source, $target, $root = 'global') { - if (!is_array($source) && !$source instanceof Varien_Object - || !is_array($target) && !$target instanceof Varien_Object + if (!(is_array($source) || $source instanceof Varien_Object) + || !(is_array($target) || $target instanceof Varien_Object) ) { return false; } @@ -525,7 +525,7 @@ public function copyFieldset($fieldset, $aspect, $source, $target, $root = 'glob public function decorateArray($array, $prefix = 'decorated_', $forceSetAll = false) { // check if array or an object to be iterated given - if (!is_array($array) && !is_object($array)) { + if (!(is_array($array) || is_object($array))) { return $array; } diff --git a/app/code/core/Mage/Core/Helper/String.php b/app/code/core/Mage/Core/Helper/String.php index 2c474029177..dd9ec89dc0f 100644 --- a/app/code/core/Mage/Core/Helper/String.php +++ b/app/code/core/Mage/Core/Helper/String.php @@ -350,7 +350,7 @@ public function parseQueryStr($str) */ protected function _validateQueryStr($str) { - return $str && str_contains($str, '='); + return !(!$str || !str_contains($str, '=')); } /** diff --git a/app/code/core/Mage/Customer/Model/Api/Resource.php b/app/code/core/Mage/Customer/Model/Api/Resource.php index 67daa20796b..4c684a1fcf7 100644 --- a/app/code/core/Mage/Customer/Model/Api/Resource.php +++ b/app/code/core/Mage/Customer/Model/Api/Resource.php @@ -45,7 +45,8 @@ class Mage_Customer_Model_Api_Resource extends Mage_Api_Model_Resource_Abstract protected function _isAllowedAttribute($attribute, ?array $filter = null) { if (!is_null($filter) - && (!in_array($attribute->getAttributeCode(), $filter) && !in_array($attribute->getAttributeId(), $filter)) + && !(in_array($attribute->getAttributeCode(), $filter) + || in_array($attribute->getAttributeId(), $filter)) ) { return false; } diff --git a/app/code/core/Mage/Eav/Model/Entity/Abstract.php b/app/code/core/Mage/Eav/Model/Entity/Abstract.php index 97eb67592c1..18fdf7dd84d 100644 --- a/app/code/core/Mage/Eav/Model/Entity/Abstract.php +++ b/app/code/core/Mage/Eav/Model/Entity/Abstract.php @@ -660,7 +660,7 @@ public function walkAttributes($partMethod, array $args = []) */ protected function _isCallableAttributeInstance($instance, $method, $args) { - return is_object($instance) && method_exists($instance, $method); + return !(!is_object($instance) || !method_exists($instance, $method)); } /** diff --git a/app/code/core/Mage/Paypal/Model/Express/Checkout.php b/app/code/core/Mage/Paypal/Model/Express/Checkout.php index 94d437c4dbc..979feaa7817 100644 --- a/app/code/core/Mage/Paypal/Model/Express/Checkout.php +++ b/app/code/core/Mage/Paypal/Model/Express/Checkout.php @@ -755,7 +755,8 @@ protected function _setBillingAgreementRequest() $isRequested = $this->_isBARequested || $this->_quote->getPayment() ->getAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT); - if ($this->_config->allow_ba_signup != Mage_Paypal_Model_Config::EC_BA_SIGNUP_AUTO && !($isRequested && $this->_config->shouldAskToCreateBillingAgreement()) + if (!($this->_config->allow_ba_signup == Mage_Paypal_Model_Config::EC_BA_SIGNUP_AUTO + || $isRequested && $this->_config->shouldAskToCreateBillingAgreement()) ) { return $this; } diff --git a/app/code/core/Mage/Sales/Model/Order.php b/app/code/core/Mage/Sales/Model/Order.php index fe82fda3f8e..6d3a81cec00 100644 --- a/app/code/core/Mage/Sales/Model/Order.php +++ b/app/code/core/Mage/Sales/Model/Order.php @@ -677,7 +677,7 @@ public function canVoidPayment() */ protected function _canVoidOrder() { - return !$this->canUnhold() && !$this->isPaymentReview(); + return !($this->canUnhold() || $this->isPaymentReview()); } /** diff --git a/app/code/core/Mage/Sales/Model/Order/Payment/Transaction.php b/app/code/core/Mage/Sales/Model/Order/Payment/Transaction.php index c47abfa6529..b2bf223756b 100644 --- a/app/code/core/Mage/Sales/Model/Order/Payment/Transaction.php +++ b/app/code/core/Mage/Sales/Model/Order/Payment/Transaction.php @@ -357,7 +357,7 @@ public function canVoidAuthorizationCompletely() { try { $authTransaction = $this->closeAuthorization('', true); - return !$authTransaction->hasChildTransaction() && !$this->_children; + return !($authTransaction->hasChildTransaction() || $this->_children); } catch (Mage_Core_Exception $e) { // jam all logical exceptions, fallback to false } diff --git a/lib/Varien/File/Uploader.php b/lib/Varien/File/Uploader.php index cb3ea36ff60..0acc053944b 100644 --- a/lib/Varien/File/Uploader.php +++ b/lib/Varien/File/Uploader.php @@ -546,7 +546,7 @@ private function _createDestinationFolder($destinationFolder) $destinationFolder = substr($destinationFolder, 0, -1); } - if (!@is_dir($destinationFolder) && !@mkdir($destinationFolder, 0777, true)) { + if (!(@is_dir($destinationFolder) || @mkdir($destinationFolder, 0777, true))) { throw new Exception("Unable to create directory '{$destinationFolder}'."); } return $this; diff --git a/rector.php b/rector.php index 56e18efa3f2..0b0d4c0ab7c 100644 --- a/rector.php +++ b/rector.php @@ -2,7 +2,6 @@ declare(strict_types=1); -use Rector\CodeQuality\Rector\BooleanNot\SimplifyDeMorganBinaryRector; use Rector\CodeQuality\Rector\If_\SimplifyIfReturnBoolRector; use Rector\Config\RectorConfig; @@ -17,6 +16,5 @@ ]) ->withSkipPath(__DIR__ . '/vendor') ->withRules([ - SimplifyDeMorganBinaryRector::class, SimplifyIfReturnBoolRector::class ]); From f4c78907aee2c06ae862c85939046866e49e389f Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 13 Aug 2024 01:30:49 +0200 Subject: [PATCH 12/16] Simpler config [skip ci] --- rector.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rector.php b/rector.php index 0b0d4c0ab7c..f1440ccd7ed 100644 --- a/rector.php +++ b/rector.php @@ -2,7 +2,7 @@ declare(strict_types=1); -use Rector\CodeQuality\Rector\If_\SimplifyIfReturnBoolRector; +use Rector\CodeQuality\Rector as CodeQuality; use Rector\Config\RectorConfig; return RectorConfig::configure() @@ -16,5 +16,6 @@ ]) ->withSkipPath(__DIR__ . '/vendor') ->withRules([ - SimplifyIfReturnBoolRector::class + CodeQuality\If_\SimplifyIfReturnBoolRector::class, +// CodeQuality\BooleanNot\SimplifyDeMorganBinaryRector::class, # wait for https://github.com/rectorphp/rector/issues/8781 ]); From b094298e4a745d05eaf928208f3fa53f9729e82d Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 13 Aug 2024 06:17:20 +0200 Subject: [PATCH 13/16] CompleteMissingIfElseBracketRector --- errors/report.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/errors/report.php b/errors/report.php index 4f115bcf933..fc916e86488 100644 --- a/errors/report.php +++ b/errors/report.php @@ -13,7 +13,9 @@ * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -if ($_SERVER['SCRIPT_FILENAME'] == __FILE__ && (!isset($_GET['id']) || strlen($_GET['id']) == 0)) die("Missing parameter: id"); +if ($_SERVER['SCRIPT_FILENAME'] == __FILE__ && (!isset($_GET['id']) || strlen($_GET['id']) == 0)) { + die("Missing parameter: id"); +} require_once 'processor.php'; From 030a69cac31f41fcef2366d8fec600620deb2015 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 18 Sep 2024 08:11:29 +0200 Subject: [PATCH 14/16] Added already applied rules --- rector.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rector.php b/rector.php index 96e8f989b25..eec161eb2fa 100644 --- a/rector.php +++ b/rector.php @@ -3,6 +3,7 @@ declare(strict_types=1); use Rector\CodeQuality\Rector as CodeQuality; +use Rector\DeadCode\Rector as DeadCode; use Rector\Config\RectorConfig; return RectorConfig::configure() @@ -20,4 +21,7 @@ // CodeQuality\BooleanNot\SimplifyDeMorganBinaryRector::class, # wait for https://github.com/rectorphp/rector/issues/8781 CodeQuality\Foreach_\UnusedForeachValueToArrayKeysRector::class, CodeQuality\If_\SimplifyIfReturnBoolRector::class, + DeadCode\ClassMethod\RemoveUselessParamTagRector::class, + DeadCode\ClassMethod\RemoveUselessReturnTagRector::class, + DeadCode\Property\RemoveUselessVarTagRector::class, ]); From 1a5704e54fe6c14e2ecb54d3e7a8ceb038cfb79b Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 19 Sep 2024 06:15:34 +0200 Subject: [PATCH 15/16] Fixed errors --- app/code/core/Mage/Cms/Model/Page.php | 5 ----- composer.json | 8 ++++++-- tests/unit/Mage/AdminNotification/Model/FeedTest.php | 3 --- .../Adminhtml/Block/Customer/Edit/Tab/NewsletterTest.php | 1 - tests/unit/Mage/Cms/Block/Widget/BlockTest.php | 3 --- tests/unit/Mage/Cms/Block/Widget/Page/LinkTest.php | 3 --- tests/unit/Mage/Cms/Helper/Wysiwyg/ImagesTest.php | 3 --- tests/unit/Mage/Cms/Model/PageTest.php | 3 --- tests/unit/Mage/Cms/Model/Wysiwyg/ConfigTest.php | 3 --- tests/unit/Mage/Cms/Model/Wysiwyg/Images/StorageTest.php | 3 --- tests/unit/Mage/Customer/Model/CustomerTest.php | 3 --- tests/unit/Mage/Log/Model/AggregationTest.php | 3 --- tests/unit/Mage/Log/Model/CustomerTest.php | 3 --- 13 files changed, 6 insertions(+), 38 deletions(-) diff --git a/app/code/core/Mage/Cms/Model/Page.php b/app/code/core/Mage/Cms/Model/Page.php index beb9d8b5eb3..f488fd8c894 100644 --- a/app/code/core/Mage/Cms/Model/Page.php +++ b/app/code/core/Mage/Cms/Model/Page.php @@ -126,9 +126,6 @@ public function checkIdentifier($identifier, $storeId) /** * Retrieves cms page title from DB by passed identifier. - * - * @param string $identifier - * @return string */ public function getCmsPageTitleByIdentifier(string $identifier): string { @@ -139,7 +136,6 @@ public function getCmsPageTitleByIdentifier(string $identifier): string * Retrieves cms page title from DB by passed id. * * @param string|int $id - * @return string */ public function getCmsPageTitleById($id): string { @@ -150,7 +146,6 @@ public function getCmsPageTitleById($id): string * Retrieves cms page identifier from DB by passed id. * * @param string|int $id - * @return string */ public function getCmsPageIdentifierById($id): string { diff --git a/composer.json b/composer.json index 4915b577a44..4a17a660bd4 100644 --- a/composer.json +++ b/composer.json @@ -135,7 +135,9 @@ "phpstan": "vendor/bin/phpstan analyze", "phpunit:test": "XDEBUG_MODE=off php vendor/bin/phpunit --no-coverage --testdox", "phpunit:coverage": "XDEBUG_MODE=coverage php vendor/bin/phpunit --testdox", - "phpunit:coverage-local": "XDEBUG_MODE=coverage php vendor/bin/phpunit --coverage-html build/coverage --testdox" + "phpunit:coverage-local": "XDEBUG_MODE=coverage php vendor/bin/phpunit --coverage-html build/coverage --testdox", + "rector:test": "vendor/bin/rector process --dry-run", + "rector:fix": "vendor/bin/rector process" }, "scripts-descriptions": { "php-cs-fixer:test": "Run php-cs-fixer", @@ -143,6 +145,8 @@ "phpstan": "Run phpstan", "phpunit:test": "Run PHPUnit", "phpunit:coverage": "Run PHPUnit with code coverage", - "phpunit:coverage-local": "Run PHPUnit with local HTML code coverage" + "phpunit:coverage-local": "Run PHPUnit with local HTML code coverage", + "rector:test": "Run rector", + "rector:fix": "Run rector and fix issues" } } diff --git a/tests/unit/Mage/AdminNotification/Model/FeedTest.php b/tests/unit/Mage/AdminNotification/Model/FeedTest.php index c5ef6917895..0bc2d458d4c 100644 --- a/tests/unit/Mage/AdminNotification/Model/FeedTest.php +++ b/tests/unit/Mage/AdminNotification/Model/FeedTest.php @@ -23,9 +23,6 @@ class FeedTest extends TestCase { - /** - * @var Mage_AdminNotification_Model_Feed - */ public Mage_AdminNotification_Model_Feed $subject; public function setUp(): void diff --git a/tests/unit/Mage/Adminhtml/Block/Customer/Edit/Tab/NewsletterTest.php b/tests/unit/Mage/Adminhtml/Block/Customer/Edit/Tab/NewsletterTest.php index 817bcf863d2..94a24582212 100644 --- a/tests/unit/Mage/Adminhtml/Block/Customer/Edit/Tab/NewsletterTest.php +++ b/tests/unit/Mage/Adminhtml/Block/Customer/Edit/Tab/NewsletterTest.php @@ -34,7 +34,6 @@ public function setUp(): void } /** - * @return void * * @group Mage_Adminhtml * @group Mage_Adminhtml_Block diff --git a/tests/unit/Mage/Cms/Block/Widget/BlockTest.php b/tests/unit/Mage/Cms/Block/Widget/BlockTest.php index 481a048740c..32e53b340b2 100644 --- a/tests/unit/Mage/Cms/Block/Widget/BlockTest.php +++ b/tests/unit/Mage/Cms/Block/Widget/BlockTest.php @@ -23,9 +23,6 @@ class BlockTest extends TestCase { - /** - * @var Mage_Cms_Block_Widget_Block - */ public Mage_Cms_Block_Widget_Block $subject; public function setUp(): void diff --git a/tests/unit/Mage/Cms/Block/Widget/Page/LinkTest.php b/tests/unit/Mage/Cms/Block/Widget/Page/LinkTest.php index 65205901b21..a08bf86c9e2 100644 --- a/tests/unit/Mage/Cms/Block/Widget/Page/LinkTest.php +++ b/tests/unit/Mage/Cms/Block/Widget/Page/LinkTest.php @@ -23,9 +23,6 @@ class LinkTest extends TestCase { - /** - * @var Mage_Cms_Block_Widget_Page_Link - */ public Mage_Cms_Block_Widget_Page_Link $subject; public function setUp(): void diff --git a/tests/unit/Mage/Cms/Helper/Wysiwyg/ImagesTest.php b/tests/unit/Mage/Cms/Helper/Wysiwyg/ImagesTest.php index 8139c185075..d84135dbafb 100644 --- a/tests/unit/Mage/Cms/Helper/Wysiwyg/ImagesTest.php +++ b/tests/unit/Mage/Cms/Helper/Wysiwyg/ImagesTest.php @@ -26,9 +26,6 @@ class ImagesTest extends TestCase { public const TEST_STRING = '0123456789'; - /** - * @var Mage_Cms_Helper_Wysiwyg_Images - */ public Mage_Cms_Helper_Wysiwyg_Images $subject; public function setUp(): void diff --git a/tests/unit/Mage/Cms/Model/PageTest.php b/tests/unit/Mage/Cms/Model/PageTest.php index 3b318a2f15c..5e5779c8a2b 100644 --- a/tests/unit/Mage/Cms/Model/PageTest.php +++ b/tests/unit/Mage/Cms/Model/PageTest.php @@ -23,9 +23,6 @@ class PageTest extends TestCase { - /** - * @var Mage_Cms_Model_Page - */ public Mage_Cms_Model_Page $subject; public function setUp(): void diff --git a/tests/unit/Mage/Cms/Model/Wysiwyg/ConfigTest.php b/tests/unit/Mage/Cms/Model/Wysiwyg/ConfigTest.php index 45dc4949635..c106ba0c128 100644 --- a/tests/unit/Mage/Cms/Model/Wysiwyg/ConfigTest.php +++ b/tests/unit/Mage/Cms/Model/Wysiwyg/ConfigTest.php @@ -26,9 +26,6 @@ class ConfigTest extends TestCase { public const TEST_STRING = '0123456789'; - /** - * @var Mage_Cms_Model_Wysiwyg_Config - */ public Mage_Cms_Model_Wysiwyg_Config $subject; public function setUp(): void diff --git a/tests/unit/Mage/Cms/Model/Wysiwyg/Images/StorageTest.php b/tests/unit/Mage/Cms/Model/Wysiwyg/Images/StorageTest.php index d0d85f845ec..cdbf85fd8ff 100644 --- a/tests/unit/Mage/Cms/Model/Wysiwyg/Images/StorageTest.php +++ b/tests/unit/Mage/Cms/Model/Wysiwyg/Images/StorageTest.php @@ -27,9 +27,6 @@ class StorageTest extends TestCase { public const TEST_STRING = '0123456789'; - /** - * @var Mage_Cms_Model_Wysiwyg_Images_Storage - */ public Mage_Cms_Model_Wysiwyg_Images_Storage $subject; public function setUp(): void diff --git a/tests/unit/Mage/Customer/Model/CustomerTest.php b/tests/unit/Mage/Customer/Model/CustomerTest.php index 4accfe15f34..e6d4cb953eb 100644 --- a/tests/unit/Mage/Customer/Model/CustomerTest.php +++ b/tests/unit/Mage/Customer/Model/CustomerTest.php @@ -24,9 +24,6 @@ class CustomerTest extends TestCase { - /** - * @var Mage_Customer_Model_Customer - */ public Mage_Customer_Model_Customer $subject; public function setUp(): void diff --git a/tests/unit/Mage/Log/Model/AggregationTest.php b/tests/unit/Mage/Log/Model/AggregationTest.php index ee6192d3cce..129d0f39c1a 100644 --- a/tests/unit/Mage/Log/Model/AggregationTest.php +++ b/tests/unit/Mage/Log/Model/AggregationTest.php @@ -23,9 +23,6 @@ class AggregationTest extends TestCase { - /** - * @var Mage_Log_Model_Aggregation - */ public Mage_Log_Model_Aggregation $subject; public function setUp(): void diff --git a/tests/unit/Mage/Log/Model/CustomerTest.php b/tests/unit/Mage/Log/Model/CustomerTest.php index 8261eeb49cb..532f9526426 100644 --- a/tests/unit/Mage/Log/Model/CustomerTest.php +++ b/tests/unit/Mage/Log/Model/CustomerTest.php @@ -23,9 +23,6 @@ class CustomerTest extends TestCase { - /** - * @var Mage_Log_Model_Customer - */ public Mage_Log_Model_Customer $subject; public function setUp(): void From ae0df9e54a0fe94e4030a2865d2275d872fad78f Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 19 Sep 2024 06:57:25 +0200 Subject: [PATCH 16/16] Ignore dev shell-scripts --- rector.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rector.php b/rector.php index eec161eb2fa..15f253b03a7 100644 --- a/rector.php +++ b/rector.php @@ -17,6 +17,10 @@ __DIR__ . '/tests', ]) ->withSkipPath(__DIR__ . '/vendor') + ->withSkip([ + __DIR__ . '/shell/translations.php', + __DIR__ . '/shell/update-copyright.php.php' + ]) ->withRules([ // CodeQuality\BooleanNot\SimplifyDeMorganBinaryRector::class, # wait for https://github.com/rectorphp/rector/issues/8781 CodeQuality\Foreach_\UnusedForeachValueToArrayKeysRector::class,