diff --git a/.phpstan.dist.baseline.neon b/.phpstan.dist.baseline.neon index f1663f0ea35..84dddd48cf6 100644 --- a/.phpstan.dist.baseline.neon +++ b/.phpstan.dist.baseline.neon @@ -4764,12 +4764,6 @@ parameters: count: 1 path: app/code/core/Mage/Index/Model/Lock/Storage/Db.php - - - message: '#^Property Mage_Index_Model_Lock_Storage_Db\:\:\$_helper \(Mage_Index_Model_Resource_Helper_Mysql4\) does not accept Mage_Core_Model_Resource_Helper_Abstract\.$#' - identifier: assign.propertyType - count: 1 - path: app/code/core/Mage/Index/Model/Lock/Storage/Db.php - - message: '#^Call to function is_array\(\) with '''' will always evaluate to false\.$#' identifier: function.impossibleType @@ -7128,54 +7122,6 @@ parameters: count: 3 path: app/design/adminhtml/default/default/template/api2/role/users_grid_js.phtml - - - message: '#^Call to protected method _isSelected\(\) of class Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option\.$#' - identifier: method.protected - count: 1 - path: app/design/adminhtml/default/default/template/bundle/product/composite/fieldset/options/type/checkbox.phtml - - - - message: '#^Call to protected method _isSelected\(\) of class Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option\.$#' - identifier: method.protected - count: 1 - path: app/design/adminhtml/default/default/template/bundle/product/composite/fieldset/options/type/multi.phtml - - - - message: '#^Call to protected method _getDefaultValues\(\) of class Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option\.$#' - identifier: method.protected - count: 1 - path: app/design/adminhtml/default/default/template/bundle/product/composite/fieldset/options/type/radio.phtml - - - - message: '#^Call to protected method _isSelected\(\) of class Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option\.$#' - identifier: method.protected - count: 1 - path: app/design/adminhtml/default/default/template/bundle/product/composite/fieldset/options/type/radio.phtml - - - - message: '#^Call to protected method _showSingle\(\) of class Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option\.$#' - identifier: method.protected - count: 1 - path: app/design/adminhtml/default/default/template/bundle/product/composite/fieldset/options/type/radio.phtml - - - - message: '#^Call to protected method _getDefaultValues\(\) of class Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option\.$#' - identifier: method.protected - count: 1 - path: app/design/adminhtml/default/default/template/bundle/product/composite/fieldset/options/type/select.phtml - - - - message: '#^Call to protected method _isSelected\(\) of class Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option\.$#' - identifier: method.protected - count: 1 - path: app/design/adminhtml/default/default/template/bundle/product/composite/fieldset/options/type/select.phtml - - - - message: '#^Call to protected method _showSingle\(\) of class Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option\.$#' - identifier: method.protected - count: 1 - path: app/design/adminhtml/default/default/template/bundle/product/composite/fieldset/options/type/select.phtml - - message: '#^Variable \$this might not be defined\.$#' identifier: variable.undefined @@ -7218,24 +7164,12 @@ parameters: count: 2 path: app/design/adminhtml/default/default/template/catalog/product/attribute/new/created.phtml - - - message: '#^Call to protected method _getHeader\(\) of class Mage_Adminhtml_Block_Catalog_Product_Attribute_Set_Main\.$#' - identifier: method.protected - count: 1 - path: app/design/adminhtml/default/default/template/catalog/product/attribute/set/main.phtml - - message: '#^Variable \$this might not be defined\.$#' identifier: variable.undefined count: 5 path: app/design/adminhtml/default/default/template/catalog/product/attribute/set/toolbar/add.phtml - - - message: '#^Call to protected method _getHeader\(\) of class Mage_Adminhtml_Block_Catalog_Product_Attribute_Set_Toolbar_Main\.$#' - identifier: method.protected - count: 1 - path: app/design/adminhtml/default/default/template/catalog/product/attribute/set/toolbar/main.phtml - - message: '#^Access to an undefined property Mage_Catalog_Model_Product_Option\:\:\$decoratedIsLast\.$#' identifier: property.notFound @@ -7590,12 +7524,6 @@ parameters: count: 1 path: app/design/adminhtml/default/default/template/permissions/role_users_grid_js.phtml - - - message: '#^Call to protected method _getGridHtml\(\) of class Mage_Adminhtml_Block_Permissions_Tab_Rolesusers\.$#' - identifier: method.protected - count: 1 - path: app/design/adminhtml/default/default/template/permissions/rolesusers.phtml - - message: '#^Call to an undefined method Mage_Core_Block_Abstract\:\:_getSelectedRoles\(\)\.$#' identifier: method.notFound @@ -8124,54 +8052,6 @@ parameters: count: 9 path: app/design/frontend/base/default/template/bundle/catalog/product/view/type/bundle.phtml - - - message: '#^Call to protected method _isSelected\(\) of class Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option\.$#' - identifier: method.protected - count: 1 - path: app/design/frontend/base/default/template/bundle/catalog/product/view/type/bundle/option/checkbox.phtml - - - - message: '#^Call to protected method _isSelected\(\) of class Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option\.$#' - identifier: method.protected - count: 1 - path: app/design/frontend/base/default/template/bundle/catalog/product/view/type/bundle/option/multi.phtml - - - - message: '#^Call to protected method _getDefaultValues\(\) of class Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option\.$#' - identifier: method.protected - count: 1 - path: app/design/frontend/base/default/template/bundle/catalog/product/view/type/bundle/option/radio.phtml - - - - message: '#^Call to protected method _isSelected\(\) of class Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option\.$#' - identifier: method.protected - count: 2 - path: app/design/frontend/base/default/template/bundle/catalog/product/view/type/bundle/option/radio.phtml - - - - message: '#^Call to protected method _showSingle\(\) of class Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option\.$#' - identifier: method.protected - count: 1 - path: app/design/frontend/base/default/template/bundle/catalog/product/view/type/bundle/option/radio.phtml - - - - message: '#^Call to protected method _getDefaultValues\(\) of class Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option\.$#' - identifier: method.protected - count: 1 - path: app/design/frontend/base/default/template/bundle/catalog/product/view/type/bundle/option/select.phtml - - - - message: '#^Call to protected method _isSelected\(\) of class Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option\.$#' - identifier: method.protected - count: 2 - path: app/design/frontend/base/default/template/bundle/catalog/product/view/type/bundle/option/select.phtml - - - - message: '#^Call to protected method _showSingle\(\) of class Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option\.$#' - identifier: method.protected - count: 1 - path: app/design/frontend/base/default/template/bundle/catalog/product/view/type/bundle/option/select.phtml - - message: '#^Unreachable statement \- code above always terminates\.$#' identifier: deadCode.unreachable @@ -8316,12 +8196,6 @@ parameters: count: 1 path: app/design/frontend/base/default/template/catalog/product/price.phtml - - - message: '#^Call to protected method _isSecure\(\) of class Mage_Core_Block_Abstract\.$#' - identifier: method.protected - count: 1 - path: app/design/frontend/base/default/template/catalog/product/view.phtml - - message: '#^Variable \$this might not be defined\.$#' identifier: variable.undefined @@ -8568,12 +8442,6 @@ parameters: count: 10 path: app/design/frontend/base/default/template/checkout/multishipping/success.phtml - - - message: '#^Cannot call method isEnabled\(\) on Mage_Core_Block_Abstract\|false\.$#' - identifier: method.nonObject - count: 5 - path: app/design/frontend/base/default/template/checkout/onepage/billing.phtml - - message: '#^Variable \$this might not be defined\.$#' identifier: variable.undefined @@ -8784,24 +8652,12 @@ parameters: count: 13 path: app/design/frontend/base/default/template/customer/form/confirmation.phtml - - - message: '#^Cannot call method isEnabled\(\) on Mage_Core_Block_Abstract\|false\.$#' - identifier: method.nonObject - count: 3 - path: app/design/frontend/base/default/template/customer/form/edit.phtml - - message: '#^Variable \$this might not be defined\.$#' identifier: variable.undefined count: 16 path: app/design/frontend/base/default/template/customer/form/newsletter.phtml - - - message: '#^Cannot call method isEnabled\(\) on Mage_Core_Block_Abstract\|false\.$#' - identifier: method.nonObject - count: 3 - path: app/design/frontend/base/default/template/customer/form/register.phtml - - message: '#^Variable \$this might not be defined\.$#' identifier: variable.undefined @@ -8964,18 +8820,6 @@ parameters: count: 145 path: app/design/frontend/base/default/template/giftmessage/inline.phtml - - - message: '#^Call to protected method _getEnhancedEcommerceDataForAnalytics4\(\) of class Mage_GoogleAnalytics_Block_Ga\.$#' - identifier: method.protected - count: 1 - path: app/design/frontend/base/default/template/googleanalytics/ga.phtml - - - - message: '#^Call to protected method _getPageTrackingCode\(\) of class Mage_GoogleAnalytics_Block_Ga\.$#' - identifier: method.protected - count: 1 - path: app/design/frontend/base/default/template/googleanalytics/ga.phtml - - message: '#^Variable \$crumbs might not be defined\.$#' identifier: variable.undefined @@ -9150,12 +8994,6 @@ parameters: count: 1 path: app/design/frontend/base/default/template/paypal/payment/redirect.phtml - - - message: '#^Cannot call method isEnabled\(\) on Mage_Core_Block_Abstract\|false\.$#' - identifier: method.nonObject - count: 4 - path: app/design/frontend/base/default/template/persistent/checkout/onepage/billing.phtml - - message: '#^If condition is always true\.$#' identifier: if.alwaysTrue @@ -9168,12 +9006,6 @@ parameters: count: 1 path: app/design/frontend/base/default/template/persistent/checkout/onepage/login.phtml - - - message: '#^Cannot call method isEnabled\(\) on Mage_Core_Block_Abstract\|false\.$#' - identifier: method.nonObject - count: 3 - path: app/design/frontend/base/default/template/persistent/customer/form/register.phtml - - message: '#^Variable \$this might not be defined\.$#' identifier: variable.undefined @@ -9462,24 +9294,6 @@ parameters: count: 6 path: app/design/frontend/rwd/default/template/bundle/catalog/product/view/type/bundle/availability.phtml - - - message: '#^Call to protected method _getDefaultValues\(\) of class Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option\.$#' - identifier: method.protected - count: 1 - path: app/design/frontend/rwd/default/template/bundle/catalog/product/view/type/bundle/option/select.phtml - - - - message: '#^Call to protected method _isSelected\(\) of class Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option\.$#' - identifier: method.protected - count: 2 - path: app/design/frontend/rwd/default/template/bundle/catalog/product/view/type/bundle/option/select.phtml - - - - message: '#^Call to protected method _showSingle\(\) of class Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option\.$#' - identifier: method.protected - count: 1 - path: app/design/frontend/rwd/default/template/bundle/catalog/product/view/type/bundle/option/select.phtml - - message: '#^Cannot call method setFilter\(\) on class\-string\|object\.$#' identifier: method.nonObject @@ -9516,12 +9330,6 @@ parameters: count: 1 path: app/design/frontend/rwd/default/template/catalog/product/price.phtml - - - message: '#^Call to protected method _isSecure\(\) of class Mage_Core_Block_Abstract\.$#' - identifier: method.protected - count: 1 - path: app/design/frontend/rwd/default/template/catalog/product/view.phtml - - message: '#^Variable \$this might not be defined\.$#' identifier: variable.undefined @@ -9726,12 +9534,6 @@ parameters: count: 13 path: app/design/frontend/rwd/default/template/customer/form/confirmation.phtml - - - message: '#^Cannot call method isEnabled\(\) on Mage_Core_Block_Abstract\|false\.$#' - identifier: method.nonObject - count: 3 - path: app/design/frontend/rwd/default/template/customer/form/edit.phtml - - message: '#^Variable \$this might not be defined\.$#' identifier: variable.undefined @@ -9858,12 +9660,6 @@ parameters: count: 70 path: app/design/frontend/rwd/default/template/paypal/express/review/address.phtml - - - message: '#^Cannot call method isEnabled\(\) on Mage_Core_Block_Abstract\|false\.$#' - identifier: method.nonObject - count: 4 - path: app/design/frontend/rwd/default/template/persistent/checkout/onepage/billing.phtml - - message: '#^If condition is always true\.$#' identifier: if.alwaysTrue @@ -9876,12 +9672,6 @@ parameters: count: 1 path: app/design/frontend/rwd/default/template/persistent/checkout/onepage/login.phtml - - - message: '#^Cannot call method isEnabled\(\) on Mage_Core_Block_Abstract\|false\.$#' - identifier: method.nonObject - count: 3 - path: app/design/frontend/rwd/default/template/persistent/customer/form/register.phtml - - message: '#^Variable \$this might not be defined\.$#' identifier: variable.undefined diff --git a/.phpstan.dist.neon b/.phpstan.dist.neon index ae4e2d07669..18b037a8d58 100644 --- a/.phpstan.dist.neon +++ b/.phpstan.dist.neon @@ -68,6 +68,11 @@ parameters: # Instantiated class not found - lib/Varien/Image/Adapter.php + + # TMP exclude: test plugin + - app/code/core/Mage/ConfigurableSwatches/Helper/Mediafallback.php + - app/code/core/Mage/Eav/Model/Adminhtml/System/Config/Source/Inputtype.php + - tests/unit/Mage/Adminhtml/Block/Widget/GridTest.php tmpDir: .phpstan.cache level: 5 checkFunctionNameCase: true diff --git a/app/Mage.php b/app/Mage.php index ec7df4782f2..b67f2beced9 100644 --- a/app/Mage.php +++ b/app/Mage.php @@ -14,8 +14,9 @@ * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -define('DS', DIRECTORY_SEPARATOR); -define('PS', PATH_SEPARATOR); +defined('DS') || define('DS', DIRECTORY_SEPARATOR); +defined('PS') || define('PS', PATH_SEPARATOR); + define('BP', dirname(__DIR__)); Mage::register('original_include_path', get_include_path()); @@ -278,7 +279,7 @@ public static function register($key, $value, $graceful = false) if ($graceful) { return; } - self::throwException('Mage registry key "' . $key . '" already exists'); + self::throwException("Mage registry key $key already exists"); } self::$_registry[$key] = $value; } @@ -331,7 +332,7 @@ public static function setRoot($appRoot = '') if (is_dir($appRoot) && is_readable($appRoot)) { self::$_appRoot = $appRoot; } else { - self::throwException($appRoot . ' is not a directory or not readable by this user'); + self::throwException("$appRoot is not a directory or not readable by this user"); } } @@ -490,17 +491,21 @@ public static function getConfig() * Add observer to events object * * @param string $eventName - * @param callback $callback + * @param callable $callback * @param array $data * @param string $observerName - * @param string $observerClass + * @param class-string|'' $observerClass * @return Varien_Event_Collection + * @throws Mage_Core_Exception */ public static function addObserver($eventName, $callback, $data = [], $observerName = '', $observerClass = '') { if ($observerClass == '') { $observerClass = 'Varien_Event_Observer'; } + if (!class_exists($observerClass)) { + self::throwException("Invalid observer class: $observerClass"); + } $observer = new $observerClass(); $observer->setName($observerName)->addData($data)->setEventName($eventName)->setCallback($callback); return self::getEvents()->addObserver($observer); @@ -524,128 +529,157 @@ public static function dispatchEvent($name, array $data = []) } /** - * Retrieve model object + * Retrieve helper singleton by alias + * + * ```php + * $helper = Mage::helper('core'); // Mage_Core_Helper_Data + * $helper = Mage::helper('core/url'); // Mage_Core_Helper_Url + * ``` * - * @link Mage_Core_Model_Config::getModelInstance - * @param string $modelClass - * @param array|string|object $arguments - * @return Mage_Core_Model_Abstract|false + * @param string $helperAlias + * @return Mage_Core_Helper_Abstract|false */ - public static function getModel($modelClass = '', $arguments = []) + public static function helper($helperAlias) { - return self::getConfig()->getModelInstance($modelClass, $arguments); + $registryKey = '_helper/' . $helperAlias; + if (!isset(self::$_registry[$registryKey])) { + self::register($registryKey, self::getConfig()->getHelperInstance($helperAlias)); + } + return self::$_registry[$registryKey]; } /** - * Retrieve model object singleton + * Retrieve model instance by alias * - * @param string $modelClass - * @return Mage_Core_Model_Abstract|false + * ```php + * $model = Mage::getModel('core/store'); // Mage_Core_Model_Store + * ``` + * + * @param string $modelAlias + * @param array|string|object $arguments + * @return Mage_Core_Model_Abstract|false */ - public static function getSingleton($modelClass = '', array $arguments = []) + public static function getModel($modelAlias, $arguments = []) { - $registryKey = '_singleton/' . $modelClass; - if (!isset(self::$_registry[$registryKey])) { - self::register($registryKey, self::getModel($modelClass, $arguments)); - } - return self::$_registry[$registryKey]; + return self::getConfig()->getModelInstance($modelAlias, $arguments); } /** - * Retrieve object of resource model + * Retrieve model singleton by alias * - * @param string $modelClass - * @param array $arguments - * @return Mage_Core_Model_Resource_Db_Collection_Abstract|false + * ```php + * $model = Mage::getModel('core/session'); // Mage_Core_Model_Session + * ``` + * + * @param string $modelAlias + * @return Mage_Core_Model_Abstract|false */ - public static function getResourceModel($modelClass, $arguments = []) + public static function getSingleton($modelAlias, array $arguments = []) { - return self::getConfig()->getResourceModelInstance($modelClass, $arguments); + $registryKey = '_singleton/' . $modelAlias; + if (!isset(self::$_registry[$registryKey])) { + self::register($registryKey, self::getModel($modelAlias, $arguments)); + } + return self::$_registry[$registryKey]; } /** - * Retrieve Controller instance by ClassName + * Retrieve resource model by alias * - * @param string $class - * @param Mage_Core_Controller_Request_Http $request - * @param Mage_Core_Controller_Response_Http $response - * @return Mage_Core_Controller_Front_Action + * ```php + * $model = Mage::getResourceModel('core/store_collection'); // Mage_Core_Model_Resource_Store_Collection + * ``` + * + * @param string $modelAlias + * @param array $arguments + * @return Mage_Core_Model_Resource_Db_Collection_Abstract|false */ - public static function getControllerInstance($class, $request, $response, array $invokeArgs = []) + public static function getResourceModel($modelAlias, $arguments = []) { - return new $class($request, $response, $invokeArgs); + return self::getConfig()->getResourceModelInstance($modelAlias, $arguments); } /** - * Retrieve resource model object singleton + * Retrieve resource model singleton by alias + * + * ```php + * $model = Mage::getResourceSingleton('core/session'); // Mage_Core_Model_Resource_Session + * ``` * - * @param string $modelClass - * @return object + * @param string $modelAlias + * @return Mage_Core_Model_Resource_Db_Collection_Abstract|false */ - public static function getResourceSingleton($modelClass = '', array $arguments = []) + public static function getResourceSingleton($modelAlias, array $arguments = []) { - $registryKey = '_resource_singleton/' . $modelClass; + $registryKey = '_resource_singleton/' . $modelAlias; if (!isset(self::$_registry[$registryKey])) { - self::register($registryKey, self::getResourceModel($modelClass, $arguments)); + self::register($registryKey, self::getResourceModel($modelAlias, $arguments)); } return self::$_registry[$registryKey]; } /** - * Retrieve block object + * Retrieve resource helper model singleton * - * @param string $type - * @return Mage_Core_Block_Abstract|false + * ```php + * $model = Mage::getResourceHelper('core'); // Mage_Core_Model_Resource_Helper_Mysql4 + * ``` + * + * @param string $moduleAlias + * @return Mage_Core_Model_Resource_Helper_Abstract|false */ - public static function getBlockSingleton($type) + public static function getResourceHelper($moduleAlias) { - $action = self::app()->getFrontController()->getAction(); - return $action ? $action->getLayout()->getBlockSingleton($type) : false; + $registryKey = '_resource_helper/' . $moduleAlias; + if (!isset(self::$_registry[$registryKey])) { + self::register($registryKey, self::getConfig()->getResourceHelperInstance($moduleAlias)); + } + return self::$_registry[$registryKey]; } /** - * Retrieve helper object + * Retrieve Controller instance by ClassName * - * @param string $name the helper name - * @return Mage_Core_Helper_Abstract + * @param class-string $class + * @param Mage_Core_Controller_Request_Http $request + * @param Mage_Core_Controller_Response_Http $response + * @return Mage_Core_Controller_Front_Action + * @throws Mage_Core_Exception */ - public static function helper($name) + public static function getControllerInstance($class, $request, $response, array $invokeArgs = []) { - $registryKey = '_helper/' . $name; - if (!isset(self::$_registry[$registryKey])) { - $helperClass = self::getConfig()->getHelperClassName($name); - self::register($registryKey, new $helperClass()); + if (!class_exists($class)) { + self::throwException("Invalid controller class: $class"); } - return self::$_registry[$registryKey]; + return new $class($request, $response, $invokeArgs); } /** - * Retrieve resource helper object + * Retrieve block object * - * @param string $moduleName - * @return Mage_Core_Model_Resource_Helper_Abstract + * @param string $type + * @return Mage_Core_Block_Abstract|false */ - public static function getResourceHelper($moduleName) + public static function getBlockSingleton($type) { - $registryKey = '_resource_helper/' . $moduleName; - if (!isset(self::$_registry[$registryKey])) { - $helperClass = self::getConfig()->getResourceHelper($moduleName); - self::register($registryKey, $helperClass); - } - return self::$_registry[$registryKey]; + $action = self::app()->getFrontController()->getAction(); + return $action ? $action->getLayout()->getBlockSingleton($type) : false; } /** * Return new exception by module to be thrown * - * @param string $module + * @param string $moduleName * @param string $message * @param integer $code * @return Mage_Core_Exception */ - public static function exception($module = 'Mage_Core', $message = '', $code = 0) + public static function exception($moduleName = 'Mage_Core', $message = '', $code = 0) { - $className = $module . '_Exception'; + $className = $moduleName . '_Exception'; + if (!class_exists($className)) { + $className = 'Mage_Core_Exception'; + } return new $className($message, $code); } @@ -654,6 +688,7 @@ public static function exception($module = 'Mage_Core', $message = '', $code = 0 * * @param string $message * @param string $messageStorage + * @return never * @throws Mage_Core_Exception */ public static function throwException($message, $messageStorage = null) @@ -784,8 +819,8 @@ public static function run($code = '', $type = 'store', $options = []) */ private static function _setIsInstalled($options = []) { - if (isset($options['is_installed']) && $options['is_installed']) { - self::$_isInstalled = true; + if (isset($options['is_installed'])) { + self::$_isInstalled = (bool) $options['is_installed']; } } diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/InvoiceController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/InvoiceController.php index 8b7dc0b97c4..fd170a1fef0 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/InvoiceController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/InvoiceController.php @@ -239,7 +239,7 @@ public function saveAction() $invoice->register(); if (!empty($data['send_email'])) { - $invoice->setEmailSent(true); + $invoice->setEmailSent(1); } $invoice->getOrder()->setCustomerNoteNotify(!empty($data['send_email'])); diff --git a/app/code/core/Mage/Checkout/Model/Session.php b/app/code/core/Mage/Checkout/Model/Session.php index aee6c546a9e..8e129d4d182 100644 --- a/app/code/core/Mage/Checkout/Model/Session.php +++ b/app/code/core/Mage/Checkout/Model/Session.php @@ -77,7 +77,7 @@ * @method string getSharedWishlist() * @method $this setSharedWishlist(string $value) * @method int getSingleWishlistId() - * @method $this setSingleWishlistId(int $value) + * @method $this setSingleWishlistId(int|null $value) * @method array getSteps() * @method $this setSteps(array $value) * diff --git a/app/code/core/Mage/Core/Controller/Varien/Front.php b/app/code/core/Mage/Core/Controller/Varien/Front.php index 381e705ea44..c126d579223 100644 --- a/app/code/core/Mage/Core/Controller/Varien/Front.php +++ b/app/code/core/Mage/Core/Controller/Varien/Front.php @@ -18,7 +18,7 @@ * @category Mage * @package Mage_Core * - * @method Mage_Core_Controller_Varien_Action getAction() + * @method Mage_Core_Controller_Varien_Action|null getAction() * @method $this setAction(Mage_Core_Controller_Varien_Action $value) * @method bool getNoRender() */ diff --git a/app/code/core/Mage/Core/Model/Config.php b/app/code/core/Mage/Core/Model/Config.php index f88d34aa119..399b4b148d3 100644 --- a/app/code/core/Mage/Core/Model/Config.php +++ b/app/code/core/Mage/Core/Model/Config.php @@ -1164,31 +1164,6 @@ public function getModuleConfig($moduleName = '') } } - /** - * Get module setup class instance. - * - * Defaults to Mage_Core_Setup - * - * @param string|Mage_Core_Model_Config_Element $module - * @return object - */ - public function getModuleSetup($module = '') - { - $className = 'Mage_Core_Setup'; - if ($module !== '') { - if (is_string($module)) { - $module = $this->getModuleConfig($module); - } - if (isset($module->setup)) { - $moduleClassName = $module->setup->getClassName(); - if (!empty($moduleClassName)) { - $className = $moduleClassName; - } - } - } - return new $className($module); - } - /** * Get base filesystem directory. depends on $type * @@ -1329,21 +1304,51 @@ public function getPathVars($args = null) return $path; } + /** + * Retrieve class name from config.xml node + * + * @return string|false + */ + public function getNodeClassName(string $path) + { + $config = Mage::getConfig()->getNode($path); + if (!$config) { + return false; + } + return $config->getClassName(); + } + + /** + * Retrieve class instance from config.xml node + * + * @param string $path + * @return Mage_Core_Model_Abstract|false + */ + public function getNodeClassInstance($path) + { + $className = $this->getNodeClassName($path); + if ($className === false || !class_exists($className)) { + return false; + } + // phpcs:ignore Ecg.Classes.ObjectInstantiation.DirectInstantiation + return new $className(); + } + /** * Retrieve class name by class group * * @param string $groupType currently supported model, block, helper - * @param string $classId slash separated class identifier, ex. group/class + * @param string $classAlias slash separated class identifier, ex. group/class * @param string $groupRootNode optional config path for group config * @return string */ - public function getGroupedClassName($groupType, $classId, $groupRootNode = null) + public function getGroupedClassName($groupType, $classAlias, $groupRootNode = null) { if (empty($groupRootNode)) { $groupRootNode = 'global/' . $groupType . 's'; } - $classArr = explode('/', trim($classId)); + $classArr = explode('/', trim($classAlias)); $group = $classArr[0]; $class = !empty($classArr[1]) ? $classArr[1] : null; @@ -1395,8 +1400,8 @@ public function getGroupedClassName($groupType, $classId, $groupRootNode = null) /** * Retrieve block class name * - * @param string $blockType - * @return string + * @param string $blockType + * @return string */ public function getBlockClassName($blockType) { @@ -1409,109 +1414,147 @@ public function getBlockClassName($blockType) /** * Retrieve helper class name * - * @param string $helperName - * @return string + * @param string $helperAlias + * @return string */ - public function getHelperClassName($helperName) + public function getHelperClassName($helperAlias) { - if (!str_contains($helperName, '/')) { - $helperName .= '/data'; + if (!str_contains($helperAlias, '/')) { + $helperAlias .= '/data'; } - return $this->getGroupedClassName('helper', $helperName); + return $this->getGroupedClassName('helper', $helperAlias); } /** - * Retrieve resource helper instance + * Retrieve helper instance * - * Example: - * $config->getResourceHelper('cms') - * will instantiate Mage_Cms_Model_Resource_Helper_ - * - * @param string $moduleName - * @return Mage_Core_Model_Resource_Helper_Abstract|false + * @return Mage_Core_Helper_Abstract|false */ - public function getResourceHelper($moduleName) + public function getHelperInstance(string $helperAlias) { - $connectionModel = $this->_getResourceConnectionModel($moduleName); - $helperClass = sprintf('%s/helper_%s', $moduleName, $connectionModel); - $helperClassName = $this->_getResourceModelFactoryClassName($helperClass); - if ($helperClassName) { - return $this->getModelInstance($helperClassName, $moduleName); + $className = $this->getHelperClassName($helperAlias); + if (!class_exists($className)) { + return false; } - - return false; + Varien_Profiler::start('CORE::create_object_of::' . $className); + // phpcs:ignore Ecg.Classes.ObjectInstantiation.DirectInstantiation + $obj = new $className(); + Varien_Profiler::stop('CORE::create_object_of::' . $className); + return $obj; } /** - * Retrieve module class name + * Retrieve model class name * - * @param string $modelClass - * @return string + * @param string $modelAlias + * @return string */ - public function getModelClassName($modelClass) + public function getModelClassName($modelAlias) { - $modelClass = trim($modelClass); - if (!str_contains($modelClass, '/')) { - return $modelClass; + $modelAlias = trim($modelAlias); + if (!str_contains($modelAlias, '/')) { + return $modelAlias; } - return $this->getGroupedClassName('model', $modelClass); + return $this->getGroupedClassName('model', $modelAlias); } /** - * Get model class instance. - * - * Example: - * $config->getModelInstance('catalog/product') + * Retrieve model instance * - * Will instantiate Mage_Catalog_Model_Resource_Product - * - * @param string $modelClass + * @param string $modelAlias * @param array|object $constructArguments * @return Mage_Core_Model_Abstract|false - * @see Mage_Catalog_Model_Resource_Product */ - public function getModelInstance($modelClass = '', $constructArguments = []) + public function getModelInstance($modelAlias, $constructArguments = []) { - $className = $this->getModelClassName($modelClass); - if (class_exists($className)) { - Varien_Profiler::start('CORE::create_object_of::' . $className); - $obj = new $className($constructArguments); - Varien_Profiler::stop('CORE::create_object_of::' . $className); - return $obj; - } else { + $className = $this->getModelClassName($modelAlias); + if (!class_exists($className)) { return false; } + Varien_Profiler::start('CORE::create_object_of::' . $className); + // phpcs:ignore Ecg.Classes.ObjectInstantiation.DirectInstantiation + $obj = new $className($constructArguments); + Varien_Profiler::stop('CORE::create_object_of::' . $className); + return $obj; } /** - * @param string $path - * @return bool + * Retrieve resource model class name + * + * @param string $modelAlias + * @return string|false */ - public function getNodeClassInstance($path) + public function getResourceModelClassName($modelAlias) { - $config = Mage::getConfig()->getNode($path); - if (!$config) { - return false; - } else { - $className = $config->getClassName(); - return new $className(); + $factoryName = $this->_getResourceModelFactoryClassName($modelAlias); + if ($factoryName) { + return $this->getModelClassName($factoryName); } + return false; } /** - * Get resource model object by alias + * Retrieve resource model instance * - * @param string $modelClass - * @param array $constructArguments + * @param string $modelAlias + * @param array $constructArguments * @return Mage_Core_Model_Resource_Db_Collection_Abstract|false */ - public function getResourceModelInstance($modelClass = '', $constructArguments = []) + public function getResourceModelInstance($modelAlias, $constructArguments = []) + { + $className = $this->getResourceModelClassName($modelAlias); + if ($className === false || !class_exists($className)) { + return false; + } + Varien_Profiler::start('CORE::create_object_of::' . $className); + // phpcs:ignore Ecg.Classes.ObjectInstantiation.DirectInstantiation + $obj = new $className($constructArguments); + Varien_Profiler::stop('CORE::create_object_of::' . $className); + return $obj; + } + + /** + * Retrieve resource helper class name + * + * @return string|false + */ + public function getResourceHelperClassName(string $moduleAlias) + { + $connectionModel = $this->_getResourceConnectionModel($moduleAlias); + $modelClass = sprintf('%s/helper_%s', $moduleAlias, $connectionModel); + + return $this->getResourceModelClassName($modelClass); + } + + /** + * Retrieve resource helper instance + * + * @return Mage_Core_Model_Resource_Helper_Abstract|false + */ + public function getResourceHelperInstance(string $moduleAlias) { - $factoryName = $this->_getResourceModelFactoryClassName($modelClass); - if (!$factoryName) { + $className = $this->getResourceHelperClassName($moduleAlias); + if ($className === false || !class_exists($className)) { return false; } - return $this->getModelInstance($factoryName, $constructArguments); + Varien_Profiler::start('CORE::create_object_of::' . $className); + // phpcs:ignore Ecg.Classes.ObjectInstantiation.DirectInstantiation + $obj = new $className($moduleAlias); + Varien_Profiler::stop('CORE::create_object_of::' . $className); + return $obj; + } + + /** + * Retrieve resource helper instance + * + * @param string $moduleAlias + * @return Mage_Core_Model_Resource_Helper_Abstract|false + * @deprecated Use getResourceHelperInstance() method instead + * @see Mage_Core_Model_Config::getResourceHelperInstance() + */ + public function getResourceHelper($moduleAlias) + { + return $this->getResourceHelperInstance($moduleAlias); } /** @@ -1774,21 +1817,6 @@ protected function _getResourceModelFactoryClassName($modelClass) return $resourceModel . '/' . $model; } - /** - * Get a resource model class name - * - * @param string $modelClass - * @return string|false - */ - public function getResourceModelClassName($modelClass) - { - $factoryName = $this->_getResourceModelFactoryClassName($modelClass); - if ($factoryName) { - return $this->getModelClassName($factoryName); - } - return false; - } - /** * Makes all events to lower-case * diff --git a/app/code/core/Mage/Core/Model/Layout.php b/app/code/core/Mage/Core/Model/Layout.php index 576c5a32476..f32a1fad0e9 100644 --- a/app/code/core/Mage/Core/Model/Layout.php +++ b/app/code/core/Mage/Core/Model/Layout.php @@ -446,17 +446,21 @@ public function unsetBlock($name) /** * Block Factory * - * @param string $type - * @param string|null $name - * @return Mage_Core_Block_Abstract|false + * @param string|Mage_Core_Block_Abstract $type + * @param string $name + * @return Mage_Core_Block_Abstract|false */ public function createBlock($type, $name = '', array $attributes = []) { - try { - $block = $this->_getBlockInstance($type, $attributes); - } catch (Exception $e) { - Mage::logException($e); - return false; + if ($type instanceof Mage_Core_Block_Abstract) { + $block = $type; + } else { + try { + $block = $this->_getBlockInstance($type, $attributes); + } catch (Exception $e) { + Mage::logException($e); + return false; + } } if (empty($name) || $name[0] === '.') { @@ -465,8 +469,6 @@ public function createBlock($type, $name = '', array $attributes = []) $block->setAnonSuffix(substr($name, 1)); } $name = 'ANONYMOUS_' . count($this->_blocks); - } elseif (isset($this->_blocks[$name]) && Mage::getIsDeveloperMode()) { - //Mage::throwException(Mage::helper('core')->__('Block with name "%s" already exists', $name)); } $block->setType($type); @@ -494,24 +496,21 @@ public function addBlock($block, $blockName) /** * Create block object instance based on block type * - * @param string $block + * @param string $type * @return Mage_Core_Block_Abstract + * @throws Mage_Core_Exception */ - protected function _getBlockInstance($block, array $attributes = []) + protected function _getBlockInstance($type, array $attributes = []) { - if (is_string($block)) { - if (str_contains($block, '/')) { - if (!$block = Mage::getConfig()->getBlockClassName($block)) { - Mage::throwException(Mage::helper('core')->__('Invalid block type: %s', $block)); - } - } - if (class_exists($block, false) || mageFindClassFile($block)) { - $block = new $block($attributes); - } + $className = Mage::getConfig()->getBlockClassName($type); + if ($className === false || !class_exists($className)) { + Mage::throwException(Mage::helper('core')->__('Invalid block type: %s', $type)); } + // phpcs:ignore Ecg.Classes.ObjectInstantiation.DirectInstantiation + $block = new $className($attributes); if (!$block instanceof Mage_Core_Block_Abstract) { $block = is_object($block) ? get_class($block) : $block; - Mage::throwException(Mage::helper('core')->__('Invalid block type: %s (not instance of Mage_Core_Block_Abstract)', $block)); + Mage::throwException(Mage::helper('core')->__('Invalid block type: %s (not instance of Mage_Core_Block_Abstract)', $type)); } return $block; } @@ -594,23 +593,22 @@ public function getMessagesBlock() /** * @param string $type - * @return Mage_Core_Block_Abstract|object + * @return Mage_Core_Block_Abstract + * @throws Mage_Core_Exception */ public function getBlockSingleton($type) { if (!isset($this->_helpers[$type])) { $className = Mage::getConfig()->getBlockClassName($type); - if (!$className) { + if ($className === false || !class_exists($className)) { Mage::throwException(Mage::helper('core')->__('Invalid block type: %s', $type)); } $helper = new $className(); - if ($helper) { - if ($helper instanceof Mage_Core_Block_Abstract) { - $helper->setLayout($this); - } - $this->_helpers[$type] = $helper; + if ($helper instanceof Mage_Core_Block_Abstract) { + $helper->setLayout($this); } + $this->_helpers[$type] = $helper; } return $this->_helpers[$type]; } @@ -624,7 +622,7 @@ public function getBlockSingleton($type) public function helper($name) { $helper = Mage::helper($name); - if (!$helper) { + if ($helper === false) { return false; } return $helper->setLayout($this); diff --git a/app/code/core/Mage/Customer/Model/Session.php b/app/code/core/Mage/Customer/Model/Session.php index 7bb9b6add30..f4b9b525131 100644 --- a/app/code/core/Mage/Customer/Model/Session.php +++ b/app/code/core/Mage/Customer/Model/Session.php @@ -32,12 +32,12 @@ * @method $this setBeforeWishlistRequest(array $value) * @method $this unsBeforeWishlistRequest() * @method string getBeforeWishlistUrl() - * @method $this setBeforeWishlistUrl(string $value) + * @method $this setBeforeWishlistUrl(string|null $value) * @method array getCustomerFormData() * @method $this setCustomerFormData(array $value) * @method bool hasDisplayOutOfStockProducts() - * @method string getDisplayOutOfStockProducts(string $value) - * @method $this setDisplayOutOfStockProducts() + * @method string getDisplayOutOfStockProducts() + * @method $this setDisplayOutOfStockProducts(string $value) * @method string getForgottenEmail() * @method $this setForgottenEmail(string $value) * @method $this unsForgottenEmail() diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Payment.php b/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Payment.php index 9f0794e1ffa..e2f24eae817 100644 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Payment.php +++ b/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Payment.php @@ -38,7 +38,7 @@ protected function _getFrontendClass($element) * Check whether current payment method is enabled * * @param Varien_Data_Form_Element_Abstract $element - * @param callback|null $configCallback + * @param callable|null $configCallback * @return bool */ protected function _isPaymentEnabled($element, $configCallback = null) diff --git a/app/code/core/Mage/Sales/Model/Config.php b/app/code/core/Mage/Sales/Model/Config.php index bdcb055623a..5ff9e74fc41 100644 --- a/app/code/core/Mage/Sales/Model/Config.php +++ b/app/code/core/Mage/Sales/Model/Config.php @@ -24,7 +24,7 @@ class Mage_Sales_Model_Config /** * @param string $type - * @return bool + * @return Mage_Core_Model_Abstract|false */ public function getQuoteRuleConditionInstance($type) { @@ -33,7 +33,7 @@ public function getQuoteRuleConditionInstance($type) /** * @param string $type - * @return bool + * @return Mage_Core_Model_Abstract|false */ public function getQuoteRuleActionInstance($type) { diff --git a/app/code/core/Mage/Sales/Model/Order/Invoice.php b/app/code/core/Mage/Sales/Model/Order/Invoice.php index 6198f7d434f..ada18525370 100644 --- a/app/code/core/Mage/Sales/Model/Order/Invoice.php +++ b/app/code/core/Mage/Sales/Model/Order/Invoice.php @@ -862,7 +862,7 @@ public function sendEmail($notifyCustomer = true, $comment = '') $mailer->send(); if ($notifyCustomer) { - $this->setEmailSent(true); + $this->setEmailSent(1); $this->_getResource()->saveAttribute($this, 'email_sent'); } diff --git a/app/code/core/Mage/Sales/Model/Order/Invoice/Api.php b/app/code/core/Mage/Sales/Model/Order/Invoice/Api.php index b15d16f848c..7f8543f074d 100644 --- a/app/code/core/Mage/Sales/Model/Order/Invoice/Api.php +++ b/app/code/core/Mage/Sales/Model/Order/Invoice/Api.php @@ -143,7 +143,7 @@ public function create($orderIncrementId, $itemsQty = [], $comment = null, $emai } if ($email) { - $invoice->setEmailSent(true); + $invoice->setEmailSent(1); } $invoice->getOrder()->setIsInProcess(true); diff --git a/app/code/core/Mage/Sales/Model/Order/Invoice/Api/V2.php b/app/code/core/Mage/Sales/Model/Order/Invoice/Api/V2.php index 4fc2175572f..32e7aa900ed 100644 --- a/app/code/core/Mage/Sales/Model/Order/Invoice/Api/V2.php +++ b/app/code/core/Mage/Sales/Model/Order/Invoice/Api/V2.php @@ -60,7 +60,7 @@ public function create($invoiceIncrementId, $itemsQty = [], $comment = null, $em } if ($email) { - $invoice->setEmailSent(true); + $invoice->setEmailSent(1); } $invoice->getOrder()->setIsInProcess(true); diff --git a/app/code/core/Mage/Sales/Model/Quote/Address/Item.php b/app/code/core/Mage/Sales/Model/Quote/Address/Item.php index 5810bf523c7..95ac372e02c 100644 --- a/app/code/core/Mage/Sales/Model/Quote/Address/Item.php +++ b/app/code/core/Mage/Sales/Model/Quote/Address/Item.php @@ -77,8 +77,10 @@ * @method $this setName(string $value) * @method string getDescription() * @method $this setDescription(string $value) + * * @method int getFreeShipping() * @method $this setFreeShipping(int $value) + * * @method int getIsQtyDecimal() * @method $this setIsQtyDecimal(int $value) * @method float getDiscountPercent() diff --git a/app/code/core/Mage/Sales/Model/Quote/Item/Abstract.php b/app/code/core/Mage/Sales/Model/Quote/Item/Abstract.php index 6b54dfc1bf1..e10db31a0c7 100644 --- a/app/code/core/Mage/Sales/Model/Quote/Item/Abstract.php +++ b/app/code/core/Mage/Sales/Model/Quote/Item/Abstract.php @@ -129,7 +129,7 @@ * @method $this setQty(float $value) * * @method float getRowTax() - * @method $this setRowTax(int $rowTax) + * @method $this setRowTax(float $rowTax) * @method float getRowTotal() * @method $this setRowTotal(float $value) * @method $this setRowTotalExcTax(float $value) diff --git a/app/code/core/Mage/Sales/Model/Recurring/Profile.php b/app/code/core/Mage/Sales/Model/Recurring/Profile.php index 77e14940f43..04b3a1fc294 100644 --- a/app/code/core/Mage/Sales/Model/Recurring/Profile.php +++ b/app/code/core/Mage/Sales/Model/Recurring/Profile.php @@ -75,14 +75,14 @@ * @method $this setInitAmount(float $value) * @method int getInitMayFail() * @method $this setInitMayFail(int $value) - * @method string getOrderInfo() - * @method $this setOrderInfo(string $value) - * @method string getOrderItemInfo() - * @method $this setOrderItemInfo(string $value) - * @method string getBillingAddressInfo() - * @method $this setBillingAddressInfo(string $value) - * @method string getShippingAddressInfo() - * @method $this setShippingAddressInfo(string $value) + * @method array getOrderInfo() + * @method $this setOrderInfo(array $value) + * @method array getOrderItemInfo() + * @method $this setOrderItemInfo(array $value) + * @method array getBillingAddressInfo() + * @method $this setBillingAddressInfo(array $value) + * @method array getShippingAddressInfo() + * @method $this setShippingAddressInfo(array $value) * @method string getProfileVendorInfo() * @method $this setProfileVendorInfo(string $value) * @method string getAdditionalInfo() diff --git a/app/code/core/Mage/SalesRule/Model/Coupon.php b/app/code/core/Mage/SalesRule/Model/Coupon.php index 92495f415be..3afaafec6f2 100644 --- a/app/code/core/Mage/SalesRule/Model/Coupon.php +++ b/app/code/core/Mage/SalesRule/Model/Coupon.php @@ -34,8 +34,8 @@ * @method $this setUsagePerCustomer(int $value) * @method int getTimesUsed() * @method $this setTimesUsed(int $value) - * @method Zend_Date getExpirationDate() - * @method $this setExpirationDate(Zend_Date $value) + * @method string getExpirationDate() + * @method $this setExpirationDate(string $value) * @method int getIsPrimary() * @method $this setIsPrimary(int $value) * @method int getType() diff --git a/app/code/core/Mage/SalesRule/Model/Quote/Freeshipping.php b/app/code/core/Mage/SalesRule/Model/Quote/Freeshipping.php index a27629c75a6..ca5c756b28e 100644 --- a/app/code/core/Mage/SalesRule/Model/Quote/Freeshipping.php +++ b/app/code/core/Mage/SalesRule/Model/Quote/Freeshipping.php @@ -57,7 +57,7 @@ public function collect(Mage_Sales_Model_Quote_Address $address) foreach ($items as $item) { if ($item->getNoDiscount()) { $isAllFree = false; - $item->setFreeShipping(false); + $item->setFreeShipping(0); } else { /** * Child item discount we calculate for parent @@ -82,7 +82,7 @@ public function collect(Mage_Sales_Model_Quote_Address $address) } } if ($isAllFree && !$address->getFreeShipping()) { - $address->setFreeShipping(true); + $address->setFreeShipping(1); } return $this; } diff --git a/app/code/core/Mage/SalesRule/Model/Rule.php b/app/code/core/Mage/SalesRule/Model/Rule.php index 2acb66e1d08..45a5a8e43fa 100644 --- a/app/code/core/Mage/SalesRule/Model/Rule.php +++ b/app/code/core/Mage/SalesRule/Model/Rule.php @@ -289,7 +289,7 @@ public function getPrimaryCoupon() if ($this->_primaryCoupon === null) { $this->_primaryCoupon = Mage::getModel('salesrule/coupon'); $this->_primaryCoupon->loadPrimaryByRule($this->getId()); - $this->_primaryCoupon->setRule($this)->setIsPrimary(true); + $this->_primaryCoupon->setRule($this)->setIsPrimary(1); } return $this->_primaryCoupon; } @@ -402,7 +402,7 @@ public function acquireCoupon($saveNewlyCreated = true, $saveAttemptCount = 10) } $coupon = Mage::getModel('salesrule/coupon'); $coupon->setRule($this) - ->setIsPrimary(false) + ->setIsPrimary(0) ->setUsageLimit($this->getUsesPerCoupon() ? $this->getUsesPerCoupon() : null) ->setUsagePerCustomer($this->getUsesPerCustomer() ? $this->getUsesPerCustomer() : null) ->setExpirationDate($this->getToDate()); diff --git a/app/code/core/Mage/SalesRule/Model/Validator.php b/app/code/core/Mage/SalesRule/Model/Validator.php index 033beb4dc48..c8e77a17437 100644 --- a/app/code/core/Mage/SalesRule/Model/Validator.php +++ b/app/code/core/Mage/SalesRule/Model/Validator.php @@ -243,7 +243,7 @@ protected function _canProcessRule($rule, $address) public function processFreeShipping(Mage_Sales_Model_Quote_Item_Abstract $item) { $address = $this->_getAddress($item); - $item->setFreeShipping(false); + $item->setFreeShipping(0); foreach ($this->_getRules() as $rule) { /** @var Mage_SalesRule_Model_Rule $rule */ @@ -257,11 +257,11 @@ public function processFreeShipping(Mage_Sales_Model_Quote_Item_Abstract $item) switch ($rule->getSimpleFreeShipping()) { case Mage_SalesRule_Model_Rule::FREE_SHIPPING_ITEM: - $item->setFreeShipping($rule->getDiscountQty() ? $rule->getDiscountQty() : true); + $item->setFreeShipping($rule->getDiscountQty() ? $rule->getDiscountQty() : 1); break; case Mage_SalesRule_Model_Rule::FREE_SHIPPING_ADDRESS: - $address->setFreeShipping(true); + $address->setFreeShipping(1); break; } if ($rule->getStopRulesProcessing()) { diff --git a/app/code/core/Mage/Tag/Model/Tag/Relation.php b/app/code/core/Mage/Tag/Model/Tag/Relation.php index e7f89aabb23..2a5b0bd0e04 100644 --- a/app/code/core/Mage/Tag/Model/Tag/Relation.php +++ b/app/code/core/Mage/Tag/Model/Tag/Relation.php @@ -27,8 +27,8 @@ * @method array getAddedProductIds() * @method $this setAddedProductIds(array $value) * @method $this setCreatedAt(string $value) - * @method int getCustomerId() - * @method $this setCustomerId(int $value) + * @method int|null getCustomerId() + * @method $this setCustomerId(int|null $value) * @method int getProductId() * @method $this setProductId(int $value) * @method $this setProductIds(array $value) diff --git a/app/code/core/Mage/Tax/Model/Calculation/Rate.php b/app/code/core/Mage/Tax/Model/Calculation/Rate.php index 1e49eb589d6..098b02f3a23 100644 --- a/app/code/core/Mage/Tax/Model/Calculation/Rate.php +++ b/app/code/core/Mage/Tax/Model/Calculation/Rate.php @@ -39,12 +39,12 @@ * @method $this setTaxPostcode(string $value) * @method array getTitle() * @method $this setTitle(array $value) - * @method int getZipIsRange() - * @method $this setZipIsRange(int $value) - * @method int getZipFrom() - * @method $this setZipFrom(int $value) - * @method int getZipTo() - * @method $this setZipTo(int $value) + * @method int|null getZipIsRange() + * @method $this setZipIsRange(int|null $value) + * @method int|null getZipFrom() + * @method $this setZipFrom(int|null $value) + * @method int|null getZipTo() + * @method $this setZipTo(int|null $value) */ class Mage_Tax_Model_Calculation_Rate extends Mage_Core_Model_Abstract { diff --git a/app/code/core/Mage/Widget/Model/Widget/Instance.php b/app/code/core/Mage/Widget/Model/Widget/Instance.php index b275f301ddf..72f1763763e 100644 --- a/app/code/core/Mage/Widget/Model/Widget/Instance.php +++ b/app/code/core/Mage/Widget/Model/Widget/Instance.php @@ -29,7 +29,7 @@ * @method $this setStoreIds(string $value) * @method string getTitle() * @method $this setTitle(string $value) - * @method $this setWidgetParameters(string $value) + * @method $this setWidgetParameters(array $value) * @method int getSortOrder() * @method $this setSortOrder(int $value) */ diff --git a/composer.json b/composer.json index 8fcc1fe5ca2..46049f5ee7e 100644 --- a/composer.json +++ b/composer.json @@ -6,6 +6,25 @@ "AFL-3.0" ], "type": "magento-source", + "repositories": [ + { + "type": "package", + "package": { + "name": "macopedia/phpstan-magento1", + "version": "dev-topic-om", + "source": { + "url": "https://github.com/justinbeaty/maho-phpstan-plugin.git", + "type": "git", + "reference": "topic-om" + }, + "autoload": { + "psr-4": { + "PHPStanMagento1\\": "src/" + } + } + } + } + ], "require": { "php": ">=7.4 <8.5", "ext-ctype": "*", @@ -50,7 +69,7 @@ "composer/composer": "^2.7", "dealerdirect/phpcodesniffer-composer-installer": "^1.0.0", "friendsofphp/php-cs-fixer": "^3.6", - "macopedia/phpstan-magento1": "^1.1", + "macopedia/phpstan-magento1": "dev-topic-om", "magento-ecg/coding-standard": "^4.5", "openmage/dev-meta-package": "^1.0.5", "perftools/php-profiler": "^1.1", diff --git a/composer.lock b/composer.lock index 956b1e81002..33898bd68d7 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "d58658786c3829777ebb5701141ff35e", + "content-hash": "05e25c2b39f88702a46cb39616fbc601", "packages": [ { "name": "colinmollenhour/cache-backend-redis", @@ -3796,42 +3796,18 @@ }, { "name": "macopedia/phpstan-magento1", - "version": "v1.1.0", + "version": "dev-topic-om", "source": { "type": "git", - "url": "https://github.com/macopedia/phpstan-magento1.git", - "reference": "01418cc9a536ffbf298fdf7ea3b9fac1f87a0508" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/macopedia/phpstan-magento1/zipball/01418cc9a536ffbf298fdf7ea3b9fac1f87a0508", - "reference": "01418cc9a536ffbf298fdf7ea3b9fac1f87a0508", - "shasum": "" - }, - "require": { - "php": ">= 7.4", - "phpstan/phpstan": "^1.12.11 | ^2.0.2" - }, - "replace": { - "inviqa/phpstan-magento1": "0.1.5", - "vianetz/phpstan-magento1": "0.1.5" + "url": "https://github.com/justinbeaty/maho-phpstan-plugin.git", + "reference": "topic-om" }, "type": "library", "autoload": { "psr-4": { "PHPStanMagento1\\": "src/" } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Extension for PHPStan to allow analysis of Magento 1 code.", - "support": { - "issues": "https://github.com/macopedia/phpstan-magento1/issues", - "source": "https://github.com/macopedia/phpstan-magento1/tree/v1.1.0" - }, - "time": "2024-11-19T10:50:38+00:00" + } }, { "name": "magento-ecg/coding-standard", @@ -7485,7 +7461,9 @@ ], "aliases": [], "minimum-stability": "dev", - "stability-flags": {}, + "stability-flags": { + "macopedia/phpstan-magento1": 20 + }, "prefer-stable": true, "prefer-lowest": false, "platform": { diff --git a/lib/Varien/Data/Collection/Filesystem.php b/lib/Varien/Data/Collection/Filesystem.php index f202e3d1c77..ed2bc328c4c 100644 --- a/lib/Varien/Data/Collection/Filesystem.php +++ b/lib/Varien/Data/Collection/Filesystem.php @@ -386,7 +386,7 @@ protected function _generateRow($filename) * @param string $field * @param mixed $value * @param string $type 'and'|'or' - * @param callback $callback + * @param callable $callback * @param bool $isInverted * @return $this */ @@ -440,7 +440,7 @@ protected function _filterRow($row) * Invokes specified callback * Skips, if there is no filtered key in the row * - * @param callback $callback + * @param callable $callback * @param array $callbackParams * @return bool */ diff --git a/lib/Varien/Object/Mapper.php b/lib/Varien/Object/Mapper.php index efce3e1a7e7..e42043e6e7c 100644 --- a/lib/Varien/Object/Mapper.php +++ b/lib/Varien/Object/Mapper.php @@ -40,8 +40,8 @@ class Varien_Object_Mapper * => $from->setData($key, ) * array(, ) => $from->$method($key, ) * - * @param array|Varien_Object|callback $from - * @param array|Varien_Object|callback $to + * @param array|Varien_Object|callable $from + * @param array|Varien_Object|callable $to * @return array|Varien_Object */ public static function &accumulateByMap($from, $to, array $map, array $defaults = [])