From 03b8e6de00fbab084a2d9cfc417a09469fd9884a Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Sat, 28 Jul 2018 19:42:55 +0200 Subject: [PATCH 1/2] Removed unreachable code --- .../Magento/CatalogSearch/Block/Advanced/Form.php | 9 --------- .../Magento/MediaStorage/Model/File/Storage/File.php | 11 ++++------- .../Sales/Model/Service/CreditmemoService.php | 12 ------------ .../Shipping/Block/Adminhtml/Order/Tracking/View.php | 7 +------ .../Controller/Adminhtml/Widget/Instance/Save.php | 2 -- 5 files changed, 5 insertions(+), 36 deletions(-) diff --git a/app/code/Magento/CatalogSearch/Block/Advanced/Form.php b/app/code/Magento/CatalogSearch/Block/Advanced/Form.php index 68e4233e8deaf..b1d0a6431dcdf 100644 --- a/app/code/Magento/CatalogSearch/Block/Advanced/Form.php +++ b/app/code/Magento/CatalogSearch/Block/Advanced/Form.php @@ -181,15 +181,6 @@ public function getCurrencyCount() public function getCurrency($attribute) { return $this->_storeManager->getStore()->getCurrentCurrencyCode(); - - $baseCurrency = $this->_storeManager->getStore()->getBaseCurrency()->getCurrencyCode(); - return $this->getAttributeValue( - $attribute, - 'currency' - ) ? $this->getAttributeValue( - $attribute, - 'currency' - ) : $baseCurrency; } /** diff --git a/app/code/Magento/MediaStorage/Model/File/Storage/File.php b/app/code/Magento/MediaStorage/Model/File/Storage/File.php index 149d829e2acbe..ffbc2e3e90aad 100644 --- a/app/code/Magento/MediaStorage/Model/File/Storage/File.php +++ b/app/code/Magento/MediaStorage/Model/File/Storage/File.php @@ -286,11 +286,10 @@ public function saveDir($dir) */ public function saveFile($file, $overwrite = true) { - if (isset( - $file['filename'] - ) && !empty($file['filename']) && isset( - $file['content'] - ) && !empty($file['content']) + if (isset($file['filename']) + && !empty($file['filename']) + && isset($file['content']) + && !empty($file['content']) ) { try { $filename = isset( @@ -307,8 +306,6 @@ public function saveFile($file, $overwrite = true) } else { throw new \Magento\Framework\Exception\LocalizedException(__('Wrong file info format')); } - - return false; } /** diff --git a/app/code/Magento/Sales/Model/Service/CreditmemoService.php b/app/code/Magento/Sales/Model/Service/CreditmemoService.php index 24f56c0dbd595..aa872a809803a 100644 --- a/app/code/Magento/Sales/Model/Service/CreditmemoService.php +++ b/app/code/Magento/Sales/Model/Service/CreditmemoService.php @@ -104,18 +104,6 @@ public function __construct( public function cancel($id) { throw new \Magento\Framework\Exception\LocalizedException(__('You can not cancel Credit Memo')); - try { - $creditmemo = $this->creditmemoRepository->get($id); - $creditmemo->setState(\Magento\Sales\Model\Order\Creditmemo::STATE_CANCELED); - foreach ($creditmemo->getAllItems() as $item) { - $item->cancel(); - } - $this->eventManager->dispatch('sales_order_creditmemo_cancel', ['creditmemo' => $creditmemo]); - $this->creditmemoRepository->save($creditmemo); - } catch (\Exception $e) { - throw new \Magento\Framework\Exception\LocalizedException(__('Could not cancel creditmemo'), $e); - } - return true; } /** diff --git a/app/code/Magento/Shipping/Block/Adminhtml/Order/Tracking/View.php b/app/code/Magento/Shipping/Block/Adminhtml/Order/Tracking/View.php index 00fc6fce1bfb8..356483c9a5dd7 100644 --- a/app/code/Magento/Shipping/Block/Adminhtml/Order/Tracking/View.php +++ b/app/code/Magento/Shipping/Block/Adminhtml/Order/Tracking/View.php @@ -92,11 +92,6 @@ public function getRemoveUrl($track) public function getCarrierTitle($code) { $carrier = $this->_carrierFactory->create($code); - if ($carrier) { - return $carrier->getConfigData('title'); - } else { - return __('Custom Value'); - } - return false; + return $carrier ? $carrier->getConfigData('title') : __('Custom Value'); } } diff --git a/app/code/Magento/Widget/Controller/Adminhtml/Widget/Instance/Save.php b/app/code/Magento/Widget/Controller/Adminhtml/Widget/Instance/Save.php index 98275c3b906db..b5d31dc10be34 100644 --- a/app/code/Magento/Widget/Controller/Adminhtml/Widget/Instance/Save.php +++ b/app/code/Magento/Widget/Controller/Adminhtml/Widget/Instance/Save.php @@ -49,7 +49,5 @@ public function execute() $this->_redirect('adminhtml/*/edit', ['_current' => true]); return; } - $this->_redirect('adminhtml/*/'); - return; } } From 470b5076291aecfef873e8a983d82621174e9167 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 31 Jul 2018 14:03:32 +0200 Subject: [PATCH 2/2] Fixed static test (supress warnings for unused parameter) --- app/code/Magento/CatalogSearch/Block/Advanced/Form.php | 1 + app/code/Magento/Sales/Model/Service/CreditmemoService.php | 1 + 2 files changed, 2 insertions(+) diff --git a/app/code/Magento/CatalogSearch/Block/Advanced/Form.php b/app/code/Magento/CatalogSearch/Block/Advanced/Form.php index b1d0a6431dcdf..4d1957991d1bf 100644 --- a/app/code/Magento/CatalogSearch/Block/Advanced/Form.php +++ b/app/code/Magento/CatalogSearch/Block/Advanced/Form.php @@ -177,6 +177,7 @@ public function getCurrencyCount() * * @param AbstractAttribute $attribute * @return string + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function getCurrency($attribute) { diff --git a/app/code/Magento/Sales/Model/Service/CreditmemoService.php b/app/code/Magento/Sales/Model/Service/CreditmemoService.php index aa872a809803a..e8f2e6e5305f7 100644 --- a/app/code/Magento/Sales/Model/Service/CreditmemoService.php +++ b/app/code/Magento/Sales/Model/Service/CreditmemoService.php @@ -100,6 +100,7 @@ public function __construct( * @param int $id Credit Memo Id * @return bool * @throws \Magento\Framework\Exception\LocalizedException + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function cancel($id) {