Skip to content

Commit 4a3b6fa

Browse files
sreichelkiatng
andauthored
More phpstan fixes (#4291)
* fixes * fixes * updated tests * typo * Update app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Run.php Co-authored-by: Ng Kiat Siong <[email protected]> * #4291 (comment) * revert #4291 (comment) * reverted comments #4291 (comment) * phpcs * removed some phpcs comments * typo * revert * fix * typo * update * update baseline * reverted * Update app/code/core/Mage/Adminhtml/Model/Sales/Order/Create.php Co-authored-by: Ng Kiat Siong <[email protected]> * reverted some cs-comments * cs * reverted some cs-comments * cs * minor cs [skip ci] * reverted some cs-comments [skip ci] * minor cs [skip ci] * minor cs [skip ci] * minor cs [skip ci] --------- Co-authored-by: Ng Kiat Siong <[email protected]>
1 parent ceebab5 commit 4a3b6fa

File tree

73 files changed

+216
-635
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+216
-635
lines changed

.github/workflows/phpstan.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
uses: actions/cache/restore@v4
4141
with:
4242
path: .phpstan.cache
43-
key: "phpstan-result-cache-${{ github.run_id }}"
43+
key: phpstan-result-cache-${{ matrix.php-versions }}-${{ github.run_id }}
4444
restore-keys: |
4545
phpstan-result-cache-
4646
@@ -52,4 +52,4 @@ jobs:
5252
if: always()
5353
with:
5454
path: .phpstan.cache
55-
key: "phpstan-result-cache-${{ github.run_id }}"
55+
key: phpstan-result-cache-${{ matrix.php-versions }}-${{ github.run_id }}

.phpstan.dist.baseline.neon

Lines changed: 9 additions & 429 deletions
Large diffs are not rendered by default.

app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tab/Wizard.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ protected function _prepareLayout()
5959
public function getAttributes($entityType)
6060
{
6161
if (!isset($this->_attributes[$entityType])) {
62+
$attributes = [];
6263
switch ($entityType) {
6364
case 'product':
6465
$attributes = Mage::getSingleton('catalog/convert_parser_product')

app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Run.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ public function getExceptions()
172172
$liStyle = 'background-color:#FFD; ';
173173
break;
174174
case Varien_Convert_Exception::NOTICE:
175+
default:
175176
$img = 'fam_bullet_success.gif';
176177
$liStyle = 'background-color:#DDF; ';
177178
break;

app/code/core/Mage/Adminhtml/Model/Sales/Order/Create.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1116,6 +1116,10 @@ protected function _setQuoteAddress(Mage_Sales_Model_Quote_Address $address, arr
11161116
return $this;
11171117
}
11181118

1119+
/**
1120+
* @param array|Mage_Sales_Model_Quote_Address $address
1121+
* @return $this
1122+
*/
11191123
public function setShippingAddress($address)
11201124
{
11211125
if (is_array($address)) {
@@ -1164,6 +1168,10 @@ public function getBillingAddress()
11641168
return $this->getQuote()->getBillingAddress();
11651169
}
11661170

1171+
/**
1172+
* @param array|Mage_Sales_Model_Quote_Address $address
1173+
* @return $this
1174+
*/
11671175
public function setBillingAddress($address)
11681176
{
11691177
if (is_array($address)) {
@@ -1173,6 +1181,8 @@ public function setBillingAddress($address)
11731181
->setAddressType(Mage_Sales_Model_Quote_Address::TYPE_BILLING);
11741182
$this->_setQuoteAddress($billingAddress, $address);
11751183
$billingAddress->implodeStreetAddress();
1184+
} elseif ($address instanceof Mage_Sales_Model_Quote_Address) {
1185+
$billingAddress = $address;
11761186
}
11771187

11781188
if ($this->getShippingAddress()->getSameAsBilling()) {
@@ -1488,7 +1498,6 @@ protected function _prepareQuoteItems()
14881498
{
14891499
foreach ($this->getQuote()->getAllItems() as $item) {
14901500
$options = [];
1491-
// phpcs:ignore Ecg.Performance.Loop.DataLoad
14921501
$productOptions = $item->getProduct()->getTypeInstance(true)->getOrderOptions($item->getProduct());
14931502
if ($productOptions) {
14941503
$productOptions['info_buyRequest']['options'] = $this->_prepareOptionsForRequest($item);

app/code/core/Mage/Adminhtml/Model/System/Store.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ public function getStoreValuesForForm($empty = false, $all = false)
129129
if ($website->getId() != $group->getWebsiteId()) {
130130
continue;
131131
}
132+
$values = [];
132133
$groupShow = false;
133134
foreach ($this->_storeCollection as $store) {
134135
if ($group->getId() != $store->getGroupId()) {

app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,11 @@ public function massCancelAction()
344344
$countCancelOrder = 0;
345345
$countNonCancelOrder = 0;
346346
foreach ($orderIds as $orderId) {
347+
// phpcs:ignore Ecg.Performance.Loop.ModelLSD
347348
$order = Mage::getModel('sales/order')->load($orderId);
348349
if ($order->canCancel()) {
349350
$order->cancel()
351+
// phpcs:ignore Ecg.Performance.Loop.ModelLSD
350352
->save();
351353
$countCancelOrder++;
352354
} else {
@@ -375,9 +377,11 @@ public function massHoldAction()
375377
$countHoldOrder = 0;
376378

377379
foreach ($orderIds as $orderId) {
380+
// phpcs:ignore Ecg.Performance.Loop.ModelLSD
378381
$order = Mage::getModel('sales/order')->load($orderId);
379382
if ($order->canHold()) {
380383
$order->hold()
384+
// phpcs:ignore Ecg.Performance.Loop.ModelLSD
381385
->save();
382386
$countHoldOrder++;
383387
}
@@ -409,9 +413,11 @@ public function massUnholdAction()
409413
$countNonUnholdOrder = 0;
410414

411415
foreach ($orderIds as $orderId) {
416+
// phpcs:ignore Ecg.Performance.Loop.ModelLSD
412417
$order = Mage::getModel('sales/order')->load($orderId);
413418
if ($order->canUnhold()) {
414419
$order->unhold()
420+
// phpcs:ignore Ecg.Performance.Loop.ModelLSD
415421
->save();
416422
$countUnholdOrder++;
417423
} else {
@@ -449,18 +455,19 @@ public function massPrintAction()
449455

450456
/**
451457
* Print invoices for selected orders
458+
*
459+
* @return Mage_Adminhtml_Sales_OrderController|void
452460
*/
453461
public function pdfinvoicesAction()
454462
{
455463
$orderIds = $this->getRequest()->getPost('order_ids');
456-
$flag = false;
457464
if (!empty($orderIds)) {
458465
foreach ($orderIds as $orderId) {
459466
$invoices = Mage::getResourceModel('sales/order_invoice_collection')
460467
->setOrderFilter($orderId)
468+
// phpcs:ignore Ecg.Performance.Loop.ModelLSD
461469
->load();
462470
if ($invoices->getSize() > 0) {
463-
$flag = true;
464471
if (!isset($pdf)) {
465472
$pdf = Mage::getModel('sales/order_pdf_invoice')->getPdf($invoices);
466473
} else {
@@ -469,7 +476,7 @@ public function pdfinvoicesAction()
469476
}
470477
}
471478
}
472-
if ($flag) {
479+
if (isset($pdf) && $pdf instanceof Zend_Pdf) {
473480
return $this->_prepareDownloadResponse(
474481
'invoice' . Mage::getSingleton('core/date')->date('Y-m-d_H-i-s') . '.pdf',
475482
$pdf->render(),
@@ -485,18 +492,19 @@ public function pdfinvoicesAction()
485492

486493
/**
487494
* Print shipments for selected orders
495+
*
496+
* @return Mage_Adminhtml_Sales_OrderController|void
488497
*/
489498
public function pdfshipmentsAction()
490499
{
491500
$orderIds = $this->getRequest()->getPost('order_ids');
492-
$flag = false;
493501
if (!empty($orderIds)) {
494502
foreach ($orderIds as $orderId) {
495503
$shipments = Mage::getResourceModel('sales/order_shipment_collection')
496504
->setOrderFilter($orderId)
505+
// phpcs:ignore Ecg.Performance.Loop.ModelLSD
497506
->load();
498507
if ($shipments->getSize()) {
499-
$flag = true;
500508
if (!isset($pdf)) {
501509
$pdf = Mage::getModel('sales/order_pdf_shipment')->getPdf($shipments);
502510
} else {
@@ -505,7 +513,7 @@ public function pdfshipmentsAction()
505513
}
506514
}
507515
}
508-
if ($flag) {
516+
if (isset($pdf) && $pdf instanceof Zend_Pdf) {
509517
return $this->_prepareDownloadResponse(
510518
'packingslip' . Mage::getSingleton('core/date')->date('Y-m-d_H-i-s') . '.pdf',
511519
$pdf->render(),
@@ -521,18 +529,19 @@ public function pdfshipmentsAction()
521529

522530
/**
523531
* Print creditmemos for selected orders
532+
*
533+
* @return Mage_Adminhtml_Sales_OrderController|void
524534
*/
525535
public function pdfcreditmemosAction()
526536
{
527537
$orderIds = $this->getRequest()->getPost('order_ids');
528-
$flag = false;
529538
if (!empty($orderIds)) {
530539
foreach ($orderIds as $orderId) {
531540
$creditmemos = Mage::getResourceModel('sales/order_creditmemo_collection')
532541
->setOrderFilter($orderId)
542+
// phpcs:ignore Ecg.Performance.Loop.ModelLSD
533543
->load();
534544
if ($creditmemos->getSize()) {
535-
$flag = true;
536545
if (!isset($pdf)) {
537546
$pdf = Mage::getModel('sales/order_pdf_creditmemo')->getPdf($creditmemos);
538547
} else {
@@ -541,7 +550,7 @@ public function pdfcreditmemosAction()
541550
}
542551
}
543552
}
544-
if ($flag) {
553+
if (isset($pdf) && $pdf instanceof Zend_Pdf) {
545554
return $this->_prepareDownloadResponse(
546555
'creditmemo' . Mage::getSingleton('core/date')->date('Y-m-d_H-i-s') . '.pdf',
547556
$pdf->render(),
@@ -557,18 +566,19 @@ public function pdfcreditmemosAction()
557566

558567
/**
559568
* Print all documents for selected orders
569+
*
570+
* @return Mage_Adminhtml_Sales_OrderController|void
560571
*/
561572
public function pdfdocsAction()
562573
{
563574
$orderIds = $this->getRequest()->getPost('order_ids');
564-
$flag = false;
565575
if (!empty($orderIds)) {
566576
foreach ($orderIds as $orderId) {
567577
$invoices = Mage::getResourceModel('sales/order_invoice_collection')
568578
->setOrderFilter($orderId)
579+
// phpcs:ignore Ecg.Performance.Loop.ModelLSD
569580
->load();
570581
if ($invoices->getSize()) {
571-
$flag = true;
572582
if (!isset($pdf)) {
573583
$pdf = Mage::getModel('sales/order_pdf_invoice')->getPdf($invoices);
574584
} else {
@@ -579,9 +589,9 @@ public function pdfdocsAction()
579589

580590
$shipments = Mage::getResourceModel('sales/order_shipment_collection')
581591
->setOrderFilter($orderId)
592+
// phpcs:ignore Ecg.Performance.Loop.ModelLSD
582593
->load();
583594
if ($shipments->getSize()) {
584-
$flag = true;
585595
if (!isset($pdf)) {
586596
$pdf = Mage::getModel('sales/order_pdf_shipment')->getPdf($shipments);
587597
} else {
@@ -592,9 +602,9 @@ public function pdfdocsAction()
592602

593603
$creditmemos = Mage::getResourceModel('sales/order_creditmemo_collection')
594604
->setOrderFilter($orderId)
605+
// phpcs:ignore Ecg.Performance.Loop.ModelLSD
595606
->load();
596607
if ($creditmemos->getSize()) {
597-
$flag = true;
598608
if (!isset($pdf)) {
599609
$pdf = Mage::getModel('sales/order_pdf_creditmemo')->getPdf($creditmemos);
600610
} else {
@@ -603,7 +613,7 @@ public function pdfdocsAction()
603613
}
604614
}
605615
}
606-
if ($flag) {
616+
if (isset($pdf) && $pdf instanceof Zend_Pdf) {
607617
return $this->_prepareDownloadResponse(
608618
'docs' . Mage::getSingleton('core/date')->date('Y-m-d_H-i-s') . '.pdf',
609619
$pdf->render(),

app/code/core/Mage/Adminhtml/controllers/System/StoreController.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,23 +113,30 @@ public function editStoreAction()
113113
if (!Mage::registry('store_action')) {
114114
Mage::register('store_action', 'edit');
115115
}
116+
117+
$itemId = null;
118+
$model = null;
119+
$title = '';
120+
$notExists = '';
121+
$codeBase = '';
122+
116123
switch (Mage::registry('store_type')) {
117124
case 'website':
118-
$itemId = $this->getRequest()->getParam('website_id', null);
125+
$itemId = $this->getRequest()->getParam('website_id');
119126
$model = Mage::getModel('core/website');
120127
$title = Mage::helper('core')->__('Website');
121128
$notExists = Mage::helper('core')->__('The website does not exist.');
122129
$codeBase = Mage::helper('core')->__('Before modifying the website code please make sure that it is not used in index.php.');
123130
break;
124131
case 'group':
125-
$itemId = $this->getRequest()->getParam('group_id', null);
132+
$itemId = $this->getRequest()->getParam('group_id');
126133
$model = Mage::getModel('core/store_group');
127134
$title = Mage::helper('core')->__('Store');
128135
$notExists = Mage::helper('core')->__('The store does not exist');
129136
$codeBase = false;
130137
break;
131138
case 'store':
132-
$itemId = $this->getRequest()->getParam('store_id', null);
139+
$itemId = $this->getRequest()->getParam('store_id');
133140
$model = Mage::getModel('core/store');
134141
$title = Mage::helper('core')->__('Store View');
135142
$notExists = Mage::helper('core')->__("Store view doesn't exist");

app/code/core/Mage/Api2/Helper/Data.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ class Mage_Api2_Helper_Data extends Mage_Core_Helper_Abstract
4242
/**
4343
* Compare order to be used in adapters list sort
4444
*
45-
* @param int $a
46-
* @param int $b
45+
* @param array $a
46+
* @param array $b
4747
* @return int
4848
*/
4949
protected static function _compareOrder($a, $b)

app/code/core/Mage/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option/Selection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public function getSelectionSearchUrl()
136136
/**
137137
* Check if used website scope price
138138
*
139-
* @return string
139+
* @return bool
140140
*/
141141
public function isUsedWebsitePrice()
142142
{

0 commit comments

Comments
 (0)