From bd0a98dd12024b85e2fe9713e2ed3f7e58c53cf3 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Fri, 7 Nov 2025 02:50:09 +0100 Subject: [PATCH 1/3] PhpStan: fix falsy empty --- .phpstan.dist.baseline.neon | 126 ------------------ app/code/core/Mage/Captcha/Model/Zend.php | 2 +- app/code/core/Mage/Core/Model/App.php | 4 +- .../Model/Mysql4/Design/Theme/Collection.php | 2 +- .../Model/Resource/Db/Collection/Abstract.php | 5 +- app/code/core/Mage/Customer/Helper/Data.php | 8 +- .../core/Mage/Eav/Model/Entity/Abstract.php | 3 +- .../Eav/Model/Entity/Attribute/Abstract.php | 8 +- .../Eav/Model/Entity/Collection/Abstract.php | 3 +- app/code/core/Mage/Eav/Model/Entity/Type.php | 2 +- .../Entity/Summary/Collection/Abstract.php | 2 +- app/code/core/Mage/Rule/Model/Abstract.php | 2 +- .../Mage/Sales/Model/Order/Creditmemo.php | 2 +- .../core/Mage/Sales/Model/Order/Shipment.php | 4 +- app/code/core/Mage/Sales/Model/Quote.php | 1 + .../core/Mage/Shipping/Model/Shipping.php | 2 +- lib/Varien/Data/Form/Abstract.php | 2 +- lib/Varien/Io/Sftp.php | 23 ++-- 18 files changed, 40 insertions(+), 161 deletions(-) diff --git a/.phpstan.dist.baseline.neon b/.phpstan.dist.baseline.neon index 432468efc38..f0b7a3b9194 100644 --- a/.phpstan.dist.baseline.neon +++ b/.phpstan.dist.baseline.neon @@ -1140,12 +1140,6 @@ parameters: count: 1 path: app/code/core/Mage/Bundle/Model/Resource/Option/Collection.php - - - rawMessage: 'Property Mage_Captcha_Model_Zend::$_helper (Mage_Captcha_Helper_Data) in empty() is not falsy.' - identifier: empty.property - count: 1 - path: app/code/core/Mage/Captcha/Model/Zend.php - - rawMessage: 'Return type (Mage_Customer_Model_Session) of method Mage_Captcha_Model_Zend::getSession() should be compatible with return type (Zend_Session_Namespace) of method Zend_Captcha_Word::getSession()' identifier: method.childReturnType @@ -2322,18 +2316,6 @@ parameters: count: 1 path: app/code/core/Mage/Core/Model/App.php - - - rawMessage: 'Property Mage_Core_Model_App::$_request (Mage_Core_Controller_Request_Http) in empty() is not falsy.' - identifier: empty.property - count: 1 - path: app/code/core/Mage/Core/Model/App.php - - - - rawMessage: 'Property Mage_Core_Model_App::$_response (Mage_Core_Controller_Response_Http) in empty() is not falsy.' - identifier: empty.property - count: 1 - path: app/code/core/Mage/Core/Model/App.php - - rawMessage: 'Method Mage_Core_Model_Cache::getDbAdapter() should return Zend_Db_Adapter_Abstract but returns Varien_Db_Adapter_Interface|false.' identifier: return.type @@ -2544,12 +2526,6 @@ parameters: count: 1 path: app/code/core/Mage/Core/Model/Resource/Db/Collection/Abstract.php - - - rawMessage: 'Property Mage_Core_Model_Resource_Db_Collection_Abstract::$_resource (Mage_Core_Model_Resource_Db_Abstract) in empty() is not falsy.' - identifier: empty.property - count: 1 - path: app/code/core/Mage/Core/Model/Resource/Db/Collection/Abstract.php - - rawMessage: Result of && is always false. identifier: booleanAnd.alwaysFalse @@ -2730,24 +2706,6 @@ parameters: count: 1 path: app/code/core/Mage/Customer/Block/Newsletter.php - - - rawMessage: 'Property Mage_Customer_Helper_Data::$_customer (Mage_Customer_Model_Customer) in empty() is not falsy.' - identifier: empty.property - count: 1 - path: app/code/core/Mage/Customer/Helper/Data.php - - - - rawMessage: 'Property Mage_Customer_Helper_Data::$_groups (Mage_Customer_Model_Entity_Group_Collection) does not accept Mage_Customer_Model_Resource_Group_Collection.' - identifier: assign.propertyType - count: 1 - path: app/code/core/Mage/Customer/Helper/Data.php - - - - rawMessage: 'Property Mage_Customer_Helper_Data::$_groups (Mage_Customer_Model_Entity_Group_Collection) in empty() is not falsy.' - identifier: empty.property - count: 1 - path: app/code/core/Mage/Customer/Helper/Data.php - - rawMessage: 'Parameter #1 $entity of method Mage_Customer_Model_Api_Resource::getAllowedAttributes() expects Mage_Eav_Model_Entity_Abstract, Mage_Customer_Model_Address given.' identifier: argument.type @@ -3138,42 +3096,18 @@ parameters: count: 1 path: app/code/core/Mage/Eav/Model/Entity/Abstract.php - - - rawMessage: 'Property Mage_Eav_Model_Entity_Abstract::$_type (Mage_Eav_Model_Entity_Type) in empty() is not falsy.' - identifier: empty.property - count: 1 - path: app/code/core/Mage/Eav/Model/Entity/Abstract.php - - rawMessage: 'Call to an undefined method Mage_Core_Model_Resource_Db_Abstract::getIdByCode().' identifier: method.notFound count: 1 path: app/code/core/Mage/Eav/Model/Entity/Attribute/Abstract.php - - - rawMessage: 'Property Mage_Eav_Model_Entity_Attribute_Abstract::$_backend (Mage_Eav_Model_Entity_Attribute_Backend_Abstract) in empty() is not falsy.' - identifier: empty.property - count: 1 - path: app/code/core/Mage/Eav/Model/Entity/Attribute/Abstract.php - - rawMessage: 'Property Mage_Eav_Model_Entity_Attribute_Abstract::$_entity (Mage_Eav_Model_Entity_Abstract) does not accept Mage_Eav_Model_Entity_Type.' identifier: assign.propertyType count: 1 path: app/code/core/Mage/Eav/Model/Entity/Attribute/Abstract.php - - - rawMessage: 'Property Mage_Eav_Model_Entity_Attribute_Abstract::$_frontend (Mage_Eav_Model_Entity_Attribute_Frontend_Abstract) in empty() is not falsy.' - identifier: empty.property - count: 1 - path: app/code/core/Mage/Eav/Model/Entity/Attribute/Abstract.php - - - - rawMessage: 'Property Mage_Eav_Model_Entity_Attribute_Abstract::$_source (Mage_Eav_Model_Entity_Attribute_Source_Abstract) in empty() is not falsy.' - identifier: empty.property - count: 1 - path: app/code/core/Mage/Eav/Model/Entity/Attribute/Abstract.php - - rawMessage: 'Call to an undefined method Mage_Eav_Model_Resource_Entity_Attribute_Group::deleteGroups().' identifier: method.notFound @@ -3216,12 +3150,6 @@ parameters: count: 1 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 - count: 1 - path: app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php - - rawMessage: 'Parameter #1 $code of method Mage_Eav_Model_Entity_Setup::updateEntityType() expects string, int given.' identifier: argument.type @@ -3234,12 +3162,6 @@ parameters: count: 1 path: app/code/core/Mage/Eav/Model/Entity/Setup.php - - - rawMessage: 'Property Mage_Eav_Model_Entity_Type::$_sets (Mage_Eav_Model_Resource_Entity_Attribute_Set_Collection) in empty() is not falsy.' - identifier: empty.property - count: 1 - path: app/code/core/Mage/Eav/Model/Entity/Type.php - - rawMessage: 'Parameter #1 $attribute of static method Mage_Eav_Model_Attribute_Data::factory() expects Mage_Eav_Model_Attribute, Mage_Eav_Model_Entity_Attribute given.' identifier: argument.type @@ -3798,12 +3720,6 @@ parameters: count: 1 path: app/code/core/Mage/Reports/Model/Resource/Customer/Collection.php - - - rawMessage: 'Property Mage_Reports_Model_Resource_Entity_Summary_Collection_Abstract::$_entityCollection (Mage_Eav_Model_Entity_Collection_Abstract) in empty() is not falsy.' - identifier: empty.property - count: 1 - path: app/code/core/Mage/Reports/Model/Resource/Entity/Summary/Collection/Abstract.php - - rawMessage: 'Call to an undefined method Varien_Data_Collection_Db::getResource().' identifier: method.notFound @@ -3882,12 +3798,6 @@ parameters: count: 1 path: app/code/core/Mage/Rss/Helper/Data.php - - - rawMessage: 'Property Mage_Rule_Model_Abstract::$_conditions (Mage_Rule_Model_Condition_Combine) in empty() is not falsy.' - identifier: empty.property - count: 1 - path: app/code/core/Mage/Rule/Model/Abstract.php - - rawMessage: 'Call to an undefined method Mage_Rule_Model_Action_Interface::getId().' identifier: method.notFound @@ -3984,12 +3894,6 @@ parameters: count: 2 path: app/code/core/Mage/Sales/Model/Entity/Quote.php - - - rawMessage: 'Property Mage_Sales_Model_Order_Creditmemo::$_items (iterable&Mage_Sales_Model_Resource_Order_Creditmemo_Item_Collection) in empty() is not falsy.' - identifier: empty.property - count: 1 - path: app/code/core/Mage/Sales/Model/Order/Creditmemo.php - - rawMessage: 'Call to an undefined method Mage_Catalog_Model_Product_Type_Abstract::getForceApplyDiscountToParentItem().' identifier: method.notFound @@ -4062,18 +3966,6 @@ parameters: count: 1 path: app/code/core/Mage/Sales/Model/Order/Pdf/Shipment/Packaging.php - - - rawMessage: 'Property Mage_Sales_Model_Order_Shipment::$_items (Mage_Sales_Model_Resource_Order_Shipment_Item_Collection) in empty() is not falsy.' - identifier: empty.property - count: 1 - path: app/code/core/Mage/Sales/Model/Order/Shipment.php - - - - rawMessage: 'Property Mage_Sales_Model_Order_Shipment::$_tracks (Mage_Sales_Model_Resource_Order_Shipment_Track_Collection) in empty() is not falsy.' - identifier: empty.property - count: 1 - path: app/code/core/Mage/Sales/Model/Order/Shipment.php - - rawMessage: 'Call to an undefined method Mage_Eav_Model_Entity_Abstract::getStoreId().' identifier: method.notFound @@ -4128,12 +4020,6 @@ parameters: count: 1 path: app/code/core/Mage/Sales/Model/Quote.php - - - rawMessage: 'Parameter #2 $array of function implode expects array, list given.' - identifier: argument.type - count: 1 - path: app/code/core/Mage/Sales/Model/Quote.php - - rawMessage: 'Method Mage_Sales_Model_Quote_Address::getItemsCollection() should return Mage_Eav_Model_Entity_Collection_Abstract but returns Mage_Sales_Model_Resource_Quote_Address_Item_Collection.' identifier: return.type @@ -4374,12 +4260,6 @@ parameters: count: 1 path: app/code/core/Mage/Shipping/Model/Info.php - - - rawMessage: 'Property Mage_Shipping_Model_Shipping::$_result (Mage_Shipping_Model_Rate_Result) in empty() is not falsy.' - identifier: empty.property - count: 1 - path: app/code/core/Mage/Shipping/Model/Shipping.php - - rawMessage: 'Call to an undefined method Mage_Shipping_Model_Rate_Result::getAllTrackings().' identifier: method.notFound @@ -5700,12 +5580,6 @@ parameters: count: 1 path: lib/Varien/Data/Collection/Db.php - - - rawMessage: 'Property Varien_Data_Form_Abstract::$_elements (Varien_Data_Form_Element_Collection) in empty() is not falsy.' - identifier: empty.property - count: 1 - path: lib/Varien/Data/Form/Abstract.php - - rawMessage: Access to an undefined property Varien_Data_Form_Element_Fieldset::$_sortDirection. identifier: property.notFound diff --git a/app/code/core/Mage/Captcha/Model/Zend.php b/app/code/core/Mage/Captcha/Model/Zend.php index 406a01d168f..8c21e87acc6 100644 --- a/app/code/core/Mage/Captcha/Model/Zend.php +++ b/app/code/core/Mage/Captcha/Model/Zend.php @@ -334,7 +334,7 @@ protected function _getFontPath() */ protected function _getHelper() { - if (empty($this->_helper)) { + if (is_null($this->_helper)) { $this->_helper = Mage::helper('captcha'); } diff --git a/app/code/core/Mage/Core/Model/App.php b/app/code/core/Mage/Core/Model/App.php index 64da31cc987..24f78d6adc7 100644 --- a/app/code/core/Mage/Core/Model/App.php +++ b/app/code/core/Mage/Core/Model/App.php @@ -1309,7 +1309,7 @@ public function cleanAllSessions() */ public function getRequest() { - if (empty($this->_request)) { + if (is_null($this->_request)) { $this->_request = new Mage_Core_Controller_Request_Http(); } @@ -1366,7 +1366,7 @@ public function isCurrentlySecure() */ public function getResponse() { - if (empty($this->_response)) { + if (is_null($this->_response)) { $this->_response = new Mage_Core_Controller_Response_Http(); $this->_response->headersSentThrowsException = Mage::$headersSentThrowsException; $this->_response->setHeader('Content-Type', 'text/html; charset=UTF-8'); diff --git a/app/code/core/Mage/Core/Model/Mysql4/Design/Theme/Collection.php b/app/code/core/Mage/Core/Model/Mysql4/Design/Theme/Collection.php index 018142f9ea1..94dfd63f952 100644 --- a/app/code/core/Mage/Core/Model/Mysql4/Design/Theme/Collection.php +++ b/app/code/core/Mage/Core/Model/Mysql4/Design/Theme/Collection.php @@ -18,7 +18,7 @@ class Mage_Core_Model_Mysql4_Design_Theme_Collection extends Varien_Directory_Co /** * @return $this */ - public function load() + public function load($printQuery = false, $logQuery = false) { $packages = $this->getData('themes'); if (is_null($packages)) { diff --git a/app/code/core/Mage/Core/Model/Resource/Db/Collection/Abstract.php b/app/code/core/Mage/Core/Model/Resource/Db/Collection/Abstract.php index 761a39670d1..8d1b7f22c39 100644 --- a/app/code/core/Mage/Core/Model/Resource/Db/Collection/Abstract.php +++ b/app/code/core/Mage/Core/Model/Resource/Db/Collection/Abstract.php @@ -35,7 +35,7 @@ abstract class Mage_Core_Model_Resource_Db_Collection_Abstract extends Varien_Da * * @var Mage_Core_Model_Resource_Db_Abstract */ - protected $_resource; + protected $_resource = null; /** * Fields to select in query @@ -105,6 +105,7 @@ abstract class Mage_Core_Model_Resource_Db_Collection_Abstract extends Varien_Da * Collection constructor * * @param Mage_Core_Model_Resource_Db_Abstract $resource + * @throws Zend_Exception */ public function __construct($resource = null) { @@ -454,7 +455,7 @@ public function getResourceModelName() */ public function getResource() { - if (empty($this->_resource)) { + if (is_null($this->_resource) || $this->_resource === []) { $this->_resource = Mage::getResourceModel($this->getResourceModelName()); } diff --git a/app/code/core/Mage/Customer/Helper/Data.php b/app/code/core/Mage/Customer/Helper/Data.php index 2ac4d0afc15..13c19fe0fe8 100644 --- a/app/code/core/Mage/Customer/Helper/Data.php +++ b/app/code/core/Mage/Customer/Helper/Data.php @@ -97,7 +97,7 @@ class Mage_Customer_Helper_Data extends Mage_Core_Helper_Abstract /** * Customer groups collection * - * @var Mage_Customer_Model_Entity_Group_Collection + * @var Mage_Customer_Model_Resource_Group_Collection */ protected $_groups; @@ -118,7 +118,7 @@ public function isLoggedIn() */ public function getCustomer() { - if (empty($this->_customer)) { + if (is_null($this->_customer)) { $this->_customer = Mage::getSingleton('customer/session')->getCustomer(); } @@ -128,11 +128,11 @@ public function getCustomer() /** * Retrieve customer groups collection * - * @return Mage_Customer_Model_Entity_Group_Collection + * @return Mage_Customer_Model_Resource_Group_Collection */ public function getGroups() { - if (empty($this->_groups)) { + if (is_null($this->_groups)) { $this->_groups = Mage::getModel('customer/group')->getResourceCollection() ->setRealGroupsFilter() ->load(); diff --git a/app/code/core/Mage/Eav/Model/Entity/Abstract.php b/app/code/core/Mage/Eav/Model/Entity/Abstract.php index 87bd00d76c2..2b5f35eade6 100644 --- a/app/code/core/Mage/Eav/Model/Entity/Abstract.php +++ b/app/code/core/Mage/Eav/Model/Entity/Abstract.php @@ -258,11 +258,12 @@ public function setType($type) /** * Retrieve current entity config * + * @throws Mage_Core_Exception * @return Mage_Eav_Model_Entity_Type */ public function getEntityType() { - if (empty($this->_type)) { + if (is_null($this->_type)) { throw Mage::exception('Mage_Eav', Mage::helper('eav')->__('Entity is not initialized')); } diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute/Abstract.php b/app/code/core/Mage/Eav/Model/Entity/Attribute/Abstract.php index 3ad0211b747..ef1ef8c0574 100644 --- a/app/code/core/Mage/Eav/Model/Entity/Attribute/Abstract.php +++ b/app/code/core/Mage/Eav/Model/Entity/Attribute/Abstract.php @@ -424,11 +424,12 @@ public function getEntityIdField() /** * Retrieve backend instance * + * @throws Mage_Core_Exception * @return Mage_Eav_Model_Entity_Attribute_Backend_Abstract */ public function getBackend() { - if (empty($this->_backend)) { + if (is_null($this->_backend)) { if (!$this->getBackendModel()) { $this->setBackendModel($this->_getDefaultBackendModel()); } @@ -451,7 +452,7 @@ public function getBackend() */ public function getFrontend() { - if (empty($this->_frontend)) { + if (is_null($this->_frontend)) { if (!$this->getFrontendModel()) { $this->setFrontendModel($this->_getDefaultFrontendModel()); } @@ -466,11 +467,12 @@ public function getFrontend() /** * Retrieve source instance * + * @throws Mage_Core_Exception * @return Mage_Eav_Model_Entity_Attribute_Source_Abstract */ public function getSource() { - if (empty($this->_source)) { + if (is_null($this->_source)) { if (!$this->getSourceModel()) { $this->setSourceModel($this->_getDefaultSourceModel()); } diff --git a/app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php b/app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php index e6d069ba21c..7bd5bc4798d 100644 --- a/app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php +++ b/app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php @@ -198,11 +198,12 @@ public function setEntity($entity) /** * Get collection's entity object * + * @throws Mage_Core_Exception * @return Mage_Eav_Model_Entity_Abstract */ public function getEntity() { - if (empty($this->_entity)) { + if (is_null($this->_entity)) { throw Mage::exception('Mage_Eav', Mage::helper('eav')->__('Entity is not initialized')); } diff --git a/app/code/core/Mage/Eav/Model/Entity/Type.php b/app/code/core/Mage/Eav/Model/Entity/Type.php index af9151054ac..0c6a6f517dd 100644 --- a/app/code/core/Mage/Eav/Model/Entity/Type.php +++ b/app/code/core/Mage/Eav/Model/Entity/Type.php @@ -150,7 +150,7 @@ protected function _getAttributeCollection() */ public function getAttributeSetCollection() { - if (empty($this->_sets)) { + if (is_null($this->_sets)) { $this->_sets = Mage::getModel('eav/entity_attribute_set')->getResourceCollection() ->setEntityTypeFilter($this->getId()); } diff --git a/app/code/core/Mage/Reports/Model/Resource/Entity/Summary/Collection/Abstract.php b/app/code/core/Mage/Reports/Model/Resource/Entity/Summary/Collection/Abstract.php index a6e67c69243..6bb22e389be 100644 --- a/app/code/core/Mage/Reports/Model/Resource/Entity/Summary/Collection/Abstract.php +++ b/app/code/core/Mage/Reports/Model/Resource/Entity/Summary/Collection/Abstract.php @@ -96,7 +96,7 @@ public function setStoreFilter($storeId) */ public function getCollection() { - if (empty($this->_entityCollection)) { + if (is_null($this->_entityCollection)) { $this->_initCollection(); } diff --git a/app/code/core/Mage/Rule/Model/Abstract.php b/app/code/core/Mage/Rule/Model/Abstract.php index 67e1f358a48..b228512b0d1 100644 --- a/app/code/core/Mage/Rule/Model/Abstract.php +++ b/app/code/core/Mage/Rule/Model/Abstract.php @@ -167,7 +167,7 @@ public function setConditions($conditions) */ public function getConditions() { - if (empty($this->_conditions)) { + if (is_null($this->_conditions)) { $this->_resetConditions(); } diff --git a/app/code/core/Mage/Sales/Model/Order/Creditmemo.php b/app/code/core/Mage/Sales/Model/Order/Creditmemo.php index d9f71cc23a4..6715aff17fc 100644 --- a/app/code/core/Mage/Sales/Model/Order/Creditmemo.php +++ b/app/code/core/Mage/Sales/Model/Order/Creditmemo.php @@ -287,7 +287,7 @@ public function getShippingAddress() */ public function getItemsCollection() { - if (empty($this->_items)) { + if (is_null($this->_items)) { $this->_items = Mage::getResourceModel('sales/order_creditmemo_item_collection') ->setCreditmemoFilter($this->getId()); diff --git a/app/code/core/Mage/Sales/Model/Order/Shipment.php b/app/code/core/Mage/Sales/Model/Order/Shipment.php index cf75b814d34..fd3536e60d5 100644 --- a/app/code/core/Mage/Sales/Model/Order/Shipment.php +++ b/app/code/core/Mage/Sales/Model/Order/Shipment.php @@ -239,7 +239,7 @@ public function register() */ public function getItemsCollection() { - if (empty($this->_items)) { + if (is_null($this->_items)) { $this->_items = Mage::getResourceModel('sales/order_shipment_item_collection') ->setShipmentFilter($this->getId()); @@ -304,7 +304,7 @@ public function addItem(Mage_Sales_Model_Order_Shipment_Item $item) */ public function getTracksCollection() { - if (empty($this->_tracks)) { + if (is_null($this->_tracks)) { $this->_tracks = Mage::getResourceModel('sales/order_shipment_track_collection') ->setShipmentFilter($this->getId()); diff --git a/app/code/core/Mage/Sales/Model/Quote.php b/app/code/core/Mage/Sales/Model/Quote.php index 63e2d5d0d98..b7c664e3144 100644 --- a/app/code/core/Mage/Sales/Model/Quote.php +++ b/app/code/core/Mage/Sales/Model/Quote.php @@ -1093,6 +1093,7 @@ public function addProductAdvanced(Mage_Catalog_Model_Product $product, $request // collect errors instead of throwing first one if ($item->getHasError()) { $message = $item->getMessage(); + /** @var string $message */ if (!in_array($message, $errors)) { // filter duplicate messages $errors[] = $message; } diff --git a/app/code/core/Mage/Shipping/Model/Shipping.php b/app/code/core/Mage/Shipping/Model/Shipping.php index 8558e6d5b6a..670de1ad0e6 100644 --- a/app/code/core/Mage/Shipping/Model/Shipping.php +++ b/app/code/core/Mage/Shipping/Model/Shipping.php @@ -55,7 +55,7 @@ class Mage_Shipping_Model_Shipping */ public function getResult() { - if (empty($this->_result)) { + if (is_null($this->_result)) { $this->_result = Mage::getModel('shipping/rate_result'); } diff --git a/lib/Varien/Data/Form/Abstract.php b/lib/Varien/Data/Form/Abstract.php index 79803de5e10..43dbad1c156 100644 --- a/lib/Varien/Data/Form/Abstract.php +++ b/lib/Varien/Data/Form/Abstract.php @@ -62,7 +62,7 @@ public function addType($type, $className) */ public function getElements() { - if (empty($this->_elements)) { + if (is_null($this->_elements)) { $this->_elements = new Varien_Data_Form_Element_Collection($this); } diff --git a/lib/Varien/Io/Sftp.php b/lib/Varien/Io/Sftp.php index bceb7e4dc9f..7f7524d1578 100644 --- a/lib/Varien/Io/Sftp.php +++ b/lib/Varien/Io/Sftp.php @@ -7,6 +7,8 @@ * @package Varien_Io */ +use phpseclib3\Net\SFTP; + /** * Sftp client interface * @@ -20,18 +22,15 @@ class Varien_Io_Sftp extends Varien_Io_Abstract implements Varien_Io_Interface public const SSH2_PORT = 22; /** - * @var \phpseclib3\Net\SFTP + * @var SFTP */ protected $_connection = null; /** * Open a SFTP connection to a remote site. * - * @param array $args Connection arguments - * @param string $args[host] Remote hostname - * @param string $args[username] Remote username - * @param string $args[password] Connection password - * @param int $args[timeout] Connection timeout [=10] + * @param array{host?: mixed, username?: mixed, password?: mixed, timeout?: int} $args Connection arguments + * @throws Exception */ public function open(array $args = []) { @@ -46,7 +45,7 @@ public function open(array $args = []) $port = self::SSH2_PORT; } - $this->_connection = new \phpseclib3\Net\SFTP($host, $port, $args['timeout']); + $this->_connection = new SFTP($host, $port, $args['timeout']); if (!$this->_connection->login($args['username'], $args['password'])) { throw new Exception(__('Unable to open SFTP connection as %s@%s', $args['username'], $args['host'])); } @@ -57,14 +56,14 @@ public function open(array $args = []) */ public function close() { - return $this->_connection->disconnect(); + $this->_connection->disconnect(); } /** * Create a directory * - * @param $mode Ignored here; uses logged-in user's umask - * @param $recursive Analogous to mkdir -p + * @param int $mode Ignored here; uses logged-in user's umask + * @param bool $recursive Analogous to mkdir -p * * Note: if $recursive is true and an error occurs mid-execution, * false is returned and some part of the hierarchy might be created. @@ -152,7 +151,7 @@ public function read($filename, $dest = null) /** * Write a file - * @param $src Must be a local file name + * @param resource|string $src Must be a local file name */ public function write($filename, $src, $mode = null) { @@ -214,6 +213,6 @@ public function rawls() */ public function writeFile($filename, $src) { - return $this->_connection->put($filename, $src, \phpseclib3\Net\SFTP::SOURCE_LOCAL_FILE); + return $this->_connection->put($filename, $src, SFTP::SOURCE_LOCAL_FILE); } } From 63afa1f7815d7a497d2c48782c61b3d16d20dd65 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Fri, 7 Nov 2025 05:32:58 +0100 Subject: [PATCH 2/3] fixes --- .phpstan.dist.baseline.neon | 132 +----------------- .../core/Mage/Admin/Model/Resource/Roles.php | 38 +++-- .../Block/Promo/Quote/Edit/Tab/Main.php | 6 +- .../Adminhtml/Block/Report/Grid/Abstract.php | 2 +- .../Permissions/BlockController.php | 14 +- .../Permissions/VariableController.php | 14 +- .../System/Convert/ProfileController.php | 42 ++++-- .../Mage/Catalog/Model/Resource/Category.php | 4 +- .../Mage/Catalog/Model/Resource/Config.php | 8 +- app/code/core/Mage/Catalog/Model/Url.php | 10 +- .../core/Mage/CatalogSearch/Helper/Data.php | 2 +- .../core/Mage/Checkout/Model/Type/Onepage.php | 2 +- app/code/core/Mage/Core/Model/Abstract.php | 16 ++- .../core/Mage/Core/Model/Design/Fallback.php | 10 +- .../core/Mage/Core/Model/Design/Package.php | 2 +- .../Model/Resource/Db/Collection/Abstract.php | 11 +- .../Install/Model/Installer/Db/Abstract.php | 2 +- .../Mage/Rule/Model/Condition/Abstract.php | 8 +- .../Model/Quote/Address/Total/Shipping.php | 10 +- .../Mage/Shipping/Model/Carrier/Abstract.php | 2 +- .../Usa/Model/Shipping/Carrier/Abstract.php | 4 +- 21 files changed, 136 insertions(+), 203 deletions(-) diff --git a/.phpstan.dist.baseline.neon b/.phpstan.dist.baseline.neon index f0b7a3b9194..c57f02a6caa 100644 --- a/.phpstan.dist.baseline.neon +++ b/.phpstan.dist.baseline.neon @@ -24,12 +24,6 @@ parameters: count: 1 path: app/code/core/Mage/Admin/Model/Resource/Acl.php - - - rawMessage: 'Parameter #1 $role of method Mage_Admin_Model_Resource_Roles::_updateRoleUsersAcl() expects Mage_Admin_Model_Roles, Mage_Core_Model_Abstract given.' - identifier: argument.type - count: 1 - path: app/code/core/Mage/Admin/Model/Resource/Roles.php - - rawMessage: 'Call to an undefined method Mage_Admin_Model_Resource_Roles::update().' identifier: method.notFound @@ -138,12 +132,6 @@ parameters: count: 1 path: app/code/core/Mage/Adminhtml/Block/Permissions/Usernroles.php - - - rawMessage: 'Parameter #3 $refValues of method Mage_Adminhtml_Block_Widget_Form_Element_Dependence::addFieldDependence() expects array|string, int given.' - identifier: argument.type - count: 3 - path: app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Main.php - - rawMessage: 'Parameter #1 $collection of method Mage_Adminhtml_Block_Widget_Grid::setCollection() expects Varien_Data_Collection_Db, Mage_Reports_Model_Resource_Report_Collection given.' identifier: argument.type @@ -162,12 +150,6 @@ parameters: count: 1 path: app/code/core/Mage/Adminhtml/Block/Report/Grid/Abstract.php - - - rawMessage: 'Property Mage_Adminhtml_Block_Report_Grid_Abstract::$_columnGroupBy (string) in isset() is not nullable.' - identifier: isset.property - count: 1 - path: app/code/core/Mage/Adminhtml/Block/Report/Grid/Abstract.php - - rawMessage: 'Parameter #1 $value of method Zend_Currency::toCurrency() expects float|int|null, string given.' identifier: argument.type @@ -558,18 +540,6 @@ parameters: count: 1 path: app/code/core/Mage/Adminhtml/controllers/CustomerController.php - - - rawMessage: 'Variable $id in isset() always exists and is not nullable.' - identifier: isset.variable - count: 1 - path: app/code/core/Mage/Adminhtml/controllers/Permissions/BlockController.php - - - - rawMessage: 'Variable $id in isset() always exists and is not nullable.' - identifier: isset.variable - count: 1 - path: app/code/core/Mage/Adminhtml/controllers/Permissions/VariableController.php - - rawMessage: 'Cannot call method aggregate() on Mage_Core_Model_Resource_Db_Collection_Abstract|false.' identifier: method.nonObject @@ -672,12 +642,6 @@ parameters: count: 4 path: app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php - - - rawMessage: 'Variable $data in isset() always exists and is not nullable.' - identifier: isset.variable - count: 1 - path: app/code/core/Mage/Adminhtml/controllers/System/Convert/ProfileController.php - - rawMessage: 'Cannot call method fetchRates() on Mage_Core_Model_Abstract|false.' identifier: method.nonObject @@ -1656,12 +1620,6 @@ parameters: count: 1 path: app/code/core/Mage/Catalog/Model/Resource/Category.php - - - rawMessage: 'Property Mage_Catalog_Model_Resource_Category::$_storeId (int) on left side of ?? is not nullable.' - identifier: nullCoalesce.property - count: 1 - path: app/code/core/Mage/Catalog/Model/Resource/Category.php - - rawMessage: 'Property Mage_Catalog_Model_Resource_Category::$_tree (Varien_Data_Tree_Db) does not accept Varien_Data_Tree_Dbp.' identifier: assign.propertyType @@ -1740,12 +1698,6 @@ parameters: count: 1 path: app/code/core/Mage/Catalog/Model/Resource/Category/Tree.php - - - rawMessage: 'Property Mage_Catalog_Model_Resource_Config::$_storeId (int) on left side of ?? is not nullable.' - identifier: nullCoalesce.property - count: 1 - path: app/code/core/Mage/Catalog/Model/Resource/Config.php - - rawMessage: Binary operation "-" between int and non-falsy-string results in an error. identifier: binaryOp.invalid @@ -1878,12 +1830,6 @@ parameters: count: 2 path: app/code/core/Mage/Catalog/Model/Url.php - - - rawMessage: 'Property Mage_Catalog_Model_Url::$_saveRewritesHistory (bool) on left side of ?? is not nullable.' - identifier: nullCoalesce.property - count: 1 - path: app/code/core/Mage/Catalog/Model/Url.php - - rawMessage: 'Call to an undefined method Mage_CatalogIndex_Model_Resource_Attribute::checkCount().' identifier: method.notFound @@ -2028,12 +1974,6 @@ parameters: count: 1 path: app/code/core/Mage/CatalogSearch/Helper/Data.php - - - rawMessage: 'Property Mage_CatalogSearch_Helper_Data::$_queryText (string) in isset() is not nullable.' - identifier: isset.property - count: 1 - path: app/code/core/Mage/CatalogSearch/Helper/Data.php - - rawMessage: 'Method Mage_CatalogSearch_Model_Advanced::getProductCollection() should return Mage_CatalogSearch_Model_Resource_Advanced_Collection but returns array|float|int|string|false|null.' identifier: return.type @@ -2160,12 +2100,6 @@ parameters: count: 1 path: app/code/core/Mage/Checkout/Model/Type/Onepage.php - - - rawMessage: 'Property Mage_Checkout_Model_Type_Onepage::$_quote (Mage_Sales_Model_Quote) on left side of ?? is not nullable.' - identifier: nullCoalesce.property - count: 1 - path: app/code/core/Mage/Checkout/Model/Type/Onepage.php - - rawMessage: 'Parameter #1 $qty of method Mage_Sales_Model_Quote_Item::setQty() expects float, array|string|null given.' identifier: argument.type @@ -2304,12 +2238,6 @@ parameters: count: 1 path: app/code/core/Mage/Core/Model/Abstract.php - - - rawMessage: 'Property Mage_Core_Model_Abstract::$_isObjectNew (bool) on left side of ?? is not nullable.' - identifier: nullCoalesce.property - count: 1 - path: app/code/core/Mage/Core/Model/Abstract.php - - rawMessage: 'Parameter #1 $group of method Mage_Core_Model_App::_getStoreByGroup() expects int, string given.' identifier: argument.type @@ -2376,18 +2304,6 @@ parameters: count: 1 path: app/code/core/Mage/Core/Model/Design/Config.php - - - rawMessage: 'Property Mage_Core_Model_Design_Fallback::$_store (Mage_Core_Model_Store) on left side of ?? is not nullable.' - identifier: nullCoalesce.property - count: 1 - path: app/code/core/Mage/Core/Model/Design/Fallback.php - - - - rawMessage: 'Property Mage_Core_Model_Design_Package::$_store (int|Mage_Core_Model_Store|string) on left side of ?? is not nullable.' - identifier: nullCoalesce.property - count: 1 - path: app/code/core/Mage/Core/Model/Design/Package.php - - rawMessage: 'Parameter #1 $policyCode of method Mage_Core_Model_Domainpolicy::_getDomainPolicyByCode() expects string, int given.' identifier: argument.type @@ -2526,30 +2442,12 @@ parameters: count: 1 path: app/code/core/Mage/Core/Model/Resource/Db/Collection/Abstract.php - - - rawMessage: Result of && is always false. - identifier: booleanAnd.alwaysFalse - count: 1 - path: app/code/core/Mage/Core/Model/Resource/Db/Collection/Abstract.php - - - - rawMessage: 'Variable $alias in isset() always exists and is always null.' - identifier: isset.variable - count: 1 - path: app/code/core/Mage/Core/Model/Resource/Db/Collection/Abstract.php - - rawMessage: Variable $alias might not be defined. identifier: variable.undefined count: 3 path: app/code/core/Mage/Core/Model/Resource/Db/Collection/Abstract.php - - - rawMessage: 'Variable $columnsToSelect in isset() always exists and is not nullable.' - identifier: isset.variable - count: 1 - path: app/code/core/Mage/Core/Model/Resource/Db/Collection/Abstract.php - - rawMessage: 'Parameter #1 $date of method Mage_Core_Model_Resource_Db_Collection_Abstract::formatDate() expects int|string|Zend_Date, true given.' identifier: argument.type @@ -3354,12 +3252,6 @@ parameters: count: 1 path: app/code/core/Mage/Install/Model/Installer/Db.php - - - rawMessage: 'Property Mage_Install_Model_Installer_Db_Abstract::$_connection (Varien_Db_Adapter_Interface) in isset() is not nullable.' - identifier: isset.property - count: 1 - path: app/code/core/Mage/Install/Model/Installer/Db/Abstract.php - - rawMessage: Binary operation "+" between non-falsy-string and 1 results in an error. identifier: binaryOp.invalid @@ -3834,12 +3726,6 @@ parameters: count: 1 path: app/code/core/Mage/Rule/Model/Condition/Abstract.php - - - rawMessage: 'Property Mage_Rule_Model_Condition_Abstract::$_inputType (string) on left side of ?? is not nullable.' - identifier: nullCoalesce.property - count: 1 - path: app/code/core/Mage/Rule/Model/Condition/Abstract.php - - rawMessage: 'Method Mage_Rule_Model_Condition_Abstract::loadArray() invoked with 2 parameters, 1 required.' identifier: arguments.count @@ -4068,12 +3954,6 @@ parameters: count: 1 path: app/code/core/Mage/Sales/Model/Quote/Address/Total/Shipping.php - - - rawMessage: 'Variable $addressQty in isset() always exists and is not nullable.' - identifier: isset.variable - count: 1 - path: app/code/core/Mage/Sales/Model/Quote/Address/Total/Shipping.php - - rawMessage: Instanceof between Mage_Sales_Model_Quote_Item_Option and Mage_Sales_Model_Quote_Item_Option will always evaluate to true. identifier: instanceof.alwaysTrue @@ -4428,12 +4308,6 @@ parameters: count: 1 path: app/code/core/Mage/Usa/Helper/Data.php - - - rawMessage: 'Property Mage_Shipping_Model_Carrier_Abstract::$_code (string) on left side of ?? is not nullable.' - identifier: nullCoalesce.property - count: 1 - path: app/code/core/Mage/Usa/Model/Shipping/Carrier/Abstract.php - - rawMessage: Access to an undefined property Mage_Usa_Model_Shipping_Carrier_Dhl::$_rawTrackRequest. identifier: property.notFound @@ -4620,6 +4494,12 @@ parameters: count: 1 path: app/code/core/Mage/Wishlist/Controller/Abstract.php + - + rawMessage: Variable $wishlist might not be defined. + identifier: variable.undefined + count: 1 + path: app/code/core/Mage/Wishlist/controllers/IndexController.php + - rawMessage: 'Call to an undefined method Mage_Core_Block_Abstract::_getUsers().' identifier: method.notFound diff --git a/app/code/core/Mage/Admin/Model/Resource/Roles.php b/app/code/core/Mage/Admin/Model/Resource/Roles.php index cef76d1fad1..a96070e1e9f 100644 --- a/app/code/core/Mage/Admin/Model/Resource/Roles.php +++ b/app/code/core/Mage/Admin/Model/Resource/Roles.php @@ -39,25 +39,27 @@ protected function _construct() /** * Process role before saving * + * @param Mage_Admin_Model_Roles $object + * @throws Mage_Core_Exception * @return $this */ - protected function _beforeSave(Mage_Core_Model_Abstract $role) + protected function _beforeSave(Mage_Core_Model_Abstract $object) { - if ($role->getId() == '') { - if ($role->getIdFieldName()) { - $role->unsetData($role->getIdFieldName()); + if ($object->getId() == '') { + if ($object->getIdFieldName()) { + $object->unsetData($object->getIdFieldName()); } else { - $role->unsetData('id'); + $object->unsetData('id'); } } - if ($role->getPid() > 0) { + if ($object->getPid() > 0) { $select = $this->_getReadAdapter()->select() ->from($this->getMainTable(), ['tree_level']) ->where("{$this->getIdFieldName()} = :pid"); $binds = [ - 'pid' => (int) $role->getPid(), + 'pid' => (int) $object->getPid(), ]; $treeLevel = $this->_getReadAdapter()->fetchOne($select, $binds); @@ -65,8 +67,8 @@ protected function _beforeSave(Mage_Core_Model_Abstract $role) $treeLevel = 0; } - $role->setTreeLevel($treeLevel + 1); - $role->setRoleName($role->getName()); + $object->setTreeLevel($treeLevel + 1); + $object->setRoleName($object->getName()); return $this; } @@ -74,11 +76,13 @@ protected function _beforeSave(Mage_Core_Model_Abstract $role) /** * Process role after saving * + * @param Mage_Admin_Model_Roles $object + * @throws Zend_Cache_Exception * @return $this */ - protected function _afterSave(Mage_Core_Model_Abstract $role) + protected function _afterSave(Mage_Core_Model_Abstract $object) { - $this->_updateRoleUsersAcl($role); + $this->_updateRoleUsersAcl($object); Mage::app()->getCache()->clean( Zend_Cache::CLEANING_MODE_MATCHING_TAG, [Mage_Adminhtml_Block_Page_Menu::CACHE_TAGS], @@ -89,19 +93,23 @@ protected function _afterSave(Mage_Core_Model_Abstract $role) /** * Process role after deleting * + * @param Mage_Admin_Model_Roles $object + * @throws Mage_Core_Exception * @return $this */ - protected function _afterDelete(Mage_Core_Model_Abstract $role) + protected function _afterDelete(Mage_Core_Model_Abstract $object) { $adapter = $this->_getWriteAdapter(); - $adapter->delete($this->getMainTable(), ['parent_id = ?' => (int) $role->getId()]); - $adapter->delete($this->_ruleTable, ['role_id = ?' => (int) $role->getId()]); + $adapter->delete($this->getMainTable(), ['parent_id = ?' => (int) $object->getId()]); + $adapter->delete($this->_ruleTable, ['role_id = ?' => (int) $object->getId()]); return $this; } /** * Get role users * + * @param Mage_Admin_Model_Roles $role + * @throws Mage_Core_Exception * @return array */ public function getRoleUsers(Mage_Admin_Model_Roles $role) @@ -118,6 +126,8 @@ public function getRoleUsers(Mage_Admin_Model_Roles $role) /** * Update role users * + * @throws Mage_Core_Exception + * @throws Zend_Db_Adapter_Exception * @return bool */ private function _updateRoleUsersAcl(Mage_Admin_Model_Roles $role) diff --git a/app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Main.php b/app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Main.php index 41693434244..e769314671b 100644 --- a/app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Main.php +++ b/app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Main.php @@ -249,17 +249,17 @@ protected function _prepareForm() ->addFieldDependence( $couponCodeFiled->getName(), $couponTypeFiled->getName(), - Mage_SalesRule_Model_Rule::COUPON_TYPE_SPECIFIC, + (string) Mage_SalesRule_Model_Rule::COUPON_TYPE_SPECIFIC, ) ->addFieldDependence( $autoGenerationCheckbox->getName(), $couponTypeFiled->getName(), - Mage_SalesRule_Model_Rule::COUPON_TYPE_SPECIFIC, + (string) Mage_SalesRule_Model_Rule::COUPON_TYPE_SPECIFIC, ) ->addFieldDependence( $usesPerCouponFiled->getName(), $couponTypeFiled->getName(), - Mage_SalesRule_Model_Rule::COUPON_TYPE_SPECIFIC, + (string) Mage_SalesRule_Model_Rule::COUPON_TYPE_SPECIFIC, )); Mage::dispatchEvent('adminhtml_promo_quote_edit_tab_main_prepare_form', ['form' => $form]); diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Grid/Abstract.php b/app/code/core/Mage/Adminhtml/Block/Report/Grid/Abstract.php index 605abd95a2c..9b3a215c010 100644 --- a/app/code/core/Mage/Adminhtml/Block/Report/Grid/Abstract.php +++ b/app/code/core/Mage/Adminhtml/Block/Report/Grid/Abstract.php @@ -36,7 +36,7 @@ public function __construct() $this->setFilterVisibility(false); $this->setPagerVisibility(false); $this->setUseAjax(false); - if (isset($this->_columnGroupBy)) { + if (!is_null($this->_columnGroupBy)) { $this->isColumnGrouped($this->_columnGroupBy, true); } diff --git a/app/code/core/Mage/Adminhtml/controllers/Permissions/BlockController.php b/app/code/core/Mage/Adminhtml/controllers/Permissions/BlockController.php index 5948221784e..153de4947be 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Permissions/BlockController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Permissions/BlockController.php @@ -59,6 +59,8 @@ public function newAction() /** * Edit action + * + * @throws Mage_Core_Exception */ public function editAction() { @@ -88,7 +90,7 @@ public function editAction() Mage::register('permissions_block', $model); - if (isset($id)) { + if ($id) { $breadcrumb = $this->__('Edit Block'); } else { $breadcrumb = $this->__('New Block'); @@ -106,6 +108,8 @@ public function editAction() /** * Save action * + * @throws Mage_Core_Exception + * @throws Zend_Validate_Exception * @return $this|void */ public function saveAction() @@ -144,9 +148,9 @@ public function saveAction() $this->_redirect('*/*/'); return; - } catch (Exception $e) { + } catch (Exception $exception) { // display error message - Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); + Mage::getSingleton('adminhtml/session')->addError($exception->getMessage()); // save data in session Mage::getSingleton('adminhtml/session')->setFormData($data); // redirect to edit form @@ -172,8 +176,8 @@ public function deleteAction() Mage::getSingleton('adminhtml/session')->addSuccess($this->__('Block has been deleted.')); $this->_redirect('*/*/'); return; - } catch (Exception $e) { - Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); + } catch (Exception $exception) { + Mage::getSingleton('adminhtml/session')->addError($exception->getMessage()); $this->_redirect('*/*/edit', ['block_id' => $id]); return; } diff --git a/app/code/core/Mage/Adminhtml/controllers/Permissions/VariableController.php b/app/code/core/Mage/Adminhtml/controllers/Permissions/VariableController.php index f0a92cf8cb6..eadf7eadd8c 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Permissions/VariableController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Permissions/VariableController.php @@ -58,6 +58,8 @@ public function newAction() /** * Edit action + * + * @throws Mage_Core_Exception */ public function editAction() { @@ -87,7 +89,7 @@ public function editAction() Mage::register('permissions_variable', $model); - if (isset($id)) { + if ($id) { $breadcrumb = $this->__('Edit Variable'); } else { $breadcrumb = $this->__('New Variable'); @@ -105,6 +107,8 @@ public function editAction() /** * Save action * + * @throws Mage_Core_Exception + * @throws Zend_Validate_Exception * @return $this|void */ public function saveAction() @@ -143,9 +147,9 @@ public function saveAction() $this->_redirect('*/*/'); return; - } catch (Exception $e) { + } catch (Exception $exception) { // display error message - Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); + Mage::getSingleton('adminhtml/session')->addError($exception->getMessage()); // save data in session Mage::getSingleton('adminhtml/session')->setFormData($data); // redirect to edit form @@ -171,8 +175,8 @@ public function deleteAction() Mage::getSingleton('adminhtml/session')->addSuccess($this->__('Variable has been deleted.')); $this->_redirect('*/*/'); return; - } catch (Exception $e) { - Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); + } catch (Exception $exception) { + Mage::getSingleton('adminhtml/session')->addError($exception->getMessage()); $this->_redirect('*/*/edit', ['variable_id' => $id]); return; } diff --git a/app/code/core/Mage/Adminhtml/controllers/System/Convert/ProfileController.php b/app/code/core/Mage/Adminhtml/controllers/System/Convert/ProfileController.php index 663cc47ad0b..26abf7e8278 100644 --- a/app/code/core/Mage/Adminhtml/controllers/System/Convert/ProfileController.php +++ b/app/code/core/Mage/Adminhtml/controllers/System/Convert/ProfileController.php @@ -20,6 +20,9 @@ class Mage_Adminhtml_System_Convert_ProfileController extends Mage_Adminhtml_Con */ public const ADMIN_RESOURCE = 'admin/system/convert/profiles'; + /** + * @throws Mage_Core_Exception + */ protected function _initProfile($idFieldName = 'id') { $this->_title($this->__('System')) @@ -98,6 +101,8 @@ public function gridAction() /** * Profile edit action + * + * @throws Mage_Core_Exception */ public function editAction() { @@ -139,6 +144,8 @@ public function newAction() /** * Delete profile action + * + * @throws Mage_Core_Exception */ public function deleteAction() { @@ -150,8 +157,8 @@ public function deleteAction() Mage::getSingleton('adminhtml/session')->addSuccess( Mage::helper('adminhtml')->__('The profile has been deleted.'), ); - } catch (Exception $e) { - Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); + } catch (Exception $exception) { + Mage::getSingleton('adminhtml/session')->addError($exception->getMessage()); } } @@ -160,6 +167,8 @@ public function deleteAction() /** * Save profile action + * + * @throws Mage_Core_Exception */ public function saveAction() { @@ -171,9 +180,7 @@ public function saveAction() $profile = Mage::registry('current_convert_profile'); // Prepare profile saving data - if (isset($data)) { - $profile->addData($data); - } + $profile->addData($data); try { $profile->save(); @@ -181,9 +188,9 @@ public function saveAction() Mage::getSingleton('adminhtml/session')->addSuccess( Mage::helper('adminhtml')->__('The profile has been saved.'), ); - } catch (Exception $e) { - Mage::logException($e); - Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); + } catch (Exception $exception) { + Mage::logException($exception); + Mage::getSingleton('adminhtml/session')->addError($exception->getMessage()); Mage::getSingleton('adminhtml/session')->setConvertProfileData($data); $this->getResponse()->setRedirect($this->getUrl('*/*/edit', ['id' => $profile->getId()])); return; @@ -202,6 +209,9 @@ public function saveAction() } } + /** + * @throws Mage_Core_Exception + */ public function runAction() { $this->_initProfile(); @@ -209,6 +219,9 @@ public function runAction() $this->renderLayout(); } + /** + * @throws Mage_Core_Exception + */ public function batchRunAction() { if ($this->getRequest()->isPost()) { @@ -231,7 +244,6 @@ public function batchRunAction() } $batchImportModel = $batchModel->getBatchImportModel(); - $importIds = $batchImportModel->getIdCollection(); /** @var Mage_Catalog_Model_Convert_Adapter_Product $adapter */ $adapter = Mage::getModel($batchModel->getAdapter()); @@ -249,8 +261,8 @@ public function batchRunAction() try { $importData = $batchImportModel->getBatchData(); $adapter->saveRow($importData); - } catch (Exception $e) { - $errors[] = $e->getMessage(); + } catch (Exception $exception) { + $errors[] = $exception->getMessage(); continue; } @@ -279,12 +291,16 @@ public function batchRunAction() } } + /** + * @throws Throwable + * @throws Mage_Core_Exception + */ public function batchFinishAction() { $batchId = $this->getRequest()->getParam('id'); if ($batchId) { - $batchModel = Mage::getModel('dataflow/batch')->load($batchId); /** @var Mage_Dataflow_Model_Batch $batchModel */ + $batchModel = Mage::getModel('dataflow/batch')->load($batchId); if ($batchModel->getId()) { $result = []; @@ -304,6 +320,8 @@ public function batchFinishAction() /** * Customer orders grid + * + * @throws Mage_Core_Exception */ public function historyAction() { diff --git a/app/code/core/Mage/Catalog/Model/Resource/Category.php b/app/code/core/Mage/Catalog/Model/Resource/Category.php index 46a2eb41fc1..47a418fad90 100644 --- a/app/code/core/Mage/Catalog/Model/Resource/Category.php +++ b/app/code/core/Mage/Catalog/Model/Resource/Category.php @@ -31,14 +31,14 @@ class Mage_Catalog_Model_Resource_Category extends Mage_Catalog_Model_Resource_A /** * Id of 'is_active' category attribute * - * @var int + * @var null|int */ protected $_isActiveAttributeId = null; /** * Store id * - * @var int + * @var null|int */ protected $_storeId = null; diff --git a/app/code/core/Mage/Catalog/Model/Resource/Config.php b/app/code/core/Mage/Catalog/Model/Resource/Config.php index 4882bcd6b5b..521eae47bd7 100644 --- a/app/code/core/Mage/Catalog/Model/Resource/Config.php +++ b/app/code/core/Mage/Catalog/Model/Resource/Config.php @@ -24,9 +24,9 @@ class Mage_Catalog_Model_Resource_Config extends Mage_Core_Model_Resource_Db_Abs /** * Store id * - * @var int + * @var null|int */ - protected $_storeId = null; + protected $_storeId = null; protected function _construct() { @@ -49,6 +49,7 @@ public function setStoreId($storeId) * Return store id. * If is not set return current app store * + * @throws Mage_Core_Model_Store_Exception * @return int */ public function getStoreId() @@ -59,6 +60,7 @@ public function getStoreId() /** * Retrieve catalog_product entity type id * + * @throws Mage_Core_Exception * @return int */ public function getEntityTypeId() @@ -73,6 +75,7 @@ public function getEntityTypeId() /** * Retrieve Product Attributes Used in Catalog Product listing * + * @throws Mage_Core_Exception * @return array */ public function getAttributesUsedInListing() @@ -100,6 +103,7 @@ public function getAttributesUsedInListing() /** * Retrieve Used Product Attributes for Catalog Product Listing Sort By * + * @throws Mage_Core_Exception * @return array */ public function getAttributesUsedForSortBy() diff --git a/app/code/core/Mage/Catalog/Model/Url.php b/app/code/core/Mage/Catalog/Model/Url.php index fb7c33671f8..dd96abb1a11 100644 --- a/app/code/core/Mage/Catalog/Model/Url.php +++ b/app/code/core/Mage/Catalog/Model/Url.php @@ -83,7 +83,7 @@ class Mage_Catalog_Model_Url extends Varien_Object /** * Flag to overwrite config settings for Catalog URL rewrites history maintenance * - * @var bool + * @var null|bool */ protected $_saveRewritesHistory = null; @@ -280,6 +280,7 @@ public function getShouldSaveRewritesHistory($storeId = null) * Used to make full reindexing of url rewrites * * @param int $storeId + * @throws Mage_Core_Exception * @return $this */ public function refreshRewrites($storeId = null) @@ -309,6 +310,7 @@ public function refreshRewrites($storeId = null) * * @param string $parentPath * @param bool $refreshProducts + * @throws Mage_Core_Exception * @return $this */ protected function _refreshCategoryRewrites(Varien_Object $category, $parentPath = null, $refreshProducts = true) @@ -418,6 +420,7 @@ protected function _refreshProductRewrite(Varien_Object $product, Varien_Object /** * Refresh products for category * + * @throws Mage_Core_Exception * @return $this */ protected function _refreshCategoryProductRewrites(Varien_Object $category) @@ -471,6 +474,7 @@ protected function _refreshCategoryProductRewrites(Varien_Object $category) * @param int $categoryId * @param null|int $storeId * @param bool $refreshProducts + * @throws Mage_Core_Exception * @return $this */ public function refreshCategoryRewrite($categoryId, $storeId = null, $refreshProducts = true) @@ -510,6 +514,7 @@ public function refreshCategoryRewrite($categoryId, $storeId = null, $refreshPro * * @param int $productId * @param null|int $storeId + * @throws Mage_Core_Exception * @return $this */ public function refreshProductRewrite($productId, $storeId = null) @@ -561,6 +566,7 @@ public function refreshProductRewrite($productId, $storeId = null) * Refresh all product rewrites for designated store * * @param null|int $storeId + * @throws Mage_Core_Exception * @return $this */ public function refreshProductRewrites($storeId) @@ -760,6 +766,7 @@ public function getCategoryUrlSuffix($storeId) * * @param Mage_Catalog_Model_Category|Varien_Object $category * @param string $parentPath + * @throws Mage_Core_Exception * @return string */ public function getCategoryRequestPath($category, $parentPath) @@ -823,6 +830,7 @@ protected function _deleteOldTargetPath($requestPath, $idPath, $storeId) * * @param Mage_Catalog_Model_Product|Varien_Object $product * @param Mage_Catalog_Model_Category|Varien_Object $category + * @throws Mage_Core_Exception * @return string */ public function getProductRequestPath($product, $category) diff --git a/app/code/core/Mage/CatalogSearch/Helper/Data.php b/app/code/core/Mage/CatalogSearch/Helper/Data.php index 8f67678e627..fd751d28112 100644 --- a/app/code/core/Mage/CatalogSearch/Helper/Data.php +++ b/app/code/core/Mage/CatalogSearch/Helper/Data.php @@ -106,7 +106,7 @@ public function isMinQueryLength() */ public function getQueryText() { - if (!isset($this->_queryText)) { + if (is_null($this->_queryText)) { $this->_queryText = $this->_getRequest()->getParam($this->getQueryParamName()); if ($this->_queryText === null) { $this->_queryText = ''; diff --git a/app/code/core/Mage/Checkout/Model/Type/Onepage.php b/app/code/core/Mage/Checkout/Model/Type/Onepage.php index c259c7ff583..dffc6fe9f5d 100644 --- a/app/code/core/Mage/Checkout/Model/Type/Onepage.php +++ b/app/code/core/Mage/Checkout/Model/Type/Onepage.php @@ -41,7 +41,7 @@ class Mage_Checkout_Model_Type_Onepage protected $_checkoutSession; /** - * @var Mage_Sales_Model_Quote + * @var null|Mage_Sales_Model_Quote */ protected $_quote = null; diff --git a/app/code/core/Mage/Core/Model/Abstract.php b/app/code/core/Mage/Core/Model/Abstract.php index 5850534ad70..0adcba83a29 100644 --- a/app/code/core/Mage/Core/Model/Abstract.php +++ b/app/code/core/Mage/Core/Model/Abstract.php @@ -87,7 +87,7 @@ abstract class Mage_Core_Model_Abstract extends Varien_Object /** * Flag which allow detect object state: is it new object (without id) or existing one (with id) * - * @var bool + * @var null|bool */ protected $_isObjectNew = null; @@ -169,6 +169,7 @@ protected function _setResourceModel($resourceName, $resourceCollectionName = nu /** * Get resource instance * + * @throws Mage_Core_Exception * @return Mage_Core_Model_Resource_Db_Abstract|object */ protected function _getResource() @@ -188,6 +189,7 @@ protected function _getResource() /** * Retrieve identifier field name for model * + * @throws Mage_Core_Exception * @return string */ public function getIdFieldName() @@ -203,6 +205,7 @@ public function getIdFieldName() /** * Retrieve model object identifier * + * @throws Mage_Core_Exception * @return null|int|string */ public function getId() @@ -219,6 +222,7 @@ public function getId() * Declare model object identifier value * * @param mixed $id + * @throws Mage_Core_Exception * @return $this */ public function setId($id) @@ -276,6 +280,8 @@ public function getCollection() * * @param null|int|string $id * @param null|string $field + * @throws Mage_Core_Exception + * @throws Exception * @return $this */ public function load($id, $field = null) @@ -396,6 +402,7 @@ public function save() /** * Callback function which called after transaction commit in resource model * + * @throws Mage_Core_Exception * @return $this */ public function afterCommitCallback() @@ -413,6 +420,7 @@ public function afterCommitCallback() * created in this transaction * * @param bool $flag + * @throws Mage_Core_Exception * @return bool */ public function isObjectNew($flag = null) @@ -427,6 +435,7 @@ public function isObjectNew($flag = null) /** * Processing object before save data * + * @throws Mage_Core_Exception * @return $this */ protected function _beforeSave() @@ -444,6 +453,7 @@ protected function _beforeSave() * Get list of cache tags applied to model object. * Return false if cache tags are not supported by model * + * @throws Mage_Core_Exception * @return array|false */ public function getCacheTags() @@ -472,6 +482,7 @@ public function getCacheTags() /** * Get cache tags associated with object id * + * @throws Mage_Core_Exception * @return array|false */ public function getCacheIdTags() @@ -494,6 +505,7 @@ public function getCacheIdTags() /** * Remove model object related cache * + * @throws Mage_Core_Exception * @return $this */ public function cleanModelCache() @@ -545,6 +557,7 @@ public function delete() /** * Processing object before delete data * + * @throws Mage_Core_Exception * @return $this */ protected function _beforeDelete() @@ -598,6 +611,7 @@ protected function _afterDeleteCommit() /** * Retrieve model resource * + * @throws Mage_Core_Exception * @return Mage_Core_Model_Resource_Db_Abstract */ public function getResource() diff --git a/app/code/core/Mage/Core/Model/Design/Fallback.php b/app/code/core/Mage/Core/Model/Design/Fallback.php index 16404d72a54..ae0daa10bd5 100644 --- a/app/code/core/Mage/Core/Model/Design/Fallback.php +++ b/app/code/core/Mage/Core/Model/Design/Fallback.php @@ -15,12 +15,12 @@ class Mage_Core_Model_Design_Fallback { /** - * @var Mage_Core_Model_Design_Config + * @var null|Mage_Core_Model_Design_Config */ protected $_config = null; /** - * @var Mage_Core_Model_Store + * @var null|Mage_Core_Model_Store */ protected $_store = null; @@ -46,6 +46,7 @@ public function __construct(array $params = []) /** * Retrieve store * + * @throws Mage_Core_Model_Store_Exception * @return Mage_Core_Model_Store */ public function getStore() @@ -55,6 +56,7 @@ public function getStore() /** * @param int|Mage_Core_Model_Store|string $store + * @throws Mage_Core_Model_Store_Exception * @return $this */ public function setStore($store) @@ -74,6 +76,7 @@ public function setStore($store) * @param string $area * @param string $package * @param string $theme + * @throws Mage_Core_Exception * @return array */ public function getFallbackScheme($area, $package, $theme) @@ -158,6 +161,7 @@ protected function _checkVisited($area, $package, $theme) /** * Get fallback scheme when inheritance is not defined (backward compatibility) * + * @throws Mage_Core_Model_Store_Exception * @return array */ protected function _getLegacyFallbackScheme() @@ -171,6 +175,8 @@ protected function _getLegacyFallbackScheme() /** * Default theme getter + * + * @throws Mage_Core_Model_Store_Exception * @return string */ protected function _getFallbackTheme() diff --git a/app/code/core/Mage/Core/Model/Design/Package.php b/app/code/core/Mage/Core/Model/Design/Package.php index 1547b25f36a..84b32e18f69 100644 --- a/app/code/core/Mage/Core/Model/Design/Package.php +++ b/app/code/core/Mage/Core/Model/Design/Package.php @@ -34,7 +34,7 @@ class Mage_Core_Model_Design_Package /** * Current Store for generation ofr base_dir and base_url * - * @var int|Mage_Core_Model_Store|string + * @var null|int|Mage_Core_Model_Store|string */ protected $_store = null; diff --git a/app/code/core/Mage/Core/Model/Resource/Db/Collection/Abstract.php b/app/code/core/Mage/Core/Model/Resource/Db/Collection/Abstract.php index 8d1b7f22c39..94fdf5562f6 100644 --- a/app/code/core/Mage/Core/Model/Resource/Db/Collection/Abstract.php +++ b/app/code/core/Mage/Core/Model/Resource/Db/Collection/Abstract.php @@ -220,16 +220,7 @@ protected function _initSelectFields() $alias = null; } - if ($field instanceof Zend_Db_Expr) { - $column = $field->__toString(); - } else { - $column = $field; - } - - if (($alias !== null && in_array($alias, $columnsToSelect)) - // If field already joined from another table - || ($alias === null && isset($alias, $columnsToSelect)) - ) { + if ($alias !== null && in_array($alias, $columnsToSelect)) { continue; } diff --git a/app/code/core/Mage/Install/Model/Installer/Db/Abstract.php b/app/code/core/Mage/Install/Model/Installer/Db/Abstract.php index 462ece734a9..7186fe4d9b0 100644 --- a/app/code/core/Mage/Install/Model/Installer/Db/Abstract.php +++ b/app/code/core/Mage/Install/Model/Installer/Db/Abstract.php @@ -103,7 +103,7 @@ public function supportEngine() */ protected function _getConnection() { - if (!isset($this->_connection)) { + if (is_null($this->_connection)) { $resource = Mage::getSingleton('core/resource'); $connection = $resource->createConnection('install', $this->getType(), $this->getConnectionData()); $this->_connection = $connection; diff --git a/app/code/core/Mage/Rule/Model/Condition/Abstract.php b/app/code/core/Mage/Rule/Model/Condition/Abstract.php index 43d465d02a7..ae41d666a20 100644 --- a/app/code/core/Mage/Rule/Model/Condition/Abstract.php +++ b/app/code/core/Mage/Rule/Model/Condition/Abstract.php @@ -52,19 +52,21 @@ abstract class Mage_Rule_Model_Condition_Abstract extends Varien_Object implemen /** * Defines which operators will be available for this condition * - * @var string + * @var null|string */ protected $_inputType = null; /** * Default values for possible operator options - * @var array + * + * @var null|array */ protected $_defaultOperatorOptions = null; /** * Default combinations of operator options, depending on input type - * @var array + * + * @var null|array */ protected $_defaultOperatorInputByType = null; diff --git a/app/code/core/Mage/Sales/Model/Quote/Address/Total/Shipping.php b/app/code/core/Mage/Sales/Model/Quote/Address/Total/Shipping.php index 2c19e24d8d0..aca2a36b33c 100644 --- a/app/code/core/Mage/Sales/Model/Quote/Address/Total/Shipping.php +++ b/app/code/core/Mage/Sales/Model/Quote/Address/Total/Shipping.php @@ -26,7 +26,6 @@ public function collect(Mage_Sales_Model_Quote_Address $address) { parent::collect($address); - $oldWeight = $address->getWeight(); $address->setWeight(0); $address->setFreeMethodWeight(0); $this->_setAmount(0) @@ -37,9 +36,7 @@ public function collect(Mage_Sales_Model_Quote_Address $address) return $this; } - $method = $address->getShippingMethod(); - $freeAddress = $address->getFreeShipping(); - + $freeAddress = $address->getFreeShipping(); $addressWeight = $address->getWeight(); $freeMethodWeight = $address->getFreeMethodWeight(); @@ -131,10 +128,7 @@ public function collect(Mage_Sales_Model_Quote_Address $address) } } - if (isset($addressQty)) { - $address->setItemQty($addressQty); - } - + $address->setItemQty($addressQty); $address->setWeight($addressWeight); $address->setFreeMethodWeight($freeMethodWeight); diff --git a/app/code/core/Mage/Shipping/Model/Carrier/Abstract.php b/app/code/core/Mage/Shipping/Model/Carrier/Abstract.php index 2f35d20daa7..d01911e3688 100644 --- a/app/code/core/Mage/Shipping/Model/Carrier/Abstract.php +++ b/app/code/core/Mage/Shipping/Model/Carrier/Abstract.php @@ -24,7 +24,7 @@ abstract class Mage_Shipping_Model_Carrier_Abstract extends Varien_Object /** * Carrier's code * - * @var string + * @var null|string */ protected $_code; diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Abstract.php b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Abstract.php index c931f2880db..9605d4d5d01 100644 --- a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Abstract.php +++ b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Abstract.php @@ -46,7 +46,7 @@ public function setActiveFlag($code = 'active') /** * Return code of carrier * - * @return string + * @return null|string */ public function getCarrierCode() { @@ -55,8 +55,6 @@ public function getCarrierCode() public function getTrackingInfo($tracking) { - $info = []; - $result = $this->getTracking($tracking); if ($result instanceof Mage_Shipping_Model_Tracking_Result) { From 96b3fcc8f12c8843f2157e42e82dac812d884206 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Fri, 7 Nov 2025 05:45:41 +0100 Subject: [PATCH 3/3] rector --- app/code/core/Mage/Admin/Model/Resource/Roles.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/code/core/Mage/Admin/Model/Resource/Roles.php b/app/code/core/Mage/Admin/Model/Resource/Roles.php index a96070e1e9f..5f47586da96 100644 --- a/app/code/core/Mage/Admin/Model/Resource/Roles.php +++ b/app/code/core/Mage/Admin/Model/Resource/Roles.php @@ -108,7 +108,6 @@ protected function _afterDelete(Mage_Core_Model_Abstract $object) /** * Get role users * - * @param Mage_Admin_Model_Roles $role * @throws Mage_Core_Exception * @return array */