From 80aa85c0c123c5f6e4a2b003e6d81b3badab629a Mon Sep 17 00:00:00 2001 From: Flyingmana Date: Fri, 3 Feb 2023 23:04:10 +0100 Subject: [PATCH 01/20] set phpstan config to use bleedingEdge --- phpstan.dist.neon | 1 + 1 file changed, 1 insertion(+) diff --git a/phpstan.dist.neon b/phpstan.dist.neon index d1a8ecd75a1..5bb1048fdfd 100644 --- a/phpstan.dist.neon +++ b/phpstan.dist.neon @@ -2,6 +2,7 @@ includes: - vendor/macopedia/phpstan-magento1/extension.neon - phpstan.dist.issues.neon - phpstan.dist.baseline.neon + - phar://phpstan.phar/conf/bleedingEdge.neon parameters: magentoRootPath: %currentWorkingDirectory% paths: From 9424c2085ceba953a9d9493ad8ed381ff230360b Mon Sep 17 00:00:00 2001 From: Flyingmana Date: Fri, 3 Feb 2023 23:14:22 +0100 Subject: [PATCH 02/20] pseudo change to trigger phpstan --- index.php | 1 + 1 file changed, 1 insertion(+) diff --git a/index.php b/index.php index 9a92a906174..c08eeccc9e7 100644 --- a/index.php +++ b/index.php @@ -28,6 +28,7 @@ require MAGENTO_ROOT . '/app/bootstrap.php'; require_once $mageFilename; + #Varien_Profiler::enable(); umask(0); From 9c178cedd5b37443d629f1b473fda89a68c6d549 Mon Sep 17 00:00:00 2001 From: Mohamed ELIDRISSI <67818913+elidrissidev@users.noreply.github.com> Date: Tue, 7 Feb 2023 22:05:50 +0100 Subject: [PATCH 03/20] Some phpstan fixes --- .../Model/Resource/Fulltext/Collection.php | 2 +- lib/Mage/HTTP/Client/Curl.php | 2 +- lib/Varien/Data/Form/Element/Obscure.php | 2 +- phpstan.dist.baseline.neon | 25 ------------------- 4 files changed, 3 insertions(+), 28 deletions(-) diff --git a/app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext/Collection.php b/app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext/Collection.php index 7c2dbfc2e28..99273b4d6d8 100644 --- a/app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext/Collection.php +++ b/app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext/Collection.php @@ -43,7 +43,7 @@ class Mage_CatalogSearch_Model_Resource_Fulltext_Collection extends Mage_Catalog /** * Sort order by relevance * - * @var null + * @var int */ protected $_relevanceSortOrder = SORT_DESC; diff --git a/lib/Mage/HTTP/Client/Curl.php b/lib/Mage/HTTP/Client/Curl.php index 566d02a3047..5bca9c30d98 100644 --- a/lib/Mage/HTTP/Client/Curl.php +++ b/lib/Mage/HTTP/Client/Curl.php @@ -104,7 +104,7 @@ class Mage_HTTP_Client_Curl implements Mage_HTTP_IClient * User ovverides options hash * Are applied before curl_exec * - * @var array(); + * @var array */ protected $_curlUserOptions = []; diff --git a/lib/Varien/Data/Form/Element/Obscure.php b/lib/Varien/Data/Form/Element/Obscure.php index 48f6006082c..dc636ba5807 100644 --- a/lib/Varien/Data/Form/Element/Obscure.php +++ b/lib/Varien/Data/Form/Element/Obscure.php @@ -51,7 +51,7 @@ public function getEscapedValue($index = null) /** * Returns list of html attributes possible to output in HTML * - * @return array() + * @return array */ public function getHtmlAttributes() { diff --git a/phpstan.dist.baseline.neon b/phpstan.dist.baseline.neon index 0ffaed6e133..900ec02be1b 100644 --- a/phpstan.dist.baseline.neon +++ b/phpstan.dist.baseline.neon @@ -2700,21 +2700,6 @@ parameters: count: 1 path: app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext.php - - - message: "#^If condition is always false\\.$#" - count: 1 - path: app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext/Collection.php - - - - message: "#^Property Mage_CatalogSearch_Model_Resource_Fulltext_Collection\\:\\:\\$_relevanceSortOrder \\(null\\) does not accept default value of type int\\.$#" - count: 1 - path: app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext/Collection.php - - - - message: "#^Property Mage_CatalogSearch_Model_Resource_Fulltext_Collection\\:\\:\\$_relevanceSortOrder \\(null\\) does not accept int\\.$#" - count: 1 - path: app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext/Collection.php - - message: "#^If condition is always true\\.$#" count: 1 @@ -6545,11 +6530,6 @@ parameters: count: 1 path: app/code/core/Mage/Sales/controllers/Billing/AgreementController.php - - - message: "#^Comparison operation \"\\!\\=\" between int and \\(array\\\\|string\\) results in an error\\.$#" - count: 1 - path: app/code/core/Mage/Sales/controllers/DownloadController.php - - message: "#^Negated boolean expression is always false\\.$#" count: 1 @@ -7215,11 +7195,6 @@ parameters: count: 1 path: app/code/core/Mage/Wishlist/Model/Item/Option.php - - - message: "#^Comparison operation \"\\!\\=\" between int and \\(array\\\\|string\\) results in an error\\.$#" - count: 1 - path: app/code/core/Mage/Wishlist/controllers/IndexController.php - - message: "#^Method Mage_Wishlist_IndexController\\:\\:_addItemToWishList\\(\\) with return type void returns mixed but should not return anything\\.$#" count: 1 From 97a8cd4a7848248997ff51bb61e941f4e11801ec Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Tue, 7 Feb 2023 21:10:36 +0000 Subject: [PATCH 04/20] removed empty line --- index.php | 1 - 1 file changed, 1 deletion(-) diff --git a/index.php b/index.php index c08eeccc9e7..9a92a906174 100644 --- a/index.php +++ b/index.php @@ -28,7 +28,6 @@ require MAGENTO_ROOT . '/app/bootstrap.php'; require_once $mageFilename; - #Varien_Profiler::enable(); umask(0); From 133769406f14381471df2684d726cbbab113ce76 Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Sat, 18 Feb 2023 10:59:05 +0000 Subject: [PATCH 05/20] Update IndexController.php --- app/code/core/Mage/Wishlist/controllers/IndexController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/core/Mage/Wishlist/controllers/IndexController.php b/app/code/core/Mage/Wishlist/controllers/IndexController.php index 2cb68af2804..c5a29398cee 100644 --- a/app/code/core/Mage/Wishlist/controllers/IndexController.php +++ b/app/code/core/Mage/Wishlist/controllers/IndexController.php @@ -730,7 +730,7 @@ public function downloadCustomOptionAction() $optionId = null; if (strpos($option->getCode(), Mage_Catalog_Model_Product_Type_Abstract::OPTION_PREFIX) === 0) { $optionId = str_replace(Mage_Catalog_Model_Product_Type_Abstract::OPTION_PREFIX, '', $option->getCode()); - if ((int)$optionId != $optionId) { + if (!is_numeric($optionId)) { return $this->_forward('noRoute'); } } From 14abb809e5e3920f1f6ef34f51d541c8ec08a070 Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Sat, 18 Feb 2023 19:04:22 +0000 Subject: [PATCH 06/20] PHP suggestion --- app/code/core/Mage/Sales/controllers/DownloadController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/core/Mage/Sales/controllers/DownloadController.php b/app/code/core/Mage/Sales/controllers/DownloadController.php index 0069e1b76d4..ea4b7b71d8d 100644 --- a/app/code/core/Mage/Sales/controllers/DownloadController.php +++ b/app/code/core/Mage/Sales/controllers/DownloadController.php @@ -169,7 +169,7 @@ public function downloadCustomOptionAction() $optionId = null; if (strpos($option->getCode(), Mage_Catalog_Model_Product_Type_Abstract::OPTION_PREFIX) === 0) { $optionId = str_replace(Mage_Catalog_Model_Product_Type_Abstract::OPTION_PREFIX, '', $option->getCode()); - if ((int)$optionId != $optionId) { + if (!is_numeric($optionId)) { $optionId = null; } } From 96ebe2d18195b1a098b95d8ab705b517ee02e641 Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Sat, 18 Feb 2023 19:14:09 +0000 Subject: [PATCH 07/20] PHP Suggestion: removed unreachable condition --- .../core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php index 8c192ee611a..87bf3198970 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php @@ -130,11 +130,8 @@ public function getRootByIds($ids) $categoryTreeResource = Mage::getResourceSingleton('catalog/category_tree'); $ids = $categoryTreeResource->getExistingCategoryIdsBySpecifiedIds($ids); $tree = $categoryTreeResource->loadByIds($ids); - $rootId = Mage_Catalog_Model_Category::TREE_ROOT_ID; $root = $tree->getNodeById($rootId); - if ($root && $rootId != Mage_Catalog_Model_Category::TREE_ROOT_ID) { - $root->setIsVisible(true); - } elseif ($root && $root->getId() == Mage_Catalog_Model_Category::TREE_ROOT_ID) { + if ($root && $root->getId() == Mage_Catalog_Model_Category::TREE_ROOT_ID) { $root->setName(Mage::helper('catalog')->__('Root')); } From a8a9a9e8b7aaae037c3bb2173763d17e67b709bb Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Sat, 18 Feb 2023 19:23:32 +0000 Subject: [PATCH 08/20] Update phpstan.dist.baseline.neon --- phpstan.dist.baseline.neon | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/phpstan.dist.baseline.neon b/phpstan.dist.baseline.neon index 91edea220bd..c695a95cc6d 100644 --- a/phpstan.dist.baseline.neon +++ b/phpstan.dist.baseline.neon @@ -70,26 +70,6 @@ parameters: count: 1 path: app/code/core/Mage/Adminhtml/Block/Cache/Grid.php - - - message: "#^If condition is always true\\.$#" - count: 3 - path: app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php - - - - message: "#^Left side of && is always true\\.$#" - count: 2 - path: app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php - - - - message: "#^Right side of && is always false\\.$#" - count: 1 - path: app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php - - - - message: "#^Unreachable statement \\- code above always terminates\\.$#" - count: 2 - path: app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php - - message: "#^Negated boolean expression is always false\\.$#" count: 1 From 43fa045bad08f88987b3e40e209b75855a828467 Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Sat, 18 Feb 2023 20:29:09 +0000 Subject: [PATCH 09/20] PHPStan suggestions --- .../Block/Catalog/Category/Abstract.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php index 87bf3198970..a8a04753288 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php @@ -40,8 +40,9 @@ public function getCategory() public function getCategoryId() { - if ($this->getCategory()) { - return $this->getCategory()->getId(); + $category = $this->getCategory(); + if (is_object($category) && $category->getId()) { + return $category->getId(); } return Mage_Catalog_Model_Category::TREE_ROOT_ID; } @@ -53,7 +54,8 @@ public function getCategoryName() public function getCategoryPath() { - if ($this->getCategory()) { + $category = $this->getCategory(); + if (is_object($category) && $category->getId()) { return $this->getCategory()->getPath(); } return Mage_Catalog_Model_Category::TREE_ROOT_ID; @@ -93,8 +95,9 @@ public function getRoot($parentNodeCategory = null, $recursionLevel = 3) $tree = Mage::getResourceSingleton('catalog/category_tree') ->load(null, $recursionLevel); - if ($this->getCategory()) { - $tree->loadEnsuredNodes($this->getCategory(), $tree->getNodeById($rootId)); + $category = $this->getCategory(); + if (is_object($category) and $category->getId()) { + $tree->loadEnsuredNodes($category, $tree->getNodeById($rootId)); } $tree->addCollectionData($this->getCategoryCollection()); @@ -130,6 +133,7 @@ public function getRootByIds($ids) $categoryTreeResource = Mage::getResourceSingleton('catalog/category_tree'); $ids = $categoryTreeResource->getExistingCategoryIdsBySpecifiedIds($ids); $tree = $categoryTreeResource->loadByIds($ids); + $rootId = Mage_Catalog_Model_Category::TREE_ROOT_ID; $root = $tree->getNodeById($rootId); if ($root && $root->getId() == Mage_Catalog_Model_Category::TREE_ROOT_ID) { $root->setName(Mage::helper('catalog')->__('Root')); @@ -145,9 +149,7 @@ public function getNode($parentNodeCategory, $recursionLevel = 2) { $tree = Mage::getResourceModel('catalog/category_tree'); - $nodeId = $parentNodeCategory->getId(); - $parentId = $parentNodeCategory->getParentId(); - + $nodeId = $parentNodeCategory->getId(); $node = $tree->loadNode($nodeId); $node->loadChildren($recursionLevel); From 469749b8f2caf3f0bdefca2ea3c120eb3703e38e Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Sat, 18 Feb 2023 20:29:40 +0000 Subject: [PATCH 10/20] Update phpstan.dist.baseline.neon --- phpstan.dist.baseline.neon | 90 +++++++++++++++----------------------- 1 file changed, 35 insertions(+), 55 deletions(-) diff --git a/phpstan.dist.baseline.neon b/phpstan.dist.baseline.neon index c695a95cc6d..9d5527f21a1 100644 --- a/phpstan.dist.baseline.neon +++ b/phpstan.dist.baseline.neon @@ -10,11 +10,6 @@ parameters: count: 1 path: app/Mage.php - - - message: "#^Right side of && is always true\\.$#" - count: 1 - path: app/Mage.php - - message: "#^Comparison operation \"\\=\\=\" between \\(Varien_Simplexml_Element\\|null\\) and 1 results in an error\\.$#" count: 1 @@ -70,6 +65,11 @@ parameters: count: 1 path: app/code/core/Mage/Adminhtml/Block/Cache/Grid.php + - + message: "#^Left side of && is always true\\.$#" + count: 2 + path: app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php + - message: "#^Negated boolean expression is always false\\.$#" count: 1 @@ -2680,6 +2680,21 @@ parameters: count: 1 path: app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext.php + - + message: "#^If condition is always false\\.$#" + count: 1 + path: app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext/Collection.php + + - + message: "#^Property Mage_CatalogSearch_Model_Resource_Fulltext_Collection\\:\\:\\$_relevanceSortOrder \\(null\\) does not accept default value of type int\\.$#" + count: 1 + path: app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext/Collection.php + + - + message: "#^Property Mage_CatalogSearch_Model_Resource_Fulltext_Collection\\:\\:\\$_relevanceSortOrder \\(null\\) does not accept int\\.$#" + count: 1 + path: app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext/Collection.php + - message: "#^If condition is always true\\.$#" count: 1 @@ -4520,6 +4535,11 @@ parameters: count: 1 path: app/code/core/Mage/GoogleAnalytics/Block/Ga.php + - + message: "#^Method Mage_GoogleAnalytics_Helper_Data\\:\\:isUseUniversalAnalytics\\(\\) should return string but returns bool\\.$#" + count: 1 + path: app/code/core/Mage/GoogleAnalytics/Helper/Data.php + - message: "#^Return type \\(void\\) of method Mage_GoogleCheckout_Model_Payment\\:\\:authorize\\(\\) should be compatible with return type \\(\\$this\\(Mage_Payment_Model_Method_Abstract\\)\\) of method Mage_Payment_Model_Method_Abstract\\:\\:authorize\\(\\)$#" count: 1 @@ -6505,6 +6525,11 @@ parameters: count: 1 path: app/code/core/Mage/Sales/controllers/Billing/AgreementController.php + - + message: "#^Comparison operation \"\\!\\=\" between int and \\(array\\\\|string\\) results in an error\\.$#" + count: 1 + path: app/code/core/Mage/Sales/controllers/DownloadController.php + - message: "#^Negated boolean expression is always false\\.$#" count: 1 @@ -7170,6 +7195,11 @@ parameters: count: 1 path: app/code/core/Mage/Wishlist/Model/Item/Option.php + - + message: "#^Comparison operation \"\\!\\=\" between int and \\(array\\\\|string\\) results in an error\\.$#" + count: 1 + path: app/code/core/Mage/Wishlist/controllers/IndexController.php + - message: "#^Method Mage_Wishlist_IndexController\\:\\:_addItemToWishList\\(\\) with return type void returns mixed but should not return anything\\.$#" count: 1 @@ -7610,11 +7640,6 @@ parameters: count: 1 path: lib/Varien/Image/Adapter/Abstract.php - - - message: "#^Binary operation \"\\*\\=\" between string and 1024 results in an error\\.$#" - count: 1 - path: lib/Varien/Image/Adapter/Gd2.php - - message: "#^Class GdImage not found\\.$#" count: 1 @@ -7625,51 +7650,6 @@ parameters: count: 1 path: lib/Varien/Image/Adapter/Gd2.php - - - message: "#^If condition is always true\\.$#" - count: 1 - path: lib/Varien/Io/File.php - - - - message: "#^Negated boolean expression is always false\\.$#" - count: 8 - path: lib/Varien/Io/File.php - - - - message: "#^Access to an undefined property Varien_Object_Cache\\:\\:\\$_referencesByObject\\.$#" - count: 1 - path: lib/Varien/Object/Cache.php - - - - message: "#^Method Varien_Object_Cache\\:\\:reference\\(\\) should return bool but empty return statement found\\.$#" - count: 1 - path: lib/Varien/Object/Cache.php - - - - message: "#^Negated boolean expression is always false\\.$#" - count: 1 - path: lib/Varien/Object/Cache.php - - - - message: "#^Offset 'function' on array\\{function\\: string, line\\?\\: int, file\\?\\: string, class\\?\\: class\\-string, type\\?\\: '\\-\\>'\\|'\\:\\:', args\\?\\: array, object\\?\\: object\\} in isset\\(\\) always exists and is not nullable\\.$#" - count: 1 - path: lib/Varien/Object/Cache.php - - - - message: "#^Undefined variable\\: \\$ids$#" - count: 1 - path: lib/Varien/Object/Cache.php - - - - message: "#^Undefined variable\\: \\$references$#" - count: 1 - path: lib/Varien/Object/Cache.php - - - - message: "#^Cannot call method hasData\\(\\) on array\\|\\(callable\\)\\|object\\.$#" - count: 1 - path: lib/Varien/Object/Mapper.php - - message: "#^Call to an undefined method SimpleXMLElement\\:\\:setNode\\(\\)\\.$#" count: 1 From f6c544f47a8189ec421732fe832aec7fd674ff3a Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Sat, 18 Feb 2023 20:48:08 +0000 Subject: [PATCH 11/20] Update phpstan.dist.baseline.neon --- phpstan.dist.baseline.neon | 100 ++++++++++++++++++++++++++----------- 1 file changed, 70 insertions(+), 30 deletions(-) diff --git a/phpstan.dist.baseline.neon b/phpstan.dist.baseline.neon index 9d5527f21a1..91edea220bd 100644 --- a/phpstan.dist.baseline.neon +++ b/phpstan.dist.baseline.neon @@ -10,6 +10,11 @@ parameters: count: 1 path: app/Mage.php + - + message: "#^Right side of && is always true\\.$#" + count: 1 + path: app/Mage.php + - message: "#^Comparison operation \"\\=\\=\" between \\(Varien_Simplexml_Element\\|null\\) and 1 results in an error\\.$#" count: 1 @@ -65,11 +70,26 @@ parameters: count: 1 path: app/code/core/Mage/Adminhtml/Block/Cache/Grid.php + - + message: "#^If condition is always true\\.$#" + count: 3 + path: app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php + - message: "#^Left side of && is always true\\.$#" count: 2 path: app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php + - + message: "#^Right side of && is always false\\.$#" + count: 1 + path: app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php + + - + message: "#^Unreachable statement \\- code above always terminates\\.$#" + count: 2 + path: app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php + - message: "#^Negated boolean expression is always false\\.$#" count: 1 @@ -2680,21 +2700,6 @@ parameters: count: 1 path: app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext.php - - - message: "#^If condition is always false\\.$#" - count: 1 - path: app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext/Collection.php - - - - message: "#^Property Mage_CatalogSearch_Model_Resource_Fulltext_Collection\\:\\:\\$_relevanceSortOrder \\(null\\) does not accept default value of type int\\.$#" - count: 1 - path: app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext/Collection.php - - - - message: "#^Property Mage_CatalogSearch_Model_Resource_Fulltext_Collection\\:\\:\\$_relevanceSortOrder \\(null\\) does not accept int\\.$#" - count: 1 - path: app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext/Collection.php - - message: "#^If condition is always true\\.$#" count: 1 @@ -4535,11 +4540,6 @@ parameters: count: 1 path: app/code/core/Mage/GoogleAnalytics/Block/Ga.php - - - message: "#^Method Mage_GoogleAnalytics_Helper_Data\\:\\:isUseUniversalAnalytics\\(\\) should return string but returns bool\\.$#" - count: 1 - path: app/code/core/Mage/GoogleAnalytics/Helper/Data.php - - message: "#^Return type \\(void\\) of method Mage_GoogleCheckout_Model_Payment\\:\\:authorize\\(\\) should be compatible with return type \\(\\$this\\(Mage_Payment_Model_Method_Abstract\\)\\) of method Mage_Payment_Model_Method_Abstract\\:\\:authorize\\(\\)$#" count: 1 @@ -6525,11 +6525,6 @@ parameters: count: 1 path: app/code/core/Mage/Sales/controllers/Billing/AgreementController.php - - - message: "#^Comparison operation \"\\!\\=\" between int and \\(array\\\\|string\\) results in an error\\.$#" - count: 1 - path: app/code/core/Mage/Sales/controllers/DownloadController.php - - message: "#^Negated boolean expression is always false\\.$#" count: 1 @@ -7195,11 +7190,6 @@ parameters: count: 1 path: app/code/core/Mage/Wishlist/Model/Item/Option.php - - - message: "#^Comparison operation \"\\!\\=\" between int and \\(array\\\\|string\\) results in an error\\.$#" - count: 1 - path: app/code/core/Mage/Wishlist/controllers/IndexController.php - - message: "#^Method Mage_Wishlist_IndexController\\:\\:_addItemToWishList\\(\\) with return type void returns mixed but should not return anything\\.$#" count: 1 @@ -7640,6 +7630,11 @@ parameters: count: 1 path: lib/Varien/Image/Adapter/Abstract.php + - + message: "#^Binary operation \"\\*\\=\" between string and 1024 results in an error\\.$#" + count: 1 + path: lib/Varien/Image/Adapter/Gd2.php + - message: "#^Class GdImage not found\\.$#" count: 1 @@ -7650,6 +7645,51 @@ parameters: count: 1 path: lib/Varien/Image/Adapter/Gd2.php + - + message: "#^If condition is always true\\.$#" + count: 1 + path: lib/Varien/Io/File.php + + - + message: "#^Negated boolean expression is always false\\.$#" + count: 8 + path: lib/Varien/Io/File.php + + - + message: "#^Access to an undefined property Varien_Object_Cache\\:\\:\\$_referencesByObject\\.$#" + count: 1 + path: lib/Varien/Object/Cache.php + + - + message: "#^Method Varien_Object_Cache\\:\\:reference\\(\\) should return bool but empty return statement found\\.$#" + count: 1 + path: lib/Varien/Object/Cache.php + + - + message: "#^Negated boolean expression is always false\\.$#" + count: 1 + path: lib/Varien/Object/Cache.php + + - + message: "#^Offset 'function' on array\\{function\\: string, line\\?\\: int, file\\?\\: string, class\\?\\: class\\-string, type\\?\\: '\\-\\>'\\|'\\:\\:', args\\?\\: array, object\\?\\: object\\} in isset\\(\\) always exists and is not nullable\\.$#" + count: 1 + path: lib/Varien/Object/Cache.php + + - + message: "#^Undefined variable\\: \\$ids$#" + count: 1 + path: lib/Varien/Object/Cache.php + + - + message: "#^Undefined variable\\: \\$references$#" + count: 1 + path: lib/Varien/Object/Cache.php + + - + message: "#^Cannot call method hasData\\(\\) on array\\|\\(callable\\)\\|object\\.$#" + count: 1 + path: lib/Varien/Object/Mapper.php + - message: "#^Call to an undefined method SimpleXMLElement\\:\\:setNode\\(\\)\\.$#" count: 1 From 8ed769ab0053b98eb0b3e81fefd73ec4e6372123 Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Sat, 18 Feb 2023 20:59:41 +0000 Subject: [PATCH 12/20] Update phpstan.dist.baseline.neon --- phpstan.dist.baseline.neon | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/phpstan.dist.baseline.neon b/phpstan.dist.baseline.neon index 91edea220bd..5b78e1550e1 100644 --- a/phpstan.dist.baseline.neon +++ b/phpstan.dist.baseline.neon @@ -70,26 +70,11 @@ parameters: count: 1 path: app/code/core/Mage/Adminhtml/Block/Cache/Grid.php - - - message: "#^If condition is always true\\.$#" - count: 3 - path: app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php - - message: "#^Left side of && is always true\\.$#" count: 2 path: app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php - - - message: "#^Right side of && is always false\\.$#" - count: 1 - path: app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php - - - - message: "#^Unreachable statement \\- code above always terminates\\.$#" - count: 2 - path: app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php - - message: "#^Negated boolean expression is always false\\.$#" count: 1 From 86182c3c766852ea6bf4961326d1c2a09c86b049 Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Sun, 26 Feb 2023 14:39:36 +0000 Subject: [PATCH 13/20] removed ignored errors --- phpstan.dist.baseline.neon | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/phpstan.dist.baseline.neon b/phpstan.dist.baseline.neon index 0a483712564..c6eb9b13e49 100644 --- a/phpstan.dist.baseline.neon +++ b/phpstan.dist.baseline.neon @@ -70,11 +70,6 @@ parameters: count: 1 path: app/code/core/Mage/Adminhtml/Block/Cache/Grid.php - - - message: "#^Right side of && is always false\\.$#" - count: 1 - path: app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php - - message: "#^Cannot call method addAttributeToSelect\\(\\) on Mage_Core_Model_Resource_Db_Collection_Abstract\\|false\\.$#" count: 1 @@ -1830,16 +1825,6 @@ parameters: count: 1 path: app/code/core/Mage/CatalogSearch/Model/Layer/Filter/Attribute.php - - - message: "#^Property Mage_CatalogSearch_Model_Resource_Fulltext_Collection\\:\\:\\$_relevanceSortOrder \\(null\\) does not accept default value of type int\\.$#" - count: 1 - path: app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext/Collection.php - - - - message: "#^Property Mage_CatalogSearch_Model_Resource_Fulltext_Collection\\:\\:\\$_relevanceSortOrder \\(null\\) does not accept int\\.$#" - count: 1 - path: app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext/Collection.php - - message: "#^If condition is always true\\.$#" count: 1 @@ -3470,11 +3455,6 @@ parameters: count: 1 path: app/code/core/Mage/Payment/Model/Method/Cc.php - - - message: "#^Left side of && is always true\\.$#" - count: 1 - path: app/code/core/Mage/Payment/Model/Method/Cc.php - - message: "#^Method Mage_Payment_Model_Recurring_Profile\\:\\:exportStartDatetime\\(\\) should return string\\|Zend_Date but empty return statement found\\.$#" count: 1 @@ -3840,11 +3820,6 @@ parameters: count: 1 path: app/code/core/Mage/Reports/Model/Totals.php - - - message: "#^If condition is always false\\.$#" - count: 1 - path: app/code/core/Mage/Reports/Model/Totals.php - - message: "#^Return type \\(string\\) of method Mage_Review_Block_Form\\:\\:getAction\\(\\) should be compatible with return type \\(Mage_Core_Controller_Varien_Action\\) of method Mage_Core_Block_Abstract\\:\\:getAction\\(\\)$#" count: 1 @@ -4285,11 +4260,6 @@ parameters: count: 1 path: app/code/core/Mage/Sales/controllers/Billing/AgreementController.php - - - message: "#^Comparison operation \"\\!\\=\" between int and \\(array\\\\|string\\) results in an error\\.$#" - count: 1 - path: app/code/core/Mage/Sales/controllers/DownloadController.php - - message: "#^Method Mage_Sales_Recurring_ProfileController\\:\\:preDispatch\\(\\) should return \\$this\\(Mage_Sales_Recurring_ProfileController\\) but empty return statement found\\.$#" count: 1 From 18c8159ade4c84cc5b150a4b5e779b48345cea63 Mon Sep 17 00:00:00 2001 From: server prod Date: Sun, 26 Feb 2023 16:10:28 +0000 Subject: [PATCH 14/20] regenerated baseline --- phpstan.dist.baseline.neon | 110 +++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) diff --git a/phpstan.dist.baseline.neon b/phpstan.dist.baseline.neon index c6eb9b13e49..171a910bbfc 100644 --- a/phpstan.dist.baseline.neon +++ b/phpstan.dist.baseline.neon @@ -485,6 +485,11 @@ parameters: count: 1 path: app/code/core/Mage/Adminhtml/controllers/Permissions/VariableController.php + - + message: "#^Call to function is_array\\(\\) with non\\-empty\\-array will always evaluate to true\\.$#" + count: 2 + path: app/code/core/Mage/Adminhtml/controllers/PollController.php + - message: "#^Cannot call method aggregate\\(\\) on Mage_Core_Model_Resource_Db_Collection_Abstract\\|false\\.$#" count: 2 @@ -730,6 +735,11 @@ parameters: count: 1 path: app/code/core/Mage/Api2/Model/Resource.php + - + message: "#^Call to function method_exists\\(\\) with Varien_Data_Collection_Db and 'addFieldToFilter' will always evaluate to true\\.$#" + count: 1 + path: app/code/core/Mage/Api2/Model/Resource.php + - message: "#^Method Mage_Api2_Model_Resource\\:\\:_create\\(\\) invoked with 1 parameter, 0 required\\.$#" count: 1 @@ -1225,6 +1235,11 @@ parameters: count: 1 path: app/code/core/Mage/Catalog/Model/Api2/Product/Validator/Product.php + - + message: "#^Strict comparison using \\!\\=\\= between mixed and 0 will always evaluate to true\\.$#" + count: 1 + path: app/code/core/Mage/Catalog/Model/Api2/Product/Validator/Product.php + - message: "#^Call to an undefined method Varien_Object\\:\\:formatUrlKey\\(\\)\\.$#" count: 1 @@ -1400,6 +1415,11 @@ parameters: count: 1 path: app/code/core/Mage/Catalog/Model/Product/Attribute/Media/Api/V2.php + - + message: "#^Call to function is_array\\(\\) with array will always evaluate to true\\.$#" + count: 1 + path: app/code/core/Mage/Catalog/Model/Product/Attribute/Tierprice/Api.php + - message: "#^Access to an undefined property object\\:\\:\\$customer_group_id\\.$#" count: 1 @@ -1510,6 +1530,11 @@ parameters: count: 1 path: app/code/core/Mage/Catalog/Model/Resource/Abstract.php + - + message: "#^PHPDoc tag @var with type Mage_Catalog_Model_Entity_Attribute is not subtype of native type non\\-empty\\-array\\.$#" + count: 1 + path: app/code/core/Mage/Catalog/Model/Resource/Abstract.php + - message: "#^Right side of \\|\\| is always true\\.$#" count: 1 @@ -1615,6 +1640,11 @@ parameters: count: 2 path: app/code/core/Mage/Catalog/Model/Resource/Product.php + - + message: "#^Call to function is_array\\(\\) with non\\-empty\\-array will always evaluate to true\\.$#" + count: 1 + path: app/code/core/Mage/Catalog/Model/Resource/Product.php + - message: "#^Method Mage_Catalog_Model_Resource_Product_Attribute_Backend_Media\\:\\:insertGallery\\(\\) should return int but returns string\\.$#" count: 1 @@ -1695,6 +1725,11 @@ parameters: count: 1 path: app/code/core/Mage/Catalog/Model/Resource/Product/Link/Product/Collection.php + - + message: "#^Loose comparison using \\=\\= between true and true will always evaluate to true\\.$#" + count: 2 + path: app/code/core/Mage/Catalog/Model/Url.php + - message: "#^Property Mage_Catalog_Model_Url\\:\\:\\$_saveRewritesHistory \\(bool\\) on left side of \\?\\? is not nullable\\.$#" count: 1 @@ -1790,6 +1825,11 @@ parameters: count: 1 path: app/code/core/Mage/CatalogInventory/Model/Resource/Stock/Item/Collection.php + - + message: "#^Call to function is_numeric\\(\\) with int will always evaluate to true\\.$#" + count: 1 + path: app/code/core/Mage/CatalogInventory/Model/Stock/Item.php + - message: "#^Variable \\$parentItem in empty\\(\\) always exists and is not falsy\\.$#" count: 1 @@ -1845,6 +1885,11 @@ parameters: count: 1 path: app/code/core/Mage/Checkout/Block/Cart/Crosssell.php + - + message: "#^Loose comparison using \\=\\= between numeric\\-string and '' will always evaluate to false\\.$#" + count: 1 + path: app/code/core/Mage/Checkout/Block/Cart/Item/Renderer.php + - message: "#^Property Mage_Checkout_Block_Cart_Shipping\\:\\:\\$_address \\(array\\) does not accept Mage_Sales_Model_Quote_Address\\.$#" count: 1 @@ -1875,6 +1920,11 @@ parameters: count: 1 path: app/code/core/Mage/Checkout/Block/Onepage/Success.php + - + message: "#^PHPDoc tag @var with type Mage_Sales_Model_Quote_Item is not subtype of native type null\\.$#" + count: 1 + path: app/code/core/Mage/Checkout/Model/Api/Resource/Product.php + - message: "#^Negated boolean expression is always false\\.$#" count: 1 @@ -1890,6 +1940,11 @@ parameters: count: 1 path: app/code/core/Mage/Checkout/Model/Cart/Customer/Api/V2.php + - + message: "#^Strict comparison using \\!\\=\\= between array\\ and null will always evaluate to true\\.$#" + count: 2 + path: app/code/core/Mage/Checkout/Model/Cart/Customer/Api/V2.php + - message: "#^Unreachable statement \\- code above always terminates\\.$#" count: 1 @@ -1900,6 +1955,11 @@ parameters: count: 1 path: app/code/core/Mage/Checkout/Model/Cart/Payment/Api/V2.php + - + message: "#^Strict comparison using \\!\\=\\= between array\\ and null will always evaluate to true\\.$#" + count: 1 + path: app/code/core/Mage/Checkout/Model/Cart/Payment/Api/V2.php + - message: "#^Unreachable statement \\- code above always terminates\\.$#" count: 1 @@ -2505,6 +2565,11 @@ parameters: count: 1 path: app/code/core/Mage/Customer/Block/Newsletter.php + - + message: "#^Call to function is_array\\(\\) with array will always evaluate to true\\.$#" + count: 1 + path: app/code/core/Mage/Customer/Helper/Address.php + - message: "#^Property Mage_Customer_Helper_Data\\:\\:\\$_customer \\(Mage_Customer_Model_Customer\\) in empty\\(\\) is not falsy\\.$#" count: 1 @@ -2560,6 +2625,11 @@ parameters: count: 1 path: app/code/core/Mage/Customer/Model/Customer/Api/V2.php + - + message: "#^Strict comparison using \\!\\=\\= between array\\ and null will always evaluate to true\\.$#" + count: 1 + path: app/code/core/Mage/Customer/Model/Customer/Api/V2.php + - message: "#^Unreachable statement \\- code above always terminates\\.$#" count: 1 @@ -3455,6 +3525,11 @@ parameters: count: 1 path: app/code/core/Mage/Payment/Model/Method/Cc.php + - + message: "#^Loose comparison using \\!\\= between ''\\|'OT' and 'SS' will always evaluate to true\\.$#" + count: 1 + path: app/code/core/Mage/Payment/Model/Method/Cc.php + - message: "#^Method Mage_Payment_Model_Recurring_Profile\\:\\:exportStartDatetime\\(\\) should return string\\|Zend_Date but empty return statement found\\.$#" count: 1 @@ -3695,6 +3770,11 @@ parameters: count: 1 path: app/code/core/Mage/ProductAlert/controllers/AddController.php + - + message: "#^PHPDoc tag @var with type Mage_Catalog_Model_Product is not subtype of native type 0\\|0\\.0\\|''\\|'0'\\|array\\{\\}\\|false\\|null\\.$#" + count: 1 + path: app/code/core/Mage/ProductAlert/controllers/AddController.php + - message: "#^Method Mage_Rating_Model_Resource_Rating\\:\\:getEntityIdByCode\\(\\) should return int but returns string\\|false\\|null\\.$#" count: 1 @@ -3820,6 +3900,11 @@ parameters: count: 1 path: app/code/core/Mage/Reports/Model/Totals.php + - + message: "#^Loose comparison using \\!\\= between 0 and 0 will always evaluate to false\\.$#" + count: 1 + path: app/code/core/Mage/Reports/Model/Totals.php + - message: "#^Return type \\(string\\) of method Mage_Review_Block_Form\\:\\:getAction\\(\\) should be compatible with return type \\(Mage_Core_Controller_Varien_Action\\) of method Mage_Core_Block_Abstract\\:\\:getAction\\(\\)$#" count: 1 @@ -4140,6 +4225,11 @@ parameters: count: 1 path: app/code/core/Mage/Sales/Model/Quote/Address/Total/Tax.php + - + message: "#^Instanceof between Mage_Sales_Model_Quote_Item_Option and Mage_Sales_Model_Quote_Item_Option will always evaluate to true\\.$#" + count: 1 + path: app/code/core/Mage/Sales/Model/Quote/Item.php + - message: "#^Method Mage_Sales_Model_Quote_Item\\:\\:__clone\\(\\) with return type void returns \\$this\\(Mage_Sales_Model_Quote_Item\\) but should not return anything\\.$#" count: 1 @@ -4480,6 +4570,11 @@ parameters: count: 1 path: app/code/core/Mage/Tax/Model/Config/Price/Include.php + - + message: "#^Call to function is_string\\(\\) with string will always evaluate to true\\.$#" + count: 1 + path: app/code/core/Mage/Tax/Model/Resource/Calculation.php + - message: "#^Return type \\(array\\) of method Mage_Tax_Model_Sales_Total_Quote_Nominal_Tax\\:\\:fetch\\(\\) should be compatible with return type \\(\\$this\\(Mage_Tax_Model_Sales_Total_Quote_Tax\\)\\) of method Mage_Tax_Model_Sales_Total_Quote_Tax\\:\\:fetch\\(\\)$#" count: 1 @@ -4660,6 +4755,11 @@ parameters: count: 1 path: app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups.php + - + message: "#^PHPDoc tag @var with type SimpleXMLElement is not subtype of native type null\\.$#" + count: 1 + path: app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups.php + - message: "#^Property Mage_Usa_Model_Shipping_Carrier_Ups\\:\\:\\$_baseCurrencyRate \\(float\\) does not accept string\\.$#" count: 1 @@ -5080,6 +5180,11 @@ parameters: count: 1 path: lib/Varien/File/Uploader/Image.php + - + message: "#^Call to function is_callable\\(\\) with array\\{\\$this\\(Varien_Filter_Template\\), 'dependDirective'\\|'ifDirective'\\} will always evaluate to true\\.$#" + count: 1 + path: lib/Varien/Filter/Template.php + - message: "#^Right side of && is always false\\.$#" count: 1 @@ -5120,6 +5225,11 @@ parameters: count: 1 path: lib/Varien/Image/Adapter/Gd2.php + - + message: "#^Strict comparison using \\=\\=\\= between false and false will always evaluate to true\\.$#" + count: 1 + path: lib/Varien/Image/Adapter/Gd2.php + - message: "#^Access to an undefined property Varien_Object_Cache\\:\\:\\$_referencesByObject\\.$#" count: 1 From 3cb3c63309e35f67468cf1017569ab8707b8c02a Mon Sep 17 00:00:00 2001 From: Mohamed ELIDRISSI <67818913+elidrissidev@users.noreply.github.com> Date: Mon, 27 Feb 2023 09:57:35 +0100 Subject: [PATCH 15/20] Fix some newly ignored errors --- .../Adminhtml/controllers/PollController.php | 56 +++++++++---------- app/code/core/Mage/Api2/Model/Resource.php | 5 +- .../Model/Product/Attribute/Tierprice/Api.php | 4 -- .../core/Mage/Customer/Helper/Address.php | 4 +- .../Mage/Tax/Model/Resource/Calculation.php | 2 +- .../Mage/Usa/Model/Shipping/Carrier/Ups.php | 2 +- lib/Varien/Image/Adapter/Gd2.php | 4 +- phpstan.dist.baseline.neon | 35 ------------ 8 files changed, 32 insertions(+), 80 deletions(-) diff --git a/app/code/core/Mage/Adminhtml/controllers/PollController.php b/app/code/core/Mage/Adminhtml/controllers/PollController.php index 7a785dc2603..6005d9654f0 100644 --- a/app/code/core/Mage/Adminhtml/controllers/PollController.php +++ b/app/code/core/Mage/Adminhtml/controllers/PollController.php @@ -141,24 +141,22 @@ public function validateAction() Mage::throwException(Mage::helper('adminhtml')->__('Please, select "Visible in Stores" for this poll first.')); } - if (is_array($stores)) { - $storeIds = []; - foreach ($stores as $storeIdList) { - $storeIdList = explode(',', $storeIdList); - if (!$storeIdList) { - continue; - } - foreach ($storeIdList as $storeId) { - if ($storeId > 0) { - $storeIds[] = $storeId; - } - } + $storeIds = []; + foreach ($stores as $storeIdList) { + $storeIdList = explode(',', $storeIdList); + if (!$storeIdList) { + continue; } - if (count($storeIds) === 0) { - Mage::throwException(Mage::helper('adminhtml')->__('Please, select "Visible in Stores" for this poll first.')); + foreach ($storeIdList as $storeId) { + if ($storeId > 0) { + $storeIds[] = $storeId; + } } - $pollModel->setStoreIds($storeIds); } + if (count($storeIds) === 0) { + Mage::throwException(Mage::helper('adminhtml')->__('Please, select "Visible in Stores" for this poll first.')); + } + $pollModel->setStoreIds($storeIds); $answers = $this->getRequest()->getParam('answer'); @@ -166,23 +164,21 @@ public function validateAction() Mage::throwException(Mage::helper('adminhtml')->__('Please, add some answers to this poll first.')); } - if (is_array($answers)) { - $_titles = []; - foreach ($answers as $key => $answer) { - if (in_array($answer['title'], $_titles)) { - Mage::throwException(Mage::helper('adminhtml')->__('Your answers contain duplicates.')); - } - $_titles[] = $answer['title']; - - $answerModel = Mage::getModel('poll/poll_answer'); - if ((int) $key > 0) { - $answerModel->setId($key); - } - $answerModel->setAnswerTitle($answer['title']) - ->setVotesCount($answer['votes']); + $_titles = []; + foreach ($answers as $key => $answer) { + if (in_array($answer['title'], $_titles)) { + Mage::throwException(Mage::helper('adminhtml')->__('Your answers contain duplicates.')); + } + $_titles[] = $answer['title']; - $pollModel->addAnswer($answerModel); + $answerModel = Mage::getModel('poll/poll_answer'); + if ((int) $key > 0) { + $answerModel->setId($key); } + $answerModel->setAnswerTitle($answer['title']) + ->setVotesCount($answer['votes']); + + $pollModel->addAnswer($answerModel); } $pollModel->save(); diff --git a/app/code/core/Mage/Api2/Model/Resource.php b/app/code/core/Mage/Api2/Model/Resource.php index 200dbbf1a22..31ff249c55b 100644 --- a/app/code/core/Mage/Api2/Model/Resource.php +++ b/app/code/core/Mage/Api2/Model/Resource.php @@ -765,12 +765,11 @@ protected function _applyFilter(Varien_Data_Collection_Db $collection) if (!is_array($filter)) { $this->_critical(self::RESOURCE_COLLECTION_FILTERING_ERROR); } + if (method_exists($collection, 'addAttributeToFilter')) { $methodName = 'addAttributeToFilter'; - } elseif (method_exists($collection, 'addFieldToFilter')) { - $methodName = 'addFieldToFilter'; } else { - return $this; + $methodName = 'addFieldToFilter'; } $allowedAttributes = $this->getFilter()->getAllowedAttributes(self::OPERATION_ATTRIBUTE_READ); diff --git a/app/code/core/Mage/Catalog/Model/Product/Attribute/Tierprice/Api.php b/app/code/core/Mage/Catalog/Model/Product/Attribute/Tierprice/Api.php index d10eed288fd..ecc5d0e2384 100644 --- a/app/code/core/Mage/Catalog/Model/Product/Attribute/Tierprice/Api.php +++ b/app/code/core/Mage/Catalog/Model/Product/Attribute/Tierprice/Api.php @@ -122,10 +122,6 @@ public function prepareTierPrices($product, $tierPrices = null) return null; } - if (!is_array($tierPrices)) { - $this->_fault('data_invalid', Mage::helper('catalog')->__('Invalid Tier Prices')); - } - $updateValue = []; foreach ($tierPrices as $tierPrice) { diff --git a/app/code/core/Mage/Customer/Helper/Address.php b/app/code/core/Mage/Customer/Helper/Address.php index bb156c5269a..58028887cee 100644 --- a/app/code/core/Mage/Customer/Helper/Address.php +++ b/app/code/core/Mage/Customer/Helper/Address.php @@ -229,9 +229,7 @@ public function convertStreetLines($origStreets, $toCount) --$modulo; } $values = array_slice($origStreets, $offset, $neededLinesCount); - if (is_array($values)) { - $lines[] = implode(' ', $values); - } + $lines[] = implode(' ', $values); } } diff --git a/app/code/core/Mage/Tax/Model/Resource/Calculation.php b/app/code/core/Mage/Tax/Model/Resource/Calculation.php index 56e9ae64ac1..d63d2069881 100644 --- a/app/code/core/Mage/Tax/Model/Resource/Calculation.php +++ b/app/code/core/Mage/Tax/Model/Resource/Calculation.php @@ -307,7 +307,7 @@ protected function _getRates($request) ->where("rate.tax_region_id IN(?)", [0, (int)$regionId]); $postcodeIsNumeric = is_numeric($postcode); $postcodeIsRange = false; - if (is_string($postcode) && preg_match('/^(.+)-(.+)$/', $postcode, $matches)) { + if (preg_match('/^(.+)-(.+)$/', $postcode, $matches)) { if (is_numeric($matches[2]) && strlen($matches[2]) < 5) { $postcodeIsNumeric = true; } else { diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups.php b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups.php index 1072da4a62b..38494f521b9 100644 --- a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups.php +++ b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups.php @@ -1494,7 +1494,7 @@ protected function _formShipmentRequest(Varien_Object $request) $deliveryConfirmation = $packageParams->getDeliveryConfirmation(); if ($deliveryConfirmation) { - /** @var SimpleXMLElement $serviceOptionsNode */ + /** @var SimpleXMLElement|null $serviceOptionsNode */ $serviceOptionsNode = null; switch ($this->_getDeliveryConfirmationLevel($request->getRecipientAddressCountryCode())) { case self::DELIVERY_CONFIRMATION_PACKAGE: diff --git a/lib/Varien/Image/Adapter/Gd2.php b/lib/Varien/Image/Adapter/Gd2.php index 738151eddb0..cc4e94bab27 100644 --- a/lib/Varien/Image/Adapter/Gd2.php +++ b/lib/Varien/Image/Adapter/Gd2.php @@ -440,8 +440,6 @@ public function watermark($watermarkImage, $positionX = 0, $positionY = 0, $wate 'Unsupported watermark image format.' ), $watermarkImage); - $merged = false; - if ($this->getWatermarkWidth() && $this->getWatermarkHeigth() && ($this->getWatermarkPosition() != self::POSITION_STRETCH) @@ -559,7 +557,7 @@ public function watermark($watermarkImage, $positionX = 0, $positionY = 0, $wate ); } - if ($repeat === false && $merged === false) { + if ($repeat === false) { imagecopymerge( $this->_imageHandler, $watermark, diff --git a/phpstan.dist.baseline.neon b/phpstan.dist.baseline.neon index 171a910bbfc..28db462d6c5 100644 --- a/phpstan.dist.baseline.neon +++ b/phpstan.dist.baseline.neon @@ -485,11 +485,6 @@ parameters: count: 1 path: app/code/core/Mage/Adminhtml/controllers/Permissions/VariableController.php - - - message: "#^Call to function is_array\\(\\) with non\\-empty\\-array will always evaluate to true\\.$#" - count: 2 - path: app/code/core/Mage/Adminhtml/controllers/PollController.php - - message: "#^Cannot call method aggregate\\(\\) on Mage_Core_Model_Resource_Db_Collection_Abstract\\|false\\.$#" count: 2 @@ -735,11 +730,6 @@ parameters: count: 1 path: app/code/core/Mage/Api2/Model/Resource.php - - - message: "#^Call to function method_exists\\(\\) with Varien_Data_Collection_Db and 'addFieldToFilter' will always evaluate to true\\.$#" - count: 1 - path: app/code/core/Mage/Api2/Model/Resource.php - - message: "#^Method Mage_Api2_Model_Resource\\:\\:_create\\(\\) invoked with 1 parameter, 0 required\\.$#" count: 1 @@ -1415,11 +1405,6 @@ parameters: count: 1 path: app/code/core/Mage/Catalog/Model/Product/Attribute/Media/Api/V2.php - - - message: "#^Call to function is_array\\(\\) with array will always evaluate to true\\.$#" - count: 1 - path: app/code/core/Mage/Catalog/Model/Product/Attribute/Tierprice/Api.php - - message: "#^Access to an undefined property object\\:\\:\\$customer_group_id\\.$#" count: 1 @@ -2565,11 +2550,6 @@ parameters: count: 1 path: app/code/core/Mage/Customer/Block/Newsletter.php - - - message: "#^Call to function is_array\\(\\) with array will always evaluate to true\\.$#" - count: 1 - path: app/code/core/Mage/Customer/Helper/Address.php - - message: "#^Property Mage_Customer_Helper_Data\\:\\:\\$_customer \\(Mage_Customer_Model_Customer\\) in empty\\(\\) is not falsy\\.$#" count: 1 @@ -4570,11 +4550,6 @@ parameters: count: 1 path: app/code/core/Mage/Tax/Model/Config/Price/Include.php - - - message: "#^Call to function is_string\\(\\) with string will always evaluate to true\\.$#" - count: 1 - path: app/code/core/Mage/Tax/Model/Resource/Calculation.php - - message: "#^Return type \\(array\\) of method Mage_Tax_Model_Sales_Total_Quote_Nominal_Tax\\:\\:fetch\\(\\) should be compatible with return type \\(\\$this\\(Mage_Tax_Model_Sales_Total_Quote_Tax\\)\\) of method Mage_Tax_Model_Sales_Total_Quote_Tax\\:\\:fetch\\(\\)$#" count: 1 @@ -4755,11 +4730,6 @@ parameters: count: 1 path: app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups.php - - - message: "#^PHPDoc tag @var with type SimpleXMLElement is not subtype of native type null\\.$#" - count: 1 - path: app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups.php - - message: "#^Property Mage_Usa_Model_Shipping_Carrier_Ups\\:\\:\\$_baseCurrencyRate \\(float\\) does not accept string\\.$#" count: 1 @@ -5225,11 +5195,6 @@ parameters: count: 1 path: lib/Varien/Image/Adapter/Gd2.php - - - message: "#^Strict comparison using \\=\\=\\= between false and false will always evaluate to true\\.$#" - count: 1 - path: lib/Varien/Image/Adapter/Gd2.php - - message: "#^Access to an undefined property Varien_Object_Cache\\:\\:\\$_referencesByObject\\.$#" count: 1 From 9af7347f663aa0d6ee94a79b2d8ea8e4b61346a2 Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Mon, 27 Feb 2023 10:08:06 +0000 Subject: [PATCH 16/20] Update app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php --- .../core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php index a8a04753288..edf7512266e 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php @@ -54,8 +54,7 @@ public function getCategoryName() public function getCategoryPath() { - $category = $this->getCategory(); - if (is_object($category) && $category->getId()) { + if ($this->getCategory()) { return $this->getCategory()->getPath(); } return Mage_Catalog_Model_Category::TREE_ROOT_ID; From 6041348bf786ddbe0425eca671db367a5d2e1b0b Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Mon, 27 Feb 2023 10:08:41 +0000 Subject: [PATCH 17/20] Update app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php --- .../core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php index edf7512266e..019a2f8d3c8 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php @@ -40,8 +40,7 @@ public function getCategory() public function getCategoryId() { - $category = $this->getCategory(); - if (is_object($category) && $category->getId()) { + if ($this->getCategory()) { return $category->getId(); } return Mage_Catalog_Model_Category::TREE_ROOT_ID; From 64cb770d37f9103358556b695adea777ad9d5cb8 Mon Sep 17 00:00:00 2001 From: server prod Date: Mon, 27 Feb 2023 10:11:01 +0000 Subject: [PATCH 18/20] not needed --- .../core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php index 019a2f8d3c8..6c1aa90ce1b 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php @@ -41,7 +41,7 @@ public function getCategory() public function getCategoryId() { if ($this->getCategory()) { - return $category->getId(); + return $this->getCategory()->getId(); } return Mage_Catalog_Model_Category::TREE_ROOT_ID; } From 3be3a6d09577a8098dbcc6aa3f78821ddede1082 Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Mon, 27 Feb 2023 18:21:43 +0000 Subject: [PATCH 19/20] Update app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php --- .../core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php index 6c1aa90ce1b..2f9e9f71066 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php @@ -94,7 +94,7 @@ public function getRoot($parentNodeCategory = null, $recursionLevel = 3) ->load(null, $recursionLevel); $category = $this->getCategory(); - if (is_object($category) and $category->getId()) { + if (is_object($category) && $category->getId()) { $tree->loadEnsuredNodes($category, $tree->getNodeById($rootId)); } From dbc40f4aea8e59b7bd8a8913c7a28970afa476cb Mon Sep 17 00:00:00 2001 From: server prod Date: Tue, 28 Feb 2023 09:42:36 +0000 Subject: [PATCH 20/20] revert --- .../core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php index 2f9e9f71066..3cbd140f217 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php @@ -93,9 +93,8 @@ public function getRoot($parentNodeCategory = null, $recursionLevel = 3) $tree = Mage::getResourceSingleton('catalog/category_tree') ->load(null, $recursionLevel); - $category = $this->getCategory(); - if (is_object($category) && $category->getId()) { - $tree->loadEnsuredNodes($category, $tree->getNodeById($rootId)); + if ($this->getCategory()) { + $tree->loadEnsuredNodes($this->getCategory(), $tree->getNodeById($rootId)); } $tree->addCollectionData($this->getCategoryCollection());