From ce8622c8134be2158d571090f7515400f0241432 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 16 May 2023 17:06:49 +0200 Subject: [PATCH] rebase (#3237) Co-authored-by: Fabrizio Balliano --- app/code/core/Mage/Catalog/Model/Product/Image.php | 8 +++++--- app/code/core/Mage/Core/Controller/Request/Http.php | 2 +- app/code/core/Mage/Core/Helper/Data.php | 2 +- .../Mage/Core/Model/Resource/Setup/Query/Modifier.php | 2 +- app/code/core/Mage/Payment/Model/Method/Cc.php | 2 +- app/code/core/Mage/Uploader/Helper/File.php | 2 +- lib/Varien/Data/Form/Element/Time.php | 2 +- phpstan.dist.baseline.neon | 10 ---------- 8 files changed, 11 insertions(+), 19 deletions(-) diff --git a/app/code/core/Mage/Catalog/Model/Product/Image.php b/app/code/core/Mage/Catalog/Model/Product/Image.php index 7a96b766332..ef8f9135bfe 100644 --- a/app/code/core/Mage/Catalog/Model/Product/Image.php +++ b/app/code/core/Mage/Catalog/Model/Product/Image.php @@ -251,14 +251,16 @@ protected function _getMemoryLimit() $memoryLimit = "128M"; } + $value = (int)substr($memoryLimit, 0, -1); + if (substr($memoryLimit, -1) == 'K') { - return substr($memoryLimit, 0, -1) * 1024; + return $value * 1024; } if (substr($memoryLimit, -1) == 'M') { - return substr($memoryLimit, 0, -1) * 1024 * 1024; + return $value * 1024 * 1024; } if (substr($memoryLimit, -1) == 'G') { - return substr($memoryLimit, 0, -1) * 1024 * 1024 * 1024; + return $value * 1024 * 1024 * 1024; } return $memoryLimit; } diff --git a/app/code/core/Mage/Core/Controller/Request/Http.php b/app/code/core/Mage/Core/Controller/Request/Http.php index fc44d53ed81..be5ed7a6299 100644 --- a/app/code/core/Mage/Core/Controller/Request/Http.php +++ b/app/code/core/Mage/Core/Controller/Request/Http.php @@ -142,7 +142,7 @@ public function setPathInfo($pathInfo = null) if ($baseUrl && $pathInfo && (stripos($pathInfo, '/') !== 0)) { $pathInfo = ''; $this->setActionName('noRoute'); - } elseif (($baseUrl !== null) && ($pathInfo === false)) { + } elseif ($baseUrl !== null && !$pathInfo) { $pathInfo = ''; } elseif ($baseUrl === null) { $pathInfo = $requestUri; diff --git a/app/code/core/Mage/Core/Helper/Data.php b/app/code/core/Mage/Core/Helper/Data.php index 03e14cf5532..4928c699309 100644 --- a/app/code/core/Mage/Core/Helper/Data.php +++ b/app/code/core/Mage/Core/Helper/Data.php @@ -973,7 +973,7 @@ public function getEscapedCSVData(array $data) $value = (string)$value; $firstLetter = substr($value, 0, 1); - if ($firstLetter !== false && in_array($firstLetter, ["=", "+", "-"])) { + if ($firstLetter && in_array($firstLetter, ['=', '+', '-'])) { $data[$key] = ' ' . $value; } } diff --git a/app/code/core/Mage/Core/Model/Resource/Setup/Query/Modifier.php b/app/code/core/Mage/Core/Model/Resource/Setup/Query/Modifier.php index f9df8a5cdd7..30e48fc6eac 100644 --- a/app/code/core/Mage/Core/Model/Resource/Setup/Query/Modifier.php +++ b/app/code/core/Mage/Core/Model/Resource/Setup/Query/Modifier.php @@ -89,7 +89,7 @@ protected function _getColumnDefinitionFromSql($sql, $column) * * @param string $haystack * @param string $needle - * @param array $replacement + * @param string $replacement * @param bool $caseInsensitive * @return string */ diff --git a/app/code/core/Mage/Payment/Model/Method/Cc.php b/app/code/core/Mage/Payment/Model/Method/Cc.php index 5e8155de7c5..be0ade494a1 100644 --- a/app/code/core/Mage/Payment/Model/Method/Cc.php +++ b/app/code/core/Mage/Payment/Model/Method/Cc.php @@ -234,7 +234,7 @@ public function validateCcNum($ccNumber) $numSum = 0; for ($i = 0; $i < strlen($cardNumber); $i++) { - $currentNum = substr($cardNumber, $i, 1); + $currentNum = (int)substr($cardNumber, $i, 1); /** * Double every second digit diff --git a/app/code/core/Mage/Uploader/Helper/File.php b/app/code/core/Mage/Uploader/Helper/File.php index c256683d557..236adfbedb6 100644 --- a/app/code/core/Mage/Uploader/Helper/File.php +++ b/app/code/core/Mage/Uploader/Helper/File.php @@ -717,7 +717,7 @@ public function getDataMaxSize() public function getDataMaxSizeInBytes() { $iniSize = $this->getDataMaxSize(); - $size = substr($iniSize, 0, -1); + $size = (int)substr($iniSize, 0, -1); $parsedSize = 0; switch (strtolower(substr($iniSize, strlen($iniSize) - 1))) { case 't': diff --git a/lib/Varien/Data/Form/Element/Time.php b/lib/Varien/Data/Form/Element/Time.php index 84d56f9a4d7..f7f475d273a 100644 --- a/lib/Varien/Data/Form/Element/Time.php +++ b/lib/Varien/Data/Form/Element/Time.php @@ -56,7 +56,7 @@ public function getElementHtml() if ($value = $this->getValue()) { $values = explode(',', $value); - if (is_array($values) && count($values) == 3) { + if (count($values) === 3) { $value_hrs = $values[0]; $value_min = $values[1]; $value_sec = $values[2]; diff --git a/phpstan.dist.baseline.neon b/phpstan.dist.baseline.neon index f60ebec1f16..212a55a5b83 100644 --- a/phpstan.dist.baseline.neon +++ b/phpstan.dist.baseline.neon @@ -2300,11 +2300,6 @@ parameters: count: 1 path: app/code/core/Mage/Core/Model/Resource/Setup.php - - - message: "#^Binary operation \"\\.\" between \\(string\\|false\\) and array results in an error\\.$#" - count: 1 - path: app/code/core/Mage/Core/Model/Resource/Setup/Query/Modifier.php - - message: "#^Negated boolean expression is always false\\.$#" count: 1 @@ -3345,11 +3340,6 @@ parameters: count: 1 path: app/code/core/Mage/Payment/Model/Method/Abstract.php - - - message: "#^Binary operation \"\\-\" between string and int\\<\\-9, 9\\> results in an error\\.$#" - count: 1 - path: app/code/core/Mage/Payment/Model/Method/Cc.php - - message: "#^Loose comparison using \\!\\= between ''\\|'OT' and 'SS' will always evaluate to true\\.$#" count: 1