Skip to content

Commit 5e04bdb

Browse files
authored
PhpStan L5 fixes for Mage/Admin (#2761)
1 parent 7fe65ad commit 5e04bdb

File tree

12 files changed

+12
-138
lines changed

12 files changed

+12
-138
lines changed

.github/phpstan-baseline.neon

Lines changed: 0 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -35,46 +35,11 @@ parameters:
3535
count: 1
3636
path: ../app/code/core/Mage/Admin/Model/Config.php
3737

38-
-
39-
message: "#^Parameter \\#1 \\$sourceData of class Varien_Simplexml_Config constructor expects string\\|Varien_Simplexml_Element\\|null, Varien_Simplexml_Config given\\.$#"
40-
count: 1
41-
path: ../app/code/core/Mage/Admin/Model/Config.php
42-
43-
-
44-
message: "#^Parameter \\#2 \\$arguments of static method Mage\\:\\:getModel\\(\\) expects array\\|object, string given\\.$#"
45-
count: 2
46-
path: ../app/code/core/Mage/Admin/Model/Config.php
47-
48-
-
49-
message: "#^Parameter \\#2 \\$mergeToObject of method Mage_Core_Model_Config\\:\\:loadModulesConfiguration\\(\\) expects Mage_Core_Model_Config_Base\\|null, Varien_Simplexml_Config given\\.$#"
50-
count: 1
51-
path: ../app/code/core/Mage/Admin/Model/Config.php
52-
53-
-
54-
message: "#^Parameter \\#2 \\$resource of method Mage_Admin_Model_Config\\:\\:loadAclResources\\(\\) expects Mage_Core_Model_Config_Element\\|null, Varien_Simplexml_Element given\\.$#"
55-
count: 1
56-
path: ../app/code/core/Mage/Admin/Model/Config.php
57-
58-
-
59-
message: "#^Left side of && is always true\\.$#"
60-
count: 1
61-
path: ../app/code/core/Mage/Admin/Model/Observer.php
62-
6338
-
6439
message: "#^Cannot call method getClassName\\(\\) on SimpleXMLElement\\|false\\.$#"
6540
count: 1
6641
path: ../app/code/core/Mage/Admin/Model/Resource/Acl.php
6742

68-
-
69-
message: "#^Parameter \\#2 \\$arguments of static method Mage\\:\\:getModel\\(\\) expects array\\|object, string given\\.$#"
70-
count: 2
71-
path: ../app/code/core/Mage/Admin/Model/Resource/Acl.php
72-
73-
-
74-
message: "#^Strict comparison using \\=\\=\\= between string and false will always evaluate to false\\.$#"
75-
count: 1
76-
path: ../app/code/core/Mage/Admin/Model/Resource/Block.php
77-
7843
-
7944
message: "#^Parameter \\#1 \\$role of method Mage_Admin_Model_Resource_Roles\\:\\:_updateRoleUsersAcl\\(\\) expects Mage_Admin_Model_Roles, Mage_Core_Model_Abstract given\\.$#"
8045
count: 1
@@ -85,11 +50,6 @@ parameters:
8550
count: 1
8651
path: ../app/code/core/Mage/Admin/Model/Resource/User.php
8752

88-
-
89-
message: "#^Strict comparison using \\=\\=\\= between string and false will always evaluate to false\\.$#"
90-
count: 1
91-
path: ../app/code/core/Mage/Admin/Model/Resource/Variable.php
92-
9353
-
9454
message: "#^Call to an undefined method Mage_Admin_Model_Resource_Roles\\:\\:update\\(\\)\\.$#"
9555
count: 1
@@ -110,16 +70,6 @@ parameters:
11070
count: 1
11171
path: ../app/code/core/Mage/Admin/Model/Session.php
11272

113-
-
114-
message: "#^Call to function is_null\\(\\) with bool will always evaluate to false\\.$#"
115-
count: 1
116-
path: ../app/code/core/Mage/Admin/Model/Session.php
117-
118-
-
119-
message: "#^Parameter \\#1 \\$parent of method Mage_Admin_Model_User\\:\\:findFirstAvailableMenu\\(\\) expects Mage_Core_Model_Config_Element\\|null, Varien_Simplexml_Element given\\.$#"
120-
count: 1
121-
path: ../app/code/core/Mage/Admin/Model/User.php
122-
12373
-
12474
message: "#^Call to function is_null\\(\\) with Mage_AdminNotification_Model_Inbox will always evaluate to false\\.$#"
12575
count: 1
@@ -2305,11 +2255,6 @@ parameters:
23052255
count: 1
23062256
path: ../app/code/core/Mage/Api/Model/Acl.php
23072257

2308-
-
2309-
message: "#^Parameter \\#2 \\$arguments of static method Mage\\:\\:getModel\\(\\) expects array\\|object, string given\\.$#"
2310-
count: 1
2311-
path: ../app/code/core/Mage/Api/Model/Config.php
2312-
23132258
-
23142259
message: "#^Parameter \\#2 \\$resource of method Mage_Api_Model_Config\\:\\:loadAclResources\\(\\) expects Mage_Core_Model_Config_Element\\|null, Varien_Simplexml_Element given\\.$#"
23152260
count: 1
@@ -2330,11 +2275,6 @@ parameters:
23302275
count: 1
23312276
path: ../app/code/core/Mage/Api/Model/Resource/Acl.php
23322277

2333-
-
2334-
message: "#^Parameter \\#2 \\$arguments of static method Mage\\:\\:getModel\\(\\) expects array\\|object, string given\\.$#"
2335-
count: 2
2336-
path: ../app/code/core/Mage/Api/Model/Resource/Acl.php
2337-
23382278
-
23392279
message: "#^Method Mage_Core_Model_Resource_Db_Abstract\\:\\:load\\(\\) invoked with 1 parameter, 2\\-3 required\\.$#"
23402280
count: 1
@@ -2495,11 +2435,6 @@ parameters:
24952435
count: 1
24962436
path: ../app/code/core/Mage/Api/Model/Wsdl/Config.php
24972437

2498-
-
2499-
message: "#^Parameter \\#2 \\$mergeToObject of method Mage_Core_Model_Config\\:\\:loadModulesConfiguration\\(\\) expects Mage_Core_Model_Config_Base\\|null, \\$this\\(Mage_Api_Model_Wsdl_Config\\) given\\.$#"
2500-
count: 2
2501-
path: ../app/code/core/Mage/Api/Model/Wsdl/Config.php
2502-
25032438
-
25042439
message: "#^Parameter \\#3 \\$mergeModel of method Mage_Core_Model_Config\\:\\:loadModulesConfiguration\\(\\) expects null, Mage_Api_Model_Wsdl_Config_Base given\\.$#"
25052440
count: 2
@@ -6900,11 +6835,6 @@ parameters:
69006835
count: 1
69016836
path: ../app/code/core/Mage/Core/Helper/Js.php
69026837

6903-
-
6904-
message: "#^Parameter \\#2 \\$mergeToObject of method Mage_Core_Model_Config\\:\\:loadModulesConfiguration\\(\\) expects Mage_Core_Model_Config_Base\\|null, Varien_Simplexml_Config given\\.$#"
6905-
count: 1
6906-
path: ../app/code/core/Mage/Core/Helper/Js.php
6907-
69086838
-
69096839
message: "#^Negated boolean expression is always false\\.$#"
69106840
count: 1
@@ -7060,11 +6990,6 @@ parameters:
70606990
count: 1
70616991
path: ../app/code/core/Mage/Core/Model/Cache.php
70626992

7063-
-
7064-
message: "#^Strict comparison using \\=\\=\\= between string and false will always evaluate to false\\.$#"
7065-
count: 1
7066-
path: ../app/code/core/Mage/Core/Model/Cache.php
7067-
70686993
-
70696994
message: "#^Call to an undefined method SimpleXMLElement\\:\\:getClassName\\(\\)\\.$#"
70706995
count: 1
@@ -9190,11 +9115,6 @@ parameters:
91909115
count: 1
91919116
path: ../app/code/core/Mage/Eav/Model/Entity/Abstract.php
91929117

9193-
-
9194-
message: "#^Parameter \\#2 \\$arguments of static method Mage\\:\\:getModel\\(\\) expects array\\|object, string given\\.$#"
9195-
count: 1
9196-
path: ../app/code/core/Mage/Eav/Model/Entity/Abstract.php
9197-
91989118
-
91999119
message: "#^Property Mage_Eav_Model_Entity_Abstract\\:\\:\\$_read \\(Varien_Db_Adapter_Pdo_Mysql\\) does not accept Varien_Db_Adapter_Interface\\|false\\.$#"
92009120
count: 1
@@ -9725,11 +9645,6 @@ parameters:
97259645
count: 1
97269646
path: ../app/code/core/Mage/ImportExport/Model/Abstract.php
97279647

9728-
-
9729-
message: "#^Parameter \\#2 \\$arguments of static method Mage\\:\\:getModel\\(\\) expects array\\|object, string given\\.$#"
9730-
count: 1
9731-
path: ../app/code/core/Mage/ImportExport/Model/Abstract.php
9732-
97339648
-
97349649
message: "#^If condition is always true\\.$#"
97359650
count: 1
@@ -9865,11 +9780,6 @@ parameters:
98659780
count: 1
98669781
path: ../app/code/core/Mage/ImportExport/Model/Import.php
98679782

9868-
-
9869-
message: "#^Parameter \\#2 \\$arguments of static method Mage\\:\\:getModel\\(\\) expects array\\|object, string given\\.$#"
9870-
count: 3
9871-
path: ../app/code/core/Mage/ImportExport/Model/Import.php
9872-
98739783
-
98749784
message: "#^Property Mage_ImportExport_Model_Import\\:\\:\\$_entityAdapter \\(Mage_ImportExport_Model_Import_Entity_Abstract\\) does not accept Mage_Core_Model_Abstract\\|false\\.$#"
98759785
count: 1
@@ -10235,11 +10145,6 @@ parameters:
1023510145
count: 1
1023610146
path: ../app/code/core/Mage/Install/Model/Config.php
1023710147

10238-
-
10239-
message: "#^Parameter \\#2 \\$mergeToObject of method Mage_Core_Model_Config\\:\\:loadModulesConfiguration\\(\\) expects Mage_Core_Model_Config_Base\\|null, \\$this\\(Mage_Install_Model_Config\\) given\\.$#"
10240-
count: 1
10241-
path: ../app/code/core/Mage/Install/Model/Config.php
10242-
1024310148
-
1024410149
message: "#^Call to function is_null\\(\\) with Mage_Install_Model_Session will always evaluate to false\\.$#"
1024510150
count: 1
@@ -10850,11 +10755,6 @@ parameters:
1085010755
count: 1
1085110756
path: ../app/code/core/Mage/Payment/Model/Method/Abstract.php
1085210757

10853-
-
10854-
message: "#^Parameter \\#2 \\$arguments of static method Mage\\:\\:getModel\\(\\) expects array\\|object, string given\\.$#"
10855-
count: 1
10856-
path: ../app/code/core/Mage/Payment/Model/Method/Abstract.php
10857-
1085810758
-
1085910759
message: "#^Binary operation \"\\*\\=\" between string and 2 results in an error\\.$#"
1086010760
count: 1
@@ -11040,11 +10940,6 @@ parameters:
1104010940
count: 1
1104110941
path: ../app/code/core/Mage/Paypal/Model/Api/Abstract.php
1104210942

11043-
-
11044-
message: "#^Parameter \\#2 \\$arguments of static method Mage\\:\\:getModel\\(\\) expects array\\|object, string given\\.$#"
11045-
count: 1
11046-
path: ../app/code/core/Mage/Paypal/Model/Api/Abstract.php
11047-
1104810943
-
1104910944
message: "#^Call to an undefined method Mage_Paypal_Model_Api_Nvp\\:\\:_export\\(\\)\\.$#"
1105010945
count: 1
@@ -11190,11 +11085,6 @@ parameters:
1119011085
count: 1
1119111086
path: ../app/code/core/Mage/Paypal/Model/Express/Checkout.php
1119211087

11193-
-
11194-
message: "#^Parameter \\#2 \\$arguments of static method Mage\\:\\:getModel\\(\\) expects array\\|object, string given\\.$#"
11195-
count: 1
11196-
path: ../app/code/core/Mage/Paypal/Model/Express/Checkout.php
11197-
1119811088
-
1119911089
message: "#^Parameter \\#3 \\$storeId of method Mage_Customer_Model_Customer\\:\\:sendNewAccountEmail\\(\\) expects string, int given\\.$#"
1120011090
count: 2
@@ -11245,11 +11135,6 @@ parameters:
1124511135
count: 1
1124611136
path: ../app/code/core/Mage/Paypal/Model/Ipn.php
1124711137

11248-
-
11249-
message: "#^Parameter \\#2 \\$arguments of static method Mage\\:\\:getModel\\(\\) expects array\\|object, string given\\.$#"
11250-
count: 1
11251-
path: ../app/code/core/Mage/Paypal/Model/Ipn.php
11252-
1125311138
-
1125411139
message: "#^Parameter \\#2 \\$url of method Zend_Http_Client_Adapter_Interface\\:\\:write\\(\\) expects Zend_Uri_Http, string given\\.$#"
1125511140
count: 1
@@ -14375,11 +14260,6 @@ parameters:
1437514260
count: 1
1437614261
path: ../app/code/core/Mage/Shipping/Model/Carrier/Abstract.php
1437714262

14378-
-
14379-
message: "#^Parameter \\#2 \\$arguments of static method Mage\\:\\:getModel\\(\\) expects array\\|object, string given\\.$#"
14380-
count: 1
14381-
path: ../app/code/core/Mage/Shipping/Model/Carrier/Abstract.php
14382-
1438314263
-
1438414264
message: "#^Property Mage_Shipping_Model_Carrier_Abstract\\:\\:\\$_numBoxes \\(int\\) does not accept float\\.$#"
1438514265
count: 1
@@ -15070,11 +14950,6 @@ parameters:
1507014950
count: 1
1507114951
path: ../app/code/core/Mage/Widget/Model/Resource/Widget/Instance.php
1507214952

15073-
-
15074-
message: "#^Parameter \\#2 \\$mergeToObject of method Mage_Core_Model_Config\\:\\:loadModulesConfiguration\\(\\) expects Mage_Core_Model_Config_Base\\|null, Varien_Simplexml_Config given\\.$#"
15075-
count: 1
15076-
path: ../app/code/core/Mage/Widget/Model/Widget.php
15077-
1507814953
-
1507914954
message: "#^Comparison operation \"\\>\\=\" between int\\<0, max\\>\\|false and 0 is always true\\.$#"
1508014955
count: 1

app/Mage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ public static function dispatchEvent($name, array $data = [])
508508
*
509509
* @link Mage_Core_Model_Config::getModelInstance
510510
* @param string $modelClass
511-
* @param array|object $arguments
511+
* @param array|string|object $arguments
512512
* @return Mage_Core_Model_Abstract|false
513513
*/
514514
public static function getModel($modelClass = '', $arguments = [])

app/code/core/Mage/Admin/Model/Config.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ public function __construct()
4343
parent::__construct();
4444
$this->setCacheId('adminhtml_acl_menu_config');
4545

46-
/** @var Varien_Simplexml_Config $adminhtmlConfig */
4746
$adminhtmlConfig = Mage::app()->loadCache($this->getCacheId());
4847
if ($adminhtmlConfig) {
4948
$this->_adminhtmlConfig = new Varien_Simplexml_Config($adminhtmlConfig);
@@ -80,7 +79,7 @@ public function __construct()
8079
* Load Acl resources from config
8180
*
8281
* @param Mage_Admin_Model_Acl $acl
83-
* @param Mage_Core_Model_Config_Element $resource
82+
* @param Mage_Core_Model_Config_Element|Varien_Simplexml_Element $resource
8483
* @param string $parentName
8584
* @return $this
8685
*/

app/code/core/Mage/Admin/Model/Observer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function actionPreDispatchAdmin($observer)
7070
$session->login($username, $password, $request);
7171
$request->setPost('login', null);
7272
} else {
73-
if ($request && !$request->getParam('messageSent')) {
73+
if (!$request->getParam('messageSent')) {
7474
Mage::getSingleton('adminhtml/session')->addError(
7575
Mage::helper('adminhtml')->__('Invalid Form Key. Please refresh the page.')
7676
);

app/code/core/Mage/Admin/Model/Session.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class Mage_Admin_Model_Session extends Mage_Core_Model_Session_Abstract
6363
/**
6464
* Whether it is the first page after successfull login
6565
*
66-
* @var bool
66+
* @var bool|null
6767
*/
6868
protected $_isFirstPageAfterLogin;
6969

app/code/core/Mage/Admin/Model/User.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ protected function _getHelper($helperName)
504504
/**
505505
* Find first menu item that user is able to access
506506
*
507-
* @param Mage_Core_Model_Config_Element $parent
507+
* @param Mage_Core_Model_Config_Element|Varien_Simplexml_Element $parent
508508
* @param string $path
509509
* @param int $level
510510
* @return string

app/code/core/Mage/AdminNotification/Model/Feed.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public function getFrequency()
120120
/**
121121
* Retrieve Last update time
122122
*
123-
* @return int
123+
* @return string|false
124124
*/
125125
public function getLastUpdate()
126126
{

app/code/core/Mage/Core/Model/App.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1165,7 +1165,7 @@ public function getCache()
11651165
* Loading cache data
11661166
*
11671167
* @param string $id
1168-
* @return mixed
1168+
* @return string|false
11691169
*/
11701170
public function loadCache($id)
11711171
{

app/code/core/Mage/Core/Model/Cache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ public function getFrontend()
366366
* Load data from cache by id
367367
*
368368
* @param string $id
369-
* @return string
369+
* @return string|false
370370
*/
371371
public function load($id)
372372
{

app/code/core/Mage/Core/Model/Config.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,9 +1013,9 @@ public function determineOmittedNamespace($name, $asFullModuleName = false)
10131013
* specidied xml file name to one object
10141014
*
10151015
* @param string $fileName
1016-
* @param null|Mage_Core_Model_Config_Base $mergeToObject
1016+
* @param null|Mage_Core_Model_Config_Base|Varien_Simplexml_Config $mergeToObject
10171017
* @param null $mergeModel
1018-
* @return Mage_Core_Model_Config_Base
1018+
* @return Mage_Core_Model_Config_Base|Varien_Simplexml_Config
10191019
*/
10201020
public function loadModulesConfiguration($fileName, $mergeToObject = null, $mergeModel = null)
10211021
{

0 commit comments

Comments
 (0)