Skip to content

rector: RemoveUnusedVariableInCatchRector #4834

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
DeadCode\ClassMethod\RemoveUselessReturnTagRector::class,
DeadCode\Property\RemoveUselessVarTagRector::class,
DeadCode\StaticCall\RemoveParentCallWithoutParentRector::class,
Php80\Catch_\RemoveUnusedVariableInCatchRector::class,
])
->withPreparedSets(
deadCode: false,
Expand Down
10 changes: 5 additions & 5 deletions app/Mage.php
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ public static function init($code = '', $type = 'store', $options = [], $modules
} else {
self::$_app->init($code, $type, $options);
}
} catch (Mage_Core_Model_Session_Exception $e) {
} catch (Mage_Core_Model_Session_Exception) {
header('Location: ' . self::getBaseUrl());
die;
} catch (Mage_Core_Model_Store_Exception $e) {
Expand Down Expand Up @@ -746,7 +746,7 @@ public static function run($code = '', $type = 'store', $options = [])
'options' => $options,
]);
Varien_Profiler::stop('mage');
} catch (Mage_Core_Model_Session_Exception $e) {
} catch (Mage_Core_Model_Session_Exception) {
header('Location: ' . self::getBaseUrl());
die();
} catch (Mage_Core_Model_Store_Exception $e) {
Expand Down Expand Up @@ -857,7 +857,7 @@ public static function log($message, $level = null, $file = '', $forceLog = fals
if (empty($file)) {
$file = self::getStoreConfig('dev/log/file');
}
} catch (Exception $e) {
} catch (Exception) {
$logActive = true;
}

Expand All @@ -869,7 +869,7 @@ public static function log($message, $level = null, $file = '', $forceLog = fals

try {
$maxLogLevel = (int) self::getStoreConfig('dev/log/max_level');
} catch (Throwable $e) {
} catch (Throwable) {
$maxLogLevel = Zend_Log::DEBUG;
}

Expand Down Expand Up @@ -924,7 +924,7 @@ public static function log($message, $level = null, $file = '', $forceLog = fals

$message = addcslashes($message, '<?');
$loggers[$file]->log($message, $level);
} catch (Exception $e) {
} catch (Exception) {
}
}

Expand Down
4 changes: 2 additions & 2 deletions app/code/core/Mage/Admin/Model/Acl/Role/Registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function addParent($role, $parents)
$roleId = $role;
$role = $this->get($role);
}
} catch (Zend_Acl_Role_Registry_Exception $e) {
} catch (Zend_Acl_Role_Registry_Exception) {
throw new Zend_Acl_Role_Registry_Exception("Child Role id '$roleId' does not exist");
}

Expand All @@ -45,7 +45,7 @@ public function addParent($role, $parents)
$roleParentId = $parent;
}
$roleParent = $this->get($roleParentId);
} catch (Zend_Acl_Role_Registry_Exception $e) {
} catch (Zend_Acl_Role_Registry_Exception) {
throw new Zend_Acl_Role_Registry_Exception("Parent Role id '$roleParentId' does not exist");
}
$this->_roles[$roleId]['parents'][$roleParentId] = $roleParent;
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Admin/Model/Resource/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ protected function _unserializeExtraData(Mage_Core_Model_Abstract $user)
try {
$unsterilizedData = Mage::helper('core/unserializeArray')->unserialize($user->getExtra());
$user->setExtra($unsterilizedData);
} catch (Exception $e) {
} catch (Exception) {
$user->setExtra(false);
}
return $user;
Expand Down
6 changes: 3 additions & 3 deletions app/code/core/Mage/Admin/Model/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,12 @@ public function isAllowed($resource, $privilege = null)

try {
return $acl->isAllowed($user->getAclRole(), $resource, $privilege);
} catch (Exception $e) {
} catch (Exception) {
try {
if (!$acl->has($resource)) {
return $acl->isAllowed($user->getAclRole(), null, $privilege);
}
} catch (Exception $e) {
} catch (Exception) {
}
}
}
Expand Down Expand Up @@ -308,7 +308,7 @@ protected function _loginFailed($e, $request, $username, $message)
'user_name' => $username,
'exception' => $e,
]);
} catch (Exception $e) {
} catch (Exception) {
}

if ($request && !$request->getParam('messageSent')) {
Expand Down
4 changes: 2 additions & 2 deletions app/code/core/Mage/AdminNotification/Model/Feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public function getFeedData()

try {
$xml = new SimpleXMLElement($data);
} catch (Exception $e) {
} catch (Exception) {
return false;
}

Expand All @@ -159,7 +159,7 @@ public function getFeedXml()
try {
$data = $this->getFeedData();
$xml = new SimpleXMLElement($data);
} catch (Exception $e) {
} catch (Exception) {
$xml = new SimpleXMLElement('<?xml version="1.0" encoding="utf-8" ?><feed />');
}

Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Adminhtml/Block/Page/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ protected function _checkAcl($resource)
{
try {
$res = Mage::getSingleton('admin/session')->isAllowed($resource);
} catch (Exception $e) {
} catch (Exception) {
return false;
}
return $res;
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Adminhtml/Block/Report/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ protected function _prepareCollection()
$to = $this->getLocale()->date($this->getFilter('report_to'), Zend_Date::DATE_SHORT, null, false);

$collection->setInterval($from, $to);
} catch (Exception $e) {
} catch (Exception) {
$this->_errors[] = Mage::helper('reports')->__('Invalid date specified.');
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected function _getFormat()
);
break;
}
} catch (Exception $e) {
} catch (Exception) {
}
}
$format = self::$_format;
Expand Down Expand Up @@ -75,7 +75,7 @@ public function render(Varien_Object $row)
$data = ($this->getColumn()->getGmtoffset())
? Mage::app()->getLocale()->date($data, $dateFormat)->toString($format)
: Mage::getSingleton('core/locale')->date($data, $dateFormat, null, false)->toString($format);
} catch (Exception $e) {
} catch (Exception) {
$data = ($this->getColumn()->getTimezone())
? Mage::app()->getLocale()->date($data, $dateFormat)->toString($format)
: Mage::getSingleton('core/locale')->date($data, $dateFormat, null, false)->toString($format);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function getCustomizedOptionValue($optionInfo)
try {
$group = Mage::getModel('catalog/product_option')->groupFactory($optionInfo['option_type']);
return $group->getCustomizedView($optionInfo);
} catch (Exception $e) {
} catch (Exception) {
return $default;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ protected function _convertDate($date, $locale)
$dateObj->setTimezone(Mage_Core_Model_Locale::DEFAULT_TIMEZONE);

return $dateObj;
} catch (Exception $e) {
} catch (Exception) {
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected function _convertDate($date, $locale)
$dateObj->setTimezone(Mage_Core_Model_Locale::DEFAULT_TIMEZONE);

return $dateObj;
} catch (Exception $e) {
} catch (Exception) {
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function render(Varien_Object $row)
$data = Mage::getSingleton('core/locale')
->date($data, Zend_Date::ISO_8601, null, false)->toString($format);
}
} catch (Exception $e) {
} catch (Exception) {
if ($this->getColumn()->getTimezone()) {
$data = Mage::app()->getLocale()
->date($data, Varien_Date::DATETIME_INTERNAL_FORMAT)->toString($format);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function render(Varien_Object $row)
$data = Mage::app()->getLocale()
->date($data, Varien_Date::DATETIME_INTERNAL_FORMAT, $locale, $useTimezone)
->toString($format);
} catch (Exception $e) {
} catch (Exception) {
$data = Mage::app()->getLocale()
->date($data, Varien_Date::DATETIME_INTERNAL_FORMAT)->toString($format);
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Adminhtml/Model/Config/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ protected function _isSectionAllowed($section)
$session->getData('acl')->get($resourceLookup)->getResourceId(),
);
}
} catch (Exception $e) {
} catch (Exception) {
return false;
}
return false;
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Adminhtml/Model/Sales/Order/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ protected function _parseOptions(Mage_Sales_Model_Quote_Item $item, $additionalO
);
}
[$label, $value] = explode(':', $additionalOption, 2);
} catch (Exception $e) {
} catch (Exception) {
Mage::throwException(Mage::helper('adminhtml')->__('There is an error in one of the option rows.'));
}
$label = trim($label);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected function _afterSave()
->setValue($cronExprString)
->setPath(self::CRON_STRING_PATH)
->save();
} catch (Exception $e) {
} catch (Exception) {
throw new Exception(Mage::helper('cron')->__('Unable to save the cron expression.'));
}
return $this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ protected function _afterSave()
->setValue((string) Mage::getConfig()->getNode(self::CRON_MODEL_PATH))
->setPath(self::CRON_MODEL_PATH)
->save();
} catch (Exception $e) {
} catch (Exception) {
Mage::throwException(Mage::helper('adminhtml')->__('Unable to save the cron expression.'));
}
return $this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected function _afterSave()
->setValue((string) Mage::getConfig()->getNode(self::CRON_MODEL_PATH))
->setPath(self::CRON_MODEL_PATH)
->save();
} catch (Exception $e) {
} catch (Exception) {
throw new Exception(Mage::helper('cron')->__('Unable to save the cron expression.'));
}
return $this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected function _beforeSave()
{
try {
Mage::helper('core/unserializeArray')->unserialize(serialize($this->getValue()));
} catch (Exception $e) {
} catch (Exception) {
Mage::throwException(Mage::helper('adminhtml')->__('Serialized data is incorrect'));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected function _afterSave()
->setValue((string) Mage::getConfig()->getNode(self::CRON_MODEL_PATH))
->setPath(self::CRON_MODEL_PATH)
->save();
} catch (Exception $e) {
} catch (Exception) {
throw new Exception(Mage::helper('cron')->__('Unable to save the cron expression.'));
}
return $this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function deleteAction()
try {
Mage::getModel('api/roles')->load($rid)->delete();
Mage::getSingleton('adminhtml/session')->addSuccess($this->__('The role has been deleted.'));
} catch (Exception $e) {
} catch (Exception) {
Mage::getSingleton('adminhtml/session')->addError($this->__('An error occurred while deleting this role.'));
}

Expand Down Expand Up @@ -186,7 +186,7 @@ public function saveRoleAction()

$rid = $role->getId();
Mage::getSingleton('adminhtml/session')->addSuccess($this->__('The role has been saved.'));
} catch (Exception $e) {
} catch (Exception) {
Mage::getSingleton('adminhtml/session')->addError($this->__('An error occurred while saving this role.'));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ public function deleteAction()
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
$this->getResponse()->setRedirect($this->getUrl('*/*/edit', ['_current' => true]));
return;
} catch (Exception $e) {
} catch (Exception) {
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('catalog')->__('An error occurred while trying to delete the category.'));
$this->getResponse()->setRedirect($this->getUrl('*/*/edit', ['_current' => true]));
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function saveAction()
} else {
try {
$model->save();
} catch (Exception $e) {
} catch (Exception) {
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('catalog')->__('An error occurred while saving this group.'));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public function deleteAction()

$this->_getSession()->addSuccess($this->__('The attribute set has been removed.'));
$this->getResponse()->setRedirect($this->getUrl('*/*/'));
} catch (Exception $e) {
} catch (Exception) {
$this->_getSession()->addError($this->__('An error occurred while deleting this set.'));
$this->_redirectReferer();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function saveAction()
return;
} catch (Mage_Core_Exception $e) {
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
} catch (Exception $e) {
} catch (Exception) {
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('checkout')->__('An error occurred while saving this condition.'));
}

Expand Down Expand Up @@ -123,7 +123,7 @@ public function deleteAction()
return;
} catch (Mage_Core_Exception $e) {
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
} catch (Exception $e) {
} catch (Exception) {
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('checkout')->__('An error occurred while deleting this condition.'));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function treeJsonAction()
$this->getLayout()->createBlock('adminhtml/cms_wysiwyg_images_tree')
->getTreeJson(),
);
} catch (Exception $e) {
} catch (Exception) {
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode([]));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function directiveAction()
}
$image = Varien_Image_Adapter::factory('GD2');
$image->open($url);
} catch (Exception $e) {
} catch (Exception) {
$image = Varien_Image_Adapter::factory('GD2');
$image->open(Mage::getSingleton('cms/wysiwyg_config')->getSkinImagePlaceholderPath());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public function resetPasswordAction()
'minAdminPasswordLength' => $this->_getModel('admin/user')->getMinAdminPasswordLength(),
];
$this->_outTemplate('resetforgottenpassword', $data);
} catch (Exception $exception) {
} catch (Exception) {
$this->_getSession()->addError(Mage::helper('adminhtml')->__('Your password reset link has expired.'));
$this->_redirect('*/*/forgotpassword', ['_nosecret' => true]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public function updateQtyAction()
'message' => $e->getMessage(),
];
$response = Mage::helper('core')->jsonEncode($response);
} catch (Exception $e) {
} catch (Exception) {
$response = [
'error' => true,
'message' => $this->__('Cannot update the item\'s quantity.'),
Expand Down Expand Up @@ -323,7 +323,7 @@ public function cancelAction()
$this->_getSession()->addSuccess($this->__('The credit memo has been canceled.'));
} catch (Mage_Core_Exception $e) {
$this->_getSession()->addError($e->getMessage());
} catch (Exception $e) {
} catch (Exception) {
$this->_getSession()->addError($this->__('Unable to cancel the credit memo.'));
}
$this->_redirect('*/*/view', ['creditmemo_id' => $creditmemo->getId()]);
Expand All @@ -345,7 +345,7 @@ public function voidAction()
$this->_getSession()->addSuccess($this->__('The credit memo has been voided.'));
} catch (Mage_Core_Exception $e) {
$this->_getSession()->addError($e->getMessage());
} catch (Exception $e) {
} catch (Exception) {
$this->_getSession()->addError($this->__('Unable to void the credit memo.'));
}
$this->_redirect('*/*/view', ['creditmemo_id' => $creditmemo->getId()]);
Expand Down Expand Up @@ -385,7 +385,7 @@ public function addCommentAction()
'message' => $e->getMessage(),
];
$response = Mage::helper('core')->jsonEncode($response);
} catch (Exception $e) {
} catch (Exception) {
$response = [
'error' => true,
'message' => $this->__('Cannot add new comment.'),
Expand Down
Loading
Loading