Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PhpStan L5 fixes for Mage/Admin #2761

Merged
merged 2 commits into from
Nov 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 0 additions & 125 deletions .github/phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -35,46 +35,11 @@ parameters:
count: 1
path: ../app/code/core/Mage/Admin/Model/Config.php

-
message: "#^Parameter \\#1 \\$sourceData of class Varien_Simplexml_Config constructor expects string\\|Varien_Simplexml_Element\\|null, Varien_Simplexml_Config given\\.$#"
count: 1
path: ../app/code/core/Mage/Admin/Model/Config.php

-
message: "#^Parameter \\#2 \\$arguments of static method Mage\\:\\:getModel\\(\\) expects array\\|object, string given\\.$#"
count: 2
path: ../app/code/core/Mage/Admin/Model/Config.php

-
message: "#^Parameter \\#2 \\$mergeToObject of method Mage_Core_Model_Config\\:\\:loadModulesConfiguration\\(\\) expects Mage_Core_Model_Config_Base\\|null, Varien_Simplexml_Config given\\.$#"
count: 1
path: ../app/code/core/Mage/Admin/Model/Config.php

-
message: "#^Parameter \\#2 \\$resource of method Mage_Admin_Model_Config\\:\\:loadAclResources\\(\\) expects Mage_Core_Model_Config_Element\\|null, Varien_Simplexml_Element given\\.$#"
count: 1
path: ../app/code/core/Mage/Admin/Model/Config.php

-
message: "#^Left side of && is always true\\.$#"
count: 1
path: ../app/code/core/Mage/Admin/Model/Observer.php

-
message: "#^Cannot call method getClassName\\(\\) on SimpleXMLElement\\|false\\.$#"
count: 1
path: ../app/code/core/Mage/Admin/Model/Resource/Acl.php

-
message: "#^Parameter \\#2 \\$arguments of static method Mage\\:\\:getModel\\(\\) expects array\\|object, string given\\.$#"
count: 2
path: ../app/code/core/Mage/Admin/Model/Resource/Acl.php

-
message: "#^Strict comparison using \\=\\=\\= between string and false will always evaluate to false\\.$#"
count: 1
path: ../app/code/core/Mage/Admin/Model/Resource/Block.php

-
message: "#^Parameter \\#1 \\$role of method Mage_Admin_Model_Resource_Roles\\:\\:_updateRoleUsersAcl\\(\\) expects Mage_Admin_Model_Roles, Mage_Core_Model_Abstract given\\.$#"
count: 1
Expand All @@ -85,11 +50,6 @@ parameters:
count: 1
path: ../app/code/core/Mage/Admin/Model/Resource/User.php

-
message: "#^Strict comparison using \\=\\=\\= between string and false will always evaluate to false\\.$#"
count: 1
path: ../app/code/core/Mage/Admin/Model/Resource/Variable.php

-
message: "#^Call to an undefined method Mage_Admin_Model_Resource_Roles\\:\\:update\\(\\)\\.$#"
count: 1
Expand All @@ -110,16 +70,6 @@ parameters:
count: 1
path: ../app/code/core/Mage/Admin/Model/Session.php

-
message: "#^Call to function is_null\\(\\) with bool will always evaluate to false\\.$#"
count: 1
path: ../app/code/core/Mage/Admin/Model/Session.php

-
message: "#^Parameter \\#1 \\$parent of method Mage_Admin_Model_User\\:\\:findFirstAvailableMenu\\(\\) expects Mage_Core_Model_Config_Element\\|null, Varien_Simplexml_Element given\\.$#"
count: 1
path: ../app/code/core/Mage/Admin/Model/User.php

-
message: "#^Call to function is_null\\(\\) with Mage_AdminNotification_Model_Inbox will always evaluate to false\\.$#"
count: 1
Expand Down Expand Up @@ -2305,11 +2255,6 @@ parameters:
count: 1
path: ../app/code/core/Mage/Api/Model/Acl.php

-
message: "#^Parameter \\#2 \\$arguments of static method Mage\\:\\:getModel\\(\\) expects array\\|object, string given\\.$#"
count: 1
path: ../app/code/core/Mage/Api/Model/Config.php

-
message: "#^Parameter \\#2 \\$resource of method Mage_Api_Model_Config\\:\\:loadAclResources\\(\\) expects Mage_Core_Model_Config_Element\\|null, Varien_Simplexml_Element given\\.$#"
count: 1
Expand All @@ -2330,11 +2275,6 @@ parameters:
count: 1
path: ../app/code/core/Mage/Api/Model/Resource/Acl.php

-
message: "#^Parameter \\#2 \\$arguments of static method Mage\\:\\:getModel\\(\\) expects array\\|object, string given\\.$#"
count: 2
path: ../app/code/core/Mage/Api/Model/Resource/Acl.php

-
message: "#^Method Mage_Core_Model_Resource_Db_Abstract\\:\\:load\\(\\) invoked with 1 parameter, 2\\-3 required\\.$#"
count: 1
Expand Down Expand Up @@ -2495,11 +2435,6 @@ parameters:
count: 1
path: ../app/code/core/Mage/Api/Model/Wsdl/Config.php

-
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\\.$#"
count: 2
path: ../app/code/core/Mage/Api/Model/Wsdl/Config.php

-
message: "#^Parameter \\#3 \\$mergeModel of method Mage_Core_Model_Config\\:\\:loadModulesConfiguration\\(\\) expects null, Mage_Api_Model_Wsdl_Config_Base given\\.$#"
count: 2
Expand Down Expand Up @@ -6900,11 +6835,6 @@ parameters:
count: 1
path: ../app/code/core/Mage/Core/Helper/Js.php

-
message: "#^Parameter \\#2 \\$mergeToObject of method Mage_Core_Model_Config\\:\\:loadModulesConfiguration\\(\\) expects Mage_Core_Model_Config_Base\\|null, Varien_Simplexml_Config given\\.$#"
count: 1
path: ../app/code/core/Mage/Core/Helper/Js.php

-
message: "#^Negated boolean expression is always false\\.$#"
count: 1
Expand Down Expand Up @@ -7060,11 +6990,6 @@ parameters:
count: 1
path: ../app/code/core/Mage/Core/Model/Cache.php

-
message: "#^Strict comparison using \\=\\=\\= between string and false will always evaluate to false\\.$#"
count: 1
path: ../app/code/core/Mage/Core/Model/Cache.php

-
message: "#^Call to an undefined method SimpleXMLElement\\:\\:getClassName\\(\\)\\.$#"
count: 1
Expand Down Expand Up @@ -9190,11 +9115,6 @@ parameters:
count: 1
path: ../app/code/core/Mage/Eav/Model/Entity/Abstract.php

-
message: "#^Parameter \\#2 \\$arguments of static method Mage\\:\\:getModel\\(\\) expects array\\|object, string given\\.$#"
count: 1
path: ../app/code/core/Mage/Eav/Model/Entity/Abstract.php

-
message: "#^Property Mage_Eav_Model_Entity_Abstract\\:\\:\\$_read \\(Varien_Db_Adapter_Pdo_Mysql\\) does not accept Varien_Db_Adapter_Interface\\|false\\.$#"
count: 1
Expand Down Expand Up @@ -9725,11 +9645,6 @@ parameters:
count: 1
path: ../app/code/core/Mage/ImportExport/Model/Abstract.php

-
message: "#^Parameter \\#2 \\$arguments of static method Mage\\:\\:getModel\\(\\) expects array\\|object, string given\\.$#"
count: 1
path: ../app/code/core/Mage/ImportExport/Model/Abstract.php

-
message: "#^If condition is always true\\.$#"
count: 1
Expand Down Expand Up @@ -9865,11 +9780,6 @@ parameters:
count: 1
path: ../app/code/core/Mage/ImportExport/Model/Import.php

-
message: "#^Parameter \\#2 \\$arguments of static method Mage\\:\\:getModel\\(\\) expects array\\|object, string given\\.$#"
count: 3
path: ../app/code/core/Mage/ImportExport/Model/Import.php

-
message: "#^Property Mage_ImportExport_Model_Import\\:\\:\\$_entityAdapter \\(Mage_ImportExport_Model_Import_Entity_Abstract\\) does not accept Mage_Core_Model_Abstract\\|false\\.$#"
count: 1
Expand Down Expand Up @@ -10235,11 +10145,6 @@ parameters:
count: 1
path: ../app/code/core/Mage/Install/Model/Config.php

-
message: "#^Parameter \\#2 \\$mergeToObject of method Mage_Core_Model_Config\\:\\:loadModulesConfiguration\\(\\) expects Mage_Core_Model_Config_Base\\|null, \\$this\\(Mage_Install_Model_Config\\) given\\.$#"
count: 1
path: ../app/code/core/Mage/Install/Model/Config.php

-
message: "#^Call to function is_null\\(\\) with Mage_Install_Model_Session will always evaluate to false\\.$#"
count: 1
Expand Down Expand Up @@ -10850,11 +10755,6 @@ parameters:
count: 1
path: ../app/code/core/Mage/Payment/Model/Method/Abstract.php

-
message: "#^Parameter \\#2 \\$arguments of static method Mage\\:\\:getModel\\(\\) expects array\\|object, string given\\.$#"
count: 1
path: ../app/code/core/Mage/Payment/Model/Method/Abstract.php

-
message: "#^Binary operation \"\\*\\=\" between string and 2 results in an error\\.$#"
count: 1
Expand Down Expand Up @@ -11040,11 +10940,6 @@ parameters:
count: 1
path: ../app/code/core/Mage/Paypal/Model/Api/Abstract.php

-
message: "#^Parameter \\#2 \\$arguments of static method Mage\\:\\:getModel\\(\\) expects array\\|object, string given\\.$#"
count: 1
path: ../app/code/core/Mage/Paypal/Model/Api/Abstract.php

-
message: "#^Call to an undefined method Mage_Paypal_Model_Api_Nvp\\:\\:_export\\(\\)\\.$#"
count: 1
Expand Down Expand Up @@ -11190,11 +11085,6 @@ parameters:
count: 1
path: ../app/code/core/Mage/Paypal/Model/Express/Checkout.php

-
message: "#^Parameter \\#2 \\$arguments of static method Mage\\:\\:getModel\\(\\) expects array\\|object, string given\\.$#"
count: 1
path: ../app/code/core/Mage/Paypal/Model/Express/Checkout.php

-
message: "#^Parameter \\#3 \\$storeId of method Mage_Customer_Model_Customer\\:\\:sendNewAccountEmail\\(\\) expects string, int given\\.$#"
count: 2
Expand Down Expand Up @@ -11245,11 +11135,6 @@ parameters:
count: 1
path: ../app/code/core/Mage/Paypal/Model/Ipn.php

-
message: "#^Parameter \\#2 \\$arguments of static method Mage\\:\\:getModel\\(\\) expects array\\|object, string given\\.$#"
count: 1
path: ../app/code/core/Mage/Paypal/Model/Ipn.php

-
message: "#^Parameter \\#2 \\$url of method Zend_Http_Client_Adapter_Interface\\:\\:write\\(\\) expects Zend_Uri_Http, string given\\.$#"
count: 1
Expand Down Expand Up @@ -14375,11 +14260,6 @@ parameters:
count: 1
path: ../app/code/core/Mage/Shipping/Model/Carrier/Abstract.php

-
message: "#^Parameter \\#2 \\$arguments of static method Mage\\:\\:getModel\\(\\) expects array\\|object, string given\\.$#"
count: 1
path: ../app/code/core/Mage/Shipping/Model/Carrier/Abstract.php

-
message: "#^Property Mage_Shipping_Model_Carrier_Abstract\\:\\:\\$_numBoxes \\(int\\) does not accept float\\.$#"
count: 1
Expand Down Expand Up @@ -15070,11 +14950,6 @@ parameters:
count: 1
path: ../app/code/core/Mage/Widget/Model/Resource/Widget/Instance.php

-
message: "#^Parameter \\#2 \\$mergeToObject of method Mage_Core_Model_Config\\:\\:loadModulesConfiguration\\(\\) expects Mage_Core_Model_Config_Base\\|null, Varien_Simplexml_Config given\\.$#"
count: 1
path: ../app/code/core/Mage/Widget/Model/Widget.php

-
message: "#^Comparison operation \"\\>\\=\" between int\\<0, max\\>\\|false and 0 is always true\\.$#"
count: 1
Expand Down
2 changes: 1 addition & 1 deletion app/Mage.php
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ public static function dispatchEvent($name, array $data = [])
*
* @link Mage_Core_Model_Config::getModelInstance
* @param string $modelClass
* @param array|object $arguments
* @param array|string|object $arguments
* @return Mage_Core_Model_Abstract|false
*/
public static function getModel($modelClass = '', $arguments = [])
Expand Down
3 changes: 1 addition & 2 deletions app/code/core/Mage/Admin/Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public function __construct()
parent::__construct();
$this->setCacheId('adminhtml_acl_menu_config');

/** @var Varien_Simplexml_Config $adminhtmlConfig */
$adminhtmlConfig = Mage::app()->loadCache($this->getCacheId());
if ($adminhtmlConfig) {
$this->_adminhtmlConfig = new Varien_Simplexml_Config($adminhtmlConfig);
Expand Down Expand Up @@ -80,7 +79,7 @@ public function __construct()
* Load Acl resources from config
*
* @param Mage_Admin_Model_Acl $acl
* @param Mage_Core_Model_Config_Element $resource
* @param Mage_Core_Model_Config_Element|Varien_Simplexml_Element $resource
* @param string $parentName
* @return $this
*/
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Admin/Model/Observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function actionPreDispatchAdmin($observer)
$session->login($username, $password, $request);
$request->setPost('login', null);
} else {
if ($request && !$request->getParam('messageSent')) {
if (!$request->getParam('messageSent')) {
Mage::getSingleton('adminhtml/session')->addError(
Mage::helper('adminhtml')->__('Invalid Form Key. Please refresh the page.')
);
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Admin/Model/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class Mage_Admin_Model_Session extends Mage_Core_Model_Session_Abstract
/**
* Whether it is the first page after successfull login
*
* @var bool
* @var bool|null
*/
protected $_isFirstPageAfterLogin;

Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Admin/Model/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ protected function _getHelper($helperName)
/**
* Find first menu item that user is able to access
*
* @param Mage_Core_Model_Config_Element $parent
* @param Mage_Core_Model_Config_Element|Varien_Simplexml_Element $parent
* @param string $path
* @param int $level
* @return string
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/AdminNotification/Model/Feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function getFrequency()
/**
* Retrieve Last update time
*
* @return int
* @return string|false
*/
public function getLastUpdate()
{
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Core/Model/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,7 @@ public function getCache()
* Loading cache data
*
* @param string $id
* @return mixed
* @return string|false
*/
public function loadCache($id)
{
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Core/Model/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ public function getFrontend()
* Load data from cache by id
*
* @param string $id
* @return string
* @return string|false
*/
public function load($id)
{
Expand Down
4 changes: 2 additions & 2 deletions app/code/core/Mage/Core/Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -1013,9 +1013,9 @@ public function determineOmittedNamespace($name, $asFullModuleName = false)
* specidied xml file name to one object
*
* @param string $fileName
* @param null|Mage_Core_Model_Config_Base $mergeToObject
* @param null|Mage_Core_Model_Config_Base|Varien_Simplexml_Config $mergeToObject
* @param null $mergeModel
* @return Mage_Core_Model_Config_Base
* @return Mage_Core_Model_Config_Base|Varien_Simplexml_Config
*/
public function loadModulesConfiguration($fileName, $mergeToObject = null, $mergeModel = null)
{
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Log/Model/Visitor/Online.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function prepare()
/**
* Retrieve last prepare at timestamp
*
* @return int
* @return string|false
*/
public function getPrepareAt()
{
Expand Down
2 changes: 1 addition & 1 deletion lib/Varien/Cache/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public function load($id, $doNotTestCacheValidity = false, $doNotUnserialize = f
// Seems we've got chunked data

$arr = explode('|', $data);
$chunks = isset($arr[1]) ? $arr[1] : false;
$chunks = $arr[1] ?? false;
$chunkData = [];

if ($chunks && is_numeric($chunks)) {
Expand Down