From 0f8b97e5bc9da313575c333c9c0c0c507e9536ef Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Fri, 18 Oct 2024 05:10:44 +0200 Subject: [PATCH 1/2] fixes --- .phpstan.dist.baseline.neon | 282 +----------------- app/Mage.php | 2 + app/code/core/Mage/Admin/Model/Block.php | 2 +- .../Catalog/Product/Edit/Tab/Super/Config.php | 1 + .../Tab/Newsletter/Grid/Renderer/Action.php | 1 + .../Block/Newsletter/Template/Edit.php | 1 + .../Block/Sales/Reorder/Renderer/Action.php | 1 + .../Email/Template/Grid/Renderer/Action.php | 1 + .../core/Mage/Api2/Model/Route/ApiType.php | 2 + .../core/Mage/Bundle/Model/Product/Price.php | 1 - app/code/core/Mage/Captcha/Helper/Data.php | 4 +- app/code/core/Mage/Catalog/Helper/Data.php | 4 +- .../core/Mage/Catalog/Model/Api/Resource.php | 2 +- app/code/core/Mage/Catalog/Model/Category.php | 4 +- .../Catalog/Model/Convert/Adapter/Product.php | 6 + app/code/core/Mage/Catalog/Model/Product.php | 14 +- .../Resource/Category/Flat/Collection.php | 11 +- .../Catalog/Model/Resource/Category/Tree.php | 9 +- .../Catalog/Model/Resource/Eav/Attribute.php | 2 +- app/code/core/Mage/Catalog/Model/Url.php | 2 +- .../core/Mage/Checkout/Model/Api/Resource.php | 2 +- .../Checkout/Model/Cart/Product/Api/V2.php | 2 +- app/code/core/Mage/Core/Helper/Data.php | 2 +- app/code/core/Mage/Core/Helper/String.php | 15 +- app/code/core/Mage/Core/Model/Abstract.php | 2 +- app/code/core/Mage/Core/Model/Store.php | 9 +- app/code/core/Mage/Core/Model/Store/Group.php | 1 + app/code/core/Mage/Core/Model/Website.php | 1 + .../Mage/Eav/Model/Convert/Adapter/Entity.php | 5 +- .../Entity/Attribute/Backend/Abstract.php | 5 +- .../Entity/Attribute/Backend/Interface.php | 3 +- app/code/core/Mage/Eav/Model/Entity/Type.php | 16 +- .../Resource/Form/Fieldset/Collection.php | 2 +- .../Mage/GiftMessage/Block/Message/Form.php | 1 + .../core/Mage/GiftMessage/Model/Api/V2.php | 2 +- .../Model/Export/Entity/Abstract.php | 4 +- .../Model/Import/Entity/Abstract.php | 10 +- .../core/Mage/Paypal/Model/Payflowlink.php | 11 +- .../Reports/Model/Product/Index/Abstract.php | 2 +- .../core/Mage/Sales/Block/Order/Comments.php | 4 +- .../Quote/Address/Attribute/Frontend.php | 3 +- app/code/core/Mage/Sales/Model/Quote.php | 6 +- .../core/Mage/Sales/Model/Quote/Address.php | 6 +- .../Model/Quote/Address/Total/Abstract.php | 2 +- .../Mage/SalesRule/Model/Quote/Discount.php | 6 +- .../SalesRule/Model/Quote/Freeshipping.php | 5 +- .../core/Mage/Shipping/Model/Rate/Request.php | 8 +- app/code/core/Mage/Tax/Model/Calculation.php | 2 +- .../Mage/Tax/Model/Resource/Calculation.php | 6 +- .../Mage/Tax/Model/Sales/Total/Quote/Tax.php | 7 +- .../core/Mage/Weee/Model/Total/Quote/Weee.php | 3 + lib/Magento/Db/Adapter/Pdo/Mysql.php | 1 + lib/Varien/Data/Form/Filter/Date.php | 10 +- lib/Varien/Data/Form/Filter/Datetime.php | 6 +- lib/Varien/Data/Tree/Dbp.php | 4 +- 55 files changed, 155 insertions(+), 371 deletions(-) diff --git a/.phpstan.dist.baseline.neon b/.phpstan.dist.baseline.neon index a4c1b8adbc0..c296af377ce 100644 --- a/.phpstan.dist.baseline.neon +++ b/.phpstan.dist.baseline.neon @@ -1385,16 +1385,6 @@ parameters: count: 1 path: app/code/core/Mage/Bundle/Block/Catalog/Product/List/Partof.php - - - message: "#^Call to an undefined method Mage_Catalog_Model_Product_Type_Price\\:\\:getIsPricesCalculatedByIndex\\(\\)\\.$#" - count: 1 - path: app/code/core/Mage/Bundle/Block/Catalog/Product/Price.php - - - - message: "#^Call to an undefined method Mage_Catalog_Model_Product_Type_Price\\:\\:getSelectionPreFinalPrice\\(\\)\\.$#" - count: 3 - path: app/code/core/Mage/Bundle/Block/Catalog/Product/View/Type/Bundle/Option.php - - message: "#^Variable \\$_items might not be defined\\.$#" count: 1 @@ -1405,11 +1395,6 @@ parameters: count: 1 path: app/code/core/Mage/Bundle/Helper/Catalog/Product/Configuration.php - - - message: "#^Call to an undefined method Mage_Catalog_Model_Product_Type_Price\\:\\:getSelectionFinalTotalPrice\\(\\)\\.$#" - count: 1 - path: app/code/core/Mage/Bundle/Helper/Catalog/Product/Configuration.php - - message: "#^Call to an undefined method Mage_Bundle_Model_CatalogIndex_Data_Bundle\\:\\:_addAttributeFilter\\(\\)\\.$#" count: 1 @@ -1470,11 +1455,6 @@ parameters: count: 1 path: app/code/core/Mage/Bundle/Model/Product/Price.php - - - message: "#^Call to an undefined method Mage_Catalog_Model_Product_Type_Price\\:\\:getSelectionFinalTotalPrice\\(\\)\\.$#" - count: 2 - path: app/code/core/Mage/Bundle/Model/Product/Type.php - - message: "#^Call to function is_array\\(\\) with string will always evaluate to false\\.$#" count: 1 @@ -1555,21 +1535,6 @@ parameters: count: 1 path: app/code/core/Mage/Captcha/Block/Captcha/Zend.php - - - message: "#^Call to an undefined method Mage_Captcha_Model_Interface\\:\\:isRequired\\(\\)\\.$#" - count: 9 - path: app/code/core/Mage/Captcha/Model/Observer.php - - - - message: "#^Call to an undefined method Mage_Captcha_Model_Interface\\:\\:logAttempt\\(\\)\\.$#" - count: 3 - path: app/code/core/Mage/Captcha/Model/Observer.php - - - - message: "#^Result of method Mage_Captcha_Model_Interface\\:\\:isCorrect\\(\\) \\(void\\) is used\\.$#" - count: 9 - path: app/code/core/Mage/Captcha/Model/Observer.php - - message: "#^Property Mage_Captcha_Model_Zend\\:\\:\\$_helper \\(Mage_Captcha_Helper_Data\\) in empty\\(\\) is not falsy\\.$#" count: 1 @@ -1580,16 +1545,6 @@ parameters: count: 1 path: app/code/core/Mage/Captcha/Model/Zend.php - - - message: "#^Call to an undefined method Mage_Captcha_Model_Interface\\:\\:getImgSrc\\(\\)\\.$#" - count: 1 - path: app/code/core/Mage/Captcha/controllers/Adminhtml/RefreshController.php - - - - message: "#^Call to an undefined method Mage_Captcha_Model_Interface\\:\\:getImgSrc\\(\\)\\.$#" - count: 1 - path: app/code/core/Mage/Captcha/controllers/RefreshController.php - - message: "#^Argument of an invalid type string supplied for foreach, only iterables are supported\\.$#" count: 1 @@ -1795,11 +1750,6 @@ parameters: count: 3 path: app/code/core/Mage/Catalog/Helper/Data.php - - - message: "#^Property Mage_Catalog_Helper_Data\\:\\:\\$_categoryPath \\(string\\) does not accept array\\\\>\\.$#" - count: 1 - path: app/code/core/Mage/Catalog/Helper/Data.php - - message: "#^Property Mage_Catalog_Helper_Output\\:\\:\\$_templateProcessor \\(Varien_Filter_Template\\) does not accept Mage_Core_Model_Abstract\\|false\\.$#" count: 1 @@ -1925,11 +1875,6 @@ parameters: count: 1 path: app/code/core/Mage/Catalog/Model/Category.php - - - message: "#^Method Mage_Catalog_Model_Category\\:\\:getDefaultAttributeSetId\\(\\) should return int but returns string\\|null\\.$#" - count: 1 - path: app/code/core/Mage/Catalog/Model/Category.php - - message: "#^Cannot call method getRootCategoryId\\(\\) on int\\|string\\.$#" count: 1 @@ -1966,7 +1911,7 @@ parameters: path: app/code/core/Mage/Catalog/Model/Convert/Adapter/Product.php - - message: "#^Call to an undefined method Mage_Eav_Model_Entity_Collection\\:\\:setStoreId\\(\\)\\.$#" + message: "#^Cannot call method setStoreId\\(\\) on Mage_Eav_Model_Entity_Collection\\|false\\.$#" count: 1 path: app/code/core/Mage/Catalog/Model/Convert/Adapter/Product.php @@ -1975,18 +1920,13 @@ parameters: count: 1 path: app/code/core/Mage/Catalog/Model/Convert/Adapter/Product.php - - - message: "#^Parameter \\#1 \\$joinAttr of method Mage_Eav_Model_Convert_Adapter_Entity\\:\\:setJoinAttr\\(\\) expects string, array\\ given\\.$#" - count: 1 - path: app/code/core/Mage/Catalog/Model/Convert/Adapter/Product.php - - message: "#^Property Mage_Catalog_Model_Convert_Adapter_Product\\:\\:\\$_galleryBackendModel \\(Mage_Catalog_Model_Product_Attribute_Backend_Media\\) does not accept Mage_Eav_Model_Entity_Attribute_Backend_Abstract\\.$#" count: 1 path: app/code/core/Mage/Catalog/Model/Convert/Adapter/Product.php - - message: "#^Return type \\(Mage_Catalog_Model_Resource_Product_Collection\\) of method Mage_Catalog_Model_Convert_Adapter_Product\\:\\:_getCollectionForLoad\\(\\) should be compatible with return type \\(Mage_Eav_Model_Entity_Collection\\) of method Mage_Eav_Model_Convert_Adapter_Entity\\:\\:_getCollectionForLoad\\(\\)$#" + message: "#^Return type \\(Mage_Catalog_Model_Resource_Product_Collection\\) of method Mage_Catalog_Model_Convert_Adapter_Product\\:\\:_getCollectionForLoad\\(\\) should be compatible with return type \\(Mage_Eav_Model_Entity_Collection\\|false\\) of method Mage_Eav_Model_Convert_Adapter_Entity\\:\\:_getCollectionForLoad\\(\\)$#" count: 1 path: app/code/core/Mage/Catalog/Model/Convert/Adapter/Product.php @@ -2116,7 +2056,7 @@ parameters: path: app/code/core/Mage/Catalog/Model/Product.php - - message: "#^Method Mage_Catalog_Model_Product\\:\\:getDefaultAttributeSetId\\(\\) should return int but returns string\\|null\\.$#" + message: "#^Method Mage_Catalog_Model_Product\\:\\:getPriceModel\\(\\) should return Mage_Bundle_Model_Product_Price but returns Mage_Catalog_Model_Product_Type_Price\\.$#" count: 1 path: app/code/core/Mage/Catalog/Model/Product.php @@ -2480,31 +2420,16 @@ parameters: count: 1 path: app/code/core/Mage/Catalog/Model/Resource/Category/Tree.php - - - message: "#^Parameter \\#1 \\$category \\(Mage_Catalog_Model_Category\\) of method Mage_Catalog_Model_Resource_Category_Tree\\:\\:move\\(\\) should be compatible with parameter \\$node \\(Varien_Data_Tree_Node\\) of method Varien_Data_Tree_Dbp\\:\\:move\\(\\)$#" - count: 1 - path: app/code/core/Mage/Catalog/Model/Resource/Category/Tree.php - - message: "#^Parameter \\#1 \\$connection of method Varien_Data_Tree_Dbp\\:\\:__construct\\(\\) expects Zend_Db_Adapter_Abstract, Varien_Db_Adapter_Interface\\|false given\\.$#" count: 1 path: app/code/core/Mage/Catalog/Model/Resource/Category/Tree.php - - - message: "#^Parameter \\#1 \\$node of method Varien_Data_Tree_Dbp\\:\\:move\\(\\) expects Varien_Data_Tree_Node, Mage_Catalog_Model_Category given\\.$#" - count: 1 - path: app/code/core/Mage/Catalog/Model/Resource/Category/Tree.php - - message: "#^Parameter \\#2 \\$cols of method Zend_Db_Select\\:\\:from\\(\\) expects array\\|string\\|Zend_Db_Expr, null given\\.$#" count: 1 path: app/code/core/Mage/Catalog/Model/Resource/Category/Tree.php - - - message: "#^Parameter \\#3 \\$parentNode of method Varien_Data_Tree_Dbp\\:\\:addChildNodes\\(\\) expects Varien_Data_Tree_Node, null given\\.$#" - count: 1 - path: app/code/core/Mage/Catalog/Model/Resource/Category/Tree.php - - message: "#^Parameter \\#2 \\$alias of method Varien_Db_Adapter_Interface\\:\\:quoteColumnAs\\(\\) expects string, null given\\.$#" count: 2 @@ -2620,16 +2545,6 @@ parameters: count: 1 path: app/code/core/Mage/Catalog/Model/Resource/Product/Compare/Item/Collection.php - - - message: "#^Method Mage_Catalog_Model_Resource_Product_Flat\\:\\:getTypeId\\(\\) should return int but returns string\\|null\\.$#" - count: 1 - path: app/code/core/Mage/Catalog/Model/Resource/Product/Flat.php - - - - message: "#^Parameter \\#1 \\$entity of method Mage_Eav_Model_Entity_Attribute_Abstract\\:\\:setEntity\\(\\) expects Mage_Eav_Model_Entity_Abstract, Mage_Core_Model_Resource_Abstract given\\.$#" - count: 2 - path: app/code/core/Mage/Catalog/Model/Resource/Product/Flat/Indexer.php - - message: "#^Method Mage_Catalog_Model_Resource_Product_Indexer_Abstract\\:\\:_getAttribute\\(\\) should return Mage_Catalog_Model_Resource_Eav_Attribute but returns Mage_Eav_Model_Entity_Attribute_Abstract\\|false\\.$#" count: 1 @@ -3050,11 +2965,6 @@ parameters: count: 1 path: app/code/core/Mage/CatalogSearch/Model/Resource/Advanced/Collection.php - - - message: "#^Parameter \\#1 \\$entity of method Mage_Eav_Model_Entity_Attribute_Abstract\\:\\:setEntity\\(\\) expects Mage_Eav_Model_Entity_Abstract, Mage_Core_Model_Resource_Abstract given\\.$#" - count: 1 - path: app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext.php - - message: "#^Parameter \\#1 \\$expression of class Zend_Db_Expr constructor expects string, int given\\.$#" count: 1 @@ -3180,11 +3090,6 @@ parameters: count: 1 path: app/code/core/Mage/Checkout/Model/Cart/Payment/Api/V2.php - - - message: "#^Method Mage_Checkout_Model_Cart_Product_Api_V2\\:\\:_prepareProductsData\\(\\) should return array but returns mixed\\.$#" - count: 1 - path: app/code/core/Mage/Checkout/Model/Cart/Product/Api/V2.php - - message: "#^Method Mage_Checkout_Model_Session\\:\\:getQuoteId\\(\\) invoked with 1 parameter, 0 required\\.$#" count: 1 @@ -4335,16 +4240,6 @@ parameters: count: 1 path: app/code/core/Mage/Eav/Model/Config.php - - - message: "#^Method Mage_Eav_Model_Convert_Adapter_Entity\\:\\:_getCollectionForLoad\\(\\) should return Mage_Eav_Model_Entity_Collection but returns Mage_Core_Model_Resource_Db_Collection_Abstract\\|false\\.$#" - count: 1 - path: app/code/core/Mage/Eav/Model/Convert/Adapter/Entity.php - - - - message: "#^Parameter \\#1 \\$joinAttr of method Mage_Eav_Model_Convert_Adapter_Entity\\:\\:setJoinAttr\\(\\) expects string, array\\ given\\.$#" - count: 1 - path: app/code/core/Mage/Eav/Model/Convert/Adapter/Entity.php - - message: "#^Variable \\$defBind might not be defined\\.$#" count: 1 @@ -4455,11 +4350,6 @@ parameters: count: 1 path: app/code/core/Mage/Eav/Model/Entity/Attribute/Abstract.php - - - message: "#^Return type \\(\\$this\\(Mage_Eav_Model_Entity_Attribute_Backend_Abstract\\)\\) of method Mage_Eav_Model_Entity_Attribute_Backend_Abstract\\:\\:setValueId\\(\\) should be compatible with return type \\(int\\) of method Mage_Eav_Model_Entity_Attribute_Backend_Interface\\:\\:setValueId\\(\\)$#" - count: 1 - path: app/code/core/Mage/Eav/Model/Entity/Attribute/Backend/Abstract.php - - message: "#^Variable \\$out in empty\\(\\) always exists and is not falsy\\.$#" count: 1 @@ -4675,11 +4565,6 @@ parameters: count: 1 path: app/code/core/Mage/Eav/Model/Resource/Form/Type.php - - - message: "#^Method Mage_GiftMessage_Model_Api_V2\\:\\:_prepareData\\(\\) should return array but returns mixed\\.$#" - count: 1 - path: app/code/core/Mage/GiftMessage/Model/Api/V2.php - - message: "#^Return type \\(stdClass\\) of method Mage_GiftMessage_Model_Api_V2\\:\\:_setGiftMessage\\(\\) should be compatible with return type \\(array\\) of method Mage_GiftMessage_Model_Api\\:\\:_setGiftMessage\\(\\)$#" count: 1 @@ -4805,11 +4690,6 @@ parameters: count: 1 path: app/code/core/Mage/ImportExport/Model/Import/Entity/Product.php - - - message: "#^Parameter \\#1 \\$typeId of method Mage_Eav_Model_Resource_Entity_Attribute_Set_Collection\\:\\:setEntityTypeFilter\\(\\) expects int, string\\|null given\\.$#" - count: 1 - path: app/code/core/Mage/ImportExport/Model/Import/Entity/Product.php - - message: "#^Parameter \\#1 \\$value of method Mage_Catalog_Model_Resource_Category_Collection\\:\\:getItemById\\(\\) expects int, string given\\.$#" count: 1 @@ -4830,11 +4710,6 @@ parameters: count: 1 path: app/code/core/Mage/ImportExport/Model/Import/Entity/Product.php - - - message: "#^Parameter \\#1 \\$typeId of method Mage_Eav_Model_Resource_Entity_Attribute_Set_Collection\\:\\:setEntityTypeFilter\\(\\) expects int, string\\|null given\\.$#" - count: 1 - path: app/code/core/Mage/ImportExport/Model/Import/Entity/Product/Type/Abstract.php - - message: "#^Parameter \\#1 \\$collection of method Mage_ImportExport_Model_Export\\:\\:filterAttributeCollection\\(\\) expects Mage_Eav_Model_Resource_Entity_Attribute_Collection, Mage_Core_Model_Resource_Db_Collection_Abstract\\|null given\\.$#" count: 1 @@ -5311,17 +5186,12 @@ parameters: path: app/code/core/Mage/Paypal/Model/Observer.php - - message: "#^Parameter \\#1 \\$payment of method Mage_Paypal_Model_Payflowlink\\:\\:_buildTokenRequest\\(\\) expects Mage_Sales_Model_Order_Payment, Mage_Payment_Model_Info given\\.$#" - count: 1 - path: app/code/core/Mage/Paypal/Model/Payflowlink.php - - - - message: "#^Parameter \\#1 \\$payment of method Mage_Paypal_Model_Payflowlink\\:\\:_generateSecureSilentPostHash\\(\\) expects Mage_Sales_Model_Order_Payment, Mage_Payment_Model_Info given\\.$#" + message: "#^PHPDoc tag @param for parameter \\$payment with type Mage_Payment_Model_Info is not subtype of native type Mage_Sales_Model_Order_Payment\\.$#" count: 1 path: app/code/core/Mage/Paypal/Model/Payflowlink.php - - message: "#^Parameter \\#2 \\$payment of method Mage_Paypal_Model_Payflowlink\\:\\:_processTokenErrors\\(\\) expects Mage_Sales_Model_Order_Payment, Mage_Payment_Model_Info given\\.$#" + message: "#^Parameter \\#1 \\$payment of method Mage_Paypal_Model_Payflowlink\\:\\:_buildTokenRequest\\(\\) expects Mage_Sales_Model_Order_Payment, Mage_Payment_Model_Info given\\.$#" count: 1 path: app/code/core/Mage/Paypal/Model/Payflowlink.php @@ -5825,21 +5695,6 @@ parameters: count: 1 path: app/code/core/Mage/Sales/Block/Adminhtml/Recurring/Profile/Edit/Form.php - - - message: "#^Cannot call method setParentFilter\\(\\) on Mage_Core_Model_Resource_Db_Collection_Abstract\\|false\\.$#" - count: 1 - path: app/code/core/Mage/Sales/Block/Order/Comments.php - - - - message: "#^Method Mage_Sales_Block_Order_Comments\\:\\:getComments\\(\\) should return Mage_Sales_Model_Resource_Order_Comment_Collection_Abstract but returns Mage_Core_Model_Resource_Db_Collection_Abstract\\|false\\.$#" - count: 1 - path: app/code/core/Mage/Sales/Block/Order/Comments.php - - - - message: "#^Property Mage_Sales_Block_Order_Comments\\:\\:\\$_commentCollection \\(Mage_Sales_Model_Resource_Order_Comment_Collection_Abstract\\|null\\) does not accept Mage_Core_Model_Resource_Db_Collection_Abstract\\|false\\.$#" - count: 1 - path: app/code/core/Mage/Sales/Block/Order/Comments.php - - message: "#^Call to method setOrderFilter\\(\\) on an unknown class Mage_Sales_Model_Resource_Invoice_Collection\\.$#" count: 1 @@ -5880,36 +5735,6 @@ parameters: count: 2 path: app/code/core/Mage/Sales/Model/Entity/Quote.php - - - message: "#^Return type \\(\\$this\\(Mage_Sales_Model_Entity_Quote_Address_Attribute_Frontend_Custbalance\\)\\) of method Mage_Sales_Model_Entity_Quote_Address_Attribute_Frontend_Custbalance\\:\\:fetchTotals\\(\\) should be compatible with return type \\(array\\) of method Mage_Sales_Model_Entity_Quote_Address_Attribute_Frontend\\:\\:fetchTotals\\(\\)$#" - count: 1 - path: app/code/core/Mage/Sales/Model/Entity/Quote/Address/Attribute/Frontend/Custbalance.php - - - - message: "#^Return type \\(\\$this\\(Mage_Sales_Model_Entity_Quote_Address_Attribute_Frontend_Discount\\)\\) of method Mage_Sales_Model_Entity_Quote_Address_Attribute_Frontend_Discount\\:\\:fetchTotals\\(\\) should be compatible with return type \\(array\\) of method Mage_Sales_Model_Entity_Quote_Address_Attribute_Frontend\\:\\:fetchTotals\\(\\)$#" - count: 1 - path: app/code/core/Mage/Sales/Model/Entity/Quote/Address/Attribute/Frontend/Discount.php - - - - message: "#^Return type \\(\\$this\\(Mage_Sales_Model_Entity_Quote_Address_Attribute_Frontend_Grand\\)\\) of method Mage_Sales_Model_Entity_Quote_Address_Attribute_Frontend_Grand\\:\\:fetchTotals\\(\\) should be compatible with return type \\(array\\) of method Mage_Sales_Model_Entity_Quote_Address_Attribute_Frontend\\:\\:fetchTotals\\(\\)$#" - count: 1 - path: app/code/core/Mage/Sales/Model/Entity/Quote/Address/Attribute/Frontend/Grand.php - - - - message: "#^Return type \\(\\$this\\(Mage_Sales_Model_Entity_Quote_Address_Attribute_Frontend_Shipping\\)\\) of method Mage_Sales_Model_Entity_Quote_Address_Attribute_Frontend_Shipping\\:\\:fetchTotals\\(\\) should be compatible with return type \\(array\\) of method Mage_Sales_Model_Entity_Quote_Address_Attribute_Frontend\\:\\:fetchTotals\\(\\)$#" - count: 1 - path: app/code/core/Mage/Sales/Model/Entity/Quote/Address/Attribute/Frontend/Shipping.php - - - - message: "#^Return type \\(\\$this\\(Mage_Sales_Model_Entity_Quote_Address_Attribute_Frontend_Subtotal\\)\\) of method Mage_Sales_Model_Entity_Quote_Address_Attribute_Frontend_Subtotal\\:\\:fetchTotals\\(\\) should be compatible with return type \\(array\\) of method Mage_Sales_Model_Entity_Quote_Address_Attribute_Frontend\\:\\:fetchTotals\\(\\)$#" - count: 1 - path: app/code/core/Mage/Sales/Model/Entity/Quote/Address/Attribute/Frontend/Subtotal.php - - - - message: "#^Return type \\(\\$this\\(Mage_Sales_Model_Entity_Quote_Address_Attribute_Frontend_Tax\\)\\) of method Mage_Sales_Model_Entity_Quote_Address_Attribute_Frontend_Tax\\:\\:fetchTotals\\(\\) should be compatible with return type \\(array\\) of method Mage_Sales_Model_Entity_Quote_Address_Attribute_Frontend\\:\\:fetchTotals\\(\\)$#" - count: 1 - path: app/code/core/Mage/Sales/Model/Entity/Quote/Address/Attribute/Frontend/Tax.php - - message: "#^Variable \\$oldArea might not be defined\\.$#" count: 1 @@ -5940,11 +5765,6 @@ parameters: count: 1 path: app/code/core/Mage/Sales/Model/Order/Invoice.php - - - message: "#^Property Mage_Core_Model_Abstract\\:\\:\\$_origData \\(array\\) does not accept null\\.$#" - count: 1 - path: app/code/core/Mage/Sales/Model/Order/Invoice.php - - message: "#^Parameter \\#1 \\$incrementId of method Mage_Sales_Model_Order_Invoice\\:\\:loadByIncrementId\\(\\) expects string, int given\\.$#" count: 1 @@ -6215,26 +6035,11 @@ parameters: count: 1 path: app/code/core/Mage/Sales/Model/Quote/Address/Total/Collector.php - - - message: "#^Return type \\(\\$this\\(Mage_Sales_Model_Quote_Address_Total_Discount\\)\\) of method Mage_Sales_Model_Quote_Address_Total_Discount\\:\\:fetch\\(\\) should be compatible with return type \\(array\\) of method Mage_Sales_Model_Quote_Address_Total_Abstract\\:\\:fetch\\(\\)$#" - count: 1 - path: app/code/core/Mage/Sales/Model/Quote/Address/Total/Discount.php - - - - message: "#^Return type \\(Mage_Sales_Model_Quote_Address_Total_Grand\\) of method Mage_Sales_Model_Quote_Address_Total_Grand\\:\\:fetch\\(\\) should be compatible with return type \\(array\\) of method Mage_Sales_Model_Quote_Address_Total_Abstract\\:\\:fetch\\(\\)$#" - count: 1 - path: app/code/core/Mage/Sales/Model/Quote/Address/Total/Grand.php - - message: "#^Parameter \\#2 \\$visibility of method Mage_Catalog_Helper_Data\\:\\:canApplyMsrp\\(\\) expects int\\|null, string given\\.$#" count: 1 path: app/code/core/Mage/Sales/Model/Quote/Address/Total/Msrp.php - - - message: "#^Return type \\(\\$this\\(Mage_Sales_Model_Quote_Address_Total_Nominal\\)\\) of method Mage_Sales_Model_Quote_Address_Total_Nominal\\:\\:fetch\\(\\) should be compatible with return type \\(array\\) of method Mage_Sales_Model_Quote_Address_Total_Abstract\\:\\:fetch\\(\\)$#" - count: 1 - path: app/code/core/Mage/Sales/Model/Quote/Address/Total/Nominal.php - - message: "#^Return type \\(array\\) of method Mage_Sales_Model_Quote_Address_Total_Nominal_Shipping\\:\\:fetch\\(\\) should be compatible with return type \\(Mage_Sales_Model_Quote_Address_Total_Shipping\\) of method Mage_Sales_Model_Quote_Address_Total_Shipping\\:\\:fetch\\(\\)$#" count: 1 @@ -6250,26 +6055,11 @@ parameters: count: 1 path: app/code/core/Mage/Sales/Model/Quote/Address/Total/Shipping.php - - - message: "#^Return type \\(Mage_Sales_Model_Quote_Address_Total_Shipping\\) of method Mage_Sales_Model_Quote_Address_Total_Shipping\\:\\:fetch\\(\\) should be compatible with return type \\(array\\) of method Mage_Sales_Model_Quote_Address_Total_Abstract\\:\\:fetch\\(\\)$#" - count: 1 - path: app/code/core/Mage/Sales/Model/Quote/Address/Total/Shipping.php - - message: "#^Variable \\$addressQty in isset\\(\\) always exists and is not nullable\\.$#" count: 1 path: app/code/core/Mage/Sales/Model/Quote/Address/Total/Shipping.php - - - message: "#^Return type \\(Mage_Sales_Model_Quote_Address_Total_Subtotal\\) of method Mage_Sales_Model_Quote_Address_Total_Subtotal\\:\\:fetch\\(\\) should be compatible with return type \\(array\\) of method Mage_Sales_Model_Quote_Address_Total_Abstract\\:\\:fetch\\(\\)$#" - count: 1 - path: app/code/core/Mage/Sales/Model/Quote/Address/Total/Subtotal.php - - - - message: "#^Return type \\(\\$this\\(Mage_Sales_Model_Quote_Address_Total_Tax\\)\\) of method Mage_Sales_Model_Quote_Address_Total_Tax\\:\\:fetch\\(\\) should be compatible with return type \\(array\\) of method Mage_Sales_Model_Quote_Address_Total_Abstract\\:\\:fetch\\(\\)$#" - count: 1 - path: app/code/core/Mage/Sales/Model/Quote/Address/Total/Tax.php - - message: "#^Instanceof between Mage_Sales_Model_Quote_Item_Option and Mage_Sales_Model_Quote_Item_Option will always evaluate to true\\.$#" count: 1 @@ -6451,17 +6241,7 @@ parameters: path: app/code/core/Mage/SalesRule/Model/Observer.php - - message: "#^Return type \\(Mage_SalesRule_Model_Quote_Discount\\) of method Mage_SalesRule_Model_Quote_Discount\\:\\:fetch\\(\\) should be compatible with return type \\(array\\) of method Mage_Sales_Model_Quote_Address_Total_Abstract\\:\\:fetch\\(\\)$#" - count: 1 - path: app/code/core/Mage/SalesRule/Model/Quote/Discount.php - - - - message: "#^Return type \\(Mage_SalesRule_Model_Quote_Freeshipping\\) of method Mage_SalesRule_Model_Quote_Freeshipping\\:\\:fetch\\(\\) should be compatible with return type \\(array\\) of method Mage_Sales_Model_Quote_Address_Total_Abstract\\:\\:fetch\\(\\)$#" - count: 1 - path: app/code/core/Mage/SalesRule/Model/Quote/Freeshipping.php - - - - message: "#^Return type \\(array\\) of method Mage_SalesRule_Model_Quote_Nominal_Discount\\:\\:fetch\\(\\) should be compatible with return type \\(Mage_SalesRule_Model_Quote_Discount\\) of method Mage_SalesRule_Model_Quote_Discount\\:\\:fetch\\(\\)$#" + message: "#^Return type \\(array\\) of method Mage_SalesRule_Model_Quote_Nominal_Discount\\:\\:fetch\\(\\) should be compatible with return type \\(\\$this\\(Mage_SalesRule_Model_Quote_Discount\\)\\) of method Mage_SalesRule_Model_Quote_Discount\\:\\:fetch\\(\\)$#" count: 1 path: app/code/core/Mage/SalesRule/Model/Quote/Nominal/Discount.php @@ -6775,11 +6555,6 @@ parameters: count: 4 path: app/code/core/Mage/Tax/Model/Sales/Total/Quote/Tax.php - - - message: "#^Return type \\(\\$this\\(Mage_Tax_Model_Sales_Total_Quote_Tax\\)\\) of method Mage_Tax_Model_Sales_Total_Quote_Tax\\:\\:fetch\\(\\) should be compatible with return type \\(array\\) of method Mage_Sales_Model_Quote_Address_Total_Abstract\\:\\:fetch\\(\\)$#" - count: 1 - path: app/code/core/Mage/Tax/Model/Sales/Total/Quote/Tax.php - - message: "#^Variable \\$baseRowTax might not be defined\\.$#" count: 3 @@ -7215,11 +6990,6 @@ parameters: count: 1 path: app/code/core/Mage/Weee/Model/Attribute/Backend/Weee/Tax.php - - - message: "#^Return type \\(\\$this\\(Mage_Weee_Model_Attribute_Backend_Weee_Tax\\)\\) of method Mage_Weee_Model_Attribute_Backend_Weee_Tax\\:\\:validate\\(\\) should be compatible with return type \\(bool\\) of method Mage_Eav_Model_Entity_Attribute_Backend_Abstract\\:\\:validate\\(\\)$#" - count: 1 - path: app/code/core/Mage/Weee/Model/Attribute/Backend/Weee/Tax.php - - message: "#^Parameter \\#1 \\$renderer of method Varien_Data_Form_Element_Abstract\\:\\:setRenderer\\(\\) expects Varien_Data_Form_Element_Renderer_Interface, Mage_Core_Block_Abstract\\|false given\\.$#" count: 1 @@ -7300,11 +7070,6 @@ parameters: count: 2 path: app/code/core/Mage/Weee/Model/Total/Quote/Weee.php - - - message: "#^Parameter \\#5 \\$rate of method Mage_Tax_Model_Sales_Total_Quote_Tax\\:\\:_saveAppliedTaxes\\(\\) expects float, null given\\.$#" - count: 2 - path: app/code/core/Mage/Weee/Model/Total/Quote/Weee.php - - message: "#^Method Mage_Widget_Block_Adminhtml_Widget_Chooser\\:\\:getConfig\\(\\) should return Varien_Object but returns mixed\\.$#" count: 2 @@ -7769,38 +7534,3 @@ parameters: message: "#^Parameter \\#2 \\$timestamp of function gmdate expects int, float given\\.$#" count: 1 path: shell/indexer.php - - - - message: "#^Parameter \\#1 \\$str of method Mage_Core_Helper_String\\:\\:splitWords\\(\\) expects string, null given\\.$#" - count: 1 - path: tests/unit/Mage/Core/Helper/StringTest.php - - - - message: "#^Parameter \\#1 \\$str of method Mage_Core_Helper_String\\:\\:unserialize\\(\\) expects string, null given\\.$#" - count: 1 - path: tests/unit/Mage/Core/Helper/StringTest.php - - - - message: "#^Parameter \\#1 \\$string of method Mage_Core_Helper_String\\:\\:truncate\\(\\) expects string, null given\\.$#" - count: 1 - path: tests/unit/Mage/Core/Helper/StringTest.php - - - - message: "#^Parameter \\#1 \\$value of method Varien_Data_Form_Filter_Date\\:\\:inputFilter\\(\\) expects string, null given\\.$#" - count: 1 - path: tests/unit/Varien/Data/Form/Filter/DateTest.php - - - - message: "#^Parameter \\#2 \\$locale of class Varien_Data_Form_Filter_Date constructor expects Zend_Locale\\|null, string given\\.$#" - count: 1 - path: tests/unit/Varien/Data/Form/Filter/DateTest.php - - - - message: "#^Parameter \\#1 \\$value of method Varien_Data_Form_Filter_Datetime\\:\\:inputFilter\\(\\) expects string, null given\\.$#" - count: 1 - path: tests/unit/Varien/Data/Form/Filter/DatetimeTest.php - - - - message: "#^Parameter \\#2 \\$locale of class Varien_Data_Form_Filter_Datetime constructor expects Zend_Locale\\|null, string given\\.$#" - count: 1 - path: tests/unit/Varien/Data/Form/Filter/DatetimeTest.php diff --git a/app/Mage.php b/app/Mage.php index dd016e03030..5a46c12bb7f 100644 --- a/app/Mage.php +++ b/app/Mage.php @@ -924,9 +924,11 @@ public static function log($message, $level = null, $file = '', $forceLog = fals } if (is_array($message) || is_object($message)) { + // phpcs:ignore Ecg.Security.ForbiddenFunction.Found $message = print_r($message, true); } + // phpcs:ignore Ecg.Security.ForbiddenFunction.Found $message = addcslashes($message, 'log($message, $level); } catch (Exception $e) { diff --git a/app/code/core/Mage/Admin/Model/Block.php b/app/code/core/Mage/Admin/Model/Block.php index 961e21d6ecb..dc45bda8012 100644 --- a/app/code/core/Mage/Admin/Model/Block.php +++ b/app/code/core/Mage/Admin/Model/Block.php @@ -37,7 +37,7 @@ protected function _construct() } /** - * @return array|bool + * @return array|true * @throws Exception * @throws Zend_Validate_Exception */ diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config.php index a9592168c24..4ec408c1bfd 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config.php @@ -308,6 +308,7 @@ protected function _getRequiredAttributesIds() */ public function escapeJs($string) { + // phpcs:ignore Ecg.Security.ForbiddenFunction.Found return addcslashes($string, "'\r\n\\"); } diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Newsletter/Grid/Renderer/Action.php b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Newsletter/Grid/Renderer/Action.php index c62d28fac5d..d59af0835c5 100644 --- a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Newsletter/Grid/Renderer/Action.php +++ b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Newsletter/Grid/Renderer/Action.php @@ -44,6 +44,7 @@ public function render(Varien_Object $row) protected function _getEscapedValue($value) { + // phpcs:ignore Ecg.Security.ForbiddenFunction.Found return addcslashes(htmlspecialchars($value), '\\\''); } diff --git a/app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Edit.php b/app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Edit.php index 90235d415c9..202d67080db 100644 --- a/app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Edit.php @@ -269,6 +269,7 @@ public function getJsTemplateName() if ($templateCode === null) { return ''; } + // phpcs:ignore Ecg.Security.ForbiddenFunction.Found return addcslashes($this->escapeHtml($templateCode), "\"\r\n\\"); } diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Reorder/Renderer/Action.php b/app/code/core/Mage/Adminhtml/Block/Sales/Reorder/Renderer/Action.php index 15c2a967438..d98655b8a3a 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Reorder/Renderer/Action.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Reorder/Renderer/Action.php @@ -44,6 +44,7 @@ public function render(Varien_Object $row) protected function _getEscapedValue($value) { + // phpcs:ignore Ecg.Security.ForbiddenFunction.Found return addcslashes(htmlspecialchars($value), '\\\''); } diff --git a/app/code/core/Mage/Adminhtml/Block/System/Email/Template/Grid/Renderer/Action.php b/app/code/core/Mage/Adminhtml/Block/System/Email/Template/Grid/Renderer/Action.php index 6f0f57869b7..239d0696726 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Email/Template/Grid/Renderer/Action.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Email/Template/Grid/Renderer/Action.php @@ -38,6 +38,7 @@ public function render(Varien_Object $row) protected function _getEscapedValue($value) { + // phpcs:ignore Ecg.Security.ForbiddenFunction.Found return addcslashes(htmlspecialchars($value), '\\\''); } diff --git a/app/code/core/Mage/Api2/Model/Route/ApiType.php b/app/code/core/Mage/Api2/Model/Route/ApiType.php index b5be739d300..d0cab937e82 100644 --- a/app/code/core/Mage/Api2/Model/Route/ApiType.php +++ b/app/code/core/Mage/Api2/Model/Route/ApiType.php @@ -38,6 +38,7 @@ class Mage_Api2_Model_Route_ApiType extends Mage_Api2_Model_Route_Abstract imple * @param Zend_Translate|null $translator Translator to use for this instance * @param mixed $locale */ + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassAfterLastUsed public function __construct( $route, $defaults = [], @@ -45,6 +46,7 @@ public function __construct( ?Zend_Translate $translator = null, $locale = null ) { + // phpcs:ignore Ecg.Security.ForbiddenFunction.Found parent::__construct([Mage_Api2_Model_Route_Abstract::PARAM_ROUTE => str_replace('.php', '', basename(getenv('SCRIPT_FILENAME'))) . '/:api_type']); } } diff --git a/app/code/core/Mage/Bundle/Model/Product/Price.php b/app/code/core/Mage/Bundle/Model/Product/Price.php index 7830613be94..d6c4dbd90a2 100644 --- a/app/code/core/Mage/Bundle/Model/Product/Price.php +++ b/app/code/core/Mage/Bundle/Model/Product/Price.php @@ -79,7 +79,6 @@ public function getTotalBundleItemsPrice($product, $qty = null) $selectionIds = unserialize($customOption->getValue(), ['allowed_classes' => false]); /** @var Mage_Bundle_Model_Product_Type $productType */ $productType = $product->getTypeInstance(true); - /** @var Mage_Bundle_Model_Resource_Selection_Collection $selections */ $selections = $productType->getSelectionsByIds($selectionIds, $product); $selections->addTierPriceData(); Mage::dispatchEvent('prepare_catalog_product_collection_prices', [ diff --git a/app/code/core/Mage/Captcha/Helper/Data.php b/app/code/core/Mage/Captcha/Helper/Data.php index 8a20a69f879..28d275769a9 100644 --- a/app/code/core/Mage/Captcha/Helper/Data.php +++ b/app/code/core/Mage/Captcha/Helper/Data.php @@ -62,7 +62,7 @@ public function isEnabled(): bool * Get Captcha * * @param string $formId - * @return Mage_Captcha_Model_Interface + * @return Mage_Captcha_Model_Zend */ public function getCaptcha($formId) { @@ -76,7 +76,7 @@ public function getCaptcha($formId) /** * Returns value of the node with respect to current area (frontend or backend) * - * @param string $id The last part of XML_PATH_$area_CAPTCHA_ constant (case insensitive) + * @param string $id The last part of XML_PATH_$area_CAPTCHA_ constant (case-insensitive) * @param Mage_Core_Model_Store $store * @return Mage_Core_Model_Config_Element */ diff --git a/app/code/core/Mage/Catalog/Helper/Data.php b/app/code/core/Mage/Catalog/Helper/Data.php index efe6e11db43..e3cd1f3527f 100644 --- a/app/code/core/Mage/Catalog/Helper/Data.php +++ b/app/code/core/Mage/Catalog/Helper/Data.php @@ -44,7 +44,7 @@ class Mage_Catalog_Helper_Data extends Mage_Core_Helper_Abstract /** * Breadcrumb Path cache * - * @var string + * @var string|array> */ protected $_categoryPath; @@ -236,7 +236,7 @@ public function isPriceGlobal() /** * Indicate whether to save URL Rewrite History or not (create redirects to old URLs) * - * @param int $storeId Store View + * @param null|string|bool|int|Mage_Core_Model_Store $storeId Store View * @return bool */ public function shouldSaveUrlRewritesHistory($storeId = null) diff --git a/app/code/core/Mage/Catalog/Model/Api/Resource.php b/app/code/core/Mage/Catalog/Model/Api/Resource.php index 2d2bd39a464..ddb28228b96 100644 --- a/app/code/core/Mage/Catalog/Model/Api/Resource.php +++ b/app/code/core/Mage/Catalog/Model/Api/Resource.php @@ -75,7 +75,7 @@ protected function _isAllowedAttribute($attribute, $attributes = null) /** * Retrieves store id from store code, if no store id specified, - * it use seted session or admin store + * it uses set session or admin store * * @param string|int $store * @return int diff --git a/app/code/core/Mage/Catalog/Model/Category.php b/app/code/core/Mage/Catalog/Model/Category.php index 5fd29f7a2f6..d3e5ae5775b 100644 --- a/app/code/core/Mage/Catalog/Model/Category.php +++ b/app/code/core/Mage/Catalog/Model/Category.php @@ -441,14 +441,14 @@ public function getLayoutUpdateHandle() /** * Return store id. * - * If store id is underfined for category return current active store id + * If store id is undefined for category return current active store id * * @return int */ public function getStoreId() { if ($this->hasData('store_id')) { - return $this->_getData('store_id'); + return (int)$this->_getData('store_id'); } return Mage::app()->getStore()->getId(); } diff --git a/app/code/core/Mage/Catalog/Model/Convert/Adapter/Product.php b/app/code/core/Mage/Catalog/Model/Convert/Adapter/Product.php index 931a500dc90..5ed26d15f70 100644 --- a/app/code/core/Mage/Catalog/Model/Convert/Adapter/Product.php +++ b/app/code/core/Mage/Catalog/Model/Convert/Adapter/Product.php @@ -368,6 +368,7 @@ public function parse() $importIds = $batchImportModel->getIdCollection(); foreach ($importIds as $importId) { + // phpcs:ignore Ecg.Performance.Loop.ModelLSD $batchImportModel->load($importId); $importData = $batchImportModel->getBatchData(); @@ -511,6 +512,7 @@ public function save() // if product is new, create default values first if (!$model->getId()) { $new = true; + // phpcs:ignore Ecg.Performance.Loop.ModelLSD $model->save(); // if new product and then store is not default @@ -520,6 +522,7 @@ public function save() $default = Mage::getModel('catalog/product'); $default->setData($data); $default->setStoreId(0); + // phpcs:ignore Ecg.Performance.Loop.ModelLSD $default->save(); unset($default); } // end @@ -533,6 +536,7 @@ public function save() $storeId ); } + // phpcs:ignore Ecg.Performance.Loop.ModelLSD $model->save(); } @@ -564,6 +568,7 @@ public function save() } } } + // phpcs:ignore Ecg.Performance.Loop.ModelLSD $stockItem->save(); unset($data); unset($stockItem); @@ -734,6 +739,7 @@ public function saveRow(array $importData) if (!in_array($website->getId(), $websiteIds)) { $websiteIds[] = $website->getId(); } + // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch } catch (Exception $e) { } } diff --git a/app/code/core/Mage/Catalog/Model/Product.php b/app/code/core/Mage/Catalog/Model/Product.php index fa33a886f48..ad20298d328 100644 --- a/app/code/core/Mage/Catalog/Model/Product.php +++ b/app/code/core/Mage/Catalog/Model/Product.php @@ -138,7 +138,7 @@ * @method string getMetaDescription() * @method string getMetaKeyword() * @method string getMetaTitle() - * @method $this hasMsrpEnabled(bool $value) + * @method $this hasMsrpEnabled() * @method bool getMsrpEnabled() * @method string getMsrpDisplayActualPriceType() * @@ -217,7 +217,7 @@ * @method $this setStoreIds(array $storeIds) * @method array getSwatchPrices() * - * @method int getTaxClassId() + * @method string getTaxClassId() * @method string getThumbnail() * @method float|null getTaxPercent() * @method $this setTaxPercent(float|null $value) @@ -365,7 +365,7 @@ protected function _initOldFieldsMap() public function getStoreId() { if ($this->hasData('store_id')) { - return $this->getData('store_id'); + return (int)$this->getData('store_id'); } return Mage::app()->getStore()->getId(); } @@ -417,7 +417,7 @@ public function validate() /** * Get product name * - * @return string + * @return string|null */ public function getName() { @@ -442,16 +442,18 @@ public function getPrice() * Set Price calculation flag * * @param bool $calculate + * @return $this */ public function setPriceCalculation($calculate = true) { $this->_calculatePrice = $calculate; + return $this; } /** * Get product type identifier * - * @return string + * @return string|null */ public function getTypeId() { @@ -876,7 +878,7 @@ public function cleanCache() /** * Get product price model * - * @return Mage_Catalog_Model_Product_Type_Price|Mage_Bundle_Model_Product_Price + * @return Mage_Bundle_Model_Product_Price */ public function getPriceModel() { diff --git a/app/code/core/Mage/Catalog/Model/Resource/Category/Flat/Collection.php b/app/code/core/Mage/Catalog/Model/Resource/Category/Flat/Collection.php index 9c2238fe318..ea2cc2b5944 100644 --- a/app/code/core/Mage/Catalog/Model/Resource/Category/Flat/Collection.php +++ b/app/code/core/Mage/Catalog/Model/Resource/Category/Flat/Collection.php @@ -237,16 +237,6 @@ public function addAttributeToSelect($attribute = '*') return $this; } - /** - * Retrieve resource instance - * - * @inheritDoc - */ - public function getResource() - { - return parent::getResource(); - } - /** * Add attribute to sort order * @@ -325,6 +315,7 @@ public function addPathsFilter($paths) $select = $this->getSelect(); $cond = []; foreach ($paths as $path) { + // phpcs:ignore Ecg.Sql.SlowQuery.SlowRawSql $cond[] = $this->getResource()->getReadConnection()->quoteInto('main_table.path LIKE ?', "$path%"); } if ($cond) { 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..2ffda58c629 100644 --- a/app/code/core/Mage/Catalog/Model/Resource/Category/Tree.php +++ b/app/code/core/Mage/Catalog/Model/Resource/Category/Tree.php @@ -93,7 +93,7 @@ public function __construct() */ public function setStoreId($storeId) { - $this->_storeId = (int) $storeId; + $this->_storeId = $storeId; return $this; } @@ -467,6 +467,7 @@ public function loadByIds($ids, $addCollectionData = true, $updateAnchorProductC ->where('entity_id IN (?)', $ids); $where = [$levelField . '=0' => true]; + // phpcs:ignore Ecg.Performance.FetchAll.Found foreach ($this->_conn->fetchAll($select) as $item) { if (!preg_match("#^[0-9\/]+$#", $item['path'])) { $item['path'] = ''; @@ -474,6 +475,7 @@ public function loadByIds($ids, $addCollectionData = true, $updateAnchorProductC $pathIds = explode('/', $item['path']); $level = (int)$item['level']; while ($level > 0) { + // phpcs:ignore Ecg.Performance.Loop.ArraySize $pathIds[count($pathIds) - 1] = '%'; $path = implode('/', $pathIds); $where["$levelField=$level AND $pathField LIKE '$path'"] = true; @@ -493,6 +495,7 @@ public function loadByIds($ids, $addCollectionData = true, $updateAnchorProductC $select->where(implode(' OR ', $where)); // get array of records and add them as nodes to the tree + // phpcs:ignore Ecg.Performance.FetchAll.Found $arrNodes = $this->_conn->fetchAll($select); if (!$arrNodes) { return false; @@ -535,6 +538,7 @@ public function loadBreadcrumbsArray($path, $addCollectionData = true, $withRoot $select ->where('e.entity_id IN(?)', $pathIds) ->order($this->_conn->getLengthSql('e.path') . ' ' . Varien_Db_Select::SQL_ASC); + // phpcs:ignore Ecg.Performance.FetchAll.Found $result = $this->_conn->fetchAll($select); $this->_updateAnchorProductCount($result); } @@ -557,7 +561,7 @@ protected function _updateAnchorProductCount(&$data) /** * Obtain select for categories with attributes. - * By default everything from entity table is selected + * By default, everything from entity table is selected * + name, is_active and is_anchor * Also the correct product_count is selected, depending on is the category anchor or not. * @@ -623,6 +627,7 @@ protected function _createCollectionDataSelect($sorted = true, $optionalAttribut ['COUNT(DISTINCT scp.product_id)'] ) ->where('see.entity_id = e.entity_id') + // phpcs:ignore Ecg.Sql.SlowQuery.SlowRawSql ->orWhere('see.path LIKE ?', $subConcat); $select->columns(['product_count' => $subSelect]); diff --git a/app/code/core/Mage/Catalog/Model/Resource/Eav/Attribute.php b/app/code/core/Mage/Catalog/Model/Resource/Eav/Attribute.php index e20be43040b..9ebc303c88f 100644 --- a/app/code/core/Mage/Catalog/Model/Resource/Eav/Attribute.php +++ b/app/code/core/Mage/Catalog/Model/Resource/Eav/Attribute.php @@ -222,7 +222,7 @@ public function getStoreId() if ($dataObject) { return $dataObject->getStoreId(); } - return $this->getData('store_id'); + return (int)$this->getData('store_id'); } /** diff --git a/app/code/core/Mage/Catalog/Model/Url.php b/app/code/core/Mage/Catalog/Model/Url.php index 59714787c96..0981d033c8e 100644 --- a/app/code/core/Mage/Catalog/Model/Url.php +++ b/app/code/core/Mage/Catalog/Model/Url.php @@ -211,7 +211,7 @@ public function setShouldSaveRewritesHistory($flag) /** * Indicate whether to save URL Rewrite History or not (create redirects to old URLs) * - * @param int $storeId Store View + * @param null|string|bool|int|Mage_Core_Model_Store $storeId Store View * @return bool */ public function getShouldSaveRewritesHistory($storeId = null) diff --git a/app/code/core/Mage/Checkout/Model/Api/Resource.php b/app/code/core/Mage/Checkout/Model/Api/Resource.php index b42ba5a8513..3506822d89b 100644 --- a/app/code/core/Mage/Checkout/Model/Api/Resource.php +++ b/app/code/core/Mage/Checkout/Model/Api/Resource.php @@ -72,7 +72,7 @@ protected function _isQuoteExist($quoteId) /** * Retrieves store id from store code, if no store id specified, - * it use set session or admin store + * it uses set session or admin store * * @param string|int $store * @return int diff --git a/app/code/core/Mage/Checkout/Model/Cart/Product/Api/V2.php b/app/code/core/Mage/Checkout/Model/Cart/Product/Api/V2.php index 097a78d10d7..d2a77383414 100644 --- a/app/code/core/Mage/Checkout/Model/Cart/Product/Api/V2.php +++ b/app/code/core/Mage/Checkout/Model/Cart/Product/Api/V2.php @@ -24,7 +24,7 @@ class Mage_Checkout_Model_Cart_Product_Api_V2 extends Mage_Checkout_Model_Cart_P /** * Return an Array of Object attributes. * - * @param mixed $data + * @param object|array $data * @return array */ protected function _prepareProductsData($data) diff --git a/app/code/core/Mage/Core/Helper/Data.php b/app/code/core/Mage/Core/Helper/Data.php index be63a4b91d0..366eb70b25c 100644 --- a/app/code/core/Mage/Core/Helper/Data.php +++ b/app/code/core/Mage/Core/Helper/Data.php @@ -331,7 +331,7 @@ public function getVersionHash(Mage_Core_Model_Encryption $encryptionModel) /** * Retrieve store identifier * - * @param mixed $store + * @param bool|int|Mage_Core_Model_Store|null|string $store * @return int */ public function getStoreId($store = null) diff --git a/app/code/core/Mage/Core/Helper/String.php b/app/code/core/Mage/Core/Helper/String.php index c9b80daaf55..5f3492e1070 100644 --- a/app/code/core/Mage/Core/Helper/String.php +++ b/app/code/core/Mage/Core/Helper/String.php @@ -34,7 +34,7 @@ class Mage_Core_Helper_String extends Mage_Core_Helper_Abstract * Truncate a string to a certain length if necessary, appending the $etc string. * $remainder will contain the string that has been replaced with $etc. * - * @param string $string + * @param string|null $string * @param int $length * @param string $etc * @param string &$remainder @@ -241,7 +241,7 @@ public function str_split($str, $length = 1, $keepWords = false, $trim = false, /** * Split words * - * @param string $str The source string + * @param string|null $str The source string * @param bool $uniqueOnly Unique words only * @param int $maxWordLength Limit words count * @param string $wordSeparatorRegexp @@ -306,11 +306,14 @@ public function ksortMultibyte(array &$sort) if (empty($sort)) { return false; } + // phpcs:ignore Ecg.Security.ForbiddenFunction.Found $oldLocale = setlocale(LC_COLLATE, '0'); $localeCode = Mage::app()->getLocale()->getLocaleCode(); // use fallback locale if $localeCode is not available + // phpcs:ignore Ecg.Security.ForbiddenFunction.Found setlocale(LC_COLLATE, $localeCode . '.UTF8', 'C.UTF-8', 'en_US.utf8'); ksort($sort, SORT_LOCALE_STRING); + // phpcs:ignore Ecg.Security.ForbiddenFunction.Found setlocale(LC_COLLATE, $oldLocale); return $sort; @@ -513,8 +516,8 @@ public function uniOrd($c) /** * UnSerialize string - * @param string $str - * @return mixed|null + * @param string|null $str + * @return null|void * @throws Exception */ public function unserialize($str) @@ -524,7 +527,9 @@ public function unserialize($str) } $reader = new Unserialize_Reader_ArrValue('data'); $prevChar = null; - for ($i = 0; $i < strlen($str); $i++) { + + $strLen = strlen($str); + for ($i = 0; $i < $strLen; $i++) { $char = $str[$i]; $result = $reader->read($char, $prevChar); if (!is_null($result)) { diff --git a/app/code/core/Mage/Core/Model/Abstract.php b/app/code/core/Mage/Core/Model/Abstract.php index d9a0b63b67e..e0219c6c21e 100644 --- a/app/code/core/Mage/Core/Model/Abstract.php +++ b/app/code/core/Mage/Core/Model/Abstract.php @@ -48,7 +48,7 @@ abstract class Mage_Core_Model_Abstract extends Varien_Object /** * Original data that was loaded * - * @var array + * @var array|null */ protected $_origData; diff --git a/app/code/core/Mage/Core/Model/Store.php b/app/code/core/Mage/Core/Model/Store.php index eea91b7d2e0..4584c0cc5dc 100644 --- a/app/code/core/Mage/Core/Model/Store.php +++ b/app/code/core/Mage/Core/Model/Store.php @@ -244,6 +244,7 @@ class Mage_Core_Model_Store extends Mage_Core_Model_Abstract * * @var bool */ + // phpcs:ignore Ecg.PHP.PrivateClassMember.PrivateClassMemberError private $_isReadOnly = false; /** @@ -540,6 +541,7 @@ public function processSubst($value) */ public function getDefaultBasePath() { + // phpcs:ignore Ecg.Security.Superglobal.SuperglobalUsageWarning if (!isset($_SERVER['SCRIPT_NAME'])) { return '/'; } @@ -629,6 +631,7 @@ public function getBaseUrl($type = self::URL_TYPE_LINK, $secure = null) protected function _updatePathUseRewrites($url) { if ($this->isAdmin() || !$this->getConfig(self::XML_PATH_USE_REWRITES) || !Mage::isInstalled()) { + // phpcs:ignore Ecg.Security.ForbiddenFunction.Found,Ecg.Security.Superglobal.SuperglobalUsageWarning $indexFileName = $this->_isCustomEntryPoint() ? 'index.php' : basename($_SERVER['SCRIPT_FILENAME']); $url .= $indexFileName . '/'; } @@ -696,11 +699,11 @@ public function getStoreInUrl() /** * Get store identifier * - * @return int + * @return int */ public function getId() { - return $this->_getData('store_id'); + return (int)$this->_getData('store_id'); } /** @@ -1096,10 +1099,12 @@ public function getCurrentUrl($fromStore = true) $storeUrl = Mage::app()->getStore()->isCurrentlySecure() ? $this->getUrl('', ['_secure' => true]) : $this->getUrl(''); + // phpcs:ignore Ecg.Security.ForbiddenFunction.Found $storeParsedUrl = parse_url($storeUrl); $storeParsedQuery = []; if (isset($storeParsedUrl['query'])) { + // phpcs:ignore Ecg.Security.ForbiddenFunction.Found parse_str($storeParsedUrl['query'], $storeParsedQuery); } diff --git a/app/code/core/Mage/Core/Model/Store/Group.php b/app/code/core/Mage/Core/Model/Store/Group.php index c4dac455f24..bbc0a1a6aad 100644 --- a/app/code/core/Mage/Core/Model/Store/Group.php +++ b/app/code/core/Mage/Core/Model/Store/Group.php @@ -97,6 +97,7 @@ class Mage_Core_Model_Store_Group extends Mage_Core_Model_Abstract /** * @var bool */ + // phpcs:ignore Ecg.PHP.PrivateClassMember.PrivateClassMemberError private $_isReadOnly = false; /** diff --git a/app/code/core/Mage/Core/Model/Website.php b/app/code/core/Mage/Core/Model/Website.php index 9cb4c2dea47..a55ca2a8bf7 100644 --- a/app/code/core/Mage/Core/Model/Website.php +++ b/app/code/core/Mage/Core/Model/Website.php @@ -136,6 +136,7 @@ class Mage_Core_Model_Website extends Mage_Core_Model_Abstract /** * @var bool */ + // phpcs:ignore Ecg.PHP.PrivateClassMember.PrivateClassMemberError private $_isReadOnly = false; /** diff --git a/app/code/core/Mage/Eav/Model/Convert/Adapter/Entity.php b/app/code/core/Mage/Eav/Model/Convert/Adapter/Entity.php index b1ec006c976..091300a937e 100644 --- a/app/code/core/Mage/Eav/Model/Convert/Adapter/Entity.php +++ b/app/code/core/Mage/Eav/Model/Convert/Adapter/Entity.php @@ -207,7 +207,7 @@ protected function getFieldValue($fields = [], $name = '') } /** - * @param string $joinAttr + * @param array $joinAttr * @throws Exception */ public function setJoinAttr($joinAttr) @@ -322,7 +322,7 @@ public function load() * Retrieve collection for load * * @param string $entityType - * @return Mage_Eav_Model_Entity_Collection + * @return Mage_Eav_Model_Entity_Collection|false */ protected function _getCollectionForLoad($entityType) { @@ -348,6 +348,7 @@ public function save() try { $i = 0; foreach ($collection->getIterator() as $model) { + // phpcs:ignore Ecg.Performance.Loop.ModelLSD $model->save(); $i++; } diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute/Backend/Abstract.php b/app/code/core/Mage/Eav/Model/Entity/Attribute/Backend/Abstract.php index 3824cffaab3..004767ac201 100644 --- a/app/code/core/Mage/Eav/Model/Entity/Attribute/Backend/Abstract.php +++ b/app/code/core/Mage/Eav/Model/Entity/Attribute/Backend/Abstract.php @@ -221,8 +221,8 @@ public function getDefaultValue() * Validate object * * @param Varien_Object $object - * @throws Mage_Eav_Exception - * @return bool + * @return $this|bool + * @throws Mage_Eav_Exception|Mage_Core_Exception */ public function validate($object) { @@ -309,6 +309,7 @@ public function beforeDelete($object) { return $this; } + /** * After delete method * diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute/Backend/Interface.php b/app/code/core/Mage/Eav/Model/Entity/Attribute/Backend/Interface.php index abecf19be9d..3dbdfa5e19b 100644 --- a/app/code/core/Mage/Eav/Model/Entity/Attribute/Backend/Interface.php +++ b/app/code/core/Mage/Eav/Model/Entity/Attribute/Backend/Interface.php @@ -31,9 +31,10 @@ public function getEntityIdField(); /** * @param int $valueId - * @return int + * @return $this */ public function setValueId($valueId); + public function getValueId(); /** diff --git a/app/code/core/Mage/Eav/Model/Entity/Type.php b/app/code/core/Mage/Eav/Model/Entity/Type.php index 8aea4ca4b7a..f03670a52bf 100644 --- a/app/code/core/Mage/Eav/Model/Entity/Type.php +++ b/app/code/core/Mage/Eav/Model/Entity/Type.php @@ -277,23 +277,23 @@ public function getEntityTablePrefix() } /** - * Get default attribute set identifier for etity type + * Get default attribute set identifier for entity type * - * @return string|null + * @return int|null */ public function getDefaultAttributeSetId() { - return $this->_data['default_attribute_set_id'] ?? null; + return isset($this->_data['default_attribute_set_id']) ? (int)$this->_data['default_attribute_set_id'] : null; } /** * Retrieve entity type id * - * @return string|null + * @return int|null */ public function getEntityTypeId() { - return $this->_data['entity_type_id'] ?? null; + return isset($this->_data['entity_type_id']) ? (int)$this->_data['entity_type_id'] : null; } /** @@ -333,11 +333,13 @@ public function getAttributeModel() /** * Retrieve resource entity object * - * @return Mage_Core_Model_Resource_Abstract + * @return Mage_Eav_Model_Entity_Abstract */ public function getEntity() { - return Mage::getResourceSingleton($this->_data['entity_model']); + /** @var Mage_Eav_Model_Entity_Abstract $entity */ + $entity = Mage::getResourceSingleton($this->_data['entity_model']); + return $entity; } /** diff --git a/app/code/core/Mage/Eav/Model/Resource/Form/Fieldset/Collection.php b/app/code/core/Mage/Eav/Model/Resource/Form/Fieldset/Collection.php index b2ff4aa5d14..d0d683e7908 100644 --- a/app/code/core/Mage/Eav/Model/Resource/Form/Fieldset/Collection.php +++ b/app/code/core/Mage/Eav/Model/Resource/Form/Fieldset/Collection.php @@ -66,7 +66,7 @@ public function setSortOrder() /** * Retrieve label store scope * - * @return int + * @return int|null */ public function getStoreId() { diff --git a/app/code/core/Mage/GiftMessage/Block/Message/Form.php b/app/code/core/Mage/GiftMessage/Block/Message/Form.php index 43aca122ac1..3c3ea3e45ae 100644 --- a/app/code/core/Mage/GiftMessage/Block/Message/Form.php +++ b/app/code/core/Mage/GiftMessage/Block/Message/Form.php @@ -130,6 +130,7 @@ public function getEscaped($value) */ public function getEscapedForJs($value) { + // phpcs:ignore Ecg.Security.ForbiddenFunction.Found return addcslashes($value, "\\'\n\r\t"); } diff --git a/app/code/core/Mage/GiftMessage/Model/Api/V2.php b/app/code/core/Mage/GiftMessage/Model/Api/V2.php index 2ac5b1bb2f3..b639351c36f 100644 --- a/app/code/core/Mage/GiftMessage/Model/Api/V2.php +++ b/app/code/core/Mage/GiftMessage/Model/Api/V2.php @@ -24,7 +24,7 @@ class Mage_GiftMessage_Model_Api_V2 extends Mage_GiftMessage_Model_Api /** * Return an Array of Object attributes. * - * @param Mixed $data + * @param object|array $data * @return array */ protected function _prepareData($data) diff --git a/app/code/core/Mage/ImportExport/Model/Export/Entity/Abstract.php b/app/code/core/Mage/ImportExport/Model/Export/Entity/Abstract.php index 38d48cc3b29..a280d0074c2 100644 --- a/app/code/core/Mage/ImportExport/Model/Export/Entity/Abstract.php +++ b/app/code/core/Mage/ImportExport/Model/Export/Entity/Abstract.php @@ -52,7 +52,7 @@ abstract class Mage_ImportExport_Model_Export_Entity_Abstract /** * Entity type id. * - * @var string|null + * @var int|null */ protected $_entityTypeId; @@ -436,7 +436,7 @@ abstract public function getEntityTypeCode(); /** * Entity type ID getter. * - * @return string|null + * @return int|null */ public function getEntityTypeId() { diff --git a/app/code/core/Mage/ImportExport/Model/Import/Entity/Abstract.php b/app/code/core/Mage/ImportExport/Model/Import/Entity/Abstract.php index 0088896a6a1..71f2d84d9b9 100644 --- a/app/code/core/Mage/ImportExport/Model/Import/Entity/Abstract.php +++ b/app/code/core/Mage/ImportExport/Model/Import/Entity/Abstract.php @@ -54,7 +54,7 @@ abstract class Mage_ImportExport_Model_Import_Entity_Abstract /** * Entity type id. * - * @var string|null + * @var int|null */ protected $_entityTypeId; @@ -216,8 +216,9 @@ abstract protected function _importData(); /** * Returns boolean TRUE if row scope is default (fundamental) scope. * - * @return bool + * @return true */ + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found protected function _isRowScopeDefault(array $rowData) { return true; @@ -287,6 +288,7 @@ protected function _saveValidatedBunches() $rowData = $this->_prepareRowForDb($rowData); $rowSize = strlen(Mage::helper('core')->jsonEncode($rowData)); + // phpcs:ignore Ecg.Performance.Loop.ArraySize $isBunchSizeExceeded = ($bunchSize > 0 && count($bunchRows) >= $bunchSize); if (($productDataSize + $rowSize) >= $maxDataSize || $isBunchSizeExceeded) { @@ -363,6 +365,7 @@ public function getAttributeOptions(Mage_Eav_Model_Entity_Attribute_Abstract $at } } } + // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch } catch (Exception $e) { // ignore exceptions connected with source models } @@ -398,7 +401,7 @@ abstract public function getEntityTypeCode(); /** * Entity type ID getter. * - * @return string|null + * @return int|null */ public function getEntityTypeId() { @@ -651,6 +654,7 @@ public function validateData() if (!$this->_dataValidated) { // does all permanent columns exists? if (($colsAbsent = array_diff($this->_permanentAttributes, $this->_getSource()->getColNames()))) { + // phpcs:ignore Ecg.Security.ForbiddenFunction.Found file_put_contents($this->_getSource()->getSource(), ''); Mage::throwException( Mage::helper('importexport')->__('Can not find required columns: %s', implode(', ', $colsAbsent)) diff --git a/app/code/core/Mage/Paypal/Model/Payflowlink.php b/app/code/core/Mage/Paypal/Model/Payflowlink.php index 79168be3f53..a9e3e470b90 100644 --- a/app/code/core/Mage/Paypal/Model/Payflowlink.php +++ b/app/code/core/Mage/Paypal/Model/Payflowlink.php @@ -365,6 +365,7 @@ protected function _getOrderFromResponse() /** * Build request for getting token * + * @param Mage_Sales_Model_Order_Payment|Mage_Payment_Model_Info $payment * @return Varien_Object */ protected function _buildTokenRequest(Mage_Sales_Model_Order_Payment $payment) @@ -427,7 +428,7 @@ protected function _getStoreId() { $response = $this->getResponse(); if ($response->getUser1()) { - return (int) $response->getUser1(); + return (int)$response->getUser1(); } return Mage::app()->getStore($this->getStore())->getId(); @@ -438,6 +439,7 @@ protected function _getStoreId() * * @return Mage_Paypal_Model_Payflow_Request */ + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass protected function _buildBasicRequest(Varien_Object $payment) { $request = Mage::getModel('paypal/payflow_request'); @@ -508,7 +510,7 @@ protected function _formatStr($format, $string) * Set token data in payment object * * @param Varien_Object $response - * @param Mage_Sales_Model_Order_Payment $payment + * @param Mage_Payment_Model_Info|Mage_Sales_Model_Order_Payment $payment * @throws Mage_Core_Exception */ protected function _processTokenErrors($response, $payment) @@ -538,7 +540,7 @@ protected function _getSecureSilentPostHash($payment) /** * Generate end return new secure hash value * - * @param Mage_Sales_Model_Order_Payment $payment + * @param Mage_Payment_Model_Info $payment * @return string */ protected function _generateSecureSilentPostHash($payment) @@ -566,6 +568,7 @@ protected function _addTransaction($payment, $txnId) * @param mixed $amount * @return $this */ + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassAfterLastUsed protected function _initialize(Varien_Object $payment, $amount) { return $this; @@ -590,6 +593,7 @@ public function prepareOrderReview($token = null) * @param string $txnId * @return $this */ + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassAfterLastUsed protected function _authorize(Varien_Object $payment, $amount, $transaction, $txnId) { return $this; @@ -612,6 +616,7 @@ protected function _process(Varien_Object $document) * @param mixed $amount * @return $this */ + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassAfterLastUsed protected function _checkTransaction($transaction, $amount) { return $this; diff --git a/app/code/core/Mage/Reports/Model/Product/Index/Abstract.php b/app/code/core/Mage/Reports/Model/Product/Index/Abstract.php index 64ccfd6e0cc..82adadd13c4 100644 --- a/app/code/core/Mage/Reports/Model/Product/Index/Abstract.php +++ b/app/code/core/Mage/Reports/Model/Product/Index/Abstract.php @@ -118,7 +118,7 @@ public function getCustomerId() public function getStoreId() { if ($this->hasData('store_id')) { - return $this->getData('store_id'); + return (int)$this->getData('store_id'); } return Mage::app()->getStore()->getId(); } diff --git a/app/code/core/Mage/Sales/Block/Order/Comments.php b/app/code/core/Mage/Sales/Block/Order/Comments.php index 14481951f20..a800b0930a4 100644 --- a/app/code/core/Mage/Sales/Block/Order/Comments.php +++ b/app/code/core/Mage/Sales/Block/Order/Comments.php @@ -75,7 +75,9 @@ public function getComments() Mage::throwException(Mage::helper('sales')->__('Invalid entity model')); } - $this->_commentCollection = Mage::getResourceModel($collectionClass); + /** @var Mage_Sales_Model_Resource_Order_Comment_Collection_Abstract $commentCollection */ + $commentCollection = Mage::getResourceModel($collectionClass); + $this->_commentCollection = $commentCollection; $this->_commentCollection->setParentFilter($entity) ->setCreatedAtOrder() ->addVisibleOnFrontFilter(); diff --git a/app/code/core/Mage/Sales/Model/Entity/Quote/Address/Attribute/Frontend.php b/app/code/core/Mage/Sales/Model/Entity/Quote/Address/Attribute/Frontend.php index 3a08d384dcb..dbb1d0cbfd0 100644 --- a/app/code/core/Mage/Sales/Model/Entity/Quote/Address/Attribute/Frontend.php +++ b/app/code/core/Mage/Sales/Model/Entity/Quote/Address/Attribute/Frontend.php @@ -20,8 +20,9 @@ class Mage_Sales_Model_Entity_Quote_Address_Attribute_Frontend extends Mage_Eav_Model_Entity_Attribute_Frontend_Abstract { /** - * @return array + * @return $this|array */ + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass public function fetchTotals(Mage_Sales_Model_Quote_Address $address) { return []; diff --git a/app/code/core/Mage/Sales/Model/Quote.php b/app/code/core/Mage/Sales/Model/Quote.php index 2a39d3e8f47..310fe129960 100644 --- a/app/code/core/Mage/Sales/Model/Quote.php +++ b/app/code/core/Mage/Sales/Model/Quote.php @@ -31,8 +31,8 @@ * * @method bool hasCanApplyMsrp() * @method bool getCanApplyMsrp() - * @method string getAppliedRuleIds() - * @method $this setAppliedRuleIds(string $value) + * @method string|array getAppliedRuleIds() + * @method $this setAppliedRuleIds(string|array $value) * * @method string getBaseCurrencyCode() * @method $this setBaseCurrencyCode(string $value) @@ -261,7 +261,7 @@ public function getStoreId() if (!$this->hasStoreId()) { return Mage::app()->getStore()->getId(); } - return $this->_getData('store_id'); + return (int)$this->_getData('store_id'); } /** diff --git a/app/code/core/Mage/Sales/Model/Quote/Address.php b/app/code/core/Mage/Sales/Model/Quote/Address.php index bd1522aa303..7e6f7c9442c 100644 --- a/app/code/core/Mage/Sales/Model/Quote/Address.php +++ b/app/code/core/Mage/Sales/Model/Quote/Address.php @@ -27,8 +27,8 @@ * @method string getAddressType() * @method $this setAddressType(string $value) * @method $this unsAddressType() - * @method string getAppliedRuleIds() - * @method $this setAppliedRuleIds(string $value) + * @method array getAppliedRuleIds() + * @method $this setAppliedRuleIds(array $value) * @method bool getAppliedTaxesReset() * @method $this setAppliedTaxesReset(bool $value) * @@ -1193,6 +1193,7 @@ public function setAppliedTaxes($data) * @param bool $alreadyExclTax * @return $this */ + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassAfterLastUsed public function setShippingAmount($value, $alreadyExclTax = false) { return $this->setData('shipping_amount', $value); @@ -1205,6 +1206,7 @@ public function setShippingAmount($value, $alreadyExclTax = false) * @param bool $alreadyExclTax * @return $this */ + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassAfterLastUsed public function setBaseShippingAmount($value, $alreadyExclTax = false) { return $this->setData('base_shipping_amount', $value); 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 fa8626505c7..2ce268cd1a5 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 @@ -98,7 +98,7 @@ public function collect(Mage_Sales_Model_Quote_Address $address) /** * Fetch (Retrieve data as array) * - * @return array + * @return $this|array */ public function fetch(Mage_Sales_Model_Quote_Address $address) { diff --git a/app/code/core/Mage/SalesRule/Model/Quote/Discount.php b/app/code/core/Mage/SalesRule/Model/Quote/Discount.php index c6fe7f7cd68..62a68d2a0b7 100644 --- a/app/code/core/Mage/SalesRule/Model/Quote/Discount.php +++ b/app/code/core/Mage/SalesRule/Model/Quote/Discount.php @@ -40,7 +40,7 @@ public function __construct() /** * Collect address discount amount * - * @return Mage_SalesRule_Model_Quote_Discount + * @return $this */ public function collect(Mage_Sales_Model_Quote_Address $address) { @@ -122,7 +122,7 @@ public function collect(Mage_Sales_Model_Quote_Address $address) * Aggregate item discount information to address data and related properties * * @param Mage_Sales_Model_Quote_Item_Abstract $item - * @return Mage_SalesRule_Model_Quote_Discount + * @return $this */ protected function _aggregateItemDiscount($item) { @@ -134,7 +134,7 @@ protected function _aggregateItemDiscount($item) /** * Add discount total information to address * - * @return Mage_SalesRule_Model_Quote_Discount + * @return $this */ public function fetch(Mage_Sales_Model_Quote_Address $address) { diff --git a/app/code/core/Mage/SalesRule/Model/Quote/Freeshipping.php b/app/code/core/Mage/SalesRule/Model/Quote/Freeshipping.php index f94f344a912..ed73ab14572 100644 --- a/app/code/core/Mage/SalesRule/Model/Quote/Freeshipping.php +++ b/app/code/core/Mage/SalesRule/Model/Quote/Freeshipping.php @@ -37,7 +37,7 @@ public function __construct() /** * Collect information about free shipping for all address items * - * @return Mage_SalesRule_Model_Quote_Freeshipping + * @return $this */ public function collect(Mage_Sales_Model_Quote_Address $address) { @@ -90,8 +90,9 @@ public function collect(Mage_Sales_Model_Quote_Address $address) * Add information about free shipping for all address items to address object * By default we not present such information * - * @return Mage_SalesRule_Model_Quote_Freeshipping + * @return $this */ + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass public function fetch(Mage_Sales_Model_Quote_Address $address) { return $this; diff --git a/app/code/core/Mage/Shipping/Model/Rate/Request.php b/app/code/core/Mage/Shipping/Model/Rate/Request.php index 1592088af8a..dc3285df7f6 100644 --- a/app/code/core/Mage/Shipping/Model/Rate/Request.php +++ b/app/code/core/Mage/Shipping/Model/Rate/Request.php @@ -51,8 +51,8 @@ * @method Mage_Sales_Model_Quote_Item[] getAllItems() * @method $this setAllItems(array $items) * - * @method string getBaseCurrency() - * @method $this setBaseCurrency(string $value) + * @method Mage_Directory_Model_Currency getBaseCurrency() + * @method $this setBaseCurrency(Mage_Directory_Model_Currency $value) * @method float getBaseSubtotalInclTax() * @method $this setBaseSubtotalInclTax(float $value) * @@ -117,8 +117,8 @@ * @method $this setPackageWidth(int $value) * @method int getPackageDepth() * @method $this setPackageDepth(int $value) - * @method string getPackageCurrency() - * @method $this setPackageCurrency(string $value) + * @method Mage_Directory_Model_Currency getPackageCurrency() + * @method $this setPackageCurrency(Mage_Directory_Model_Currency $value) * @method $this setPostcode(string $value) * * @method $this setRegionId(string $value) diff --git a/app/code/core/Mage/Tax/Model/Calculation.php b/app/code/core/Mage/Tax/Model/Calculation.php index 05708a39d26..d1d643b68d0 100644 --- a/app/code/core/Mage/Tax/Model/Calculation.php +++ b/app/code/core/Mage/Tax/Model/Calculation.php @@ -163,7 +163,7 @@ public function getDefaultCustomerTaxClass($store = null) /** * Get customer object * - * @return Mage_Customer_Model_Customer | false + * @return Mage_Customer_Model_Customer|false */ public function getCustomer() { diff --git a/app/code/core/Mage/Tax/Model/Resource/Calculation.php b/app/code/core/Mage/Tax/Model/Resource/Calculation.php index 4d593b8dac6..059f0f3ee74 100644 --- a/app/code/core/Mage/Tax/Model/Resource/Calculation.php +++ b/app/code/core/Mage/Tax/Model/Resource/Calculation.php @@ -335,6 +335,7 @@ protected function _getRates($request) * @see ZF-7592 issue http://framework.zend.com/issues/browse/ZF-7592 */ if ($postcodeIsNumeric || $postcodeIsRange) { + // phpcs:ignore Ecg.Sql.SlowQuery.SlowSql $select = $this->_getReadAdapter()->select()->union( [ '(' . $select . ')', @@ -350,6 +351,7 @@ protected function _getRates($request) ->order('tax_postcode ' . Varien_Db_Select::SQL_DESC) ->order('value ' . Varien_Db_Select::SQL_DESC); + // phpcs:ignore Ecg.Performance.FetchAll.Found $this->_ratesCache[$cacheKey] = $this->_getReadAdapter()->fetchAll($select); } @@ -482,8 +484,10 @@ public function getRatesByCustomerTaxClass($customerTaxClass, $productTaxClass = 'state_table.region_id = main_table.tax_region_id', ['region_code' => 'state_table.code'] ) - ->distinct(true); + // phpcs:ignore Ecg.Sql.SlowQuery.SlowSql + ->distinct(); + // phpcs:ignore Ecg.Performance.FetchAll.Found $CSP = $adapter->fetchAll($selectCSP); $result = []; diff --git a/app/code/core/Mage/Tax/Model/Sales/Total/Quote/Tax.php b/app/code/core/Mage/Tax/Model/Sales/Total/Quote/Tax.php index f09c2c9ce6c..e542f373014 100644 --- a/app/code/core/Mage/Tax/Model/Sales/Total/Quote/Tax.php +++ b/app/code/core/Mage/Tax/Model/Sales/Total/Quote/Tax.php @@ -1442,6 +1442,7 @@ protected function _calculateRowWeeeTax($discountAmount, $item, $rate, $base = t * @param float $weeeAmountExclTax * @return mixed */ + // phpcs:ignore Ecg.PHP.PrivateClassMember.PrivateClassMemberError private function _getWeeeTax($rate, $item, $discountAmount, $weeeAmountIncludingTax, $weeeAmountExclTax) { $isWeeeTaxAlreadyIncluded = $this->_weeeHelper->isTaxIncluded($this->_store); @@ -1509,7 +1510,7 @@ protected function _recalculateParent(Mage_Sales_Model_Quote_Item_Abstract $item * @param array $applied * @param float $amount * @param float $baseAmount - * @param float $rate + * @param float|null $rate */ protected function _saveAppliedTaxes( Mage_Sales_Model_Quote_Address $address, @@ -1533,8 +1534,8 @@ protected function _saveAppliedTaxes( } if (!is_null($row['percent'])) { - $row['percent'] = $row['percent'] ? $row['percent'] : 1; - $rate = $rate ? $rate : 1; + $row['percent'] = $row['percent'] ?: 1; + $rate = $rate ?: 1; $appliedAmount = $amount / $rate * $row['percent']; $baseAppliedAmount = $baseAmount / $rate * $row['percent']; diff --git a/app/code/core/Mage/Weee/Model/Total/Quote/Weee.php b/app/code/core/Mage/Weee/Model/Total/Quote/Weee.php index 8ff7cec3a49..0b9bb03dbb2 100644 --- a/app/code/core/Mage/Weee/Model/Total/Quote/Weee.php +++ b/app/code/core/Mage/Weee/Model/Total/Quote/Weee.php @@ -334,6 +334,7 @@ protected function _processTotalAmount($address, $rowValue, $baseRowValue) * * @return $this */ + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass protected function _recalculateParent(Mage_Sales_Model_Quote_Item_Abstract $item) { return $this; @@ -366,6 +367,7 @@ protected function _resetItemData($item) * * @return $this */ + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass public function fetch(Mage_Sales_Model_Quote_Address $address) { return $this; @@ -379,6 +381,7 @@ public function fetch(Mage_Sales_Model_Quote_Address $address) * @param Mage_Core_Model_Store $store * @return array */ + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassAfterLastUsed public function processConfigArray($config, $store) { return $config; diff --git a/lib/Magento/Db/Adapter/Pdo/Mysql.php b/lib/Magento/Db/Adapter/Pdo/Mysql.php index f260bc7a093..ac65868871f 100644 --- a/lib/Magento/Db/Adapter/Pdo/Mysql.php +++ b/lib/Magento/Db/Adapter/Pdo/Mysql.php @@ -105,6 +105,7 @@ protected function _quote($value) } // Fix for null-byte injection if (is_string($value)) { + // phpcs:ignore Ecg.Security.ForbiddenFunction.Found $value = addcslashes($value, "\000\032"); } return parent::_quote($value); diff --git a/lib/Varien/Data/Form/Filter/Date.php b/lib/Varien/Data/Form/Filter/Date.php index a20ce096458..4d5179d90ba 100644 --- a/lib/Varien/Data/Form/Filter/Date.php +++ b/lib/Varien/Data/Form/Filter/Date.php @@ -31,7 +31,7 @@ class Varien_Data_Form_Filter_Date implements Varien_Data_Form_Filter_Interface /** * Local * - * @var Zend_Locale + * @var string|Zend_Locale */ protected $_locale; @@ -39,7 +39,7 @@ class Varien_Data_Form_Filter_Date implements Varien_Data_Form_Filter_Interface * Initialize filter * * @param string $format Zend_Date input/output format - * @param Zend_Locale $locale + * @param string|Zend_Locale $locale */ public function __construct($format = null, $locale = null) { @@ -53,8 +53,8 @@ public function __construct($format = null, $locale = null) /** * Returns the result of filtering $value * - * @param string $value - * @return string + * @param string|null $value + * @return string|null */ public function inputFilter($value) { @@ -79,7 +79,7 @@ public function inputFilter($value) /** * Returns the result of filtering $value * - * @param string $value + * @param string|null $value * @return string */ public function outputFilter($value) diff --git a/lib/Varien/Data/Form/Filter/Datetime.php b/lib/Varien/Data/Form/Filter/Datetime.php index b7400e46b35..6c7372a771f 100644 --- a/lib/Varien/Data/Form/Filter/Datetime.php +++ b/lib/Varien/Data/Form/Filter/Datetime.php @@ -24,8 +24,8 @@ class Varien_Data_Form_Filter_Datetime extends Varien_Data_Form_Filter_Date /** * Returns the result of filtering $value * - * @param string $value - * @return string + * @param string|null $value + * @return string|null */ public function inputFilter($value) { @@ -50,7 +50,7 @@ public function inputFilter($value) /** * Returns the result of filtering $value * - * @param string $value + * @param string|null $value * @return string */ public function outputFilter($value) diff --git a/lib/Varien/Data/Tree/Dbp.php b/lib/Varien/Data/Tree/Dbp.php index 05b652533a8..d0d3e98480e 100644 --- a/lib/Varien/Data/Tree/Dbp.php +++ b/lib/Varien/Data/Tree/Dbp.php @@ -193,7 +193,7 @@ public function load($parentNode = null, $recursionLevel = 0) /** * @param Varien_Data_Tree_Node|array $children * @param string $path - * @param Varien_Data_Tree_Node $parentNode + * @param Varien_Data_Tree_Node|null $parentNode * @param int $level */ public function addChildNodes($children, $path, $parentNode, $level = 0) @@ -275,7 +275,7 @@ public function getChildren($node, $recursive = true, $result = []) * Move tree node * * @todo Use adapter for generate conditions - * @param Varien_Data_Tree_Node $node + * @param Varien_Data_Tree_Node|Varien_Object $node * @param Varien_Data_Tree_Node $newParent * @param Varien_Data_Tree_Node $prevNode */ From b66a9f1de6e96782abfb054f435b953e7dfdedb1 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Fri, 18 Oct 2024 11:35:26 +0200 Subject: [PATCH 2/2] updated tests --- tests/unit/Mage/Core/Helper/DataTest.php | 2 +- tests/unit/Mage/Page/Block/SwitchTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/Mage/Core/Helper/DataTest.php b/tests/unit/Mage/Core/Helper/DataTest.php index dd12a0b08c0..a550578fd6c 100644 --- a/tests/unit/Mage/Core/Helper/DataTest.php +++ b/tests/unit/Mage/Core/Helper/DataTest.php @@ -182,7 +182,7 @@ public function testValidateHash(): void */ public function testGetStoreId(): void { - $this->assertIsString($this->subject->getStoreId()); + $this->assertIsInt($this->subject->getStoreId()); } /** diff --git a/tests/unit/Mage/Page/Block/SwitchTest.php b/tests/unit/Mage/Page/Block/SwitchTest.php index b71c5ff1157..3844bc90f2f 100644 --- a/tests/unit/Mage/Page/Block/SwitchTest.php +++ b/tests/unit/Mage/Page/Block/SwitchTest.php @@ -56,7 +56,7 @@ public function testGetCurrentGroupId(): void */ public function testGetCurrentStoreId(): void { - $this->assertIsString($this->subject->getCurrentStoreId()); + $this->assertIsInt($this->subject->getCurrentStoreId()); } /**