Skip to content

Commit

Permalink
Remove mixed type usage to support PHP7 (#2856)
Browse files Browse the repository at this point in the history
  • Loading branch information
sreichel authored Dec 27, 2022
1 parent 6899151 commit b4c70bb
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 58 deletions.
3 changes: 2 additions & 1 deletion lib/Varien/Data/Form/Element/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down
3 changes: 2 additions & 1 deletion lib/Varien/Data/Tree/Node/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down
6 changes: 4 additions & 2 deletions lib/Varien/Db/Tree/NodeSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down
3 changes: 2 additions & 1 deletion lib/Varien/Object.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
79 changes: 27 additions & 52 deletions phpstan.dist.baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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\\<string,static\\(SimpleXMLElement\\)\\>\\:\\: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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion phpstan.dist.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ includes:
- phpstan.dist.issues.neon
- phpstan.dist.baseline.neon
parameters:
phpVersion: 80000 # PHP 8.0
magentoRootPath: %currentWorkingDirectory%
paths:
- api.php
Expand Down

0 comments on commit b4c70bb

Please sign in to comment.