Skip to content
Open
1 change: 0 additions & 1 deletion .phpstan.dist.baselines/_loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
15 changes: 0 additions & 15 deletions .phpstan.dist.baselines/argument.type.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -4896,11 +4886,6 @@
'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,
Expand Down
15 changes: 0 additions & 15 deletions .phpstan.dist.baselines/assign.propertyType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<Mage_Core_Model_Abstract>::$_map (array{fields: array<string, string>}|null) does not accept array{fields: non-empty-array<string, string|Zend_Db_Expr>}.',
'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,
Expand Down Expand Up @@ -581,16 +576,6 @@
'count' => 1,
'path' => __DIR__ . '/../lib/Mage/HTTP/Client/Socket.php',
];
$ignoreErrors[] = [
'rawMessage' => 'Property Varien_Data_Collection_Db<T of Varien_Object>::$_map (array{fields: array<string, string>}|null) does not accept non-empty-array<string, array<string, string>>.',
'count' => 2,
'path' => __DIR__ . '/../lib/Varien/Data/Collection/Db.php',
];
$ignoreErrors[] = [
'rawMessage' => 'Property Varien_Data_Collection_Db<T of Varien_Object>::$_map (array{fields: array<string, string>}|null) does not accept non-empty-array<string, 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,
Expand Down
5 changes: 0 additions & 5 deletions .phpstan.dist.baselines/booleanNot.exprNotBoolean.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 0 additions & 5 deletions .phpstan.dist.baselines/equal.notAllowed.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
15 changes: 0 additions & 15 deletions .phpstan.dist.baselines/foreach.nonIterable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>|false supplied for foreach, only iterables are supported.',
'count' => 1,
Expand Down Expand Up @@ -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<Varien_Simplexml_Element>|false|null supplied for foreach, only iterables are supported.',
'count' => 1,
Expand Down
5 changes: 0 additions & 5 deletions .phpstan.dist.baselines/function.strict.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 0 additions & 5 deletions .phpstan.dist.baselines/if.condNotBoolean.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 0 additions & 10 deletions .phpstan.dist.baselines/isset.variable.php

This file was deleted.

15 changes: 0 additions & 15 deletions .phpstan.dist.baselines/method.nonObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -4896,11 +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,
Expand All @@ -4916,11 +4906,6 @@
'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,
Expand Down
5 changes: 0 additions & 5 deletions .phpstan.dist.baselines/return.type.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 0 additions & 5 deletions .phpstan.dist.baselines/variable.undefined.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
42 changes: 24 additions & 18 deletions app/code/core/Mage/Api2/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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'];
}
}

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
13 changes: 12 additions & 1 deletion app/code/core/Mage/Payment/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,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
}
Expand Down
32 changes: 13 additions & 19 deletions app/code/core/Mage/Payment/Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,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');

uasort($_types, ['Mage_Payment_Model_Config', 'compareCcTypes']);
if (!$_types instanceof Varien_Simplexml_Element) {
return [];
}

$_types = $_types->asArray();

if (!is_array($_types)) {
return [];
}

uasort($_types, self::compareCcTypes(...));

$types = [];
foreach ($_types as $data) {
Expand Down Expand Up @@ -155,22 +165,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);
}
}
4 changes: 2 additions & 2 deletions lib/Varien/Data/Collection/Db.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string>}
* @var null|array<string, array<string, string|Zend_Db_Expr>>
Comment thread
Hanmac marked this conversation as resolved.
*/
protected $_map = null;

Expand Down Expand Up @@ -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 (!isset($this->_map[$group])) {
Comment thread
Hanmac marked this conversation as resolved.
Outdated
$this->_map[$group] = [];
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Varien/Image/Adapter/Gd2.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading