diff --git a/.phpstan.dist.baselines/_loader.php b/.phpstan.dist.baselines/_loader.php index 3d14cefd84a..b59aec7395a 100644 --- a/.phpstan.dist.baselines/_loader.php +++ b/.phpstan.dist.baselines/_loader.php @@ -58,7 +58,6 @@ __DIR__ . '/if.alwaysTrue.php', __DIR__ . '/if.condNotBoolean.php', __DIR__ . '/instanceof.alwaysTrue.php', - __DIR__ . '/isset.variable.php', __DIR__ . '/method.childParameterType.php', __DIR__ . '/method.childReturnType.php', __DIR__ . '/method.deprecated.php', diff --git a/.phpstan.dist.baselines/argument.type.php b/.phpstan.dist.baselines/argument.type.php index bc930b84ca9..6ad9cc0aa55 100644 --- a/.phpstan.dist.baselines/argument.type.php +++ b/.phpstan.dist.baselines/argument.type.php @@ -951,16 +951,6 @@ 'count' => 2, 'path' => __DIR__ . '/../app/code/core/Mage/Api/Model/Wsdl/Config/Element.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Parameter #1 $array of function uasort expects array, array|string given.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Api2/Helper/Data.php', -]; -$ignoreErrors[] = [ - 'rawMessage' => 'Parameter #2 $string of function explode expects string, string|true given.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Api2/Helper/Data.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #1 $roleId of method Mage_Api2_Model_Acl::addRole() expects int, int|string|null given.', 'count' => 1, @@ -4891,16 +4881,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Payment/Exception.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Parameter #2 $haystack of function in_array expects array, array|false given.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Payment/Helper/Data.php', -]; -$ignoreErrors[] = [ - 'rawMessage' => 'Parameter #1 $array of function uasort expects array, array|string given.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Payment/Model/Config.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #2 $array of function array_key_exists expects array, array|int given.', 'count' => 1, diff --git a/.phpstan.dist.baselines/assign.propertyType.php b/.phpstan.dist.baselines/assign.propertyType.php index 5e140fa8a59..2d9bcd53ee1 100644 --- a/.phpstan.dist.baselines/assign.propertyType.php +++ b/.phpstan.dist.baselines/assign.propertyType.php @@ -431,11 +431,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Index/Model/Resource/Lock/Resource.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Property Varien_Data_Collection_Db::$_map (array{fields: array}|null) does not accept array{fields: non-empty-array}.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Newsletter/Model/Resource/Subscriber/Collection.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Property Mage_Page_Block_Html_Pager::$_frameEnd (int) does not accept float|int.', 'count' => 1, @@ -581,16 +576,6 @@ 'count' => 1, 'path' => __DIR__ . '/../lib/Mage/HTTP/Client/Socket.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Property Varien_Data_Collection_Db::$_map (array{fields: array}|null) does not accept non-empty-array>.', - 'count' => 2, - 'path' => __DIR__ . '/../lib/Varien/Data/Collection/Db.php', -]; -$ignoreErrors[] = [ - 'rawMessage' => 'Property Varien_Data_Collection_Db::$_map (array{fields: array}|null) does not accept non-empty-array.', - 'count' => 1, - 'path' => __DIR__ . '/../lib/Varien/Data/Collection/Db.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Property Varien_Data_Form_Filter_Date::$_locale (string|Zend_Locale) does not accept string|Zend_Locale|null.', 'count' => 1, diff --git a/.phpstan.dist.baselines/booleanAnd.leftNotBoolean.php b/.phpstan.dist.baselines/booleanAnd.leftNotBoolean.php index 501368db3a1..487b2d6a25d 100644 --- a/.phpstan.dist.baselines/booleanAnd.leftNotBoolean.php +++ b/.phpstan.dist.baselines/booleanAnd.leftNotBoolean.php @@ -1591,16 +1591,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Payment/Block/Info/Container.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Only booleans are allowed in &&, Mage_Payment_Model_Method_Abstract given on the left side.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Payment/Helper/Data.php', -]; -$ignoreErrors[] = [ - 'rawMessage' => 'Only booleans are allowed in &&, object|false given on the left side.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Payment/Model/Config.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Only booleans are allowed in &&, string|null given on the left side.', 'count' => 1, diff --git a/.phpstan.dist.baselines/booleanNot.exprNotBoolean.php b/.phpstan.dist.baselines/booleanNot.exprNotBoolean.php index 3f04f86addb..6e742b142aa 100644 --- a/.phpstan.dist.baselines/booleanNot.exprNotBoolean.php +++ b/.phpstan.dist.baselines/booleanNot.exprNotBoolean.php @@ -1111,11 +1111,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Api/Model/Wsdl/Config/Element.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Only booleans are allowed in a negated boolean, Mage_Core_Model_Config_Element|false given.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Api2/Helper/Data.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Only booleans are allowed in a negated boolean, array given.', 'count' => 1, @@ -5046,21 +5041,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Payment/Block/Info.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Only booleans are allowed in a negated boolean, Mage_Payment_Model_Method_Abstract|false given.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Payment/Helper/Data.php', -]; -$ignoreErrors[] = [ - 'rawMessage' => 'Only booleans are allowed in a negated boolean, mixed given.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Payment/Helper/Data.php', -]; -$ignoreErrors[] = [ - 'rawMessage' => 'Only booleans are allowed in a negated boolean, string|null given.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Payment/Helper/Data.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Only booleans are allowed in a negated boolean, string given.', 'count' => 1, diff --git a/.phpstan.dist.baselines/equal.notAllowed.php b/.phpstan.dist.baselines/equal.notAllowed.php index dabfcf1dfaf..651a03adf20 100644 --- a/.phpstan.dist.baselines/equal.notAllowed.php +++ b/.phpstan.dist.baselines/equal.notAllowed.php @@ -4361,11 +4361,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Payment/Block/Info/Container.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Loose comparison via "==" between mixed and mixed is not allowed.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Payment/Model/Config.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Loose comparison via "==" between mixed and int is not allowed.', 'count' => 1, diff --git a/.phpstan.dist.baselines/foreach.nonIterable.php b/.phpstan.dist.baselines/foreach.nonIterable.php index 4e240a0e480..1fffab91ce2 100644 --- a/.phpstan.dist.baselines/foreach.nonIterable.php +++ b/.phpstan.dist.baselines/foreach.nonIterable.php @@ -96,11 +96,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Api/Model/Resource/User.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Argument of an invalid type array|string supplied for foreach, only iterables are supported.', - 'count' => 2, - 'path' => __DIR__ . '/../app/code/core/Mage/Api2/Helper/Data.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Argument of an invalid type list|false supplied for foreach, only iterables are supported.', 'count' => 1, @@ -471,16 +466,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Payment/Block/Info.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Argument of an invalid type array|string supplied for foreach, only iterables are supported.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Payment/Helper/Data.php', -]; -$ignoreErrors[] = [ - 'rawMessage' => 'Argument of an invalid type array|string supplied for foreach, only iterables are supported.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Payment/Model/Config.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Argument of an invalid type array|false|null supplied for foreach, only iterables are supported.', 'count' => 1, diff --git a/.phpstan.dist.baselines/function.strict.php b/.phpstan.dist.baselines/function.strict.php index ee1b3c51959..b92ffdaadd3 100644 --- a/.phpstan.dist.baselines/function.strict.php +++ b/.phpstan.dist.baselines/function.strict.php @@ -311,11 +311,6 @@ 'count' => 2, 'path' => __DIR__ . '/../app/code/core/Mage/Api/Model/Wsdl/Config/Base.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Call to function in_array() requires parameter #3 to be set.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Api2/Helper/Data.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Call to function in_array() requires parameter #3 to be set.', 'count' => 1, @@ -1216,11 +1211,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Paygate/Model/Authorizenet.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Call to function in_array() requires parameter #3 to be set.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Payment/Helper/Data.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Call to function in_array() requires parameter #3 to be set.', 'count' => 1, diff --git a/.phpstan.dist.baselines/if.condNotBoolean.php b/.phpstan.dist.baselines/if.condNotBoolean.php index d0010742a10..44af555c33c 100644 --- a/.phpstan.dist.baselines/if.condNotBoolean.php +++ b/.phpstan.dist.baselines/if.condNotBoolean.php @@ -2121,11 +2121,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Api2/Block/Adminhtml/Permissions/User/Edit/Tab/Roles.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Only booleans are allowed in an if condition, Mage_Core_Model_Config_Element|false given.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Api2/Helper/Data.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Only booleans are allowed in an if condition, array given.', 'count' => 1, @@ -6461,16 +6456,6 @@ 'count' => 2, 'path' => __DIR__ . '/../app/code/core/Mage/Payment/Block/Info/Container.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Only booleans are allowed in an if condition, Mage_Core_Model_Layout given.', - 'count' => 2, - 'path' => __DIR__ . '/../app/code/core/Mage/Payment/Helper/Data.php', -]; -$ignoreErrors[] = [ - 'rawMessage' => 'Only booleans are allowed in an if condition, string|null given.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Payment/Helper/Data.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Only booleans are allowed in an if condition, Mage_Payment_Model_Method_Abstract|false given.', 'count' => 1, diff --git a/.phpstan.dist.baselines/isset.variable.php b/.phpstan.dist.baselines/isset.variable.php deleted file mode 100644 index 5d6dbb5f2f1..00000000000 --- a/.phpstan.dist.baselines/isset.variable.php +++ /dev/null @@ -1,10 +0,0 @@ - 'Variable $destination in isset() always exists and is always null.', - 'count' => 1, - 'path' => __DIR__ . '/../lib/Varien/Image/Adapter/Gd2.php', -]; - -return ['parameters' => ['ignoreErrors' => $ignoreErrors]]; diff --git a/.phpstan.dist.baselines/method.nonObject.php b/.phpstan.dist.baselines/method.nonObject.php index 04ed310b7ff..7be2cb4a844 100644 --- a/.phpstan.dist.baselines/method.nonObject.php +++ b/.phpstan.dist.baselines/method.nonObject.php @@ -2001,11 +2001,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Api2/Block/Adminhtml/Roles/Tab/Users.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Cannot call method getNode() on Mage_Core_Model_Config|null.', - 'count' => 2, - 'path' => __DIR__ . '/../app/code/core/Mage/Api2/Helper/Data.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Cannot call method children() on array|Varien_Simplexml_Element.', 'count' => 1, @@ -4896,36 +4891,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Payment/Block/Info/Container.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Cannot call method asCanonicalArray() on Mage_Core_Model_Config_Element|false.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Payment/Helper/Data.php', -]; -$ignoreErrors[] = [ - 'rawMessage' => 'Cannot call method getBlockClassName() on Mage_Core_Model_Config|null.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Payment/Helper/Data.php', -]; -$ignoreErrors[] = [ - 'rawMessage' => 'Cannot call method getConfigData() on object|false.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Payment/Helper/Data.php', -]; -$ignoreErrors[] = [ - 'rawMessage' => 'Cannot call method setMethod() on Mage_Core_Block_Abstract|false.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Payment/Helper/Data.php', -]; -$ignoreErrors[] = [ - 'rawMessage' => 'Cannot call method asArray() on Mage_Core_Model_Config_Element|false.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Payment/Model/Config.php', -]; -$ignoreErrors[] = [ - 'rawMessage' => 'Cannot call method getNode() on Mage_Core_Model_Config|null.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Payment/Model/Config.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Cannot call method getCountryId() on Mage_Sales_Model_Order_Address|false.', 'count' => 1, diff --git a/.phpstan.dist.baselines/method.notFound.php b/.phpstan.dist.baselines/method.notFound.php index b7df587f3e1..94897b5a5cb 100644 --- a/.phpstan.dist.baselines/method.notFound.php +++ b/.phpstan.dist.baselines/method.notFound.php @@ -1351,11 +1351,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Paygate/controllers/Authorizenet/PaymentController.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Call to an undefined method object::getConfigData().', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Payment/Model/Config.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Call to an undefined method object::setTemplate().', 'count' => 1, diff --git a/.phpstan.dist.baselines/missingType.iterableValue.php b/.phpstan.dist.baselines/missingType.iterableValue.php index 87825bec716..4e549204a60 100644 --- a/.phpstan.dist.baselines/missingType.iterableValue.php +++ b/.phpstan.dist.baselines/missingType.iterableValue.php @@ -19191,11 +19191,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Payment/Block/Info/Ccsave.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Method Mage_Payment_Helper_Data::getAllBillingAgreementMethods() return type has no value type specified in iterable type array.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Payment/Helper/Data.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Method Mage_Payment_Helper_Data::getPaymentMethodList() return type has no value type specified in iterable type array.', 'count' => 1, @@ -19226,26 +19221,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Payment/Model/Config.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Method Mage_Payment_Model_Config::getActiveMethods() return type has no value type specified in iterable type array.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Payment/Model/Config.php', -]; -$ignoreErrors[] = [ - 'rawMessage' => 'Method Mage_Payment_Model_Config::getAllMethods() return type has no value type specified in iterable type array.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Payment/Model/Config.php', -]; -$ignoreErrors[] = [ - 'rawMessage' => 'Method Mage_Payment_Model_Config::getMonths() return type has no value type specified in iterable type array.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Payment/Model/Config.php', -]; -$ignoreErrors[] = [ - 'rawMessage' => 'Method Mage_Payment_Model_Config::getYears() return type has no value type specified in iterable type array.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Payment/Model/Config.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Method Mage_Payment_Model_Info::setAdditionalInformation() has parameter $key with no value type specified in iterable type array.', 'count' => 1, diff --git a/.phpstan.dist.baselines/missingType.parameter.php b/.phpstan.dist.baselines/missingType.parameter.php index 05f3a1e9c3e..1225dc83797 100644 --- a/.phpstan.dist.baselines/missingType.parameter.php +++ b/.phpstan.dist.baselines/missingType.parameter.php @@ -1196,11 +1196,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Paygate/Model/Authorizenet/Cards.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Method Mage_Payment_Helper_Data::getMethodModelClassName() has parameter $code with no type specified.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Payment/Helper/Data.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Method Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Global::getElementOriginalData() has parameter $key with no type specified.', 'count' => 1, diff --git a/.phpstan.dist.baselines/missingType.property.php b/.phpstan.dist.baselines/missingType.property.php index 2cd67b2f902..20431ec7357 100644 --- a/.phpstan.dist.baselines/missingType.property.php +++ b/.phpstan.dist.baselines/missingType.property.php @@ -2536,11 +2536,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Payment/Exception.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Property Mage_Payment_Model_Config::$_methods has no type specified.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Payment/Model/Config.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Property Mage_Payment_Model_Method_Abstract::$_canAuthorize has no type specified.', 'count' => 1, diff --git a/.phpstan.dist.baselines/property.notFound.php b/.phpstan.dist.baselines/property.notFound.php index 483f4c1c942..d94a36b198b 100644 --- a/.phpstan.dist.baselines/property.notFound.php +++ b/.phpstan.dist.baselines/property.notFound.php @@ -31,11 +31,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Customer/Model/Customer.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Access to an undefined property object::$sort_order.', - 'count' => 2, - 'path' => __DIR__ . '/../app/code/core/Mage/Payment/Helper/Data.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Access to an undefined property object::$Code.', 'count' => 3, diff --git a/.phpstan.dist.baselines/return.type.php b/.phpstan.dist.baselines/return.type.php index f68913cdf90..15ba04b727b 100644 --- a/.phpstan.dist.baselines/return.type.php +++ b/.phpstan.dist.baselines/return.type.php @@ -431,11 +431,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Api/Model/User.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Method Mage_Api2_Helper_Data::getAuthAdapters() should return array but returns array|string.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Api2/Helper/Data.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Method Mage_Api2_Model_Config::getResourceAttributes() should return array but returns array|string.', 'count' => 1, @@ -2361,16 +2356,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Payment/Block/Form.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Method Mage_Payment_Helper_Data::getMethodFormBlock() should return Mage_Core_Block_Abstract but returns Mage_Core_Block_Abstract|false.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Payment/Helper/Data.php', -]; -$ignoreErrors[] = [ - 'rawMessage' => 'Method Mage_Payment_Helper_Data::getMethodInstance() should return Mage_Payment_Model_Method_Abstract|false but returns object|false.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Payment/Helper/Data.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Method Mage_Payment_Model_Billing_AgreementAbstract::getPaymentMethodInstance() should return Mage_Payment_Model_Method_Abstract|null but returns Mage_Payment_Model_Method_Abstract|false.', 'count' => 1, diff --git a/.phpstan.dist.baselines/variable.undefined.php b/.phpstan.dist.baselines/variable.undefined.php index 71a65a78611..0b5545ed0f5 100644 --- a/.phpstan.dist.baselines/variable.undefined.php +++ b/.phpstan.dist.baselines/variable.undefined.php @@ -6,11 +6,6 @@ 'count' => 2, 'path' => __DIR__ . '/../app/code/core/Mage/Adminhtml/Model/Sales/Order/Create.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Variable $adapters might not be defined.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Api2/Helper/Data.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Variable $operationName might not be defined.', 'count' => 2, diff --git a/app/code/core/Mage/Api2/Helper/Data.php b/app/code/core/Mage/Api2/Helper/Data.php index b0404ed7d46..ccc8822a766 100644 --- a/app/code/core/Mage/Api2/Helper/Data.php +++ b/app/code/core/Mage/Api2/Helper/Data.php @@ -53,25 +53,23 @@ protected static function _compareOrder($a, $b) */ public function getAuthAdapters($enabledOnly = false) { - $adapters = Mage::getConfig()->getNode(self::XML_PATH_AUTH_ADAPTERS); + $adapters = Mage::getConfig()?->getNode(self::XML_PATH_AUTH_ADAPTERS); - if (!$adapters) { + if (!$adapters instanceof Varien_Simplexml_Element) { return []; } $adapters = $adapters->asArray(); - if ($enabledOnly) { - foreach ($adapters as $adapter) { - if (empty($adapter['enabled'])) { - unset($adapters); - } - } + if (!is_array($adapters)) { + return []; + } - $adapters = (array) $adapters; + if ($enabledOnly) { + $adapters = array_filter($adapters, fn($adapter) => !empty($adapter['enabled'])); } - uasort($adapters, ['Mage_Api2_Helper_Data', '_compareOrder']); + uasort($adapters, self::_compareOrder(...)); return $adapters; } @@ -83,14 +81,22 @@ public function getAuthAdapters($enabledOnly = false) */ public function getUserTypes() { - $userModels = []; - $types = Mage::getConfig()->getNode(self::XML_PATH_USER_TYPES); + $types = Mage::getConfig()?->getNode(self::XML_PATH_USER_TYPES); + + if (!$types instanceof Varien_Simplexml_Element) { + return []; + } - if ($types) { - foreach ($types->asArray() as $type => $params) { - if (!empty($params['allowed'])) { - $userModels[$type] = $params['model']; - } + $types = $types->asArray(); + + if (!is_array($types)) { + return []; + } + + $userModels = []; + foreach ($types as $type => $params) { + if (!empty($params['allowed'])) { + $userModels[$type] = $params['model']; } } @@ -125,7 +131,7 @@ public function getResponseRenderAdapters() */ public function isApiTypeSupported($type) { - return in_array($type, Mage_Api2_Model_Server::getApiTypes()); + return in_array($type, Mage_Api2_Model_Server::getApiTypes(), true); } /** diff --git a/app/code/core/Mage/Api2/Model/Resource/Acl/Filter/Attribute.php b/app/code/core/Mage/Api2/Model/Resource/Acl/Filter/Attribute.php index b0b3de73f5f..514c32d7dab 100644 --- a/app/code/core/Mage/Api2/Model/Resource/Acl/Filter/Attribute.php +++ b/app/code/core/Mage/Api2/Model/Resource/Acl/Filter/Attribute.php @@ -31,7 +31,7 @@ protected function _construct() * @param string $userType * @param string $resourceId * @param Mage_Api2_Model_Resource::OPERATION_ATTRIBUTE_* $operation - * @return null|bool|string + * @return null|false|string */ public function getAllowedAttributes($userType, $resourceId, $operation) { diff --git a/app/code/core/Mage/Payment/Block/Form.php b/app/code/core/Mage/Payment/Block/Form.php index 6597ebed517..763faaf8a5e 100644 --- a/app/code/core/Mage/Payment/Block/Form.php +++ b/app/code/core/Mage/Payment/Block/Form.php @@ -11,6 +11,8 @@ * Payment method form base block * * @package Mage_Payment + * + * @method $this setMethod(Mage_Payment_Model_Method_Abstract $method) */ class Mage_Payment_Block_Form extends Mage_Core_Block_Template { diff --git a/app/code/core/Mage/Payment/Block/Info.php b/app/code/core/Mage/Payment/Block/Info.php index 29c181a34bf..33293eac04b 100644 --- a/app/code/core/Mage/Payment/Block/Info.php +++ b/app/code/core/Mage/Payment/Block/Info.php @@ -12,7 +12,8 @@ * * @package Mage_Payment * - * @method bool hasIsSecureMode() + * @method bool hasIsSecureMode() + * @method $this setInfo(Mage_Payment_Model_Info $info) */ class Mage_Payment_Block_Info extends Mage_Core_Block_Template { diff --git a/app/code/core/Mage/Payment/Helper/Data.php b/app/code/core/Mage/Payment/Helper/Data.php index 3db90cf190b..7d15d37bf47 100644 --- a/app/code/core/Mage/Payment/Helper/Data.php +++ b/app/code/core/Mage/Payment/Helper/Data.php @@ -25,13 +25,14 @@ class Mage_Payment_Helper_Data extends Mage_Core_Helper_Abstract /** * Retrieve the class name of the payment method's model * - * @param $code + * @param string $code + * @param ConfigStoreId $store * @return null|string */ - public function getMethodModelClassName($code) + public function getMethodModelClassName($code, $store = null) { $key = self::XML_PATH_PAYMENT_METHODS . '/' . $code . '/model'; - return Mage::getStoreConfig($key); + return Mage::getStoreConfig($key, $store); } /** @@ -48,7 +49,11 @@ public function getMethodInstance($code) return false; } - return Mage::getModel($class); + /** + * @var false|Mage_Payment_Model_Method_Abstract $model + */ + $model = Mage::getModel($class); + return $model; } /** @@ -65,14 +70,14 @@ public function getStoreMethods($store = null, $quote = null) { $res = []; foreach (array_keys($this->getPaymentMethods($store)) as $code) { - $prefix = self::XML_PATH_PAYMENT_METHODS . '/' . $code . '/'; - if (!$model = Mage::getStoreConfig($prefix . 'model', $store)) { + $model = $this->getMethodModelClassName($code, $store); + if (!is_string($model)) { continue; } /** @var false|Mage_Payment_Model_Method_Abstract $methodInstance */ $methodInstance = Mage::getModel($model); - if (!$methodInstance) { + if (!$methodInstance instanceof Mage_Payment_Model_Method_Abstract) { continue; } @@ -82,8 +87,6 @@ public function getStoreMethods($store = null, $quote = null) continue; } - $sortOrder = (int) $methodInstance->getConfigData('sort_order', $store); - $methodInstance->setSortOrder($sortOrder); $res[] = $methodInstance; } @@ -92,14 +95,14 @@ public function getStoreMethods($store = null, $quote = null) } /** - * @param object $a - * @param object $b + * @param Mage_Payment_Model_Method_Abstract $a + * @param Mage_Payment_Model_Method_Abstract $b * @return int */ protected function _sortMethods($a, $b) { if (is_object($a)) { - return (int) $a->sort_order <=> (int) $b->sort_order; + return $a->getSortOrder() <=> $b->getSortOrder(); } return 0; @@ -108,37 +111,39 @@ protected function _sortMethods($a, $b) /** * Retrieve payment method form html * - * @return Mage_Core_Block_Abstract|Mage_Payment_Block_Form + * @return Mage_Payment_Block_Form */ public function getMethodFormBlock(Mage_Payment_Model_Method_Abstract $method) { - $block = false; $blockType = $method->getFormBlockType(); - if ($this->getLayout()) { + if ($this->getLayout() !== null) { $block = $this->getLayout()->createBlock($blockType); - $block->setMethod($method); + } else { + $className = Mage::app()->getConfig()->getBlockClassName($blockType); + $block = new $className(); } - + /** @var Mage_Payment_Block_Form $block */ + $block->setMethod($method); return $block; } /** * Retrieve payment information block * - * @return Mage_Core_Block_Abstract + * @return Mage_Payment_Block_Info * @throws Mage_Core_Exception */ public function getInfoBlock(Mage_Payment_Model_Info $info) { $blockType = $info->getMethodInstance()->getInfoBlockType(); - if ($this->getLayout()) { + if ($this->getLayout() !== null) { $block = $this->getLayout()->createBlock($blockType); } else { - $className = Mage::getConfig()->getBlockClassName($blockType); + $className = Mage::app()->getConfig()->getBlockClassName($blockType); $block = new $className(); } - /** @var Mage_Core_Block_Abstract $block */ + /** @var Mage_Payment_Block_Info $block */ $block->setInfo($info); return $block; } @@ -172,14 +177,14 @@ public function getRecurringProfileMethods($store = null) { $result = []; foreach (array_keys($this->getPaymentMethods($store)) as $code) { - $paymentMethodModelClassName = $this->getMethodModelClassName($code); - if (!$paymentMethodModelClassName) { + $paymentMethodModelClassName = $this->getMethodModelClassName($code, $store); + if (!is_string($paymentMethodModelClassName)) { continue; } /** @var Mage_Payment_Model_Method_Abstract $method */ $method = Mage::getModel($paymentMethodModelClassName); - if ($method && $method->canManageRecurringProfiles()) { + if ($method instanceof Mage_Payment_Model_Method_Abstract && $method->canManageRecurringProfiles()) { $result[] = $method; } } @@ -231,8 +236,11 @@ public function getPaymentMethodList($sorted = true, $asLabelValue = false, $wit $methods[$code] = $data['title']; } else { $paymentMethodModelClassName = $this->getMethodModelClassName($code); - if ($paymentMethodModelClassName) { - $methods[$code] = Mage::getModel($paymentMethodModelClassName)->getConfigData('title', $store); + if (is_string($paymentMethodModelClassName)) { + $methodModel = Mage::getModel($paymentMethodModelClassName); + if ($methodModel instanceof Mage_Payment_Model_Method_Abstract) { + $methods[$code] = $methodModel->getConfigData('title', $store); + } } } @@ -242,7 +250,18 @@ public function getPaymentMethodList($sorted = true, $asLabelValue = false, $wit } if ($asLabelValue && $withGroups) { - $groups = Mage::app()->getConfig()->getNode(self::XML_PATH_PAYMENT_GROUPS)->asCanonicalArray(); + $groups = Mage::app()->getConfig()->getNode(self::XML_PATH_PAYMENT_GROUPS); + + if ($groups instanceof Varien_Simplexml_Element) { + $groups = $groups->asCanonicalArray(); + + if (!is_array($groups)) { + $groups = []; + } + } else { + $groups = []; + } + foreach ($groups as $code => $title) { $methods[$code] = $title; // for sorting, see below } @@ -278,19 +297,18 @@ public function getPaymentMethodList($sorted = true, $asLabelValue = false, $wit /** * Retrieve all billing agreement methods (code and label) * - * @return array + * @return array */ public function getAllBillingAgreementMethods() { $result = []; - $interface = 'Mage_Payment_Model_Billing_Agreement_MethodInterface'; foreach ($this->getPaymentMethods() as $code => $data) { if (!isset($data['model'])) { continue; } $method = Mage::app()->getConfig()->getModelClassName($data['model']); - if (in_array($interface, class_implements($method))) { + if (is_a($method, Mage_Payment_Model_Billing_Agreement_MethodInterface::class, true)) { $result[$code] = $data['title']; } } diff --git a/app/code/core/Mage/Payment/Model/Config.php b/app/code/core/Mage/Payment/Model/Config.php index b98e29fe623..5081d32c6a6 100644 --- a/app/code/core/Mage/Payment/Model/Config.php +++ b/app/code/core/Mage/Payment/Model/Config.php @@ -18,13 +18,16 @@ */ class Mage_Payment_Model_Config { + /** + * @var array + */ protected static $_methods; /** * Retrieve active system payments * - * @param ConfigStoreId $store - * @return array + * @param ConfigStoreId $store + * @return array */ public function getActiveMethods($store = null) { @@ -32,9 +35,9 @@ public function getActiveMethods($store = null) $config = Mage::getStoreConfig('payment', $store); foreach ($config as $code => $methodConfig) { if (Mage::getStoreConfigFlag('payment/' . $code . '/active', $store) && array_key_exists('model', $methodConfig)) { - $methodModel = Mage::getModel($methodConfig['model']); - if ($methodModel && $methodModel->getConfigData('active', $store)) { - $methods[$code] = $this->_getMethod($code, $methodConfig); + $methodModel = $this->_getMethod($code, $methodConfig, $store); + if ($methodModel !== false && (bool) (int) $methodModel->getConfigData('active', $store)) { + $methods[$code] = $methodModel; } } } @@ -45,15 +48,15 @@ public function getActiveMethods($store = null) /** * Retrieve all system payments * - * @param ConfigStoreId $store - * @return array + * @param ConfigStoreId $store + * @return array */ public function getAllMethods($store = null) { $methods = []; $config = Mage::getStoreConfig('payment', $store); foreach ($config as $code => $methodConfig) { - $data = $this->_getMethod($code, $methodConfig); + $data = $this->_getMethod($code, $methodConfig, $store); if ($data !== false) { $methods[$code] = $data; } @@ -63,14 +66,15 @@ public function getAllMethods($store = null) } /** - * @param string $code - * @param array $config - * @param null|bool|int|Mage_Core_Model_Store|string $store $store + * @param string $code + * @param array $config + * @param ConfigStoreId $store * @return false|Mage_Payment_Model_Method_Abstract */ protected function _getMethod($code, $config, $store = null) { if (isset(self::$_methods[$code])) { + self::$_methods[$code]->setStore($store); return self::$_methods[$code]; } @@ -98,9 +102,19 @@ protected function _getMethod($code, $config, $store = null) */ public function getCcTypes() { - $_types = Mage::getConfig()->getNode('global/payment/cc/types')->asArray(); + $_types = Mage::getConfig()?->getNode('global/payment/cc/types'); + + if (!$_types instanceof Varien_Simplexml_Element) { + return []; + } - uasort($_types, ['Mage_Payment_Model_Config', 'compareCcTypes']); + $_types = $_types->asArray(); + + if (!is_array($_types)) { + return []; + } + + uasort($_types, self::compareCcTypes(...)); $types = []; foreach ($_types as $data) { @@ -115,7 +129,7 @@ public function getCcTypes() /** * Retrieve list of months translation * - * @return array + * @return array */ public function getMonths() { @@ -131,7 +145,7 @@ public function getMonths() /** * Retrieve array of available years * - * @return array + * @return array */ public function getYears() { @@ -155,22 +169,6 @@ public function getYears() */ public static function compareCcTypes($sortA, $sortB) { - if (!isset($sortA['order'])) { - $sortA['order'] = 0; - } - - if (!isset($sortB['order'])) { - $sortB['order'] = 0; - } - - if ($sortA['order'] == $sortB['order']) { - return 0; - } - - if ($sortA['order'] > $sortB['order']) { - return 1; - } - - return -1; + return ($sortA['order'] ?? 0) <=> ($sortB['order'] ?? 0); } } diff --git a/app/code/core/Mage/Payment/Model/Method/Abstract.php b/app/code/core/Mage/Payment/Model/Method/Abstract.php index a2a1b4bb658..42838917dce 100644 --- a/app/code/core/Mage/Payment/Model/Method/Abstract.php +++ b/app/code/core/Mage/Payment/Model/Method/Abstract.php @@ -805,4 +805,16 @@ public function debugData($debugData) { $this->_debug($debugData); } + + /** + * @return int + */ + public function getSortOrder() + { + if (!$this->hasData('sort_order')) { + $this->setData('sort_order', $this->getConfigData('sort_order')); + } + + return $this->getDataByKey('sort_order'); + } } diff --git a/lib/Varien/Data/Collection/Db.php b/lib/Varien/Data/Collection/Db.php index 1579d7ccc86..5eea149cde4 100644 --- a/lib/Varien/Data/Collection/Db.php +++ b/lib/Varien/Data/Collection/Db.php @@ -66,7 +66,7 @@ class Varien_Data_Collection_Db extends Varien_Data_Collection /** * Fields map for correlation names & real selected fields * - * @var null|array{fields: array} + * @var null|array> */ protected $_map = null; @@ -899,7 +899,7 @@ public function addFilterToMap($filter, $alias, $group = 'fields') { if (is_null($this->_map)) { $this->_map = [$group => []]; - } elseif (is_null($this->_map[$group])) { + } elseif (!array_key_exists($group, $this->_map)) { $this->_map[$group] = []; } diff --git a/lib/Varien/Image/Adapter/Gd2.php b/lib/Varien/Image/Adapter/Gd2.php index 3372fd43f27..44629e0d720 100644 --- a/lib/Varien/Image/Adapter/Gd2.php +++ b/lib/Varien/Image/Adapter/Gd2.php @@ -130,11 +130,11 @@ public function save($destination = null, $newName = null) { if (isset($destination) && isset($newName)) { $fileName = $destination . '/' . $newName; - } elseif (isset($destination) && !isset($newName)) { + } elseif (isset($destination)) { $info = pathinfo($destination); $fileName = $destination; $destination = $info['dirname']; - } elseif (!isset($destination) && isset($newName)) { + } elseif (isset($newName)) { $fileName = $this->_fileSrcPath . '/' . $newName; } else { $fileName = $this->_fileSrcPath . $this->_fileSrcName;