Skip to content

Commit e6645d2

Browse files
authored
PhpStan: fix wrong params for trim (#5072)
1 parent 689f46e commit e6645d2

File tree

3 files changed

+10
-17
lines changed

3 files changed

+10
-17
lines changed

.phpstan.dist.baseline.neon

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -378,12 +378,6 @@ parameters:
378378
count: 1
379379
path: app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tab/Wizard.php
380380

381-
-
382-
rawMessage: 'Parameter #2 $characters of function rtrim expects string, int given.'
383-
identifier: argument.type
384-
count: 1
385-
path: app/code/core/Mage/Adminhtml/Block/System/Currency/Rate/Matrix.php
386-
387381
-
388382
rawMessage: 'Method Mage_Core_Model_Email_Template::getProcessedTemplate() invoked with 2 parameters, 0-1 required.'
389383
identifier: arguments.count
@@ -4182,12 +4176,6 @@ parameters:
41824176
count: 2
41834177
path: app/code/core/Mage/Sales/Model/Entity/Quote.php
41844178

4185-
-
4186-
rawMessage: 'Parameter #1 $string of function trim expects string, float given.'
4187-
identifier: argument.type
4188-
count: 2
4189-
path: app/code/core/Mage/Sales/Model/Order/Creditmemo.php
4190-
41914179
-
41924180
rawMessage: 'Property Mage_Sales_Model_Order_Creditmemo::$_items (iterable<Mage_Sales_Model_Order_Creditmemo_Item>&Mage_Sales_Model_Resource_Order_Creditmemo_Item_Collection) in empty() is not falsy.'
41934181
identifier: empty.property

app/code/core/Mage/Adminhtml/Block/System/Currency/Rate/Matrix.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ protected function _prepareLayout()
3131

3232
foreach ($currencies as $currency) {
3333
foreach ($oldCurrencies as $key => $value) {
34-
if (!array_key_exists($currency, $oldCurrencies[$key])) {
34+
if (!array_key_exists($currency, $value)) {
3535
$oldCurrencies[$key][$currency] = '';
3636
}
3737
}
@@ -66,7 +66,7 @@ protected function _prepareRates($array)
6666
foreach ($rate as $code => $value) {
6767
$parts = explode('.', (string) $value);
6868
if (count($parts) === 2) {
69-
$parts[1] = str_pad(rtrim($parts[1], 0), 4, '0', STR_PAD_RIGHT);
69+
$parts[1] = str_pad(rtrim($parts[1], '0'), 4, '0', STR_PAD_RIGHT);
7070
$array[$key][$code] = implode('.', $parts);
7171
} elseif ($value > 0) {
7272
$array[$key][$code] = number_format($value, 4);

app/code/core/Mage/Sales/Model/Order/Creditmemo.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,7 @@ public function cancel()
554554
*
555555
* Apply to order, order items etc.
556556
*
557+
* @throws Mage_Core_Exception
557558
* @return $this
558559
*/
559560
public function register()
@@ -660,7 +661,7 @@ public function setShippingAmount($amount)
660661
*/
661662
public function setAdjustmentPositive($amount)
662663
{
663-
$amount = trim($amount);
664+
$amount = trim((string) $amount);
664665
if (str_ends_with($amount, '%')) {
665666
$amount = (float) substr($amount, 0, -1);
666667
$amount = $this->getOrder()->getGrandTotal() * $amount / 100;
@@ -682,7 +683,7 @@ public function setAdjustmentPositive($amount)
682683
*/
683684
public function setAdjustmentNegative($amount)
684685
{
685-
$amount = trim($amount);
686+
$amount = trim((string) $amount);
686687
if (str_ends_with($amount, '%')) {
687688
$amount = (float) substr($amount, 0, -1);
688689
$amount = $this->getOrder()->getGrandTotal() * $amount / 100;
@@ -705,7 +706,7 @@ public function setAdjustmentNegative($amount)
705706
* @param string $comment
706707
* @param bool $notify
707708
* @param bool $visibleOnFront
708-
*
709+
* @throws Exception
709710
* @return $this
710711
*/
711712
public function addComment($comment, $notify = false, $visibleOnFront = false)
@@ -759,6 +760,8 @@ public function getCommentsCollection($reload = false)
759760
*
760761
* @param bool $notifyCustomer
761762
* @param string $comment
763+
* @throws Mage_Core_Model_Store_Exception
764+
* @throws Exception
762765
* @return $this
763766
*/
764767
public function sendEmail($notifyCustomer = true, $comment = '')
@@ -956,6 +959,7 @@ protected function _beforeDelete()
956959
* After save object manipulations
957960
*
958961
* @inheritDoc
962+
* @throws Throwable
959963
*/
960964
protected function _afterSave()
961965
{
@@ -995,6 +999,7 @@ protected function _beforeSave()
995999
* Get creditmemos collection filtered by $filter
9961000
*
9971001
* @param null|array $filter
1002+
* @throws Mage_Core_Exception
9981003
* @return Mage_Sales_Model_Resource_Order_Creditmemo_Collection
9991004
*/
10001005
public function getFilteredCollectionItems($filter = null)

0 commit comments

Comments
 (0)