diff --git a/.phpstan.dist.baseline.neon b/.phpstan.dist.baseline.neon index 8d87f7835ba..b0a545190ae 100644 --- a/.phpstan.dist.baseline.neon +++ b/.phpstan.dist.baseline.neon @@ -5206,7 +5206,7 @@ parameters: message: '#^Comparison operation "\!\=" between array\|int and 0 results in an error\.$#' identifier: notEqual.invalid count: 1 - path: app/code/core/Mage/Reports/Model/Resource/Report/Product/Viewed/Collection.php + path: app/code/core/Mage/Reports/Model/Resource/Report/Collection/Abstract.php - message: '#^Parameter \#1 \$select of method Mage_Core_Model_Resource_Helper_Mysql4\:\:getQueryUsingAnalyticFunction\(\) expects Varien_Db_Select, Zend_Db_Select given\.$#' @@ -5814,12 +5814,6 @@ parameters: count: 1 path: app/code/core/Mage/Sales/Model/Resource/Order/Tax/Collection.php - - - message: '#^Comparison operation "\!\=" between array\|int and 0 results in an error\.$#' - identifier: notEqual.invalid - count: 1 - path: app/code/core/Mage/Sales/Model/Resource/Report/Bestsellers/Collection.php - - message: '#^Parameter \#1 \$select of method Mage_Core_Model_Resource_Helper_Mysql4\:\:getQueryUsingAnalyticFunction\(\) expects Varien_Db_Select, Zend_Db_Select given\.$#' identifier: argument.type diff --git a/app/Mage.php b/app/Mage.php index a307d5cb50b..96b868ad890 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"); } } diff --git a/app/code/core/Mage/Reports/Model/Resource/Report/Collection/Abstract.php b/app/code/core/Mage/Reports/Model/Resource/Report/Collection/Abstract.php index b502f0a6e38..7dde4c75d05 100644 --- a/app/code/core/Mage/Reports/Model/Resource/Report/Collection/Abstract.php +++ b/app/code/core/Mage/Reports/Model/Resource/Report/Collection/Abstract.php @@ -268,4 +268,48 @@ public function load($printQuery = false, $logQuery = false) } return parent::load($printQuery, $logQuery); } + + + /** + * Get SQL for get record count + * + * @return Varien_Db_Select + * @see Mage_Reports_Model_Resource_Report_Product_Viewed_Collection + * @see Mage_Sales_Model_Resource_Report_Bestsellers_Collection + */ + public function getSelectCountSql() + { + $this->_renderFilters(); + $select = clone $this->getSelect(); + $select->reset(Zend_Db_Select::ORDER); + return $this->getConnection()->select()->from($select, 'COUNT(*)'); + } + + /** + * Set ids for store restrictions + * + * @param array $storeIds + * @return $this + * @see Mage_Reports_Model_Resource_Report_Product_Viewed_Collection + * @see Mage_Sales_Model_Resource_Report_Bestsellers_Collection + */ + public function addStoreRestrictions($storeIds) + { + if (!is_array($storeIds)) { + $storeIds = [$storeIds]; + } + $currentStoreIds = $this->_storesIds; + if (isset($currentStoreIds) && $currentStoreIds != Mage_Core_Model_App::ADMIN_STORE_ID + && $currentStoreIds != [Mage_Core_Model_App::ADMIN_STORE_ID] + ) { + if (!is_array($currentStoreIds)) { + $currentStoreIds = [$currentStoreIds]; + } + $this->_storesIds = array_intersect($currentStoreIds, $storeIds); + } else { + $this->_storesIds = $storeIds; + } + + return $this; + } } diff --git a/app/code/core/Mage/Reports/Model/Resource/Report/Product/Viewed/Collection.php b/app/code/core/Mage/Reports/Model/Resource/Report/Product/Viewed/Collection.php index dbe8d77391d..30ae025b2be 100644 --- a/app/code/core/Mage/Reports/Model/Resource/Report/Product/Viewed/Collection.php +++ b/app/code/core/Mage/Reports/Model/Resource/Report/Product/Viewed/Collection.php @@ -157,45 +157,6 @@ protected function _initSelect() return $this; } - /** - * Get SQL for get record count - * - * @return Varien_Db_Select - */ - public function getSelectCountSql() - { - $this->_renderFilters(); - $select = clone $this->getSelect(); - $select->reset(Zend_Db_Select::ORDER); - return $this->getConnection()->select()->from($select, 'COUNT(*)'); - } - - /** - * Set ids for store restrictions - * - * @param array $storeIds - * @return $this - */ - public function addStoreRestrictions($storeIds) - { - if (!is_array($storeIds)) { - $storeIds = [$storeIds]; - } - $currentStoreIds = $this->_storesIds; - if (isset($currentStoreIds) && $currentStoreIds != Mage_Core_Model_App::ADMIN_STORE_ID - && $currentStoreIds != [Mage_Core_Model_App::ADMIN_STORE_ID] - ) { - if (!is_array($currentStoreIds)) { - $currentStoreIds = [$currentStoreIds]; - } - $this->_storesIds = array_intersect($currentStoreIds, $storeIds); - } else { - $this->_storesIds = $storeIds; - } - - return $this; - } - /** * Redeclare parent method for applying filters after parent method * but before adding unions and calculating totals diff --git a/app/code/core/Mage/Sales/Model/Resource/Report/Bestsellers/Collection.php b/app/code/core/Mage/Sales/Model/Resource/Report/Bestsellers/Collection.php index f2bd3a13db3..40bbec8a379 100644 --- a/app/code/core/Mage/Sales/Model/Resource/Report/Bestsellers/Collection.php +++ b/app/code/core/Mage/Sales/Model/Resource/Report/Bestsellers/Collection.php @@ -158,45 +158,6 @@ protected function _initSelect() return $this; } - /** - * Get SQL for get record count - * - * @return Varien_Db_Select - */ - public function getSelectCountSql() - { - $this->_renderFilters(); - $select = clone $this->getSelect(); - $select->reset(Zend_Db_Select::ORDER); - return $this->getConnection()->select()->from($select, 'COUNT(*)'); - } - - /** - * Set ids for store restrictions - * - * @param array $storeIds - * @return $this - */ - public function addStoreRestrictions($storeIds) - { - if (!is_array($storeIds)) { - $storeIds = [$storeIds]; - } - $currentStoreIds = $this->_storesIds; - if (isset($currentStoreIds) && $currentStoreIds != Mage_Core_Model_App::ADMIN_STORE_ID - && $currentStoreIds != [Mage_Core_Model_App::ADMIN_STORE_ID] - ) { - if (!is_array($currentStoreIds)) { - $currentStoreIds = [$currentStoreIds]; - } - $this->_storesIds = array_intersect($currentStoreIds, $storeIds); - } else { - $this->_storesIds = $storeIds; - } - - return $this; - } - /** * Redeclare parent method for applying filters after parent method * but before adding unions and calculating totals