Skip to content

Commit 22700c4

Browse files
sreichelkiatng
andauthored
PHPStan: fixed some unknown types (#2538)
* Fixed typo * Fixed unknown types * Updated phpstan-baseline.neon * Update app/code/core/Zend/Validate/EmailAddress.php Co-authored-by: Ng Kiat Siong <[email protected]> * Update app/code/core/Mage/Adminhtml/Block/System/Config/Tabs.php Co-authored-by: Ng Kiat Siong <[email protected]> * Update app/code/core/Mage/Paypal/Model/Express/Checkout.php Co-authored-by: Ng Kiat Siong <[email protected]> Co-authored-by: Ng Kiat Siong <[email protected]>
1 parent 5d9036e commit 22700c4

File tree

10 files changed

+74
-129
lines changed

10 files changed

+74
-129
lines changed

.github/phpstan-baseline.neon

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -390,21 +390,6 @@ parameters:
390390
count: 2
391391
path: ../app/code/core/Mage/Adminhtml/Block/System/Config/Form.php
392392

393-
-
394-
message: "#^Access to property \\$sort_order on an unknown class unknown_type\\.$#"
395-
count: 4
396-
path: ../app/code/core/Mage/Adminhtml/Block/System/Config/Tabs.php
397-
398-
-
399-
message: "#^Parameter \\$a of method Mage_Adminhtml_Block_System_Config_Tabs\\:\\:_sort\\(\\) has invalid type unknown_type\\.$#"
400-
count: 1
401-
path: ../app/code/core/Mage/Adminhtml/Block/System/Config/Tabs.php
402-
403-
-
404-
message: "#^Parameter \\$b of method Mage_Adminhtml_Block_System_Config_Tabs\\:\\:_sort\\(\\) has invalid type unknown_type\\.$#"
405-
count: 1
406-
path: ../app/code/core/Mage/Adminhtml/Block/System/Config/Tabs.php
407-
408393
-
409394
message: "#^Access to an undefined property Mage_Adminhtml_Block_System_Convert_Gui_Edit_Tab_Wizard\\:\\:\\$_filterStores\\.$#"
410395
count: 1
@@ -525,11 +510,6 @@ parameters:
525510
count: 3
526511
path: ../app/code/core/Mage/Adminhtml/Block/Widget/Grid.php
527512

528-
-
529-
message: "#^Parameter \\$action of method Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Action\\:\\:_toOptionHtml\\(\\) has invalid type unknown_type\\.$#"
530-
count: 1
531-
path: ../app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Action.php
532-
533513
-
534514
message: "#^Binary operation \"\\*\" between string and 1 results in an error\\.$#"
535515
count: 1
@@ -575,11 +555,6 @@ parameters:
575555
count: 1
576556
path: ../app/code/core/Mage/Adminhtml/Helper/Catalog/Product/Composite.php
577557

578-
-
579-
message: "#^Property Mage_Adminhtml_Helper_Dashboard_Abstract\\:\\:\\$_collection has unknown class Mage_Core_Model_Mysql_Collection_Abstract as its type\\.$#"
580-
count: 1
581-
path: ../app/code/core/Mage/Adminhtml/Helper/Dashboard/Abstract.php
582-
583558
-
584559
message: "#^Method Mage_Adminhtml_Model_Config\\:\\:getSection\\(\\) should return Varien_Simplexml_Element but return statement is missing\\.$#"
585560
count: 1
@@ -1730,11 +1705,6 @@ parameters:
17301705
count: 1
17311706
path: ../app/code/core/Mage/Catalog/Model/Resource/Product/Flat/Indexer.php
17321707

1733-
-
1734-
message: "#^Call to method fetch\\(\\) on an unknown class PDO_Statement\\.$#"
1735-
count: 2
1736-
path: ../app/code/core/Mage/Catalog/Model/Resource/Product/Indexer/Eav/Source.php
1737-
17381708
-
17391709
message: "#^Binary operation \"\\*\" between string and 0\\.3 results in an error\\.$#"
17401710
count: 1
@@ -1830,11 +1800,6 @@ parameters:
18301800
count: 1
18311801
path: ../app/code/core/Mage/CatalogIndex/Model/Indexer/Minimalprice.php
18321802

1833-
-
1834-
message: "#^Call to method fetchAll\\(\\) on an unknown class PDO_Statement\\.$#"
1835-
count: 1
1836-
path: ../app/code/core/Mage/CatalogIndex/Model/Resource/Data/Grouped.php
1837-
18381803
-
18391804
message: "#^Binary operation \"\\*\" between string and float results in an error\\.$#"
18401805
count: 1
@@ -1860,11 +1825,6 @@ parameters:
18601825
count: 1
18611826
path: ../app/code/core/Mage/CatalogInventory/Model/Resource/Indexer/Stock.php
18621827

1863-
-
1864-
message: "#^Call to method fetch\\(\\) on an unknown class PDO_Statement\\.$#"
1865-
count: 1
1866-
path: ../app/code/core/Mage/CatalogInventory/Model/Resource/Indexer/Stock.php
1867-
18681828
-
18691829
message: "#^Cannot call method setTypeId\\(\\) on Mage_Core_Model_Resource_Db_Collection_Abstract\\|false\\.$#"
18701830
count: 1
@@ -2950,10 +2910,6 @@ parameters:
29502910
count: 1
29512911
path: ../app/code/core/Mage/Install/Model/Installer/Db.php
29522912

2953-
-
2954-
message: "#^Property Mage_Install_Model_Installer_Db\\:\\:\\$_dbResource has unknown class database as its type\\.$#"
2955-
count: 1
2956-
path: ../app/code/core/Mage/Install/Model/Installer/Db.php
29572913

29582914
-
29592915
message: "#^Call to an undefined method Varien_Object\\:\\:addError\\(\\)\\.$#"
@@ -3355,11 +3311,6 @@ parameters:
33553311
count: 2
33563312
path: ../app/code/core/Mage/Paypal/Model/Express/Checkout.php
33573313

3358-
-
3359-
message: "#^Property Mage_Paypal_Model_Express_Checkout\\:\\:\\$_order has unknown class Mage_Sales_Model_QuoteMage_Sales_Model_Quote as its type\\.$#"
3360-
count: 1
3361-
path: ../app/code/core/Mage/Paypal/Model/Express/Checkout.php
3362-
33633314
-
33643315
message: "#^Variable \\$address might not be defined\\.$#"
33653316
count: 1
@@ -3575,11 +3526,6 @@ parameters:
35753526
count: 1
35763527
path: ../app/code/core/Mage/Reports/Model/Resource/Product/Collection.php
35773528

3578-
-
3579-
message: "#^Call to method fetchAll\\(\\) on an unknown class PDO_Statement\\.$#"
3580-
count: 1
3581-
path: ../app/code/core/Mage/Reports/Model/Resource/Product/Index/Abstract.php
3582-
35833529
-
35843530
message: "#^Comparison operation \"\\!\\=\" between array\\|int and 0 results in an error\\.$#"
35853531
count: 1

app/code/core/Mage/Adminhtml/Block/System/Config/Tabs.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ protected function _construct()
4242
}
4343

4444
/**
45-
* @param unknown_type $a
46-
* @param unknown_type $b
45+
* @param Mage_Core_Model_Config_Element $a
46+
* @param Mage_Core_Model_Config_Element $b
4747
* @return int
4848
*/
4949
protected function _sort($a, $b)

app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Action.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function render(Varien_Object $row)
6666
/**
6767
* Render single action as dropdown option html
6868
*
69-
* @param unknown_type $action
69+
* @param array $action
7070
* @param Varien_Object $row
7171
* @return string
7272
*/

app/code/core/Mage/Adminhtml/Helper/Dashboard/Abstract.php

Lines changed: 65 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -25,88 +25,87 @@
2525
* @package Mage_Adminhtml
2626
* @author Magento Core Team <[email protected]>
2727
*/
28-
abstract class Mage_Adminhtml_Helper_Dashboard_Abstract extends Mage_Core_Helper_Data
29-
{
30-
/**
31-
* Helper collection
32-
*
33-
* @var Mage_Core_Model_Mysql_Collection_Abstract|Mage_Eav_Model_Entity_Collection_Abstract|array
34-
*/
35-
protected $_collection;
28+
abstract class Mage_Adminhtml_Helper_Dashboard_Abstract extends Mage_Core_Helper_Data
29+
{
30+
/**
31+
* Helper collection
32+
*
33+
* @var Mage_Core_Model_Resource_Db_Collection_Abstract|Mage_Eav_Model_Entity_Collection_Abstract|array
34+
*/
35+
protected $_collection;
3636

37-
/**
38-
* Parameters for helper
39-
*
40-
* @var array
41-
*/
42-
protected $_params = [];
37+
/**
38+
* Parameters for helper
39+
*
40+
* @var array
41+
*/
42+
protected $_params = [];
4343

44-
public function getCollection()
45-
{
46-
if(is_null($this->_collection)) {
47-
$this->_initCollection();
48-
}
49-
return $this->_collection;
44+
public function getCollection()
45+
{
46+
if (is_null($this->_collection)) {
47+
$this->_initCollection();
5048
}
49+
return $this->_collection;
50+
}
5151

52-
abstract protected function _initCollection();
52+
abstract protected function _initCollection();
5353

54-
/**
55-
* Returns collection items
56-
*
57-
* @return array
58-
*/
59-
public function getItems()
60-
{
61-
return is_array($this->getCollection()) ? $this->getCollection() : $this->getCollection()->getItems();
62-
}
54+
/**
55+
* Returns collection items
56+
*
57+
* @return array
58+
*/
59+
public function getItems()
60+
{
61+
return is_array($this->getCollection()) ? $this->getCollection() : $this->getCollection()->getItems();
62+
}
6363

64-
public function getCount()
65-
{
66-
return count($this->getItems());
67-
}
64+
public function getCount()
65+
{
66+
return count($this->getItems());
67+
}
6868

69-
public function getColumn($index)
70-
{
71-
$result = [];
72-
foreach ($this->getItems() as $item) {
73-
if (is_array($item)) {
74-
if(isset($item[$index])) {
75-
$result[] = $item[$index];
76-
} else {
77-
$result[] = null;
78-
}
79-
} elseif ($item instanceof Varien_Object) {
80-
$result[] = $item->getData($index);
69+
public function getColumn($index)
70+
{
71+
$result = [];
72+
foreach ($this->getItems() as $item) {
73+
if (is_array($item)) {
74+
if(isset($item[$index])) {
75+
$result[] = $item[$index];
8176
} else {
8277
$result[] = null;
8378
}
79+
} elseif ($item instanceof Varien_Object) {
80+
$result[] = $item->getData($index);
81+
} else {
82+
$result[] = null;
8483
}
85-
return $result;
86-
}
87-
88-
public function setParam($name, $value)
89-
{
90-
$this->_params[$name] = $value;
9184
}
85+
return $result;
86+
}
9287

93-
public function setParams(array $params)
94-
{
95-
$this->_params = $params;
96-
}
88+
public function setParam($name, $value)
89+
{
90+
$this->_params[$name] = $value;
91+
}
9792

98-
public function getParam($name)
99-
{
100-
if(isset($this->_params[$name])) {
101-
return $this->_params[$name];
102-
}
93+
public function setParams(array $params)
94+
{
95+
$this->_params = $params;
96+
}
10397

104-
return null;
98+
public function getParam($name)
99+
{
100+
if(isset($this->_params[$name])) {
101+
return $this->_params[$name];
105102
}
106103

107-
public function getParams()
108-
{
109-
return $this->_params;
110-
}
104+
return null;
105+
}
111106

107+
public function getParams()
108+
{
109+
return $this->_params;
110+
}
112111
}

app/code/core/Mage/Install/Model/Installer/Db.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
class Mage_Install_Model_Installer_Db extends Mage_Install_Model_Installer_Abstract
2929
{
3030
/**
31-
* @var database resource
31+
* @var resource database
3232
*/
3333
protected $_dbResource;
3434

app/code/core/Mage/Paypal/Model/Express/Checkout.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ class Mage_Paypal_Model_Express_Checkout
142142
/**
143143
* Order
144144
*
145-
* @var Mage_Sales_Model_QuoteMage_Sales_Model_Quote
145+
* @var Mage_Sales_Model_Order
146146
*/
147147
protected $_order = null;
148148

app/code/core/Mage/PaypalUk/Model/Express/Checkout.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Mage_PaypalUk_Model_Express_Checkout extends Mage_Paypal_Model_Express_Che
3737

3838
/**
3939
* Payment method tpye
40-
* @var unknown_type
40+
* @var string
4141
*/
4242
protected $_methodType = Mage_Paypal_Model_Config::METHOD_WPP_PE_EXPRESS;
4343

app/code/core/Zend/Db/Select.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ public function getPart($part)
707707
*
708708
* @param integer $fetchMode OPTIONAL
709709
* @param mixed $bind An array of data to bind to the placeholders.
710-
* @return PDO_Statement|Zend_Db_Statement
710+
* @return Zend_Db_Statement
711711
*/
712712
public function query($fetchMode = null, $bind = array())
713713
{

app/code/core/Zend/Db/Statement.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ public function getAdapter()
466466
/**
467467
* Gets the resource or object setup by the
468468
* _parse
469-
* @return unknown_type
469+
* @return resource|object
470470
*/
471471
public function getDriverStatement()
472472
{

app/code/core/Zend/Validate/EmailAddress.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ public function setDeepMxCheck($deep)
324324
/**
325325
* Returns the set domainCheck option
326326
*
327-
* @return unknown
327+
* @return bool
328328
*/
329329
public function getDomainCheck()
330330
{

0 commit comments

Comments
 (0)