From b4c70bb8c4ae032ce92b5ae24d789a24482efc43 Mon Sep 17 00:00:00 2001 From: sv3n Date: Tue, 27 Dec 2022 09:52:14 +0100 Subject: [PATCH] Remove `mixed` type usage to support PHP7 (#2856) --- lib/Varien/Data/Form/Element/Collection.php | 3 +- lib/Varien/Data/Tree/Node/Collection.php | 3 +- lib/Varien/Db/Tree/NodeSet.php | 6 +- lib/Varien/Object.php | 3 +- phpstan.dist.baseline.neon | 79 +++++++-------------- phpstan.dist.neon | 1 - 6 files changed, 37 insertions(+), 58 deletions(-) diff --git a/lib/Varien/Data/Form/Element/Collection.php b/lib/Varien/Data/Form/Element/Collection.php index 8c6e7bcf76c..fcb14bffb0e 100644 --- a/lib/Varien/Data/Form/Element/Collection.php +++ b/lib/Varien/Data/Form/Element/Collection.php @@ -80,7 +80,8 @@ public function offsetSet($key, $value): void * @param mixed $key * @return mixed */ - public function offsetGet($key): mixed + #[\ReturnTypeWillChange] + public function offsetGet($key) { return $this->_elements[$key]; } diff --git a/lib/Varien/Data/Tree/Node/Collection.php b/lib/Varien/Data/Tree/Node/Collection.php index 084314167cb..46888303640 100644 --- a/lib/Varien/Data/Tree/Node/Collection.php +++ b/lib/Varien/Data/Tree/Node/Collection.php @@ -79,7 +79,8 @@ public function offsetSet($key, $value): void * @param string $key * @return mixed|Varien_Data_Tree_Node */ - public function offsetGet($key): mixed + #[\ReturnTypeWillChange] + public function offsetGet($key) { return $this->_nodes[$key]; } diff --git a/lib/Varien/Db/Tree/NodeSet.php b/lib/Varien/Db/Tree/NodeSet.php index a902bbd3de8..71582f6c7e0 100644 --- a/lib/Varien/Db/Tree/NodeSet.php +++ b/lib/Varien/Db/Tree/NodeSet.php @@ -74,12 +74,14 @@ public function next() } } - public function key(): mixed + #[\ReturnTypeWillChange] + public function key() { return $this->_current; } - public function current(): mixed + #[\ReturnTypeWillChange] + public function current() { return $this->_nodes[$this->_current]; } diff --git a/lib/Varien/Object.php b/lib/Varien/Object.php index 8b3da8d92e2..2b61732c692 100644 --- a/lib/Varien/Object.php +++ b/lib/Varien/Object.php @@ -871,7 +871,8 @@ public function offsetUnset($offset): void * @param string $offset * @return mixed */ - public function offsetGet($offset): mixed + #[\ReturnTypeWillChange] + public function offsetGet($offset) { return isset($this->_data[$offset]) ? $this->_data[$offset] : null; } diff --git a/phpstan.dist.baseline.neon b/phpstan.dist.baseline.neon index e480890bb11..57ddf979f05 100644 --- a/phpstan.dist.baseline.neon +++ b/phpstan.dist.baseline.neon @@ -1135,11 +1135,6 @@ parameters: count: 1 path: app/code/core/Mage/Api/Model/Wsdl/Config/Element.php - - - message: "#^Return type \\(array\\) of method Mage_Api_Model_Wsdl_Config_Element\\:\\:getChildren\\(\\) should be compatible with return type \\(RecursiveIterator\\|null\\) of method RecursiveIterator\\\\:\\:getChildren\\(\\)$#" - count: 1 - path: app/code/core/Mage/Api/Model/Wsdl/Config/Element.php - - message: "#^Property Mage_Api2_Block_Adminhtml_Attribute_Tab_Resource\\:\\:\\$_treeModel \\(Mage_Api2_Model_Acl_Global_Rule_Tree\\) does not accept default value of type false\\.$#" count: 1 @@ -2130,11 +2125,6 @@ parameters: count: 1 path: app/code/core/Mage/Catalog/Model/Product/Flat/Indexer.php - - - message: "#^Binary operation \"\\*\" between string and 1024 results in an error\\.$#" - count: 3 - path: app/code/core/Mage/Catalog/Model/Product/Image.php - - message: "#^Negated boolean expression is always false\\.$#" count: 1 @@ -3140,16 +3130,6 @@ parameters: count: 1 path: app/code/core/Mage/Core/Controller/Request/Http.php - - - message: "#^Result of && is always false\\.$#" - count: 1 - path: app/code/core/Mage/Core/Controller/Request/Http.php - - - - message: "#^Strict comparison using \\=\\=\\= between string and false will always evaluate to false\\.$#" - count: 1 - path: app/code/core/Mage/Core/Controller/Request/Http.php - - message: "#^Strict comparison using \\=\\=\\= between string and null will always evaluate to false\\.$#" count: 2 @@ -3646,7 +3626,7 @@ parameters: path: app/code/core/Mage/Core/Model/Resource/Setup.php - - message: "#^Binary operation \"\\.\" between string and array results in an error\\.$#" + message: "#^Binary operation \"\\.\" between \\(string\\|false\\) and array results in an error\\.$#" count: 1 path: app/code/core/Mage/Core/Model/Resource/Setup/Query/Modifier.php @@ -5065,16 +5045,6 @@ parameters: count: 2 path: app/code/core/Mage/Log/Model/Resource/Log.php - - - message: "#^Method Mage_Media_Model_File_Image\\:\\:getImage\\(\\) should return bool\\|resource but returns GdImage\\.$#" - count: 1 - path: app/code/core/Mage/Media/Model/File/Image.php - - - - message: "#^Method Mage_Media_Model_File_Image\\:\\:getTmpImage\\(\\) should return resource but returns GdImage\\|false\\.$#" - count: 1 - path: app/code/core/Mage/Media/Model/File/Image.php - - message: "#^Left side of && is always true\\.$#" count: 1 @@ -5196,7 +5166,7 @@ parameters: path: app/code/core/Mage/Payment/Model/Method/Abstract.php - - message: "#^Binary operation \"\\*\\=\" between string and 2 results in an error\\.$#" + message: "#^Binary operation \"\\-\" between string and int\\<\\-9, 9\\> results in an error\\.$#" count: 1 path: app/code/core/Mage/Payment/Model/Method/Cc.php @@ -6900,26 +6870,6 @@ parameters: count: 1 path: app/code/core/Mage/Tax/Model/Sales/Total/Quote/Tax.php - - - message: "#^Binary operation \"\\*\" between string and 1024 results in an error\\.$#" - count: 1 - path: app/code/core/Mage/Uploader/Helper/File.php - - - - message: "#^Binary operation \"\\*\" between string and 1048576 results in an error\\.$#" - count: 1 - path: app/code/core/Mage/Uploader/Helper/File.php - - - - message: "#^Binary operation \"\\*\" between string and 1073741824 results in an error\\.$#" - count: 1 - path: app/code/core/Mage/Uploader/Helper/File.php - - - - message: "#^Binary operation \"\\*\" between string and 1099511627776 results in an error\\.$#" - count: 1 - path: app/code/core/Mage/Uploader/Helper/File.php - - message: "#^Property Mage_Shipping_Model_Carrier_Abstract\\:\\:\\$_code \\(string\\) on left side of \\?\\? is not nullable\\.$#" count: 1 @@ -7375,6 +7325,11 @@ parameters: count: 2 path: lib/Mage/HTTP/Client/Curl.php + - + message: "#^Property Mage_HTTP_Client_Curl\\:\\:\\$_ch \\(object\\) does not accept resource\\.$#" + count: 1 + path: lib/Mage/HTTP/Client/Curl.php + - message: "#^Negated boolean expression is always false\\.$#" count: 2 @@ -7745,16 +7700,36 @@ parameters: count: 1 path: lib/Varien/Filter/Template/Tokenizer/Variable.php + - + message: "#^Method Varien_Http_Adapter_Curl\\:\\:_getResource\\(\\) has invalid return type CurlHandle\\.$#" + count: 1 + path: lib/Varien/Http/Adapter/Curl.php + + - + message: "#^Property Varien_Http_Adapter_Curl\\:\\:\\$_resource has unknown class CurlHandle as its type\\.$#" + count: 1 + path: lib/Varien/Http/Adapter/Curl.php + - message: "#^Method Varien_Image_Adapter_Abstract\\:\\:backgroundColor\\(\\) should return array but empty return statement found\\.$#" count: 2 path: lib/Varien/Image/Adapter/Abstract.php + - + message: "#^Property Varien_Image_Adapter_Abstract\\:\\:\\$_imageHandler has unknown class GdImage as its type\\.$#" + 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 + path: lib/Varien/Image/Adapter/Gd2.php + - message: "#^Result of \\|\\| is always true\\.$#" count: 1 diff --git a/phpstan.dist.neon b/phpstan.dist.neon index 98df53d565c..d1a8ecd75a1 100644 --- a/phpstan.dist.neon +++ b/phpstan.dist.neon @@ -3,7 +3,6 @@ includes: - phpstan.dist.issues.neon - phpstan.dist.baseline.neon parameters: - phpVersion: 80000 # PHP 8.0 magentoRootPath: %currentWorkingDirectory% paths: - api.php