From 0b1ac4c45f82444b1868fbe75eb7648135fe9002 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 6 Nov 2025 05:08:11 +0100 Subject: [PATCH 1/4] PhpStan: fix wrong params `null` given --- .phpstan.dist.baseline.neon | 108 +------- .../Catalog/Block/Product/List/Toolbar.php | 17 +- .../Checkout/Block/Cart/Item/Renderer.php | 4 +- .../Catalog/Product/Configattribute.php | 2 +- .../Product/Configattribute/Select.php | 6 +- .../Mage/Core/Model/Resource/Db/Abstract.php | 25 +- .../Block/Adminhtml/Export/Filter.php | 19 +- .../Adminhtml/Oauth/ConsumerController.php | 52 ++-- .../Model/Order/Creditmemo/Total/Shipping.php | 2 +- app/code/core/Mage/Tax/Model/Calculation.php | 21 +- .../Mage/Tax/Model/Resource/Calculation.php | 52 ++-- app/code/core/Mage/Weee/Helper/Data.php | 10 +- lib/Varien/Db/Adapter/Interface.php | 2 +- lib/Varien/Db/Adapter/Pdo/Mysql.php | 231 +++++++++++------- lib/Varien/Simplexml/Element.php | 12 +- 15 files changed, 293 insertions(+), 270 deletions(-) diff --git a/.phpstan.dist.baseline.neon b/.phpstan.dist.baseline.neon index 09023a4c978..b21d9b1333e 100644 --- a/.phpstan.dist.baseline.neon +++ b/.phpstan.dist.baseline.neon @@ -1230,12 +1230,6 @@ parameters: count: 1 path: app/code/core/Mage/Catalog/Block/Product/Compare/List.php - - - rawMessage: 'Property Mage_Catalog_Block_Product_List_Toolbar::$_collection (Mage_Core_Model_Resource_Db_Collection_Abstract) does not accept Varien_Data_Collection.' - identifier: assign.propertyType - count: 1 - path: app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php - - rawMessage: 'Parameter #1 $price of method Mage_Core_Model_Store::convertPrice() expects float, string given.' identifier: argument.type @@ -1806,12 +1800,6 @@ parameters: count: 1 path: app/code/core/Mage/Catalog/Model/Resource/Category/Tree.php - - - rawMessage: 'Parameter #2 $alias of method Varien_Db_Adapter_Interface::quoteColumnAs() expects string, null given.' - identifier: argument.type - count: 2 - path: app/code/core/Mage/Catalog/Model/Resource/Collection/Abstract.php - - rawMessage: 'Property Mage_Catalog_Model_Resource_Config::$_storeId (int) on left side of ?? is not nullable.' identifier: nullCoalesce.property @@ -1932,12 +1920,6 @@ parameters: count: 1 path: app/code/core/Mage/Catalog/Model/Resource/Product/Indexer/Price.php - - - rawMessage: 'Parameter #2 $alias of method Varien_Db_Adapter_Interface::quoteColumnAs() expects string, null given.' - identifier: argument.type - count: 1 - path: app/code/core/Mage/Catalog/Model/Resource/Product/Link/Collection.php - - rawMessage: Left side of && is always true. identifier: booleanAnd.leftAlwaysTrue @@ -2154,12 +2136,6 @@ parameters: count: 1 path: app/code/core/Mage/Checkout/Block/Cart/Abstract.php - - - rawMessage: 'Parameter #1 $productThumbnail of method Mage_Checkout_Block_Cart_Item_Renderer::overrideProductThumbnail() expects Mage_Catalog_Helper_Image, null given.' - identifier: argument.type - count: 1 - path: app/code/core/Mage/Checkout/Block/Cart/Item/Renderer/Grouped.php - - rawMessage: PHPDoc tag @var with type Mage_Sales_Model_Quote_Item is not subtype of native type null. identifier: varTag.nativeType @@ -2298,12 +2274,6 @@ parameters: count: 2 path: app/code/core/Mage/ConfigurableSwatches/Model/Resource/Catalog/Product/Type/Configurable/Product/Collection.php - - - rawMessage: 'Parameter #1 $array of function array_unshift expects array, null given.' - identifier: argument.type - count: 1 - path: app/code/core/Mage/ConfigurableSwatches/Model/System/Config/Source/Catalog/Product/Configattribute/Select.php - - rawMessage: 'Method Mage_Core_Block_Abstract::getParentBlock() should return $this(Mage_Core_Block_Abstract) but returns Mage_Core_Block_Abstract.' identifier: return.type @@ -2700,12 +2670,6 @@ parameters: count: 1 path: app/code/core/Mage/Core/Model/Resource/Session.php - - - rawMessage: 'Parameter #1 $hook of method Varien_Db_Adapter_Pdo_Mysql::setQueryHook() expects array, null given.' - identifier: argument.type - count: 1 - path: app/code/core/Mage/Core/Model/Resource/Setup.php - - rawMessage: 'Property Mage_Core_Model_Resource_Setup::$_resourceConfig (Mage_Core_Model_Config_Element) does not accept SimpleXMLElement.' identifier: assign.propertyType @@ -3312,12 +3276,6 @@ parameters: count: 1 path: app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php - - - rawMessage: 'Parameter #2 $alias of method Varien_Db_Adapter_Interface::quoteColumnAs() expects string, null given.' - identifier: argument.type - count: 4 - path: app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php - - rawMessage: 'Property Mage_Eav_Model_Entity_Collection_Abstract::$_entity (Mage_Eav_Model_Entity_Abstract) in empty() is not falsy.' identifier: empty.property @@ -3426,12 +3384,6 @@ parameters: count: 4 path: app/code/core/Mage/ImportExport/Block/Adminhtml/Export/Filter.php - - - rawMessage: 'Parameter #1 $limit of method Mage_Adminhtml_Block_Widget_Grid::setDefaultLimit() expects int, null given.' - identifier: argument.type - count: 1 - path: app/code/core/Mage/ImportExport/Block/Adminhtml/Export/Filter.php - - rawMessage: 'Method Mage_Eav_Model_Entity_Attribute_Source_Interface::getAllOptions() invoked with 1 parameter, 0 required.' identifier: arguments.count @@ -3480,6 +3432,12 @@ parameters: count: 1 path: app/code/core/Mage/ImportExport/Model/Import/Entity/Product.php + - + rawMessage: 'Method Mage_ImportExport_Model_Resource_Import_Data::getIterator() should return IteratorIterator but returns Traversable.' + identifier: return.type + count: 1 + path: app/code/core/Mage/ImportExport/Model/Resource/Import/Data.php + - rawMessage: 'Parameter #3 ...$values of function sprintf expects bool|float|int|string|null, array|null given.' identifier: argument.type @@ -3552,24 +3510,12 @@ parameters: count: 1 path: app/code/core/Mage/Newsletter/Model/Subscriber.php - - - rawMessage: 'Parameter #2 $idFieldName of method Mage_Core_Model_Resource_Db_Abstract::_init() expects string, null given.' - identifier: argument.type - count: 1 - path: app/code/core/Mage/Oauth/Model/Resource/Nonce.php - - rawMessage: 'Parameter #2 $value of method Varien_Data_Collection::addFilter() expects array|string, int given.' identifier: argument.type count: 4 path: app/code/core/Mage/Oauth/Model/Resource/Token/Collection.php - - - rawMessage: 'Parameter #1 $data of method Mage_Oauth_Adminhtml_Oauth_ConsumerController::_setFormData() expects array, null given.' - identifier: argument.type - count: 2 - path: app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/ConsumerController.php - - rawMessage: 'Call to an undefined method Mage_Payment_Model_Method_Abstract::isPartialAuthorization().' identifier: method.notFound @@ -4164,12 +4110,6 @@ parameters: count: 1 path: app/code/core/Mage/Sales/Model/Order/Creditmemo.php - - - rawMessage: 'Parameter #2 $options of method Mage_Directory_Model_Currency::format() expects array, null given.' - identifier: argument.type - count: 1 - path: app/code/core/Mage/Sales/Model/Order/Creditmemo/Total/Shipping.php - - rawMessage: 'Parameter #1 $incrementId of method Mage_Sales_Model_Order_Invoice::loadByIncrementId() expects string, int given.' identifier: argument.type @@ -4512,12 +4452,6 @@ parameters: count: 2 path: app/code/core/Mage/SalesRule/Model/Validator.php - - - rawMessage: 'Parameter #2 $title of method Mage_Weee_Helper_Data::setWeeeTaxesAppliedProperty() expects string, null given.' - identifier: argument.type - count: 2 - path: app/code/core/Mage/SalesRule/Model/Validator.php - - rawMessage: 'Parameter #4 $value of method Mage_Weee_Helper_Data::setWeeeTaxesAppliedProperty() expects string, (float|int) given.' identifier: argument.type @@ -4674,18 +4608,6 @@ parameters: count: 1 path: app/code/core/Mage/Tax/Helper/Data.php - - - rawMessage: 'Parameter #1 $request of method Mage_Tax_Model_Resource_Calculation::getCalculationProcess() expects Varien_Object, null given.' - identifier: argument.type - count: 1 - path: app/code/core/Mage/Tax/Model/Calculation.php - - - - rawMessage: 'Property Mage_Tax_Model_Calculation::$_defaultCustomerTaxClass (string) does not accept int.' - identifier: assign.propertyType - count: 1 - path: app/code/core/Mage/Tax/Model/Calculation.php - - rawMessage: 'Property Mage_Tax_Model_Calculation_Rate::$_titles (array|null) does not accept Mage_Tax_Model_Resource_Calculation_Rate_Title_Collection.' identifier: assign.propertyType @@ -5268,12 +5190,6 @@ parameters: count: 2 path: app/design/frontend/base/default/template/catalog/product/compare/list.phtml - - - rawMessage: 'Parameter #1 $order of method Mage_Catalog_Block_Product_List_Toolbar::getOrderUrl() expects string, null given.' - identifier: argument.type - count: 2 - path: app/design/frontend/base/default/template/catalog/product/list/toolbar.phtml - - rawMessage: Left side of && is always true. identifier: booleanAnd.leftAlwaysTrue @@ -5604,12 +5520,6 @@ parameters: count: 2 path: app/design/frontend/rwd/default/template/catalog/product/compare/list.phtml - - - rawMessage: 'Parameter #1 $order of method Mage_Catalog_Block_Product_List_Toolbar::getOrderUrl() expects string, null given.' - identifier: argument.type - count: 2 - path: app/design/frontend/rwd/default/template/catalog/product/list/toolbar.phtml - - rawMessage: Left side of && is always true. identifier: booleanAnd.leftAlwaysTrue @@ -5988,12 +5898,6 @@ parameters: count: 2 path: lib/Varien/Db/Adapter/Pdo/Mysql.php - - - rawMessage: 'Method Varien_Db_Adapter_Pdo_Mysql::query() should return Zend_Db_Statement_Pdo but returns PDOStatement|Zend_Db_Statement_Interface.' - identifier: return.type - count: 1 - path: lib/Varien/Db/Adapter/Pdo/Mysql.php - - rawMessage: 'Parameter #4 $result of method Varien_Db_Adapter_Pdo_Mysql::_debugStat() expects Zend_Db_Statement_Pdo|null, PDOStatement|Zend_Db_Statement_Interface given.' identifier: argument.type diff --git a/app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php b/app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php index 2e7c6863346..fa47ff9dc2d 100644 --- a/app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php +++ b/app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php @@ -199,7 +199,8 @@ protected function _memorizeParam($param, $value) /** * Set collection to pager * - * @param Varien_Data_Collection $collection + * @param Mage_Core_Model_Resource_Db_Collection_Abstract $collection + * @throws Exception * @return $this */ public function setCollection($collection) @@ -284,6 +285,7 @@ public function getLimitVarName() /** * Return current page from request * + * @throws Exception * @return int */ public function getCurrentPage() @@ -298,6 +300,7 @@ public function getCurrentPage() /** * Get grit products sort order field * + * @throws Exception * @return string */ public function getCurrentOrder() @@ -338,6 +341,7 @@ public function getCurrentOrder() /** * Retrieve current direction * + * @throws Exception * @return string */ public function getCurrentDirection() @@ -452,6 +456,7 @@ public function removeOrderFromAvailableOrders($order) * Compare defined order field vith current order field * * @param string $order + * @throws Exception * @return bool */ public function isOrderCurrent($order) @@ -462,8 +467,9 @@ public function isOrderCurrent($order) /** * Retrieve Pager URL * - * @param string $order + * @param null|string $order * @param string $direction + * @throws Exception * @return string */ public function getOrderUrl($order, $direction) @@ -498,6 +504,7 @@ public function getPagerUrl($params = []) /** * Retrieve current View mode * + * @throws Exception * @return string */ public function getCurrentMode() @@ -532,6 +539,7 @@ public function getCurrentMode() * Compare defined view mode with current active mode * * @param string $mode + * @throws Exception * @return bool */ public function isModeActive($mode) @@ -642,6 +650,7 @@ public function isExpanded() /** * Retrieve default per page values * + * @throws Exception * @return string (comma separated) */ public function getDefaultPerPageValue() @@ -684,6 +693,7 @@ public function addPagerLimit($mode, $value, $label = '') /** * Retrieve available limits for current view mode * + * @throws Exception * @return array */ public function getAvailableLimit() @@ -722,6 +732,7 @@ protected function _getAvailableLimit($mode) /** * Get specified products limit display per page * + * @throws Exception * @return string */ public function getLimit() @@ -773,6 +784,7 @@ public function getLimitUrl($limit) /** * @param int $limit + * @throws Exception * @return bool */ public function isLimitCurrent($limit) @@ -825,6 +837,7 @@ public function getLastPageNum() /** * Render pagination HTML * + * @throws Exception * @return string */ public function getPagerHtml() 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 d8da15d88c6..08f93dd3ac9 100644 --- a/app/code/core/Mage/Checkout/Block/Cart/Item/Renderer.php +++ b/app/code/core/Mage/Checkout/Block/Cart/Item/Renderer.php @@ -75,7 +75,7 @@ public function getProduct() } /** - * @param Mage_Catalog_Helper_Image $productThumbnail + * @param null|Mage_Catalog_Helper_Image $productThumbnail * @return $this */ public function overrideProductThumbnail($productThumbnail) @@ -179,7 +179,7 @@ public function getProductName() /** * Get product customize options * - * @return array|false + * @return array */ public function getProductOptions() { diff --git a/app/code/core/Mage/ConfigurableSwatches/Model/System/Config/Source/Catalog/Product/Configattribute.php b/app/code/core/Mage/ConfigurableSwatches/Model/System/Config/Source/Catalog/Product/Configattribute.php index 08b3d16431b..214d8a2487e 100644 --- a/app/code/core/Mage/ConfigurableSwatches/Model/System/Config/Source/Catalog/Product/Configattribute.php +++ b/app/code/core/Mage/ConfigurableSwatches/Model/System/Config/Source/Catalog/Product/Configattribute.php @@ -15,7 +15,7 @@ class Mage_ConfigurableSwatches_Model_System_Config_Source_Catalog_Product_Confi /** * Attributes array * - * @var null|array + * @var array */ protected $_attributes = null; diff --git a/app/code/core/Mage/ConfigurableSwatches/Model/System/Config/Source/Catalog/Product/Configattribute/Select.php b/app/code/core/Mage/ConfigurableSwatches/Model/System/Config/Source/Catalog/Product/Configattribute/Select.php index dd4da64c5b2..00aa55d2303 100644 --- a/app/code/core/Mage/ConfigurableSwatches/Model/System/Config/Source/Catalog/Product/Configattribute/Select.php +++ b/app/code/core/Mage/ConfigurableSwatches/Model/System/Config/Source/Catalog/Product/Configattribute/Select.php @@ -21,13 +21,17 @@ public function toOptionArray() { if (is_null($this->_attributes)) { parent::toOptionArray(); + $attributes = $this->_attributes; + array_unshift( - $this->_attributes, + $attributes, [ 'value' => '', 'label' => Mage::helper('configurableswatches')->__('-- Please Select --'), ], ); + + $this->_attributes = $attributes; } return $this->_attributes; diff --git a/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php b/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php index ec2e862e83e..924d1adaeee 100644 --- a/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php +++ b/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php @@ -131,7 +131,7 @@ abstract class Mage_Core_Model_Resource_Db_Abstract extends Mage_Core_Model_Reso * Standard resource model initialization * * @param string $mainTable - * @param string $idFieldName + * @param null|string $idFieldName */ protected function _init($mainTable, $idFieldName) { @@ -152,8 +152,8 @@ protected function _setResource($connections, $tables = null) $this->_resources = Mage::getSingleton('core/resource'); if (is_array($connections)) { - foreach ($connections as $k => $v) { - $this->_connections[$k] = $this->_resources->getConnection($v); + foreach ($connections as $key => $value) { + $this->_connections[$key] = $this->_resources->getConnection($value); } } elseif (is_string($connections)) { $this->_resourcePrefix = $connections; @@ -162,8 +162,8 @@ protected function _setResource($connections, $tables = null) if (is_null($tables) && is_string($connections)) { $this->_resourceModel = $this->_resourcePrefix; } elseif (is_array($tables)) { - foreach ($tables as $k => $v) { - $this->_tables[$k] = $this->_resources->getTableName($v); + foreach ($tables as $key => $value) { + $this->_tables[$key] = $this->_resources->getTableName($value); } } elseif (is_string($tables)) { $this->_resourceModel = $tables; @@ -205,6 +205,7 @@ protected function _setMainTable($mainTable, $idFieldName = null) /** * Get primary key field name * + * @throws Mage_Core_Exception * @return string */ public function getIdFieldName() @@ -220,6 +221,7 @@ public function getIdFieldName() * Returns main table name - extracted from "module/table" style and * validated by db adapter * + * @throws Mage_Core_Exception * @return string */ public function getMainTable() @@ -366,6 +368,7 @@ public function getReadConnection() * * @param mixed $value * @param null|string $field field to load by (defaults to model id) + * @throws Exception * @return $this */ public function load(Mage_Core_Model_Abstract $object, $value, $field = null) @@ -404,7 +407,7 @@ protected function _getLoadSelect($field, $value, $object) $fields = $this->_getReadAdapter()->describeTable($this->getMainTable()); if (!isset($fields[$field])) { - throw new Exception("Column \"{$field}\" does not exist in table \"{$this->getMainTable()}\""); + throw new Exception("Column \"$field\" does not exist in table \"{$this->getMainTable()}\""); } $value = $this->_getReadAdapter()->prepareColumnValue($fields[$field], $value); @@ -417,6 +420,9 @@ protected function _getLoadSelect($field, $value, $object) /** * Save object object data * + * @throws Zend_Db_Adapter_Exception + * @throws Mage_Core_Exception + * @throws Exception * @return $this */ public function save(Mage_Core_Model_Abstract $object) @@ -476,8 +482,10 @@ public function save(Mage_Core_Model_Abstract $object) * Forced save object data * forced update If duplicate unique key data * - * @deprecated + * @throws Zend_Db_Exception + * @throws Mage_Core_Exception * @return $this + * @deprecated */ public function forsedSave(Mage_Core_Model_Abstract $object) { @@ -585,6 +593,7 @@ public function getUniqueFields() /** * Prepare data for save * + * @throws Mage_Core_Exception * @return array */ protected function _prepareDataForSave(Mage_Core_Model_Abstract $object) @@ -597,6 +606,8 @@ protected function _prepareDataForSave(Mage_Core_Model_Abstract $object) * has really changed comparing with origData * * @param Mage_Core_Model_Abstract $object + * @throws Zend_Cache_Exception + * @throws Mage_Core_Exception * @return bool */ public function hasDataChanged($object) diff --git a/app/code/core/Mage/ImportExport/Block/Adminhtml/Export/Filter.php b/app/code/core/Mage/ImportExport/Block/Adminhtml/Export/Filter.php index 30008e3f200..aa5b029fd2a 100644 --- a/app/code/core/Mage/ImportExport/Block/Adminhtml/Export/Filter.php +++ b/app/code/core/Mage/ImportExport/Block/Adminhtml/Export/Filter.php @@ -42,7 +42,7 @@ public function __construct() $this->setDefaultSort('frontend_label'); $this->setDefaultDir('ASC'); $this->setPagerVisibility(false); - $this->setDefaultLimit(null); + $this->setDefaultLimit(0); $this->setUseAjax(true); } @@ -82,8 +82,9 @@ protected function _getInputHtml(Mage_Eav_Model_Entity_Attribute $attribute) /** * Multiselect field filter HTML. * - * @deprecated + * @throws Mage_Core_Exception * @return string + * @deprecated */ protected function _getMultiSelectHtml(Mage_Eav_Model_Entity_Attribute $attribute) { @@ -133,8 +134,9 @@ protected function _getNumberFromToHtml(Mage_Eav_Model_Entity_Attribute $attribu /** * Select field filter HTML. * - * @deprecated + * @throws Mage_Core_Exception * @return string + * @deprecated */ protected function _getSelectHtml(Mage_Eav_Model_Entity_Attribute $attribute) { @@ -219,6 +221,7 @@ protected function _getInputHtmlWithValue(Mage_Eav_Model_Entity_Attribute $attri * Multiselect field filter HTML with selected values * * @param mixed $value + * @throws Mage_Core_Exception * @return string */ protected function _getMultiSelectHtmlWithValue(Mage_Eav_Model_Entity_Attribute $attribute, $value) @@ -279,6 +282,7 @@ protected function _getNumberFromToHtmlWithValue(Mage_Eav_Model_Entity_Attribute * Select field filter HTML with selected value. * * @param mixed $value + * @throws Mage_Core_Exception * @return string */ protected function _getSelectHtmlWithValue(Mage_Eav_Model_Entity_Attribute $attribute, $value) @@ -293,7 +297,7 @@ protected function _getSelectHtmlWithValue(Mage_Eav_Model_Entity_Attribute $attr $options = $attribute->getSource()->getAllOptions(false); } - if (($size = count($options))) { + if (count($options)) { // add empty value option $firstOption = reset($options); @@ -319,6 +323,7 @@ protected function _getSelectHtmlWithValue(Mage_Eav_Model_Entity_Attribute $attr /** * Add columns to grid * + * @throws Exception * @return Mage_Adminhtml_Block_Widget_Grid */ protected function _prepareColumns() @@ -373,6 +378,7 @@ protected function _prepareColumns() * * @param mixed $value * @param bool $isExport + * @throws Exception * @return string */ public function decorateFilter($value, Mage_Eav_Model_Entity_Attribute $row, Varien_Object $column, $isExport) @@ -400,7 +406,7 @@ public function decorateFilter($value, Mage_Eav_Model_Entity_Attribute $row, Var */ public function getFilterElementId($attributeCode) { - return Mage_ImportExport_Model_Export::FILTER_ELEMENT_GROUP . "_{$attributeCode}"; + return Mage_ImportExport_Model_Export::FILTER_ELEMENT_GROUP . "_$attributeCode"; } /** @@ -411,7 +417,7 @@ public function getFilterElementId($attributeCode) */ public function getFilterElementName($attributeCode) { - return Mage_ImportExport_Model_Export::FILTER_ELEMENT_GROUP . "[{$attributeCode}]"; + return Mage_ImportExport_Model_Export::FILTER_ELEMENT_GROUP . "[$attributeCode]"; } /** @@ -428,6 +434,7 @@ public function getRowUrl($row) /** * Prepare collection by setting page number, sorting etc.. * + * @throws Exception * @return Mage_Eav_Model_Resource_Entity_Attribute_Collection */ public function prepareCollection(Mage_Eav_Model_Resource_Entity_Attribute_Collection $collection) diff --git a/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/ConsumerController.php b/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/ConsumerController.php index 9f8a9ae782e..db5172683d3 100644 --- a/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/ConsumerController.php +++ b/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/ConsumerController.php @@ -67,6 +67,8 @@ public function gridAction() /** * Create page action + * + * @throws Mage_Core_Exception */ public function newAction() { @@ -94,12 +96,14 @@ public function newAction() /** * Edit page action + * + * @throws Mage_Core_Exception */ public function editAction() { - $id = (int) $this->getRequest()->getParam('id'); + $consumerId = (int) $this->getRequest()->getParam('id'); - if (!$id) { + if (!$consumerId) { $this->_getSession()->addError(Mage::helper('oauth')->__('Invalid ID parameter.')); $this->_redirect('*/*/index'); return; @@ -107,10 +111,10 @@ public function editAction() /** @var Mage_Oauth_Model_Consumer $model */ $model = Mage::getModel('oauth/consumer'); - $model->load($id); + $model->load($consumerId); if (!$model->getId()) { - $this->_getSession()->addError(Mage::helper('oauth')->__('Entry with ID #%s not found.', $id)); + $this->_getSession()->addError(Mage::helper('oauth')->__('Entry with ID #%s not found.', $consumerId)); $this->_redirect('*/*/index'); return; } @@ -128,12 +132,12 @@ public function editAction() */ public function saveAction() { - $id = $this->getRequest()->getParam('id'); + $consumerId = $this->getRequest()->getParam('id'); if (!$this->_validateFormKey()) { - if ($id) { - $this->_redirect('*/*/edit', ['id' => $id]); + if ($consumerId) { + $this->_redirect('*/*/edit', ['id' => $consumerId]); } else { - $this->_redirect('*/*/new', ['id' => $id]); + $this->_redirect('*/*/new', ['id' => $consumerId]); } return; @@ -152,8 +156,8 @@ public function saveAction() $this->_getSession()->addError($error); } - if ($id) { - $this->_redirect('*/*/edit', ['id' => $id]); + if ($consumerId) { + $this->_redirect('*/*/edit', ['id' => $consumerId]); } else { $this->_redirect('*/*/new'); } @@ -164,8 +168,8 @@ public function saveAction() /** @var Mage_Oauth_Model_Consumer $model */ $model = Mage::getModel('oauth/consumer'); - if ($id) { - if (!(int) $id) { + if ($consumerId) { + if (!(int) $consumerId) { $this->_getSession()->addError( $this->__('Invalid ID parameter.'), ); @@ -173,11 +177,11 @@ public function saveAction() return; } - $model->load($id); + $model->load($consumerId); if (!$model->getId()) { $this->_getSession()->addError( - $this->__('Entry with ID #%s not found.', $id), + $this->__('Entry with ID #%s not found.', $consumerId), ); $this->_redirect('*/*/index'); return; @@ -203,18 +207,18 @@ public function saveAction() $model->save(); $this->_getSession()->addSuccess($this->__('The consumer has been saved.')); $this->_setFormData(null); - } catch (Mage_Core_Exception $e) { + } catch (Mage_Core_Exception $mageCoreException) { $this->_setFormData($data); - $this->_getSession()->addError(Mage::helper('core')->escapeHtml($e->getMessage())); + $this->_getSession()->addError(Mage::helper('core')->escapeHtml($mageCoreException->getMessage())); $this->getRequest()->setParam('back', 'edit'); - } catch (Exception $e) { + } catch (Exception $exception) { $this->_setFormData(null); - Mage::logException($e); + Mage::logException($exception); $this->_getSession()->addError($this->__('An error occurred on saving consumer data.')); } if ($this->getRequest()->getParam('back')) { - if ($id || $model->getId()) { + if ($consumerId || $model->getId()) { $this->_redirect('*/*/edit', ['id' => $model->getId()]); } else { $this->_redirect('*/*/new'); @@ -258,7 +262,7 @@ protected function _getFormData() /** * Set form data * - * @param array $data + * @param mixed $data * @return $this */ protected function _setFormData($data) @@ -299,11 +303,11 @@ public function deleteAction() $consumer->delete(); $this->_getSession()->addSuccess(Mage::helper('oauth')->__('The consumer has been deleted.')); - } catch (Mage_Core_Exception $e) { - $this->_getSession()->addError($e->getMessage()); - } catch (Exception $e) { + } catch (Mage_Core_Exception $mageCoreException) { + $this->_getSession()->addError($mageCoreException->getMessage()); + } catch (Exception $exception) { $this->_getSession()->addException( - $e, + $exception, Mage::helper('oauth')->__('An error occurred while deleting the consumer.'), ); } diff --git a/app/code/core/Mage/Sales/Model/Order/Creditmemo/Total/Shipping.php b/app/code/core/Mage/Sales/Model/Order/Creditmemo/Total/Shipping.php index f7bcc955fd4..58dac2ee11b 100644 --- a/app/code/core/Mage/Sales/Model/Order/Creditmemo/Total/Shipping.php +++ b/app/code/core/Mage/Sales/Model/Order/Creditmemo/Total/Shipping.php @@ -68,7 +68,7 @@ public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo) $baseShipping = $baseShippingAmount; } } else { - $baseAllowedAmount = $order->getBaseCurrency()->format($baseAllowedAmount, null, false); + $baseAllowedAmount = $order->getBaseCurrency()->format($baseAllowedAmount, [], false); Mage::throwException( Mage::helper('sales')->__('Maximum shipping amount allowed to refund is: %s', $baseAllowedAmount), ); diff --git a/app/code/core/Mage/Tax/Model/Calculation.php b/app/code/core/Mage/Tax/Model/Calculation.php index e5853f29d10..ec2871faeed 100644 --- a/app/code/core/Mage/Tax/Model/Calculation.php +++ b/app/code/core/Mage/Tax/Model/Calculation.php @@ -106,7 +106,7 @@ class Mage_Tax_Model_Calculation extends Mage_Core_Model_Abstract /** * Customer group * - * @var string + * @var int */ protected $_defaultCustomerTaxClass = null; @@ -146,7 +146,7 @@ public function setCustomer(Mage_Customer_Model_Customer $customer) * Get the customer default customer class * * @param null|Mage_Core_Model_Store $store - * @return string + * @return int */ public function getDefaultCustomerTaxClass($store = null) { @@ -183,6 +183,7 @@ public function getCustomer() * Delete calculation settings by rule id * * @param int $ruleId + * @throws Mage_Core_Exception * @return Mage_Tax_Model_Calculation */ public function deleteByRuleId($ruleId) @@ -195,6 +196,7 @@ public function deleteByRuleId($ruleId) * Get calculation rates by rule id * * @param int $ruleId + * @throws Mage_Core_Exception * @return array */ public function getRates($ruleId) @@ -210,6 +212,7 @@ public function getRates($ruleId) * Get allowed customer tax classes by rule id * * @param int $ruleId + * @throws Mage_Core_Exception * @return array */ public function getCustomerTaxClasses($ruleId) @@ -225,6 +228,7 @@ public function getCustomerTaxClasses($ruleId) * Get allowed product tax classes by rule id * * @param int $ruleId + * @throws Mage_Core_Exception * @return array */ public function getProductTaxClasses($ruleId) @@ -245,14 +249,14 @@ protected function _formCalculationProcess() { $title = $this->getRateTitle(); $value = $this->getRateValue(); - $id = $this->getRateId(); + $rateId = $this->getRateId(); $rate = [ 'code' => $title, 'title' => $title, 'percent' => $value, 'position' => 1, 'priority' => 1]; $process = []; $process['percent'] = $value; - $process['id'] = "{$id}-{$value}"; + $process['id'] = "$rateId-$value"; $process['rates'][] = $rate; return [$process]; @@ -383,6 +387,8 @@ public function getDefaultRateRequest($store = null) * @param null|false|Mage_Sales_Model_Quote_Address $billingAddress * @param null|int $customerTaxClass * @param null|bool|int|Mage_Core_Model_Store|string $store + * @throws Mage_Core_Model_Store_Exception + * @throws Mage_Core_Exception * @return Varien_Object */ public function getRateRequest( @@ -532,6 +538,7 @@ public function compareRequests($first, $second) * @param Varien_Object $request * @param string $fieldName * @param string $type + * @throws Mage_Core_Exception * @return array */ protected function _getRates($request, $fieldName, $type) @@ -553,6 +560,7 @@ protected function _getRates($request, $fieldName, $type) * Gets rates for all the product tax classes * * @param Varien_Object $request + * @throws Mage_Core_Exception * @return array */ public function getRatesForAllProductTaxClasses($request) @@ -564,6 +572,7 @@ public function getRatesForAllProductTaxClasses($request) * Gets rates for all the customer tax classes * * @param Varien_Object $request + * @throws Mage_Core_Exception * @return array */ public function getRatesForAllCustomerTaxClasses($request) @@ -610,7 +619,7 @@ public function getApplicableRateIds($request) */ public function reproduceProcess($rates) { - return $this->getResource()->getCalculationProcess(null, $rates); + return $this->getResource()->getCalculationProcess(new Varien_Object(), $rates); } /** @@ -644,6 +653,7 @@ public function getRatesByCustomerAndProductTaxClasses($customerTaxClass, $produ * @param float $taxRate * @param bool $priceIncludeTax * @param bool $round + * @throws Mage_Core_Model_Store_Exception * @return float */ public function calcTaxAmount($price, $taxRate, $priceIncludeTax = false, $round = true) @@ -680,6 +690,7 @@ public function truncate($price, $precision = 4) * Round tax amount * * @param float $price + * @throws Mage_Core_Model_Store_Exception * @return float */ public function round($price) diff --git a/app/code/core/Mage/Tax/Model/Resource/Calculation.php b/app/code/core/Mage/Tax/Model/Resource/Calculation.php index 67c9afcc9f4..e71d8693db4 100644 --- a/app/code/core/Mage/Tax/Model/Resource/Calculation.php +++ b/app/code/core/Mage/Tax/Model/Resource/Calculation.php @@ -37,6 +37,7 @@ protected function _construct() * Delete calculation settings by rule id * * @param int $ruleId + * @throws Mage_Core_Exception * @return $this */ public function deleteByRuleId($ruleId) @@ -53,6 +54,7 @@ public function deleteByRuleId($ruleId) * * @param string $field * @param int $ruleId + * @throws Mage_Core_Exception * @return array */ public function getDistinct($field, $ruleId) @@ -94,7 +96,7 @@ public function getRate($request) * Retrieve Calculation Process * * @param Varien_Object $request - * @param array $rates + * @param null|array $rates * @return array */ public function getCalculationProcess($request, $rates = null) @@ -109,8 +111,8 @@ public function getCalculationProcess($request, $rates = null) $currentRate = 0; $totalPercent = 0; $countedRates = count($rates); - for ($i = 0; $i < $countedRates; $i++) { - $rate = $rates[$i]; + for ($index = 0; $index < $countedRates; $index++) { + $rate = $rates[$index]; $value = ($rate['value'] ?? $rate['percent']) * 1; $oneRate = [ @@ -143,25 +145,25 @@ public function getCalculationProcess($request, $rates = null) $row['rates'][] = $oneRate; $ruleId = null; - if (isset($rates[$i + 1]['tax_calculation_rule_id'])) { + if (isset($rates[$index + 1]['tax_calculation_rule_id'])) { $ruleId = $rate['tax_calculation_rule_id']; } $priority = $rate['priority']; $ids[] = $rate['code']; - if (isset($rates[$i + 1]['tax_calculation_rule_id'])) { - while (isset($rates[$i + 1]) && $rates[$i + 1]['tax_calculation_rule_id'] == $ruleId) { - $i++; + if (isset($rates[$index + 1]['tax_calculation_rule_id'])) { + while (isset($rates[$index + 1]) && $rates[$index + 1]['tax_calculation_rule_id'] == $ruleId) { + $index++; } } $currentRate += $value; - if (!isset($rates[$i + 1]) || $rates[$i + 1]['priority'] != $priority - || (isset($rates[$i + 1]['process']) && $rates[$i + 1]['process'] != $rate['process']) + if (!isset($rates[$index + 1]) || $rates[$index + 1]['priority'] != $priority + || (isset($rates[$index + 1]['process']) && $rates[$index + 1]['process'] != $rate['process']) ) { - if (!empty($rates[$i]['calculate_subtotal'])) { + if (!empty($rates[$index]['calculate_subtotal'])) { $row['percent'] = $currentRate; $totalPercent += $currentRate; } else { @@ -210,8 +212,8 @@ protected function _createSearchPostCodeTemplates($postcode) $strArr = [(string) $postcode, $postcode . '*']; if ($strlen > 1) { - for ($i = 1; $i < $strlen; $i++) { - $strArr[] = sprintf('%s*', mb_substr($postcode, 0, - $i)); + for ($index = 1; $index < $strlen; $index++) { + $strArr[] = sprintf('%s*', mb_substr($postcode, 0, - $index)); } } @@ -223,6 +225,8 @@ protected function _createSearchPostCodeTemplates($postcode) * Notice that productClassId due to optimization can be array of ids * * @param Varien_Object $request + * @throws Zend_Db_Select_Exception + * @throws Mage_Core_Exception * @return array */ protected function _getRates($request) @@ -292,7 +296,7 @@ protected function _getRates($request) ->joinLeft( ['title_table' => $this->getTable('tax/tax_calculation_rate_title')], 'rate.tax_calculation_rate_id = title_table.tax_calculation_rate_id ' - . "AND title_table.store_id = '{$storeId}'", + . "AND title_table.store_id = '$storeId'", ['title' => $ifnullTitleValue], ) ->where('rate.tax_country_id = ?', $countryId) @@ -397,20 +401,20 @@ protected function _calculateRate($rates) $result = 0; $currentRate = 0; $countedRates = count($rates); - for ($i = 0; $i < $countedRates; $i++) { - $rate = $rates[$i]; + for ($index = 0; $index < $countedRates; $index++) { + $rate = $rates[$index]; $rule = $rate['tax_calculation_rule_id']; $value = $rate['value']; $priority = $rate['priority']; - while (isset($rates[$i + 1]) && $rates[$i + 1]['tax_calculation_rule_id'] == $rule) { - $i++; + while (isset($rates[$index + 1]) && $rates[$index + 1]['tax_calculation_rule_id'] == $rule) { + $index++; } $currentRate += $value; - if (!isset($rates[$i + 1]) || $rates[$i + 1]['priority'] != $priority) { - if (!empty($rates[$i]['calculate_subtotal'])) { + if (!isset($rates[$index + 1]) || $rates[$index + 1]['priority'] != $priority) { + if (!empty($rates[$index]['calculate_subtotal'])) { $result += $currentRate; } else { $result += $this->_collectPercent($result, $currentRate); @@ -427,6 +431,8 @@ protected function _calculateRate($rates) * Retrieve rate ids * * @param Varien_Object $request + * @throws Zend_Db_Select_Exception + * @throws Mage_Core_Exception * @return array */ public function getRateIds($request) @@ -434,12 +440,12 @@ public function getRateIds($request) $result = []; $rates = $this->_getRates($request); $countedRates = count($rates); - for ($i = 0; $i < $countedRates; $i++) { - $rate = $rates[$i]; + for ($index = 0; $index < $countedRates; $index++) { + $rate = $rates[$index]; $rule = $rate['tax_calculation_rule_id']; $result[] = $rate['tax_calculation_rate_id']; - while (isset($rates[$i + 1]) && $rates[$i + 1]['tax_calculation_rule_id'] == $rule) { - $i++; + while (isset($rates[$index + 1]) && $rates[$index + 1]['tax_calculation_rule_id'] == $rule) { + $index++; } } diff --git a/app/code/core/Mage/Weee/Helper/Data.php b/app/code/core/Mage/Weee/Helper/Data.php index 78d2845ce8f..9a94b889a58 100644 --- a/app/code/core/Mage/Weee/Helper/Data.php +++ b/app/code/core/Mage/Weee/Helper/Data.php @@ -314,7 +314,7 @@ public function getProductWeeeAttributesForRenderer( $shipping, $billing, $website, - $calculateTaxes ? $calculateTaxes : $this->typeOfDisplay($product, 1), + $calculateTaxes ?: $this->typeOfDisplay($product, 1), ); } @@ -356,7 +356,8 @@ public function getAmountForDisplay($product) * Returns amount to display including taxes * * @param Mage_Catalog_Model_Product $product - * @return float + * @throws Mage_Core_Exception + * @return float|int */ public function getAmountForDisplayInclTaxes($product) { @@ -394,7 +395,8 @@ public function getOriginalAmount($product) * * @param Mage_Catalog_Model_Product $product * @param array $tierPrices - * @param bool $includeIndex + * @param bool $includeIndex + * @throws Mage_Core_Exception * @return $this */ public function processTierPrices($product, &$tierPrices, $includeIndex = true) @@ -490,7 +492,7 @@ public function validateCatalogPricesAndFptConfiguration($store = null) * Set a value to a specific property searching FPT by title for the Item * * @param Mage_Core_Model_Abstract $item - * @param string $title + * @param null|string $title * @param string $property * @param string $value */ diff --git a/lib/Varien/Db/Adapter/Interface.php b/lib/Varien/Db/Adapter/Interface.php index 0df6bca5ace..29626e0512a 100644 --- a/lib/Varien/Db/Adapter/Interface.php +++ b/lib/Varien/Db/Adapter/Interface.php @@ -628,7 +628,7 @@ public function quoteIdentifier($ident, $auto = false); * Quote a column identifier and alias. * * @param array|string|Zend_Db_Expr $ident the identifier or expression - * @param string $alias an alias for the column + * @param null|string $alias an alias for the column * @param bool $auto if true, heed the AUTO_QUOTE_IDENTIFIERS config option * @return string the quoted identifier and alias */ diff --git a/lib/Varien/Db/Adapter/Pdo/Mysql.php b/lib/Varien/Db/Adapter/Pdo/Mysql.php index d7847ad8c50..73bd06fbef5 100644 --- a/lib/Varien/Db/Adapter/Pdo/Mysql.php +++ b/lib/Varien/Db/Adapter/Pdo/Mysql.php @@ -222,6 +222,7 @@ class Varien_Db_Adapter_Pdo_Mysql extends Zend_Db_Adapter_Pdo_Mysql implements V /** * Begin new DB transaction for connection * + * @throws Exception * @return $this */ public function beginTransaction() @@ -239,6 +240,7 @@ public function beginTransaction() /** * Commit DB transaction * + * @throws Exception * @return $this */ public function commit() @@ -259,6 +261,7 @@ public function commit() /** * Rollback DB transaction * + * @throws Exception * @return $this */ public function rollBack() @@ -355,6 +358,7 @@ protected function _getHostInfo($hostName) * Creates a PDO object and connects to the database. * * @throws Zend_Db_Adapter_Exception + * @throws Exception */ protected function _connect() { @@ -404,6 +408,7 @@ protected function _connect() * Run RAW Query * * @param string $sql + * @throws Throwable * @throws PDOException * @return Zend_Db_Statement_Interface */ @@ -416,21 +421,21 @@ public function raw_query($sql) $retry = false; try { $result = $this->query($sql); - } catch (Exception $e) { + } catch (Exception $exception) { // Convert to PDOException to maintain backwards compatibility with usage of MySQL adapter - if ($e instanceof Zend_Db_Statement_Exception) { - $e = $e->getPrevious(); - if (!($e instanceof PDOException)) { - $e = new PDOException($e->getMessage(), $e->getCode()); + if ($exception instanceof Zend_Db_Statement_Exception) { + $exception = $exception->getPrevious(); + if (!($exception instanceof PDOException)) { + $exception = new PDOException($exception->getMessage(), $exception->getCode()); } } // Check to reconnect - if ($tries < 10 && $e->getMessage() == $lostConnectionMessage) { + if ($tries < 10 && $exception->getMessage() == $lostConnectionMessage) { $retry = true; $tries++; } else { - throw $e; + throw $exception; } } } while ($retry); @@ -443,6 +448,8 @@ public function raw_query($sql) * * @param string $sql * @param int|string $field + * @throws Zend_Db_Statement_Exception + * @throws Throwable * @return bool */ // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps @@ -469,7 +476,7 @@ public function raw_fetchRow($sql, $field = null) * Check transaction level in case of DDL query * * @param string|Zend_Db_Select $sql - * @throws Zend_Db_Adapter_Exception + * @throws Varien_Db_Exception */ protected function _checkDdlTransaction($sql) { @@ -490,7 +497,8 @@ protected function _checkDdlTransaction($sql) * @param string|Zend_Db_Select $sql the SQL statement with placeholders * @param mixed $bind an array of data or data itself to bind to the placeholders * @throws Zend_Db_Adapter_Exception to re-throw PDOException - * @return Zend_Db_Statement_Pdo + * @throws Exception + * @return PDOStatement|Zend_Db_Statement|Zend_Db_Statement_Interface */ public function query($sql, $bind = []) { @@ -541,7 +549,7 @@ protected function _prepareQuery(&$sql, &$bind = []) foreach ($bind as $key => $value) { if (!is_int($key) && $key[0] != ':') { - $bind[":{$key}"] = $value; + $bind[":$key"] = $value; unset($bind[$key]); } } @@ -627,27 +635,27 @@ protected function _convertMixedBind(&$sql, &$bind) $bindResult = []; $map = []; - foreach ($bind as $k => $v) { + foreach ($bind as $bindKey => $bindValue) { // positional - if (is_int($k)) { - if (!isset($positions[$k])) { + if (is_int($bindKey)) { + if (!isset($positions[$bindKey])) { continue; } - $bindResult[$positions[$k]] = $v; + $bindResult[$positions[$bindKey]] = $bindValue; } else { $offset = 0; while (true) { - $pos = strpos($sql, $k, $offset); + $pos = strpos($sql, $bindKey, $offset); if ($pos === false) { break; } else { - $offset = $pos + strlen($k); - $bindResult[$pos] = $v; + $offset = $pos + strlen($bindKey); + $bindResult[$pos] = $bindValue; } } - $map[$k] = '?'; + $map[$bindKey] = '?'; } } @@ -664,8 +672,8 @@ protected function _convertMixedBind(&$sql, &$bind) * $hook must be either array with 'object' and 'method' entries, or null to remove hook. * Previous hook is returned. * - * @param array $hook - * @return mixed + * @param null|array $hook + * @return null|array */ public function setQueryHook($hook) { @@ -678,7 +686,7 @@ public function setQueryHook($hook) * Executes a SQL statement(s) * * @param string $sql - * @throws Zend_Db_Exception + * @throws Exception * @return array */ public function multiQuery($sql) @@ -690,6 +698,7 @@ public function multiQuery($sql) * Run Multi Query * * @param string $sql + * @throws Zend_Cache_Exception * @return array */ // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps @@ -784,6 +793,7 @@ protected function _splitMultiQuery($sql) * @param string $tableName * @param string $fkName * @param string $schemaName + * @throws Throwable * @return $this */ public function dropForeignKey($tableName, $fkName, $schemaName = null) @@ -812,11 +822,12 @@ public function dropForeignKey($tableName, $fkName, $schemaName = null) /** * Delete index from a table if it exists * - * @deprecated since 1.4.0.1 * @param string $tableName * @param string $keyName * @param string $schemaName + * @throws Throwable * @return bool|Zend_Db_Statement_Interface + *@deprecated since 1.4.0.1 */ public function dropKey($tableName, $keyName, $schemaName = null) { @@ -831,6 +842,7 @@ public function dropKey($tableName, $keyName, $schemaName = null) * @param string $refTableName * @param string $refColumnName * @param string $onDelete + * @throws Throwable * @return $this */ public function purgeOrphanRecords( @@ -872,7 +884,6 @@ public function purgeOrphanRecords( /** * Add foreign key to table. If FK with same name exist - it will be deleted * - * @deprecated since 1.4.0.1 * @param string $fkName foreign key name * @param string $tableName main table name * @param string $columnName main table field name @@ -881,7 +892,9 @@ public function purgeOrphanRecords( * @param string $onDelete on delete statement * @param string $onUpdate on update statement * @param bool $purge - * @return mixed + * @throws Throwable + * @return PDOStatement|Zend_Db_Statement|Zend_Db_Statement_Interface + * @deprecated since 1.4.0.1 */ public function addConstraint( $fkName, @@ -911,6 +924,7 @@ public function addConstraint( * @param string $tableName * @param string $columnName * @param string $schemaName + * @throws Zend_Cache_Exception * @return bool */ public function tableColumnExists($tableName, $columnName, $schemaName = null) @@ -936,8 +950,9 @@ public function tableColumnExists($tableName, $columnName, $schemaName = null) * @param string $columnName * @param array|string $definition string specific or universal array DB Server definition * @param string $schemaName + * @throws Throwable * @throws Zend_Db_Exception - * @return bool|int|Zend_Db_Statement_Interface + * @return bool|Zend_Db_Statement_Interface */ public function addColumn($tableName, $columnName, $definition, $schemaName = null) { @@ -980,6 +995,7 @@ public function addColumn($tableName, $columnName, $definition, $schemaName = nu * @param string $tableName * @param string $columnName * @param string $schemaName + * @throws Throwable * @return true|Zend_Db_Statement_Interface */ public function dropColumn($tableName, $columnName, $schemaName = null) @@ -1021,8 +1037,9 @@ public function dropColumn($tableName, $columnName, $schemaName = null) * @param array $definition * @param bool $flushData flush table statistic * @param string $schemaName + * @throws Throwable * @throws Zend_Db_Exception - * @return Zend_Db_Statement_Interface|Zend_Db_Statement_Pdo + * @return PDOStatement|Zend_Db_Statement|Zend_Db_Statement_Interface */ public function changeColumn( $tableName, @@ -1071,6 +1088,7 @@ public function changeColumn( * @param array|string $definition * @param bool $flushData * @param string $schemaName + * @throws Throwable * @throws Zend_Db_Exception * @return $this */ @@ -1106,6 +1124,8 @@ public function modifyColumn($tableName, $columnName, $definition, $flushData = * * @param string $tableName * @param string $schemaName + * @throws Zend_Db_Statement_Exception + * @throws Throwable * @return bool */ public function showTableStatus($tableName, $schemaName = null) @@ -1123,10 +1143,11 @@ public function showTableStatus($tableName, $schemaName = null) /** * Retrieve table index key list * - * @deprecated use getIndexList( * @param string $tableName * @param string $schemaName + * @throws Zend_Cache_Exception * @return array + * @deprecated use getIndexList() */ public function getKeyList($tableName, $schemaName = null) { @@ -1145,6 +1166,8 @@ public function getKeyList($tableName, $schemaName = null) * * @param string $tableName * @param string $schemaName + * @throws Zend_Db_Statement_Exception + * @throws Throwable * @return string */ public function getCreateTable($tableName, $schemaName = null) @@ -1181,6 +1204,7 @@ public function getCreateTable($tableName, $schemaName = null) * * @param string $tableName * @param string $schemaName + * @throws Zend_Cache_Exception * @return array */ public function getForeignKeys($tableName, $schemaName = null) @@ -1221,6 +1245,7 @@ public function getForeignKeys($tableName, $schemaName = null) /** * Retrieve the foreign keys tree for all tables * + * @throws Zend_Cache_Exception * @return array */ public function getForeignKeysTree() @@ -1246,6 +1271,8 @@ public function getForeignKeysTree() * comment => string; table comment * engine => string; table engine * + * @throws Zend_Db_Statement_Exception + * @throws Throwable * @return $this */ public function modifyTables($tables) @@ -1292,8 +1319,8 @@ public function modifyTables($tables) $options['COLUMN_NAME'], $options['REF_TABLE_NAME'], $options['REF_COLUMN_NAME'], - ($onDelete) ? $onDelete : Varien_Db_Adapter_Interface::FK_ACTION_NO_ACTION, - ($onUpdate) ? $onUpdate : Varien_Db_Adapter_Interface::FK_ACTION_NO_ACTION, + ($onDelete) ?: Varien_Db_Adapter_Interface::FK_ACTION_NO_ACTION, + ($onUpdate) ?: Varien_Db_Adapter_Interface::FK_ACTION_NO_ACTION, ); } } @@ -1330,6 +1357,7 @@ public function modifyTables($tables) * * @param string $tableName * @param string $schemaName + * @throws Zend_Cache_Exception * @return array */ public function getIndexList($tableName, $schemaName = null) @@ -1386,13 +1414,14 @@ public function getIndexList($tableName, $schemaName = null) /** * Add Index Key * - * @deprecated since 1.5.0.0 * @param string $tableName * @param string $indexName * @param array|string $fields * @param string $indexType * @param string $schemaName + * @throws Zend_Db_Exception * @return Zend_Db_Statement_Interface + * @deprecated since 1.5.0.0 */ public function addKey($tableName, $indexName, $fields, $indexType = 'index', $schemaName = null) { @@ -1405,14 +1434,15 @@ public function addKey($tableName, $indexName, $fields, $indexType = 'index', $s * @param string $table * @param array $fields * @param array $ids + * @throws Throwable * @return $this */ protected function _removeDuplicateEntry($table, $fields, $ids) { $where = []; - $i = 0; + $index = 0; foreach ($fields as $field) { - $where[] = $this->quoteInto($field . '=?', $ids[$i++]); + $where[] = $this->quoteInto($field . '=?', $ids[$index++]); } if (!$where) { @@ -1467,6 +1497,7 @@ protected function _debugTimer() * @param string $sql * @param array $bind * @param Zend_Db_Statement_Pdo $result + * @throws Exception * @return $this */ protected function _debugStat($type, $sql, $bind = [], $result = null) @@ -1476,7 +1507,7 @@ protected function _debugStat($type, $sql, $bind = [], $result = null) } $code = '## ' . getmypid() . ' ## '; - $nl = "\n"; + $eol = "\n"; $time = sprintf('%.4f', microtime(true) - $this->_debugTimer); if (!$this->_logAllQueries && $time < $this->_logQueryTime) { @@ -1485,32 +1516,32 @@ protected function _debugStat($type, $sql, $bind = [], $result = null) switch ($type) { case self::DEBUG_CONNECT: - $code .= 'CONNECT' . $nl; + $code .= 'CONNECT' . $eol; break; case self::DEBUG_TRANSACTION: - $code .= 'TRANSACTION ' . $sql . $nl; + $code .= 'TRANSACTION ' . $sql . $eol; break; case self::DEBUG_QUERY: - $code .= 'QUERY' . $nl; - $code .= 'SQL: ' . $sql . $nl; + $code .= 'QUERY' . $eol; + $code .= 'SQL: ' . $sql . $eol; if ($bind) { - $code .= 'BIND: ' . var_export($bind, true) . $nl; + $code .= 'BIND: ' . var_export($bind, true) . $eol; } if ($result instanceof Zend_Db_Statement_Pdo) { - $code .= 'AFF: ' . $result->rowCount() . $nl; + $code .= 'AFF: ' . $result->rowCount() . $eol; } break; } - $code .= 'TIME: ' . $time . $nl; + $code .= 'TIME: ' . $time . $eol; if ($this->_logCallStack) { - $code .= 'TRACE: ' . Varien_Debug::backtrace(true, false) . $nl; + $code .= 'TRACE: ' . Varien_Debug::backtrace(true, false) . $eol; } - $code .= $nl; + $code .= $eol; $this->_debugWriteToFile($code); @@ -1528,8 +1559,8 @@ protected function _debugException(Exception $e) throw $e; } - $nl = "\n"; - $code = 'EXCEPTION ' . $nl . $e . $nl . $nl; + $eol = "\n"; + $code = 'EXCEPTION ' . $eol . $e . $eol . $eol; $this->_debugWriteToFile($code); throw $e; @@ -1539,6 +1570,7 @@ protected function _debugException(Exception $e) * Debug write to file process * * @param string $str + * @throws Exception */ protected function _debugWriteToFile($str) { @@ -1638,6 +1670,7 @@ public function loadDdlCache($tableCacheKey, $ddlType) * * @param string $tableCacheKey * @param int $ddlType + * @throws Zend_Cache_Exception * @return $this */ public function saveDdlCache($tableCacheKey, $ddlType, $data) @@ -1663,6 +1696,7 @@ public function saveDdlCache($tableCacheKey, $ddlType, $data) * * @param string $tableName * @param string $schemaName OPTIONAL + * @throws Zend_Cache_Exception * @return $this */ public function resetDdlCache($tableName = null, $schemaName = null) @@ -1759,6 +1793,7 @@ public function decorateTableInfo($tableColumnInfo) * * @param string $tableName * @param string $schemaName OPTIONAL + * @throws Zend_Cache_Exception * @return array */ public function describeTable($tableName, $schemaName = null) @@ -1850,6 +1885,8 @@ public function getColumnCreateByDescribe($columnData) * * @param $tableName * @param $newTableName + * @throws Zend_Db_Exception + * @throws Throwable * @return Varien_Db_Ddl_Table */ public function createTableByDdl($tableName, $newTableName) @@ -1923,6 +1960,8 @@ public function createTableByDdl($tableName, $newTableName) * @param array $definition * @param bool $flushData * @param string $schemaName + * @throws Zend_Db_Exception + * @throws Throwable * @return $this */ public function modifyColumnByDdl($tableName, $columnName, $definition, $flushData = false, $schemaName = null) @@ -2005,7 +2044,8 @@ public function truncate($tableName, $schemaName = null) * @param string $tableName * @param string $engine * @param string $schemaName - * @return mixed + * @throws Throwable + * @return PDOStatement|Zend_Db_Statement|Zend_Db_Statement_Interface */ public function changeTableEngine($tableName, $engine, $schemaName = null) { @@ -2021,7 +2061,8 @@ public function changeTableEngine($tableName, $engine, $schemaName = null) * @param string $tableName * @param string $comment * @param string $schemaName - * @return mixed + * @throws Throwable + * @return PDOStatement|Zend_Db_Statement|Zend_Db_Statement_Interface */ public function changeTableComment($tableName, $comment, $schemaName = null) { @@ -2037,6 +2078,7 @@ public function changeTableComment($tableName, $comment, $schemaName = null) * @param string $tableName * @param string $increment * @param null|string $schemaName + * @throws Throwable * @return Zend_Db_Statement_Interface */ public function changeTableAutoIncrement($tableName, $increment, $schemaName = null) @@ -2051,6 +2093,7 @@ public function changeTableAutoIncrement($tableName, $increment, $schemaName = n * Special for Zero values to identity column * * @param string $table + * @throws Throwable * @return int the number of affected rows */ public function insertForce($table, array $bind) @@ -2205,6 +2248,7 @@ public function insertArray($table, array $columns, array $data) * * @param mixed $table the table to insert data into * @param array $bind column-value pairs + * @throws Zend_Db_Statement_Exception * @throws Zend_Db_Adapter_Exception * @return int the number of affected rows */ @@ -2213,7 +2257,7 @@ public function insertIgnore($table, array $bind) // extract and quote col names from the array keys $cols = []; $vals = []; - $i = 0; + $index = 0; foreach ($bind as $col => $val) { $cols[] = $this->quoteIdentifier($col, true); if ($val instanceof Zend_Db_Expr) { @@ -2223,9 +2267,9 @@ public function insertIgnore($table, array $bind) $vals[] = '?'; } elseif ($this->supportsParameters('named')) { unset($bind[$col]); - $bind[':col' . $i] = $val; - $vals[] = ':col' . $i; - $i++; + $bind[':col' . $index] = $val; + $vals[] = ':col' . $index; + $index++; } else { /** @see Zend_Db_Adapter_Exception */ #require_once 'Zend/Db/Adapter/Exception.php'; @@ -2287,7 +2331,7 @@ public function newTable($tableName = null, $schemaName = null) * Create table * * @throws Zend_Db_Exception - * @return Zend_Db_Statement_Pdo + * @return PDOStatement|Zend_Db_Statement|Zend_Db_Statement_Interface */ public function createTable(Varien_Db_Ddl_Table $table) { @@ -2318,7 +2362,7 @@ public function createTable(Varien_Db_Ddl_Table $table) * Create temporary table * * @throws Zend_Db_Exception - * @return Zend_Db_Statement_Pdo + * @return PDOStatement|Zend_Db_Statement|Zend_Db_Statement_Interface */ public function createTemporaryTable(Varien_Db_Ddl_Table $table) { @@ -2483,9 +2527,9 @@ protected function _getOptionsDefinition(Varien_Db_Ddl_Table $table) 'collate' => 'COLLATE=%s', ]; foreach ($tableProps as $key => $mask) { - $v = $table->getOption($key); - if ($v !== null) { - $definition[] = sprintf($mask, $v); + $value = $table->getOption($key); + if ($value !== null) { + $definition[] = sprintf($mask, $value); } } @@ -2497,6 +2541,7 @@ protected function _getOptionsDefinition(Varien_Db_Ddl_Table $table) * * @param array $options * @param null|string $ddlType + * @throws Zend_Db_Exception * @return string */ public function getColumnDefinitionFromDescribe($options, $ddlType = null) @@ -2514,7 +2559,6 @@ public function getColumnDefinitionFromDescribe($options, $ddlType = null) * * @param array $options * @param string $ddlType Table DDL Column type constant - * @throws Varien_Exception * @throws Zend_Db_Exception * @return string */ @@ -2522,7 +2566,6 @@ protected function _getColumnDefinition($options, $ddlType = null) { // convert keys to uppercase $options = array_change_key_case($options, CASE_UPPER); - $cType = null; $cUnsigned = false; $cNullable = true; $cDefault = false; @@ -2580,9 +2623,9 @@ protected function _getColumnDefinition($options, $ddlType = null) if ($length <= 255) { $cType = $ddlType == Varien_Db_Ddl_Table::TYPE_TEXT ? 'varchar' : 'varbinary'; $cType = sprintf('%s(%d)', $cType, $length); - } elseif ($length > 255 && $length <= 65536) { + } elseif ($length <= 65536) { $cType = $ddlType == Varien_Db_Ddl_Table::TYPE_TEXT ? 'text' : 'blob'; - } elseif ($length > 65536 && $length <= 16777216) { + } elseif ($length <= 16777216) { $cType = $ddlType == Varien_Db_Ddl_Table::TYPE_TEXT ? 'mediumtext' : 'mediumblob'; } else { $cType = $ddlType == Varien_Db_Ddl_Table::TYPE_TEXT ? 'longtext' : 'longblob'; @@ -2659,6 +2702,7 @@ protected function _getColumnDefinition($options, $ddlType = null) * * @param string $tableName * @param string $schemaName + * @throws Zend_Db_Adapter_Exception * @return bool */ public function dropTable($tableName, $schemaName = null) @@ -2675,6 +2719,7 @@ public function dropTable($tableName, $schemaName = null) * * @param string $tableName * @param string $schemaName + * @throws Zend_Db_Adapter_Exception * @return $this */ public function dropTemporaryTable($tableName, $schemaName = null) @@ -2691,6 +2736,7 @@ public function dropTemporaryTable($tableName, $schemaName = null) * * @param string $tableName * @param string $schemaName + * @throws Throwable * @throws Zend_Db_Exception * @return $this */ @@ -2712,6 +2758,8 @@ public function truncateTable($tableName, $schemaName = null) * * @param string $tableName * @param string $schemaName + * @throws Zend_Db_Statement_Exception + * @throws Throwable * @return bool */ public function isTableExists($tableName, $schemaName = null) @@ -2740,6 +2788,7 @@ public function isTableExists($tableName, $schemaName = null) * @param string $oldTableName * @param string $newTableName * @param string $schemaName + * @throws Throwable * @throws Zend_Db_Exception * @return bool */ @@ -2769,6 +2818,7 @@ public function renameTable($oldTableName, $newTableName, $schemaName = null) * * @param array $tablePairs array('oldName' => 'Name1', 'newName' => 'Name2') * + * @throws Zend_Cache_Exception * @throws Zend_Db_Exception * @return bool */ @@ -2863,17 +2913,17 @@ public function addIndex( try { $result = $this->raw_query($query); $cycle = false; - } catch (Exception $e) { + } catch (Exception $exception) { if (in_array(strtolower($indexType), ['primary', 'unique'])) { $match = []; - if (preg_match('#SQLSTATE\[23000\]: [^:]+: 1062[^\']+\'([\d-\.]+)\'#', $e->getMessage(), $match)) { + if (preg_match('#SQLSTATE\[23000\]: [^:]+: 1062[^\']+\'([\d-\.]+)\'#', $exception->getMessage(), $match)) { $ids = explode('-', $match[1]); $this->_removeDuplicateEntry($tableName, $fields, $ids); continue; } } - throw $e; + throw $exception; } } @@ -2888,6 +2938,7 @@ public function addIndex( * @param string $tableName * @param string $keyName * @param string $schemaName + * @throws Throwable * @return bool|Zend_Db_Statement_Interface */ public function dropIndex($tableName, $keyName, $schemaName = null) @@ -2929,7 +2980,8 @@ public function dropIndex($tableName, $keyName, $schemaName = null) * @param bool $purge trying remove invalid data * @param string $schemaName * @param string $refSchemaName - * @return Zend_Db_Statement_Interface|Zend_Db_Statement_Pdo + * @throws Throwable + * @return PDOStatement|Zend_Db_Statement|Zend_Db_Statement_Interface */ public function addForeignKey( $fkName, @@ -2992,6 +3044,7 @@ public function formatDate($date, $includeTime = true) /** * Run additional environment before setup * + * @throws Throwable * @return $this */ public function startSetup() @@ -3006,6 +3059,7 @@ public function startSetup() /** * Run additional environment after setup * + * @throws Throwable * @return $this */ public function endSetup() @@ -3302,7 +3356,7 @@ public function getCaseSql($valueName, $casesResults, $defaultValue = null) */ public function getConcatSql(array $data, $separator = null) { - $format = empty($separator) ? 'CONCAT(%s)' : "CONCAT_WS('{$separator}', %s)"; + $format = empty($separator) ? 'CONCAT(%s)' : "CONCAT_WS('$separator', %s)"; return new Zend_Db_Expr(sprintf($format, implode(', ', $data))); } @@ -3362,12 +3416,12 @@ protected function _getIntervalUnitSql($interval, $unit) /** * Add time values (intervals) to a date value * - * @see INTERVAL_ constants for $unit - * * @param string|Zend_Db_Expr $date quoted field name or SQL statement * @param int $interval * @param string $unit + * @throws Zend_Db_Exception * @return Zend_Db_Expr + * @see INTERVAL_ constants for $unit */ public function getDateAddSql($date, $interval, $unit) { @@ -3378,12 +3432,12 @@ public function getDateAddSql($date, $interval, $unit) /** * Subtract time values (intervals) to a date value * - * @see INTERVAL_ constants for $expr - * * @param string|Zend_Db_Expr $date quoted field name or SQL statement * @param int|string $interval * @param string $unit + * @throws Zend_Db_Exception * @return Zend_Db_Expr + * @see INTERVAL_ constants for $expr */ public function getDateSubSql($date, $interval, $unit) { @@ -3602,6 +3656,7 @@ public function getForeignKeyName($priTableName, $priColumnName, $refTableName, * * @param string $tableName * @param string $schemaName + * @throws Zend_Db_Adapter_Exception * @return $this */ public function disableTableKeys($tableName, $schemaName = null) @@ -3618,6 +3673,7 @@ public function disableTableKeys($tableName, $schemaName = null) * * @param string $tableName * @param string $schemaName + * @throws Zend_Db_Adapter_Exception * @return $this */ public function enableTableKeys($tableName, $schemaName = null) @@ -3634,6 +3690,7 @@ public function enableTableKeys($tableName, $schemaName = null) * * @param string $table insert into table * @param bool|int $mode + * @throws Zend_Cache_Exception * @return string */ public function insertFromSelect(Varien_Db_Select $select, $table, array $fields = [], $mode = false) @@ -3662,20 +3719,20 @@ public function insertFromSelect(Varien_Db_Select $select, $table, array $fields } $update = []; - foreach ($fields as $k => $v) { + foreach ($fields as $key => $fieldValue) { $field = $value = null; - if (!is_numeric($k)) { - $field = $this->quoteIdentifier($k); - if ($v instanceof Zend_Db_Expr) { - $value = $v->__toString(); - } elseif (is_string($v)) { - $value = sprintf('VALUES(%s)', $this->quoteIdentifier($v)); - } elseif (is_numeric($v)) { - $value = $this->quoteInto('?', $v); + if (!is_numeric($key)) { + $field = $this->quoteIdentifier($key); + if ($fieldValue instanceof Zend_Db_Expr) { + $value = $fieldValue->__toString(); + } elseif (is_string($fieldValue)) { + $value = sprintf('VALUES(%s)', $this->quoteIdentifier($fieldValue)); + } elseif (is_numeric($fieldValue)) { + $value = $this->quoteInto('?', $fieldValue); } - } elseif (is_string($v)) { - $value = sprintf('VALUES(%s)', $this->quoteIdentifier($v)); - $field = $this->quoteIdentifier($v); + } elseif (is_string($fieldValue)) { + $value = sprintf('VALUES(%s)', $this->quoteIdentifier($fieldValue)); + $field = $this->quoteIdentifier($fieldValue); } if ($field && $value) { @@ -3696,6 +3753,7 @@ public function insertFromSelect(Varien_Db_Select $select, $table, array $fields * * @param string $rangeField * @param int $stepCount + * @throws Zend_Db_Select_Exception * @throws Varien_Db_Exception * @return array */ @@ -3752,7 +3810,6 @@ public function selectsByRange($rangeField, Varien_Db_Select $select, $stepCount * Convert date format to unix time * * @param string|Zend_Db_Expr $date - * @throws Varien_Db_Exception * @return Zend_Db_Expr */ public function getUnixTimestamp($date) @@ -3765,7 +3822,7 @@ public function getUnixTimestamp($date) * Convert unix time to date format * * @param int|Zend_Db_Expr $timestamp - * @return mixed + * @return Zend_Db_Expr */ public function fromUnixtime($timestamp) { @@ -3777,6 +3834,7 @@ public function fromUnixtime($timestamp) * Get update table query using select object for join and update * * @param array|string $table + * @throws Zend_Db_Select_Exception * @throws Varien_Db_Exception * @return string */ @@ -3856,7 +3914,7 @@ public function updateFromSelect(Varien_Db_Select $select, $table) * Get delete from select object query * * @param string $table the table name or alias used in select - * @return int|string + * @return string */ public function deleteFromSelect(Varien_Db_Select $select, $table) { @@ -4040,6 +4098,7 @@ protected function _prepareSqlDateCondition($condition, $key) * * @param string $tableName Table name * @param string $schemaName OPTIONAL + * @throws Zend_Cache_Exception * @return string Primary Key name */ public function getPrimaryKeyName($tableName, $schemaName = null) @@ -4135,7 +4194,8 @@ protected function _getForeignKeyName($fkName) * Drop trigger * * @param string $triggerName - * @return Varien_Db_Adapter_Interface + * @throws Zend_Db_Adapter_Exception + * @return $this */ public function dropTrigger($triggerName) { @@ -4152,7 +4212,8 @@ public function dropTrigger($triggerName) * * @param string $tableName * @param bool $temporary - * @return mixed + * @throws Zend_Db_Adapter_Exception + * @return void */ public function createTableFromSelect($tableName, Zend_Db_Select $select, $temporary = false) { diff --git a/lib/Varien/Simplexml/Element.php b/lib/Varien/Simplexml/Element.php index 8917296dca1..7aa9051e06e 100644 --- a/lib/Varien/Simplexml/Element.php +++ b/lib/Varien/Simplexml/Element.php @@ -247,10 +247,10 @@ public function asNiceXml($filename = '', $level = 0) { if (is_numeric($level)) { $pad = str_pad('', $level * 3, ' ', STR_PAD_LEFT); - $newLine = "\n"; + $eol = "\n"; } else { $pad = ''; - $newLine = ''; + $eol = ''; } $out = $pad . '<' . $this->getName(); @@ -262,18 +262,18 @@ public function asNiceXml($filename = '', $level = 0) } if ($this->hasChildren()) { - $out .= '>' . $newLine; + $out .= '>' . $eol; foreach ($this->children() as $child) { $out .= $child->asNiceXml('', is_numeric($level) ? $level + 1 : true); } - $out .= $pad . 'getName() . '>' . $newLine; + $out .= $pad . 'getName() . '>' . $eol; } else { $value = (string) $this; if (strlen($value)) { - $out .= '>' . $this->xmlentities($value) . 'getName() . '>' . $newLine; + $out .= '>' . $this->xmlentities($value) . 'getName() . '>' . $eol; } else { - $out .= '/>' . $newLine; + $out .= '/>' . $eol; } } From 0e1ff3fb13a762b77b678bbbfc882f7539665012 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 6 Nov 2025 06:45:36 +0100 Subject: [PATCH 2/4] fix --- app/code/core/Mage/Tax/Model/Calculation.php | 2 +- .../Mage/Tax/Model/Resource/Calculation.php | 2 +- .../Tax/Model/Resource/CalculationTest.php | 35 +++++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 tests/unit/Mage/Tax/Model/Resource/CalculationTest.php diff --git a/app/code/core/Mage/Tax/Model/Calculation.php b/app/code/core/Mage/Tax/Model/Calculation.php index ec2871faeed..213cb41f6ba 100644 --- a/app/code/core/Mage/Tax/Model/Calculation.php +++ b/app/code/core/Mage/Tax/Model/Calculation.php @@ -619,7 +619,7 @@ public function getApplicableRateIds($request) */ public function reproduceProcess($rates) { - return $this->getResource()->getCalculationProcess(new Varien_Object(), $rates); + return $this->getResource()->getCalculationProcess(null, $rates); } /** diff --git a/app/code/core/Mage/Tax/Model/Resource/Calculation.php b/app/code/core/Mage/Tax/Model/Resource/Calculation.php index e71d8693db4..967664b2cd1 100644 --- a/app/code/core/Mage/Tax/Model/Resource/Calculation.php +++ b/app/code/core/Mage/Tax/Model/Resource/Calculation.php @@ -95,7 +95,7 @@ public function getRate($request) /** * Retrieve Calculation Process * - * @param Varien_Object $request + * @param null|Varien_Object $request * @param null|array $rates * @return array */ diff --git a/tests/unit/Mage/Tax/Model/Resource/CalculationTest.php b/tests/unit/Mage/Tax/Model/Resource/CalculationTest.php new file mode 100644 index 00000000000..6755993f522 --- /dev/null +++ b/tests/unit/Mage/Tax/Model/Resource/CalculationTest.php @@ -0,0 +1,35 @@ +getCalculationProcess(null)); + } +} From 9abed0dbdc3dda58763cc61baaf8772ba2f0d4e2 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 6 Nov 2025 07:00:11 +0100 Subject: [PATCH 3/4] fix --- app/code/core/Mage/Adminhtml/Block/Widget/Grid.php | 2 +- .../core/Mage/ImportExport/Block/Adminhtml/Export/Filter.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php b/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php index 8240b3184f4..066b47aa604 100644 --- a/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php @@ -967,7 +967,7 @@ public function getMessageBlockVisibility() } /** - * @param int $limit + * @param null|int $limit * @return $this */ public function setDefaultLimit($limit) diff --git a/app/code/core/Mage/ImportExport/Block/Adminhtml/Export/Filter.php b/app/code/core/Mage/ImportExport/Block/Adminhtml/Export/Filter.php index aa5b029fd2a..7d305c4f66d 100644 --- a/app/code/core/Mage/ImportExport/Block/Adminhtml/Export/Filter.php +++ b/app/code/core/Mage/ImportExport/Block/Adminhtml/Export/Filter.php @@ -42,7 +42,7 @@ public function __construct() $this->setDefaultSort('frontend_label'); $this->setDefaultDir('ASC'); $this->setPagerVisibility(false); - $this->setDefaultLimit(0); + $this->setDefaultLimit(null); $this->setUseAjax(true); } From c6afdeb8591c14b203ab34acc04097d207818370 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 6 Nov 2025 07:12:01 +0100 Subject: [PATCH 4/4] fix --- app/code/core/Mage/Tax/Model/Resource/Calculation.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/code/core/Mage/Tax/Model/Resource/Calculation.php b/app/code/core/Mage/Tax/Model/Resource/Calculation.php index 967664b2cd1..e24c197aedc 100644 --- a/app/code/core/Mage/Tax/Model/Resource/Calculation.php +++ b/app/code/core/Mage/Tax/Model/Resource/Calculation.php @@ -224,13 +224,17 @@ protected function _createSearchPostCodeTemplates($postcode) * Returns tax rates for request - either pereforms SELECT from DB, or returns already cached result * Notice that productClassId due to optimization can be array of ids * - * @param Varien_Object $request + * @param null|Varien_Object $request * @throws Zend_Db_Select_Exception * @throws Mage_Core_Exception * @return array */ protected function _getRates($request) { + if (!$request instanceof Varien_Object) { + return []; + } + // Extract params that influence our SELECT statement and use them to create cache key $storeId = Mage::app()->getStore($request->getStore())->getId(); $customerClassId = $request->getCustomerClassId();