diff --git a/.github/phpstan-baseline.neon b/.github/phpstan-baseline.neon index b81a01d1e39..bafd0db7d76 100644 --- a/.github/phpstan-baseline.neon +++ b/.github/phpstan-baseline.neon @@ -3215,11 +3215,6 @@ parameters: count: 1 path: ../app/code/core/Mage/Sales/Model/Order/Api.php - - - message: "#^Variable \\$data in isset\\(\\) always exists and is not nullable\\.$#" - count: 1 - path: ../app/code/core/Mage/Sales/Model/Order/Creditmemo/Api.php - - message: "#^Cannot call method addAttributeToFilter\\(\\) on Mage_Core_Model_Resource_Db_Collection_Abstract\\|false\\.$#" count: 1 diff --git a/app/code/core/Mage/Admin/Model/Config.php b/app/code/core/Mage/Admin/Model/Config.php index ba968352643..c7e25b4afd1 100644 --- a/app/code/core/Mage/Admin/Model/Config.php +++ b/app/code/core/Mage/Admin/Model/Config.php @@ -129,11 +129,7 @@ public function getAclAssert($name = '') return $asserts; } - if (isset($asserts->$name)) { - return $asserts->$name; - } - - return false; + return $asserts->$name ?? false; } /** @@ -149,11 +145,7 @@ public function getAclPrivilegeSet($name = '') return $sets; } - if (isset($sets->$name)) { - return $sets->$name; - } - - return false; + return $sets->$name ?? false; } /** diff --git a/app/code/core/Mage/Admin/Model/Observer.php b/app/code/core/Mage/Admin/Model/Observer.php index 070ad47362c..5f0c5e6f6a3 100644 --- a/app/code/core/Mage/Admin/Model/Observer.php +++ b/app/code/core/Mage/Admin/Model/Observer.php @@ -64,8 +64,8 @@ public function actionPreDispatchAdmin($observer) if ($coreSession->validateFormKey($request->getPost("form_key"))) { $postLogin = $request->getPost('login'); - $username = isset($postLogin['username']) ? $postLogin['username'] : ''; - $password = isset($postLogin['password']) ? $postLogin['password'] : ''; + $username = $postLogin['username'] ?? ''; + $password = $postLogin['password'] ?? ''; $session->login($username, $password, $request); $request->setPost('login', null); } else { diff --git a/app/code/core/Mage/Admin/Model/Session.php b/app/code/core/Mage/Admin/Model/Session.php index 5d3b6f384fb..1517dfc743a 100644 --- a/app/code/core/Mage/Admin/Model/Session.php +++ b/app/code/core/Mage/Admin/Model/Session.php @@ -189,7 +189,7 @@ public function login($username, $password, $request = null) $this->_loginFailed($e, $request, $username, $message); } - return isset($user) ? $user : null; + return $user ?? null; } /** diff --git a/app/code/core/Mage/AdminNotification/Helper/Data.php b/app/code/core/Mage/AdminNotification/Helper/Data.php index bbda2f0fc42..b9637b51a22 100644 --- a/app/code/core/Mage/AdminNotification/Helper/Data.php +++ b/app/code/core/Mage/AdminNotification/Helper/Data.php @@ -65,7 +65,7 @@ public function getUnreadNoticeCount($severity) if (is_null($this->_unreadNoticeCounts)) { $this->_unreadNoticeCounts = Mage::getModel('adminnotification/inbox')->getNoticeStatus(); } - return isset($this->_unreadNoticeCounts[$severity]) ? $this->_unreadNoticeCounts[$severity] : 0; + return $this->_unreadNoticeCounts[$severity] ?? 0; } /** diff --git a/app/code/core/Mage/AdminNotification/Model/Inbox.php b/app/code/core/Mage/AdminNotification/Model/Inbox.php index 129bb067a73..b9588cce7ac 100644 --- a/app/code/core/Mage/AdminNotification/Model/Inbox.php +++ b/app/code/core/Mage/AdminNotification/Model/Inbox.php @@ -71,10 +71,7 @@ public function getSeverities($severity = null) ]; if (!is_null($severity)) { - if (isset($severities[$severity])) { - return $severities[$severity]; - } - return null; + return $severities[$severity] ?? null; } return $severities; diff --git a/app/code/core/Mage/Adminhtml/Block/Api/Tab/Rolesedit.php b/app/code/core/Mage/Adminhtml/Block/Api/Tab/Rolesedit.php index 5bd545414a7..0170700a742 100644 --- a/app/code/core/Mage/Adminhtml/Block/Api/Tab/Rolesedit.php +++ b/app/code/core/Mage/Adminhtml/Block/Api/Tab/Rolesedit.php @@ -64,7 +64,7 @@ public function getResTreeJson() $rootArray = $this->_getNodeJson($resources,1); - return Mage::helper('core')->jsonEncode(isset($rootArray['children']) ? $rootArray['children'] : []); + return Mage::helper('core')->jsonEncode($rootArray['children'] ?? []); } protected function _sortTree($a, $b) diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tree.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tree.php index b501d3310cf..bc5900214ae 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tree.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tree.php @@ -162,13 +162,13 @@ public function getMoveUrl() public function getTree($parenNodeCategory=null) { $rootArray = $this->_getNodeJson($this->getRoot($parenNodeCategory)); - return isset($rootArray['children']) ? $rootArray['children'] : []; + return $rootArray['children'] ?? []; } public function getTreeJson($parenNodeCategory=null) { $rootArray = $this->_getNodeJson($this->getRoot($parenNodeCategory)); - return Mage::helper('core')->jsonEncode(isset($rootArray['children']) ? $rootArray['children'] : []); + return Mage::helper('core')->jsonEncode($rootArray['children'] ?? []); } /** diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Form/Renderer/Config/DateFieldsOrder.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Form/Renderer/Config/DateFieldsOrder.php index 4ec0a1c1bb3..740288e07a0 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Form/Renderer/Config/DateFieldsOrder.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Form/Renderer/Config/DateFieldsOrder.php @@ -46,9 +46,9 @@ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) } $_parts = []; - $_parts[] = $element->setValue(isset($values[0]) ? $values[0] : null)->getElementHtml(); - $_parts[] = $element->setValue(isset($values[1]) ? $values[1] : null)->getElementHtml(); - $_parts[] = $element->setValue(isset($values[2]) ? $values[2] : null)->getElementHtml(); + $_parts[] = $element->setValue($values[0] ?? null)->getElementHtml(); + $_parts[] = $element->setValue($values[1] ?? null)->getElementHtml(); + $_parts[] = $element->setValue($values[2] ?? null)->getElementHtml(); return implode(' / ', $_parts); } diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Form/Renderer/Config/YearRange.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Form/Renderer/Config/YearRange.php index d7374be1888..6266d59dd15 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Form/Renderer/Config/YearRange.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Form/Renderer/Config/YearRange.php @@ -38,8 +38,8 @@ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) $values = []; } - $from = $element->setValue(isset($values[0]) ? $values[0] : null)->getElementHtml(); - $to = $element->setValue(isset($values[1]) ? $values[1] : null)->getElementHtml(); + $from = $element->setValue($values[0] ?? null)->getElementHtml(); + $to = $element->setValue($values[1] ?? null)->getElementHtml(); return Mage::helper('adminhtml')->__('from') . ' ' . $from . ' ' . Mage::helper('adminhtml')->__('to') . ' ' . $to; diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Group/Abstract.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Group/Abstract.php index 2b82b87d7b0..4de463c915c 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Group/Abstract.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Group/Abstract.php @@ -150,7 +150,7 @@ public function getCustomerGroups($groupId = null) } if ($groupId !== null) { - return isset($this->_customerGroups[$groupId]) ? $this->_customerGroups[$groupId] : []; + return $this->_customerGroups[$groupId] ?? []; } return $this->_customerGroups; diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Newsletter/Grid/Renderer/Status.php b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Newsletter/Grid/Renderer/Status.php index 34eae6a6afa..233dc8bb577 100644 --- a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Newsletter/Grid/Renderer/Status.php +++ b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Newsletter/Grid/Renderer/Status.php @@ -48,10 +48,6 @@ public function render(Varien_Object $row) public static function getStatus($status) { - if(isset(self::$_statuses[$status])) { - return self::$_statuses[$status]; - } - - return Mage::helper('customer')->__('Unknown'); + return self::$_statuses[$status] ?? Mage::helper('customer')->__('Unknown'); } } diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Grid/Renderer/Item.php b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Grid/Renderer/Item.php index d8605f5ce76..e9c4c28ac9f 100644 --- a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Grid/Renderer/Item.php +++ b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Grid/Renderer/Item.php @@ -62,13 +62,7 @@ protected function _getProductHelper($product) // Check whether we have helper for our product $productType = $product->getTypeId(); - if (isset($productHelpers[$productType])) { - $helperName = $productHelpers[$productType]; - } else if (isset($productHelpers['default'])) { - $helperName = $productHelpers['default']; - } else { - $helperName = 'catalog/product_configuration'; - } + $helperName = $productHelpers[$productType] ?? $productHelpers['default'] ?? 'catalog/product_configuration'; $helper = Mage::helper($helperName); if (!($helper instanceof Mage_Catalog_Helper_Product_Configuration_Interface)) { diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Sales.php b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Sales.php index 19fc2d4f57a..b414efdfa5a 100644 --- a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Sales.php +++ b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Sales.php @@ -93,7 +93,7 @@ public function _beforeToHtml() public function getWebsiteCount($websiteId) { - return isset($this->_websiteCounts[$websiteId]) ? $this->_websiteCounts[$websiteId] : 0; + return $this->_websiteCounts[$websiteId] ?? 0; } public function getRows() diff --git a/app/code/core/Mage/Adminhtml/Block/Permissions/Tab/Rolesedit.php b/app/code/core/Mage/Adminhtml/Block/Permissions/Tab/Rolesedit.php index 4b2c2b7197c..29d412411dc 100644 --- a/app/code/core/Mage/Adminhtml/Block/Permissions/Tab/Rolesedit.php +++ b/app/code/core/Mage/Adminhtml/Block/Permissions/Tab/Rolesedit.php @@ -146,7 +146,7 @@ public function getResTreeJson() $rootArray = $this->_getNodeJson($resources->admin, 1); - return Mage::helper('core')->jsonEncode(isset($rootArray['children']) ? $rootArray['children'] : []); + return Mage::helper('core')->jsonEncode($rootArray['children'] ?? []); } /** diff --git a/app/code/core/Mage/Adminhtml/Block/Promo/Widget/Chooser/Daterange.php b/app/code/core/Mage/Adminhtml/Block/Promo/Widget/Chooser/Daterange.php index b9c12220edf..8d995af7fef 100644 --- a/app/code/core/Mage/Adminhtml/Block/Promo/Widget/Chooser/Daterange.php +++ b/app/code/core/Mage/Adminhtml/Block/Promo/Widget/Chooser/Daterange.php @@ -119,10 +119,8 @@ public function setRangeValues($from, $to) public function setRangeValue($delimitedString) { $split = explode($this->_rangeDelimiter, $delimitedString, 2); - $from = $split[0]; $to = ''; - if (isset($split[1])) { - $to = $split[1]; - } + $from = $split[0]; + $to = $split[1] ?? ''; return $this->setRangeValues($from, $to); } diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Config/Form/Field/YtdStart.php b/app/code/core/Mage/Adminhtml/Block/Report/Config/Form/Field/YtdStart.php index cadfb35bedf..78f1d618ae2 100644 --- a/app/code/core/Mage/Adminhtml/Block/Report/Config/Form/Field/YtdStart.php +++ b/app/code/core/Mage/Adminhtml/Block/Report/Config/Form/Field/YtdStart.php @@ -51,12 +51,12 @@ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) $_monthsHtml = $element->setStyle('width:100px;') ->setValues($_months) - ->setValue(isset($values[0]) ? $values[0] : null) + ->setValue($values[0] ?? null) ->getElementHtml(); $_daysHtml = $element->setStyle('width:50px;') ->setValues($_days) - ->setValue(isset($values[1]) ? $values[1] : null) + ->setValue($values[1] ?? null) ->getElementHtml(); return sprintf('%s %s', $_monthsHtml, $_daysHtml); diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Status/New/Form.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Status/New/Form.php index d1b6eef686f..bf5d0a426a8 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Status/New/Form.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Status/New/Form.php @@ -99,7 +99,7 @@ protected function _prepareForm() 'name' => 'store_labels['.$store->getId().']', 'required' => false, 'label' => $store->getName(), - 'value' => isset($labels[$store->getId()]) ? $labels[$store->getId()] : '', + 'value' => $labels[$store->getId()] ?? '', 'fieldset_html_class' => 'store', ]); } diff --git a/app/code/core/Mage/Adminhtml/Block/System/Config/Form/Field/Array/Abstract.php b/app/code/core/Mage/Adminhtml/Block/System/Config/Form/Field/Array/Abstract.php index a133fdaf3c0..8923e9c9c46 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Config/Form/Field/Array/Abstract.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Config/Form/Field/Array/Abstract.php @@ -172,7 +172,7 @@ protected function _renderCellTemplate($columnName) return ''; } diff --git a/app/code/core/Mage/Adminhtml/Block/System/Config/Form/Fieldset.php b/app/code/core/Mage/Adminhtml/Block/System/Config/Form/Fieldset.php index 668f75ae9e9..44c6e145d6e 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Config/Form/Fieldset.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Config/Form/Fieldset.php @@ -199,9 +199,6 @@ protected function _getCollapseState($element) return 1; } $extra = Mage::getSingleton('admin/session')->getUser()->getExtra(); - if (isset($extra['configState'][$element->getId()])) { - return $extra['configState'][$element->getId()]; - } - return false; + return $extra['configState'][$element->getId()] ?? false; } } diff --git a/app/code/core/Mage/Adminhtml/Block/System/Config/Form/Fieldset/Order/Statuses.php b/app/code/core/Mage/Adminhtml/Block/System/Config/Form/Fieldset/Order/Statuses.php index 2b2b4e4bbbf..d580ed1bfe6 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Config/Form/Fieldset/Order/Statuses.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Config/Form/Fieldset/Order/Statuses.php @@ -64,7 +64,7 @@ protected function _getFieldHtml($fieldset, $id, $status) { $configData = $this->getConfigData(); $path = 'sales/order_statuses/status_'.$id; //TODO: move as property of form - $data = isset($configData[$path]) ? $configData[$path] : []; + $data = $configData[$path] ?? []; $e = $this->_getDummyElement(); @@ -72,10 +72,10 @@ protected function _getFieldHtml($fieldset, $id, $status) [ 'name' => 'groups[order_statuses][fields][status_'.$id.'][value]', 'label' => $status, - 'value' => isset($data['value']) ? $data['value'] : $status, - 'default_value' => isset($data['default_value']) ? $data['default_value'] : '', - 'old_value' => isset($data['old_value']) ? $data['old_value'] : '', - 'inherit' => isset($data['inherit']) ? $data['inherit'] : '', + 'value' => $data['value'] ?? $status, + 'default_value' => $data['default_value'] ?? '', + 'old_value' => $data['old_value'] ?? '', + 'inherit' => $data['inherit'] ?? '', 'can_use_default_value' => $this->getForm()->canUseDefaultValue($e), 'can_use_website_value' => $this->getForm()->canUseWebsiteValue($e), ])->setRenderer($this->_getFieldRenderer()); diff --git a/app/code/core/Mage/Adminhtml/Block/System/Config/Tabs.php b/app/code/core/Mage/Adminhtml/Block/System/Config/Tabs.php index 1157cac598b..e70ff2b59cc 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Config/Tabs.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Config/Tabs.php @@ -153,11 +153,7 @@ public function addTab($code, $config) */ public function getTab($code) { - if(isset($this->_tabs[$code])) { - return $this->_tabs[$code]; - } - - return null; + return $this->_tabs[$code] ?? null; } /** diff --git a/app/code/core/Mage/Adminhtml/Block/System/Email/Template/Grid/Renderer/Type.php b/app/code/core/Mage/Adminhtml/Block/System/Email/Template/Grid/Renderer/Type.php index c9ff9aef92a..de832e269d3 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Email/Template/Grid/Renderer/Type.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Email/Template/Grid/Renderer/Type.php @@ -34,13 +34,7 @@ class Mage_Adminhtml_Block_System_Email_Template_Grid_Renderer_Type ]; public function render(Varien_Object $row) { - - $str = Mage::helper('adminhtml')->__('Unknown'); - - if(isset(self::$_types[$row->getTemplateType()])) { - $str = self::$_types[$row->getTemplateType()]; - } - + $str = self::$_types[$row->getTemplateType()] ?? Mage::helper('adminhtml')->__('Unknown'); return Mage::helper('adminhtml')->__($str); } } diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Massaction/Abstract.php b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Massaction/Abstract.php index 443400d1aa8..17f07aff672 100644 --- a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Massaction/Abstract.php +++ b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Massaction/Abstract.php @@ -84,11 +84,7 @@ public function addItem($itemId, array $item) */ public function getItem($itemId) { - if(isset($this->_items[$itemId])) { - return $this->_items[$itemId]; - } - - return null; + return $this->_items[$itemId] ?? null; } /** diff --git a/app/code/core/Mage/Adminhtml/Helper/Dashboard/Abstract.php b/app/code/core/Mage/Adminhtml/Helper/Dashboard/Abstract.php index 38c9ea65045..6c3d812b582 100644 --- a/app/code/core/Mage/Adminhtml/Helper/Dashboard/Abstract.php +++ b/app/code/core/Mage/Adminhtml/Helper/Dashboard/Abstract.php @@ -97,15 +97,11 @@ public function setParams(array $params) public function getParam($name) { - if(isset($this->_params[$name])) { - return $this->_params[$name]; - } - - return null; + return $this->_params[$name] ?? null; } public function getParams() { return $this->_params; } - } +} diff --git a/app/code/core/Mage/Adminhtml/Model/Giftmessage/Save.php b/app/code/core/Mage/Adminhtml/Model/Giftmessage/Save.php index c22e4c562b1..108d3e21520 100644 --- a/app/code/core/Mage/Adminhtml/Model/Giftmessage/Save.php +++ b/app/code/core/Mage/Adminhtml/Model/Giftmessage/Save.php @@ -324,11 +324,7 @@ protected function _getMappedType($type) 'order_item' => 'order_item' ]; - if (isset($map[$type])) { - return $map[$type]; - } - - return null; + return $map[$type] ?? null; } /** diff --git a/app/code/core/Mage/Adminhtml/Model/Sales/Order/Random.php b/app/code/core/Mage/Adminhtml/Model/Sales/Order/Random.php index d43557d7e34..a2127e6f1c3 100644 --- a/app/code/core/Mage/Adminhtml/Model/Sales/Order/Random.php +++ b/app/code/core/Mage/Adminhtml/Model/Sales/Order/Random.php @@ -107,7 +107,7 @@ protected function _getRandomProduct() { $items = $this->_getProducts(); $randKey = array_rand($items); - return isset($items[$randKey]) ? $items[$randKey] : false; + return $items[$randKey] ?? false; } protected function _getStore() diff --git a/app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Customer/Show/Customer.php b/app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Customer/Show/Customer.php index 6317d73e61b..7b0e89e7193 100644 --- a/app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Customer/Show/Customer.php +++ b/app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Customer/Show/Customer.php @@ -66,11 +66,7 @@ protected function _afterSave() ]; $value = $this->getValue(); - if (isset($valueConfig[$value])) { - $data = $valueConfig[$value]; - } else { - $data = $valueConfig['']; - } + $data = $valueConfig[$value] ?? $valueConfig['']; if ($this->getScope() == 'websites') { $website = Mage::app()->getWebsite($this->getWebsiteCode()); diff --git a/app/code/core/Mage/Adminhtml/Model/System/Config/Source/Security/Domainpolicy.php b/app/code/core/Mage/Adminhtml/Model/System/Config/Source/Security/Domainpolicy.php index 212b8f26333..178266a599e 100644 --- a/app/code/core/Mage/Adminhtml/Model/System/Config/Source/Security/Domainpolicy.php +++ b/app/code/core/Mage/Adminhtml/Model/System/Config/Source/Security/Domainpolicy.php @@ -35,7 +35,7 @@ class Mage_Adminhtml_Model_System_Config_Source_Security_Domainpolicy */ public function __construct($options = []) { - $this->_helper = isset($options['helper']) ? $options['helper'] : Mage::helper('adminhtml'); + $this->_helper = $options['helper'] ?? Mage::helper('adminhtml'); } /** diff --git a/app/code/core/Mage/Adminhtml/Model/System/Store.php b/app/code/core/Mage/Adminhtml/Model/System/Store.php index d0120d58a00..d78d5c63d08 100644 --- a/app/code/core/Mage/Adminhtml/Model/System/Store.php +++ b/app/code/core/Mage/Adminhtml/Model/System/Store.php @@ -368,10 +368,7 @@ public function getStoreName($storeId) **/ public function getStoreData($storeId) { - if (isset($this->_storeCollection[$storeId])) { - return $this->_storeCollection[$storeId]; - } - return null; + return $this->_storeCollection[$storeId] ?? null; } /** diff --git a/app/code/core/Mage/Adminhtml/controllers/CustomerController.php b/app/code/core/Mage/Adminhtml/controllers/CustomerController.php index a91cc439e5c..e689f09889d 100644 --- a/app/code/core/Mage/Adminhtml/controllers/CustomerController.php +++ b/app/code/core/Mage/Adminhtml/controllers/CustomerController.php @@ -226,11 +226,7 @@ public function saveAction() && Mage::helper('customer')->getIsRequireAdminUserToChangeUserPassword() ) { //Validate current admin password - if (isset($data['account']['current_password'])) { - $currentPassword = $data['account']['current_password']; - } else { - $currentPassword = null; - } + $currentPassword = $data['account']['current_password'] ?? null; unset($data['account']['current_password']); $errors = $this->_validateCurrentPassword($currentPassword); } diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreditmemoController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreditmemoController.php index 4469c12a2a2..984b9ff1565 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreditmemoController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreditmemoController.php @@ -37,11 +37,7 @@ protected function _getItemData() $data = Mage::getSingleton('adminhtml/session')->getFormData(true); } - if (isset($data['items'])) { - $qtys = $data['items']; - } else { - $qtys = []; - } + $qtys = $data['items'] ?? []; return $qtys; } diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/InvoiceController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/InvoiceController.php index 5b50b0774a2..d7737128c47 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/InvoiceController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/InvoiceController.php @@ -33,11 +33,7 @@ class Mage_Adminhtml_Sales_Order_InvoiceController extends Mage_Adminhtml_Contro protected function _getItemQtys() { $data = $this->getRequest()->getParam('invoice'); - if (isset($data['items'])) { - $qtys = $data['items']; - } else { - $qtys = []; - } + $qtys = $data['items'] ?? []; return $qtys; } diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php index 744dab5fef1..fdcb2536012 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php @@ -33,11 +33,7 @@ class Mage_Adminhtml_Sales_Order_ShipmentController extends Mage_Adminhtml_Contr protected function _getItemQtys() { $data = $this->getRequest()->getParam('shipment'); - if (isset($data['items'])) { - $qtys = $data['items']; - } else { - $qtys = []; - } + $qtys = $data['items'] ?? []; return $qtys; } diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php index 7188c7ea220..f9b44ea93bc 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php @@ -268,8 +268,8 @@ public function addCommentAction() try { $response = false; $data = $this->getRequest()->getPost('history'); - $notify = isset($data['is_customer_notified']) ? $data['is_customer_notified'] : false; - $visible = isset($data['is_visible_on_front']) ? $data['is_visible_on_front'] : false; + $notify = $data['is_customer_notified'] ?? false; + $visible = $data['is_visible_on_front'] ?? false; $order->addStatusHistoryComment($data['comment'], $data['status']) ->setIsVisibleOnFront($visible) diff --git a/app/code/core/Mage/Adminhtml/controllers/TagController.php b/app/code/core/Mage/Adminhtml/controllers/TagController.php index 165f5944d9a..2d340c071b1 100644 --- a/app/code/core/Mage/Adminhtml/controllers/TagController.php +++ b/app/code/core/Mage/Adminhtml/controllers/TagController.php @@ -151,7 +151,7 @@ public function saveAction() $data['name'] = trim($postData['tag_name']); $data['status'] = $postData['tag_status']; - $data['base_popularity'] = (isset($postData['base_popularity'])) ? $postData['base_popularity'] : 0; + $data['base_popularity'] = $postData['base_popularity'] ?? 0; $data['store'] = $postData['store_id']; if (!$model = $this->_initTag()) { diff --git a/app/code/core/Mage/Api/Model/Config.php b/app/code/core/Mage/Api/Model/Config.php index 83cd7c29804..cb30b428c0b 100644 --- a/app/code/core/Mage/Api/Model/Config.php +++ b/app/code/core/Mage/Api/Model/Config.php @@ -202,11 +202,7 @@ public function getAclAssert($name = '') return $asserts; } - if (isset($asserts->$name)) { - return $asserts->$name; - } - - return false; + return $asserts->$name ?? false; } /** @@ -222,11 +218,7 @@ public function getAclPrivilegeSet($name = '') return $sets; } - if (isset($sets->$name)) { - return $sets->$name; - } - - return false; + return $sets->$name ?? false; } /** diff --git a/app/code/core/Mage/Api/Model/Server/Handler/Abstract.php b/app/code/core/Mage/Api/Model/Server/Handler/Abstract.php index ca0fff7903d..87a0cf94f15 100644 --- a/app/code/core/Mage/Api/Model/Server/Handler/Abstract.php +++ b/app/code/core/Mage/Api/Model/Server/Handler/Abstract.php @@ -334,7 +334,7 @@ public function multiCall($sessionId, array $calls = [], $options = []) } $apiPath = $call[0]; - $args = (isset($call[1]) ? $call[1] : []); + $args = $call[1] ?? []; list($resourceName, $methodName) = explode('.', $apiPath); @@ -484,7 +484,7 @@ public function resources($sessionId) 'title' => (string) $resource->title, 'description' => (isset($resource->description) ? (string)$resource->description : null), 'name' => $resourceName, - 'aliases' => (isset($resourcesAlias[$resourceName]) ? $resourcesAlias[$resourceName] : []), + 'aliases' => $resourcesAlias[$resourceName] ?? [], 'methods' => $methods ]; } diff --git a/app/code/core/Mage/Api2/Model/Acl/Global/Rule/ResourcePermission.php b/app/code/core/Mage/Api2/Model/Acl/Global/Rule/ResourcePermission.php index 625b8fbfaeb..6866ce134de 100644 --- a/app/code/core/Mage/Api2/Model/Acl/Global/Rule/ResourcePermission.php +++ b/app/code/core/Mage/Api2/Model/Acl/Global/Rule/ResourcePermission.php @@ -77,10 +77,7 @@ public function getResourcesPermissions() foreach ($config->getResources() as $resourceType => $node) { $resourceId = (string)$resourceType; $allowedRoles = (array)$node->privileges; - $allowedPrivileges = []; - if (isset($allowedRoles[$roleConfigNodeName])) { - $allowedPrivileges = $allowedRoles[$roleConfigNodeName]; - } + $allowedPrivileges = $allowedRoles[$roleConfigNodeName] ?? []; foreach ($privileges as $privilege) { if (empty($allowedPrivileges[$privilege]) && isset($rulesPairs[$resourceId][$roleConfigNodeName]['privileges'][$privilege]) diff --git a/app/code/core/Mage/Api2/Model/Acl/Global/Rule/Tree.php b/app/code/core/Mage/Api2/Model/Acl/Global/Rule/Tree.php index 20069993a63..0a4b626b1e9 100644 --- a/app/code/core/Mage/Api2/Model/Acl/Global/Rule/Tree.php +++ b/app/code/core/Mage/Api2/Model/Acl/Global/Rule/Tree.php @@ -257,7 +257,7 @@ public function getTreeResources() { $this->_init(); $root = $this->_getTreeNode($this->_resourcesConfig, 1); - return isset($root[self::NAME_CHILDREN]) ? $root[self::NAME_CHILDREN] : []; + return $root[self::NAME_CHILDREN] ?? []; } /** diff --git a/app/code/core/Mage/Api2/Model/Config.php b/app/code/core/Mage/Api2/Model/Config.php index 46af130bc10..df1d5da69d0 100644 --- a/app/code/core/Mage/Api2/Model/Config.php +++ b/app/code/core/Mage/Api2/Model/Config.php @@ -179,11 +179,7 @@ public function getResourceGroups() /** @var Varien_Simplexml_Element $group */ $group = $result[0]; - if (!isset($group->children)) { - $children = new Varien_Simplexml_Element(''); - } else { - $children = $group->children; - } + $children = $group->children ?? new Varien_Simplexml_Element(''); $node->resource = 1; $children->appendChild($node); $group->appendChild($children); diff --git a/app/code/core/Mage/Api2/Model/Request.php b/app/code/core/Mage/Api2/Model/Request.php index 7c6a8ceaf23..d9c0978e1e5 100644 --- a/app/code/core/Mage/Api2/Model/Request.php +++ b/app/code/core/Mage/Api2/Model/Request.php @@ -129,7 +129,7 @@ public function getAcceptTypes() public function getApiType() { // getParam() is not used to avoid parameter fetch from $_GET or $_POST - return isset($this->_params['api_type']) ? $this->_params['api_type'] : null; + return $this->_params['api_type'] ?? null; } /** @@ -189,7 +189,7 @@ public function getFilter() public function getModel() { // getParam() is not used to avoid parameter fetch from $_GET or $_POST - return isset($this->_params['model']) ? $this->_params['model'] : null; + return $this->_params['model'] ?? null; } /** @@ -278,7 +278,7 @@ public function getRequestedAttributes() public function getResourceType() { // getParam() is not used to avoid parameter fetch from $_GET or $_POST - return isset($this->_params['type']) ? $this->_params['type'] : null; + return $this->_params['type'] ?? null; } /** @@ -299,7 +299,7 @@ public function getVersion() public function getActionType() { // getParam() is not used to avoid parameter fetch from $_GET or $_POST - return isset($this->_params['action_type']) ? $this->_params['action_type'] : null; + return $this->_params['action_type'] ?? null; } /** diff --git a/app/code/core/Mage/Api2/Model/Resource/Validator/Eav.php b/app/code/core/Mage/Api2/Model/Resource/Validator/Eav.php index 08c7c9742c9..94440244c2b 100644 --- a/app/code/core/Mage/Api2/Model/Resource/Validator/Eav.php +++ b/app/code/core/Mage/Api2/Model/Resource/Validator/Eav.php @@ -188,7 +188,7 @@ public function isValidData(array $data, $partial = false) if ($this->_eavForm->ignoreInvisible() && !$attribute->getIsVisible()) { continue; } - $attrValue = isset($data[$attribute->getAttributeCode()]) ? $data[$attribute->getAttributeCode()] : null; + $attrValue = $data[$attribute->getAttributeCode()] ?? null; $result = Mage_Eav_Model_Attribute_Data::factory($attribute, $this->_eavForm->getEntity()) ->setExtractedData($data) diff --git a/app/code/core/Mage/Api2/Model/Resource/Validator/Fields.php b/app/code/core/Mage/Api2/Model/Resource/Validator/Fields.php index 9207fd5beb0..29535c2a4bd 100644 --- a/app/code/core/Mage/Api2/Model/Resource/Validator/Fields.php +++ b/app/code/core/Mage/Api2/Model/Resource/Validator/Fields.php @@ -154,7 +154,7 @@ public function isValidData(array $data, $isPartial = false) if (!$isPartial && count($this->_requiredFields) > 0) { $notEmptyValidator = new Zend_Validate_NotEmpty(); foreach ($this->_requiredFields as $requiredField) { - if (!$notEmptyValidator->isValid(isset($data[$requiredField]) ? $data[$requiredField] : null)) { + if (!$notEmptyValidator->isValid($data[$requiredField] ?? null)) { $isValid = false; foreach ($notEmptyValidator->getMessages() as $message) { $this->_addError(sprintf('%s: %s', $requiredField, $message)); diff --git a/app/code/core/Mage/Api2/Model/Route/Abstract.php b/app/code/core/Mage/Api2/Model/Route/Abstract.php index 85b7caafe09..fe7429082c5 100644 --- a/app/code/core/Mage/Api2/Model/Route/Abstract.php +++ b/app/code/core/Mage/Api2/Model/Route/Abstract.php @@ -75,7 +75,7 @@ public function __construct(array $arguments) */ protected function _getArgumentValue($name, array $arguments) { - return isset($arguments[$name]) ? $arguments[$name] : $this->_paramsDefaultValues[$name]; + return $arguments[$name] ?? $this->_paramsDefaultValues[$name]; } /** diff --git a/app/code/core/Mage/Authorizenet/Model/Directpost/Response.php b/app/code/core/Mage/Authorizenet/Model/Directpost/Response.php index 1c9cacfae38..9d4841f2598 100644 --- a/app/code/core/Mage/Authorizenet/Model/Directpost/Response.php +++ b/app/code/core/Mage/Authorizenet/Model/Directpost/Response.php @@ -150,7 +150,7 @@ public function generateSha2Hash($signatureKey) $message = '^'; foreach ($hashFields as $field) { $fieldData = $this->getData($field); - $message .= (isset($fieldData) ? $fieldData : '') . '^'; + $message .= ($fieldData ?? '') . '^'; } return strtoupper(hash_hmac('sha512', $message, pack('H*', $signatureKey))); diff --git a/app/code/core/Mage/Authorizenet/controllers/Directpost/PaymentController.php b/app/code/core/Mage/Authorizenet/controllers/Directpost/PaymentController.php index f74db6fc394..a005393130b 100644 --- a/app/code/core/Mage/Authorizenet/controllers/Directpost/PaymentController.php +++ b/app/code/core/Mage/Authorizenet/controllers/Directpost/PaymentController.php @@ -95,7 +95,7 @@ public function responseAction() $result['key'] = $data['key']; } $result['controller_action_name'] = $data['controller_action_name']; - $result['is_secure'] = isset($data['is_secure']) ? $data['is_secure'] : false; + $result['is_secure'] = $data['is_secure'] ?? false; $params['redirect'] = Mage::helper('authorizenet')->getRedirectIframeUrl($result); } $block = $this->_getIframeBlock()->setParams($params); diff --git a/app/code/core/Mage/Backup/Helper/Data.php b/app/code/core/Mage/Backup/Helper/Data.php index 31ea167f3b1..76ddd9c857e 100644 --- a/app/code/core/Mage/Backup/Helper/Data.php +++ b/app/code/core/Mage/Backup/Helper/Data.php @@ -109,7 +109,7 @@ public function getBackupsDir() public function getExtensionByType($type) { $extensions = $this->getExtensions(); - return isset($extensions[$type]) ? $extensions[$type] : ''; + return $extensions[$type] ?? ''; } /** diff --git a/app/code/core/Mage/Backup/Model/Resource/Helper/Mysql4.php b/app/code/core/Mage/Backup/Model/Resource/Helper/Mysql4.php index 8b932d46ad3..9749a94c8d1 100644 --- a/app/code/core/Mage/Backup/Model/Resource/Helper/Mysql4.php +++ b/app/code/core/Mage/Backup/Model/Resource/Helper/Mysql4.php @@ -141,8 +141,8 @@ public function getTableCreateSql($tableName, $withForeignKeys = false) $adapter->quoteIdentifier($match[2]), $adapter->quoteIdentifier($match[3]), $adapter->quoteIdentifier($match[4]), - isset($match[5]) ? $match[5] : '', - isset($match[7]) ? $match[7] : '' + $match[5] ?? '', + $match[7] ?? '' ); } } diff --git a/app/code/core/Mage/Bundle/Block/Adminhtml/Sales/Order/Items/Renderer.php b/app/code/core/Mage/Bundle/Block/Adminhtml/Sales/Order/Items/Renderer.php index 0d6fba5fdde..076fd0dfcc4 100644 --- a/app/code/core/Mage/Bundle/Block/Adminhtml/Sales/Order/Items/Renderer.php +++ b/app/code/core/Mage/Bundle/Block/Adminhtml/Sales/Order/Items/Renderer.php @@ -55,11 +55,7 @@ public function getChilds($item) } } - if (isset($_itemsArray[$item->getOrderItem()->getId()])) { - return $_itemsArray[$item->getOrderItem()->getId()]; - } else { - return null; - } + return $_itemsArray[$item->getOrderItem()->getId()] ?? null; } /** diff --git a/app/code/core/Mage/Bundle/Block/Sales/Order/Items/Renderer.php b/app/code/core/Mage/Bundle/Block/Sales/Order/Items/Renderer.php index a391e721b06..2d65d70c70e 100644 --- a/app/code/core/Mage/Bundle/Block/Sales/Order/Items/Renderer.php +++ b/app/code/core/Mage/Bundle/Block/Sales/Order/Items/Renderer.php @@ -173,11 +173,7 @@ public function getChilds($item) } } - if (isset($_itemsArray[$item->getOrderItem()->getId()])) { - return $_itemsArray[$item->getOrderItem()->getId()]; - } else { - return null; - } + return $_itemsArray[$item->getOrderItem()->getId()] ?? null; } /** diff --git a/app/code/core/Mage/Bundle/Model/Observer.php b/app/code/core/Mage/Bundle/Model/Observer.php index 98db1ca47ef..18c290b1143 100644 --- a/app/code/core/Mage/Bundle/Model/Observer.php +++ b/app/code/core/Mage/Bundle/Model/Observer.php @@ -87,11 +87,7 @@ public function appendUpsellProducts($observer) $collection = $observer->getEvent()->getCollection(); $limit = $observer->getEvent()->getLimit(); if (is_array($limit)) { - if (isset($limit['upsell'])) { - $limit = $limit['upsell']; - } else { - $limit = 0; - } + $limit = $limit['upsell'] ?? 0; } /** @var Mage_Bundle_Model_Resource_Selection $resource */ diff --git a/app/code/core/Mage/Bundle/Model/Resource/Price/Index.php b/app/code/core/Mage/Bundle/Model/Resource/Price/Index.php index 90e0835ff3c..423f12f2463 100644 --- a/app/code/core/Mage/Bundle/Model/Resource/Price/Index.php +++ b/app/code/core/Mage/Bundle/Model/Resource/Price/Index.php @@ -391,7 +391,7 @@ public function getProductsSalableStatus($products, Mage_Core_Model_Website $web $query = $read->query($select, $bind); while ($row = $query->fetch()) { - $salable = isset($row['salable']) ? $row['salable'] : true; + $salable = $row['salable'] ?? true; $website = $row['website_id'] > 0; $status = $row['status']; @@ -774,7 +774,7 @@ public function _calculateBundleSelections( $group->getId() ]); - $selectionPrice = isset($priceIndex[$priceIndexKey]) ? $priceIndex[$priceIndexKey] : 0; + $selectionPrice = $priceIndex[$priceIndexKey] ?? 0; $selectionPrice = $this->_calculateSpecialPrice($selectionPrice, $priceData, $website); } else { if ($selection['price_type']) { // percent diff --git a/app/code/core/Mage/Bundle/Model/Sales/Order/Pdf/Items/Abstract.php b/app/code/core/Mage/Bundle/Model/Sales/Order/Pdf/Items/Abstract.php index 6ad397510f5..f7f3db33cd7 100644 --- a/app/code/core/Mage/Bundle/Model/Sales/Order/Pdf/Items/Abstract.php +++ b/app/code/core/Mage/Bundle/Model/Sales/Order/Pdf/Items/Abstract.php @@ -56,11 +56,7 @@ public function getChilds($item) } } - if (isset($_itemsArray[$item->getOrderItem()->getId()])) { - return $_itemsArray[$item->getOrderItem()->getId()]; - } else { - return null; - } + return $_itemsArray[$item->getOrderItem()->getId()] ?? null; } /** diff --git a/app/code/core/Mage/Bundle/Model/Sales/Order/Pdf/Items/Creditmemo.php b/app/code/core/Mage/Bundle/Model/Sales/Order/Pdf/Items/Creditmemo.php index 2c091cd4486..dade3344fa8 100644 --- a/app/code/core/Mage/Bundle/Model/Sales/Order/Pdf/Items/Creditmemo.php +++ b/app/code/core/Mage/Bundle/Model/Sales/Order/Pdf/Items/Creditmemo.php @@ -186,9 +186,7 @@ public function draw() if ($option['value']) { $text = []; - $_printValue = isset($option['print_value']) - ? $option['print_value'] - : strip_tags($option['value']); + $_printValue = $option['print_value'] ?? strip_tags($option['value']); $values = explode(', ', $_printValue); foreach ($values as $value) { foreach (Mage::helper('core/string')->str_split($value, 30, true, true) as $_value) { diff --git a/app/code/core/Mage/Bundle/Model/Sales/Order/Pdf/Items/Invoice.php b/app/code/core/Mage/Bundle/Model/Sales/Order/Pdf/Items/Invoice.php index 248835a4018..1ccf9abebcc 100644 --- a/app/code/core/Mage/Bundle/Model/Sales/Order/Pdf/Items/Invoice.php +++ b/app/code/core/Mage/Bundle/Model/Sales/Order/Pdf/Items/Invoice.php @@ -171,9 +171,7 @@ public function draw() if ($option['value']) { $text = []; - $_printValue = isset($option['print_value']) - ? $option['print_value'] - : strip_tags($option['value']); + $_printValue = $option['print_value'] ?? strip_tags($option['value']); $values = explode(', ', $_printValue); foreach ($values as $value) { foreach ($stringHelper->str_split($value, 30, true, true) as $_value) { diff --git a/app/code/core/Mage/Bundle/Model/Sales/Order/Pdf/Items/Shipment.php b/app/code/core/Mage/Bundle/Model/Sales/Order/Pdf/Items/Shipment.php index 8e85fdfb0ed..07dba79f6fc 100644 --- a/app/code/core/Mage/Bundle/Model/Sales/Order/Pdf/Items/Shipment.php +++ b/app/code/core/Mage/Bundle/Model/Sales/Order/Pdf/Items/Shipment.php @@ -144,9 +144,7 @@ public function draw() if ($option['value']) { $text = []; - $_printValue = isset($option['print_value']) - ? $option['print_value'] - : strip_tags($option['value']); + $_printValue = $option['print_value'] ?? strip_tags($option['value']); $values = explode(', ', $_printValue); foreach ($values as $value) { foreach (Mage::helper('core/string')->str_split($value, 50, true, true) as $_value) { diff --git a/app/code/core/Mage/Captcha/Model/Observer.php b/app/code/core/Mage/Captcha/Model/Observer.php index 3874f526dbd..094c0bcccfd 100644 --- a/app/code/core/Mage/Captcha/Model/Observer.php +++ b/app/code/core/Mage/Captcha/Model/Observer.php @@ -60,7 +60,7 @@ public function checkUserLogin($observer) $captchaModel = Mage::helper('captcha')->getCaptcha($formId); $controller = $observer->getControllerAction(); $loginParams = $controller->getRequest()->getPost('login'); - $login = isset($loginParams['username']) ? $loginParams['username'] : null; + $login = $loginParams['username'] ?? null; if ($captchaModel->isRequired($login)) { $word = $this->_getCaptchaString($controller->getRequest(), $formId); if (!$captchaModel->isCorrect($word)) { @@ -157,7 +157,7 @@ public function checkUserLoginBackend($observer) $formId = 'backend_login'; $captchaModel = Mage::helper('captcha')->getCaptcha($formId); $loginParams = Mage::app()->getRequest()->getPost('login', []); - $login = array_key_exists('username', $loginParams) ? $loginParams['username'] : null; + $login = $loginParams['username'] ?? null; if ($captchaModel->isRequired($login)) { if (!$captchaModel->isCorrect($this->_getCaptchaString(Mage::app()->getRequest(), $formId))) { $captchaModel->logAttempt($login); diff --git a/app/code/core/Mage/Catalog/Block/Product/List/Upsell.php b/app/code/core/Mage/Catalog/Block/Product/List/Upsell.php index d5492c5a139..49dd3c09d61 100644 --- a/app/code/core/Mage/Catalog/Block/Product/List/Upsell.php +++ b/app/code/core/Mage/Catalog/Block/Product/List/Upsell.php @@ -182,11 +182,7 @@ public function getItemLimit($type = '') if ($type == '') { return $this->_itemLimits; } - if (isset($this->_itemLimits[$type])) { - return $this->_itemLimits[$type]; - } else { - return 0; - } + return $this->_itemLimits[$type] ?? 0; } /** diff --git a/app/code/core/Mage/Catalog/Block/Product/View/Options.php b/app/code/core/Mage/Catalog/Block/Product/View/Options.php index 15d66c4e861..ff8c9e4205a 100644 --- a/app/code/core/Mage/Catalog/Block/Product/View/Options.php +++ b/app/code/core/Mage/Catalog/Block/Product/View/Options.php @@ -99,11 +99,7 @@ public function addOptionRenderer($type, $block, $template) */ public function getOptionRender($type) { - if (isset($this->_optionRenders[$type])) { - return $this->_optionRenders[$type]; - } - - return $this->_optionRenders['default']; + return $this->_optionRenders[$type] ?? $this->_optionRenders['default']; } /** diff --git a/app/code/core/Mage/Catalog/Block/Widget/Link.php b/app/code/core/Mage/Catalog/Block/Widget/Link.php index b42f22d3af3..f11c91cb622 100644 --- a/app/code/core/Mage/Catalog/Block/Widget/Link.php +++ b/app/code/core/Mage/Catalog/Block/Widget/Link.php @@ -72,7 +72,7 @@ public function getHref() /** @var Mage_Catalog_Helper_Product $helper */ $helper = $this->_getFactory()->getHelper('catalog/product'); $productId = $idPath[1]; - $categoryId = isset($idPath[2]) ? $idPath[2] : null; + $categoryId = $idPath[2] ?? null; $this->_href = $helper->getFullProductUrl($productId, $categoryId); } elseif (isset($idPath[0]) && isset($idPath[1]) && $idPath[0] == 'category') { diff --git a/app/code/core/Mage/Catalog/Helper/Output.php b/app/code/core/Mage/Catalog/Helper/Output.php index 9895159afec..f4f86b65538 100644 --- a/app/code/core/Mage/Catalog/Helper/Output.php +++ b/app/code/core/Mage/Catalog/Helper/Output.php @@ -87,7 +87,7 @@ public function addHandler($method, $handler) public function getHandlers($method) { $method = strtolower($method); - return isset($this->_handlers[$method]) ? $this->_handlers[$method] : []; + return $this->_handlers[$method] ?? []; } /** diff --git a/app/code/core/Mage/Catalog/Helper/Product/Compare.php b/app/code/core/Mage/Catalog/Helper/Product/Compare.php index 9523b46b872..99397d4f09b 100644 --- a/app/code/core/Mage/Catalog/Helper/Product/Compare.php +++ b/app/code/core/Mage/Catalog/Helper/Product/Compare.php @@ -91,18 +91,12 @@ class Mage_Catalog_Helper_Product_Compare extends Mage_Core_Helper_Url */ public function __construct(array $data = []) { - $this->_logCondition = isset($data['log_condition']) - ? $data['log_condition'] : Mage::helper('log'); - $this->_catalogSession = isset($data['catalog_session']) - ? $data['catalog_session'] : Mage::getSingleton('catalog/session'); - $this->_customerSession = isset($data['customer_session']) - ? $data['customer_session'] : Mage::getSingleton('customer/session'); - $this->_coreSession = isset($data['core_session']) - ? $data['core_session'] : Mage::getSingleton('core/session'); - $this->_productVisibility = isset($data['product_visibility']) - ? $data['product_visibility'] : Mage::getSingleton('catalog/product_visibility'); - $this->_logVisitor = isset($data['log_visitor']) - ? $data['log_visitor'] : Mage::getSingleton('log/visitor'); + $this->_logCondition = $data['log_condition'] ?? Mage::helper('log'); + $this->_catalogSession = $data['catalog_session'] ?? Mage::getSingleton('catalog/session'); + $this->_customerSession = $data['customer_session'] ?? Mage::getSingleton('customer/session'); + $this->_coreSession = $data['core_session'] ?? Mage::getSingleton('core/session'); + $this->_productVisibility = $data['product_visibility'] ?? Mage::getSingleton('catalog/product_visibility'); + $this->_logVisitor = $data['log_visitor'] ?? Mage::getSingleton('log/visitor'); } /** diff --git a/app/code/core/Mage/Catalog/Helper/Product/Configuration.php b/app/code/core/Mage/Catalog/Helper/Product/Configuration.php index 1d3ba0e75a5..f9d106d4eba 100644 --- a/app/code/core/Mage/Catalog/Helper/Product/Configuration.php +++ b/app/code/core/Mage/Catalog/Helper/Product/Configuration.php @@ -197,8 +197,8 @@ public function getFormattedOptionValue($optionValue, $params = null) if (!$params) { $params = []; } - $maxLength = isset($params['max_length']) ? $params['max_length'] : null; - $cutReplacer = isset($params['cut_replacer']) ? $params['cut_replacer'] : '...'; + $maxLength = $params['max_length'] ?? null; + $cutReplacer = $params['cut_replacer'] ?? '...'; // Proceed with option $optionInfo = []; diff --git a/app/code/core/Mage/Catalog/Model/Api2/Product/Website/Rest.php b/app/code/core/Mage/Catalog/Model/Api2/Product/Website/Rest.php index 48facfe1784..0578fd36242 100644 --- a/app/code/core/Mage/Catalog/Model/Api2/Product/Website/Rest.php +++ b/app/code/core/Mage/Catalog/Model/Api2/Product/Website/Rest.php @@ -119,7 +119,7 @@ protected function _multiCreate(array $data) if (!$validator->isValidDataForWebsiteAssignmentToProduct($product, $singleData)) { foreach ($validator->getErrors() as $error) { $this->_errorMessage($error, Mage_Api2_Model_Server::HTTP_BAD_REQUEST, [ - 'website_id' => isset($singleData['website_id']) ? $singleData['website_id'] : null, + 'website_id' => $singleData['website_id'] ?? null, 'product_id' => $product->getId(), ]); } @@ -161,7 +161,7 @@ protected function _multiCreate(array $data) $e->getMessage(), $e->getCode(), [ - 'website_id' => isset($singleData['website_id']) ? $singleData['website_id'] : null, + 'website_id' => $singleData['website_id'] ?? null, 'product_id' => $product->getId(), ] ); @@ -171,7 +171,7 @@ protected function _multiCreate(array $data) Mage_Api2_Model_Resource::RESOURCE_INTERNAL_ERROR, Mage_Api2_Model_Server::HTTP_INTERNAL_ERROR, [ - 'website_id' => isset($singleData['website_id']) ? $singleData['website_id'] : null, + 'website_id' => $singleData['website_id'] ?? null, 'product_id' => $product->getId(), ] ); diff --git a/app/code/core/Mage/Catalog/Model/Category/Api.php b/app/code/core/Mage/Catalog/Model/Category/Api.php index 4156f9ebd2f..b2c628db418 100644 --- a/app/code/core/Mage/Catalog/Model/Category/Api.php +++ b/app/code/core/Mage/Catalog/Model/Category/Api.php @@ -59,7 +59,7 @@ public function level($website = null, $store = null, $categoryId = null) } } elseif (in_array($store, $website->getStoreIds())) { $storeId = Mage::app()->getStore($store); - $ids = ($categoryId === null)? $store->getRootCategoryId() : $categoryId; + $ids = $categoryId ?? $store->getRootCategoryId(); } else { $this->_fault('store_not_exists'); } @@ -83,7 +83,7 @@ public function level($website = null, $store = null, $categoryId = null) } } // load all root categories else { - $ids = ($categoryId === null)? Mage_Catalog_Model_Category::TREE_ROOT_ID : $categoryId; + $ids = $categoryId ?? Mage_Catalog_Model_Category::TREE_ROOT_ID; } $collection = Mage::getModel('catalog/category')->getCollection() diff --git a/app/code/core/Mage/Catalog/Model/Config.php b/app/code/core/Mage/Catalog/Model/Config.php index b7980285341..23356b06dff 100644 --- a/app/code/core/Mage/Catalog/Model/Config.php +++ b/app/code/core/Mage/Catalog/Model/Config.php @@ -86,10 +86,7 @@ public function setStoreId($storeId) */ public function getStoreId() { - if ($this->_storeId === null) { - return Mage::app()->getStore()->getId(); - } - return $this->_storeId; + return $this->_storeId ?? Mage::app()->getStore()->getId(); } /** @@ -130,7 +127,7 @@ public function getAttributeSetName($entityTypeId, $id) if (!is_numeric($entityTypeId)) { $entityTypeId = $this->getEntityType($entityTypeId)->getId(); } - return isset($this->_attributeSetsById[$entityTypeId][$id]) ? $this->_attributeSetsById[$entityTypeId][$id] : false; + return $this->_attributeSetsById[$entityTypeId][$id] ?? false; } /** @@ -149,7 +146,7 @@ public function getAttributeSetId($entityTypeId, $name) $entityTypeId = $this->getEntityType($entityTypeId)->getId(); } $name = strtolower($name); - return isset($this->_attributeSetsByName[$entityTypeId][$name]) ? $this->_attributeSetsByName[$entityTypeId][$name] : false; + return $this->_attributeSetsByName[$entityTypeId][$name] ?? false; } /** @@ -191,7 +188,7 @@ public function getAttributeGroupName($attributeSetId, $id) if (!is_numeric($attributeSetId)) { $attributeSetId = $this->getAttributeSetId($attributeSetId); } - return isset($this->_attributeGroupsById[$attributeSetId][$id]) ? $this->_attributeGroupsById[$attributeSetId][$id] : false; + return $this->_attributeGroupsById[$attributeSetId][$id] ?? false; } /** @@ -211,7 +208,7 @@ public function getAttributeGroupId($attributeSetId, $name) $attributeSetId = $this->getAttributeSetId($attributeSetId); } $name = strtolower($name); - return isset($this->_attributeGroupsByName[$attributeSetId][$name]) ? $this->_attributeGroupsByName[$attributeSetId][$name] : false; + return $this->_attributeGroupsByName[$attributeSetId][$name] ?? false; } /** @@ -254,7 +251,7 @@ public function getProductTypeId($name) $this->loadProductTypes(); $name = strtolower($name); - return isset($this->_productTypesByName[$name]) ? $this->_productTypesByName[$name] : false; + return $this->_productTypesByName[$name] ?? false; } /** @@ -269,7 +266,7 @@ public function getProductTypeName($id) $this->loadProductTypes(); - return isset($this->_productTypesById[$id]) ? $this->_productTypesById[$id] : false; + return $this->_productTypesById[$id] ?? false; } /** diff --git a/app/code/core/Mage/Catalog/Model/Convert/Adapter/Product.php b/app/code/core/Mage/Catalog/Model/Convert/Adapter/Product.php index 89fd79f97fc..0ace5b04929 100644 --- a/app/code/core/Mage/Catalog/Model/Convert/Adapter/Product.php +++ b/app/code/core/Mage/Catalog/Model/Convert/Adapter/Product.php @@ -337,11 +337,7 @@ public function getStoreByCode($store) return Mage::app()->getStore(Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID); } - if (isset($this->_stores[$store])) { - return $this->_stores[$store]; - } - - return false; + return $this->_stores[$store] ?? false; } /** @@ -681,7 +677,7 @@ public function saveRow(array $importData) * Check product define type */ if (empty($importData['type']) || !isset($productTypes[strtolower($importData['type'])])) { - $value = isset($importData['type']) ? $importData['type'] : ''; + $value = $importData['type'] ?? ''; $message = Mage::helper('catalog')->__('Skip import row, is not valid value "%s" for field "%s"', $value, 'type'); Mage::throwException($message); } @@ -690,7 +686,7 @@ public function saveRow(array $importData) * Check product define attribute set */ if (empty($importData['attribute_set']) || !isset($productAttributeSets[$importData['attribute_set']])) { - $value = isset($importData['attribute_set']) ? $importData['attribute_set'] : ''; + $value = $importData['attribute_set'] ?? ''; $message = Mage::helper('catalog')->__('Skip import row, the value "%s" is invalid for field "%s"', $value, 'attribute_set'); Mage::throwException($message); } @@ -812,9 +808,7 @@ public function saveRow(array $importData) } $stockData = []; - $inventoryFields = isset($this->_inventoryFieldsProductTypes[$product->getTypeId()]) - ? $this->_inventoryFieldsProductTypes[$product->getTypeId()] - : []; + $inventoryFields = $this->_inventoryFieldsProductTypes[$product->getTypeId()] ?? []; foreach ($inventoryFields as $field) { if (isset($importData[$field])) { if (in_array($field, $this->_toNumber)) { diff --git a/app/code/core/Mage/Catalog/Model/Convert/Parser/Product.php b/app/code/core/Mage/Catalog/Model/Convert/Parser/Product.php index 1ace4e0a844..c13e698674d 100644 --- a/app/code/core/Mage/Catalog/Model/Convert/Parser/Product.php +++ b/app/code/core/Mage/Catalog/Model/Convert/Parser/Product.php @@ -145,10 +145,7 @@ public function getProductTypes() public function getProductTypeName($code) { $productTypes = $this->getProductTypes(); - if (isset($productTypes[$code])) { - return $productTypes[$code]; - } - return false; + return $productTypes[$code] ?? false; } /** @@ -317,7 +314,7 @@ public function parse() } // get store ids - $storeIds = $this->getStoreIds(isset($row['store']) ? $row['store'] : $this->getVar('store')); + $storeIds = $this->getStoreIds($row['store'] ?? $this->getVar('store')); if (!$storeIds) { $this->addException( Mage::helper('catalog')->__('Invalid store specified, skipping the record.'), diff --git a/app/code/core/Mage/Catalog/Model/Entity/Product/Attribute/Design/Options/Container.php b/app/code/core/Mage/Catalog/Model/Entity/Product/Attribute/Design/Options/Container.php index ebe7a23ba2c..001e8f21d44 100644 --- a/app/code/core/Mage/Catalog/Model/Entity/Product/Attribute/Design/Options/Container.php +++ b/app/code/core/Mage/Catalog/Model/Entity/Product/Attribute/Design/Options/Container.php @@ -50,9 +50,6 @@ public function getOptionText($value) } } } - if (isset($options[$value])) { - return $options[$value]; - } - return false; + return $options[$value] ?? false; } } diff --git a/app/code/core/Mage/Catalog/Model/Layer/Filter/Attribute.php b/app/code/core/Mage/Catalog/Model/Layer/Filter/Attribute.php index 4d1b692bfb3..19d0095004c 100644 --- a/app/code/core/Mage/Catalog/Model/Layer/Filter/Attribute.php +++ b/app/code/core/Mage/Catalog/Model/Layer/Filter/Attribute.php @@ -138,7 +138,7 @@ protected function _getItemsData() $data[] = [ 'label' => $option['label'], 'value' => $option['value'], - 'count' => isset($optionsCount[$option['value']]) ? $optionsCount[$option['value']] : 0, + 'count' => $optionsCount[$option['value']] ?? 0, ]; } } diff --git a/app/code/core/Mage/Catalog/Model/Product.php b/app/code/core/Mage/Catalog/Model/Product.php index c6886183f0d..40155f898c8 100644 --- a/app/code/core/Mage/Catalog/Model/Product.php +++ b/app/code/core/Mage/Catalog/Model/Product.php @@ -927,10 +927,7 @@ public function setFinalPrice($price) public function getFinalPrice($qty = null) { $price = $this->_getData('final_price'); - if ($price !== null) { - return $price; - } - return $this->getPriceModel()->getFinalPrice($qty, $this); + return $price ?? $this->getPriceModel()->getFinalPrice($qty, $this); } /** @@ -1231,7 +1228,7 @@ public function getMediaGalleryImages() continue; } $image['url'] = $this->getMediaConfig()->getMediaUrl($image['file']); - $image['id'] = isset($image['value_id']) ? $image['value_id'] : null; + $image['id'] = $image['value_id'] ?? null; $image['path'] = $this->getMediaConfig()->getMediaPath($image['file']); $images->addItem(new Varien_Object($image)); } @@ -1859,11 +1856,7 @@ public function addOption(Mage_Catalog_Model_Product_Option $option) */ public function getOptionById($optionId) { - if (isset($this->_options[$optionId])) { - return $this->_options[$optionId]; - } - - return null; + return $this->_options[$optionId] ?? null; } /** @@ -1936,10 +1929,7 @@ public function getCustomOptions() */ public function getCustomOption($code) { - if (isset($this->_customOptions[$code])) { - return $this->_customOptions[$code]; - } - return null; + return $this->_customOptions[$code] ?? null; } /** diff --git a/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Groupprice/Abstract.php b/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Groupprice/Abstract.php index 3a30de7d91f..5f8abd09b2b 100644 --- a/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Groupprice/Abstract.php +++ b/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Groupprice/Abstract.php @@ -323,7 +323,7 @@ public function afterSave($object) 'all_groups' => $useForAllGroups ? 1 : 0, 'customer_group_id' => $customerGroupId, 'value' => $data['price'], - 'is_percent' => isset($data['is_percent']) ? $data['is_percent'] : 0, + 'is_percent' => $data['is_percent'] ?? 0, ], $this->_getAdditionalUniqueFields($data)); } diff --git a/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Media.php b/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Media.php index 540732915d0..5021b8e0635 100644 --- a/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Media.php +++ b/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Media.php @@ -66,11 +66,7 @@ public function afterLoad($object) */ protected function _getDefaultValue($key, &$image) { - if (isset($image[$key . '_default'])) { - return $image[$key . '_default']; - } - - return ''; + return $image[$key . '_default'] ?? ''; } /** @@ -189,11 +185,7 @@ public function beforeSave($object) */ public function getRenamedImage($file) { - if (isset($this->_renamedImages[$file])) { - return $this->_renamedImages[$file]; - } - - return $file; + return $this->_renamedImages[$file] ?? $file; } /** @@ -693,7 +685,7 @@ public function duplicate($object) $this->_getResource()->duplicate( $this, - (isset($mediaGalleryData['duplicate']) ? $mediaGalleryData['duplicate'] : []), + $mediaGalleryData['duplicate'] ?? [], $object->getOriginalId(), $object->getId() ); diff --git a/app/code/core/Mage/Catalog/Model/Product/Option.php b/app/code/core/Mage/Catalog/Model/Product/Option.php index 8513f072a31..67443220fd7 100644 --- a/app/code/core/Mage/Catalog/Model/Product/Option.php +++ b/app/code/core/Mage/Catalog/Model/Product/Option.php @@ -181,11 +181,7 @@ public function addValue(Mage_Catalog_Model_Product_Option_Value $value) */ public function getValueById($valueId) { - if (isset($this->_values[$valueId])) { - return $this->_values[$valueId]; - } - - return null; + return $this->_values[$valueId] ?? null; } /** @@ -302,7 +298,7 @@ public function getGroupByType($type = null) self::OPTION_TYPE_TIME => self::OPTION_GROUP_DATE, ]; - return isset($optionGroupsToTypes[$type])?$optionGroupsToTypes[$type]:''; + return $optionGroupsToTypes[$type] ?? ''; } /** diff --git a/app/code/core/Mage/Catalog/Model/Product/Option/Type/Date.php b/app/code/core/Mage/Catalog/Model/Product/Option/Type/Date.php index b4e8ca5114e..582197f1fac 100644 --- a/app/code/core/Mage/Catalog/Model/Product/Option/Type/Date.php +++ b/app/code/core/Mage/Catalog/Model/Product/Option/Type/Date.php @@ -65,14 +65,14 @@ public function validateUserValue($values) if ($isValid) { $this->setUserValue( [ - 'date' => isset($value['date']) ? $value['date'] : '', + 'date' => $value['date'] ?? '', 'year' => isset($value['year']) ? intval($value['year']) : 0, 'month' => isset($value['month']) ? intval($value['month']) : 0, 'day' => isset($value['day']) ? intval($value['day']) : 0, 'hour' => isset($value['hour']) ? intval($value['hour']) : 0, 'minute' => isset($value['minute']) ? intval($value['minute']) : 0, - 'day_part' => isset($value['day_part']) ? $value['day_part'] : '', - 'date_internal' => isset($value['date_internal']) ? $value['date_internal'] : '', + 'day_part' => $value['day_part'] ?? '', + 'date_internal' => $value['date_internal'] ?? '', ] ); } elseif (!$isValid && $option->getIsRequire() && !$this->getSkipCheckRequiredOption()) { diff --git a/app/code/core/Mage/Catalog/Model/Product/Option/Type/Default.php b/app/code/core/Mage/Catalog/Model/Product/Option/Type/Default.php index b6637883cdd..4c322179b06 100644 --- a/app/code/core/Mage/Catalog/Model/Product/Option/Type/Default.php +++ b/app/code/core/Mage/Catalog/Model/Product/Option/Type/Default.php @@ -272,7 +272,7 @@ public function getFormattedOptionValue($optionValue) */ public function getCustomizedView($optionInfo) { - return isset($optionInfo['value']) ? $optionInfo['value'] : $optionInfo; + return $optionInfo['value'] ?? $optionInfo; } /** @@ -372,10 +372,7 @@ public function getProductOptions() } } } - if (isset($this->_productOptions[$this->getProduct()->getId()])) { - return $this->_productOptions[$this->getProduct()->getId()]; - } - return []; + return $this->_productOptions[$this->getProduct()->getId()] ?? []; } /** diff --git a/app/code/core/Mage/Catalog/Model/Product/Type.php b/app/code/core/Mage/Catalog/Model/Product/Type.php index c23058d169a..e0ec802a1ee 100644 --- a/app/code/core/Mage/Catalog/Model/Product/Type.php +++ b/app/code/core/Mage/Catalog/Model/Product/Type.php @@ -169,7 +169,7 @@ public static function getOptions() public static function getOptionText($optionId) { $options = self::getOptionArray(); - return isset($options[$optionId]) ? $options[$optionId] : null; + return $options[$optionId] ?? null; } /** @@ -180,10 +180,7 @@ public static function getTypes() if (is_null(self::$_types)) { $productTypes = Mage::getConfig()->getNode('global/catalog/product/type')->asArray(); foreach ($productTypes as $productKey => $productConfig) { - $moduleName = 'catalog'; - if (isset($productConfig['@']['module'])) { - $moduleName = $productConfig['@']['module']; - } + $moduleName = $productConfig['@']['module'] ?? 'catalog'; $translatedLabel = Mage::helper($moduleName)->__($productConfig['label']); $productTypes[$productKey]['label'] = $translatedLabel; } diff --git a/app/code/core/Mage/Catalog/Model/Product/Type/Abstract.php b/app/code/core/Mage/Catalog/Model/Product/Type/Abstract.php index c7936cd4cc5..a451f2d123b 100644 --- a/app/code/core/Mage/Catalog/Model/Product/Type/Abstract.php +++ b/app/code/core/Mage/Catalog/Model/Product/Type/Abstract.php @@ -434,10 +434,10 @@ public function processFileQueue() if (isset($queueOptions['operation']) && $operation = $queueOptions['operation']) { switch ($operation) { case 'receive_uploaded_file': - $src = isset($queueOptions['src_name']) ? $queueOptions['src_name'] : ''; - $dst = isset($queueOptions['dst_name']) ? $queueOptions['dst_name'] : ''; + $src = $queueOptions['src_name'] ?? ''; + $dst = $queueOptions['dst_name'] ?? ''; /** @var Zend_File_Transfer_Adapter_Http $uploader */ - $uploader = isset($queueOptions['uploader']) ? $queueOptions['uploader'] : null; + $uploader = $queueOptions['uploader'] ?? null; $path = dirname($dst); $io = new Varien_Io_File(); diff --git a/app/code/core/Mage/Catalog/Model/Product/Type/Configurable.php b/app/code/core/Mage/Catalog/Model/Product/Type/Configurable.php index 8b84544e5d0..6286604fd42 100644 --- a/app/code/core/Mage/Catalog/Model/Product/Type/Configurable.php +++ b/app/code/core/Mage/Catalog/Model/Product/Type/Configurable.php @@ -430,7 +430,7 @@ public function save($product = null) */ if ($data = $this->getProduct($product)->getConfigurableAttributesData()) { foreach ($data as $attributeData) { - $id = isset($attributeData['id']) ? $attributeData['id'] : null; + $id = $attributeData['id'] ?? null; Mage::getModel('catalog/product_type_configurable_attribute') ->setData($attributeData) ->setId($id) diff --git a/app/code/core/Mage/Catalog/Model/Product/Type/Configurable/Price.php b/app/code/core/Mage/Catalog/Model/Product/Type/Configurable/Price.php index 0053bdd4a5e..da69a31f0e1 100644 --- a/app/code/core/Mage/Catalog/Model/Product/Type/Configurable/Price.php +++ b/app/code/core/Mage/Catalog/Model/Product/Type/Configurable/Price.php @@ -80,7 +80,7 @@ public function getTotalConfigurableItemsPrice($product, $finalPrice) $attributeId = $attribute->getProductAttribute()->getId(); $value = $this->_getValueByIndex( $attribute->getPrices() ? $attribute->getPrices() : [], - isset($selectedAttributes[$attributeId]) ? $selectedAttributes[$attributeId] : null + $selectedAttributes[$attributeId] ?? null ); $product->setParentId(true); if ($value) { diff --git a/app/code/core/Mage/Catalog/Model/Product/Visibility.php b/app/code/core/Mage/Catalog/Model/Product/Visibility.php index 9fcc4bc9166..4c7fc8409d3 100644 --- a/app/code/core/Mage/Catalog/Model/Product/Visibility.php +++ b/app/code/core/Mage/Catalog/Model/Product/Visibility.php @@ -180,7 +180,7 @@ public static function getAllOptions() public static function getOptionText($optionId) { $options = self::getOptionArray(); - return isset($options[$optionId]) ? $options[$optionId] : null; + return $options[$optionId] ?? null; } /** diff --git a/app/code/core/Mage/Catalog/Model/Resource/Category.php b/app/code/core/Mage/Catalog/Model/Resource/Category.php index 03324e3673a..069a90e2216 100644 --- a/app/code/core/Mage/Catalog/Model/Resource/Category.php +++ b/app/code/core/Mage/Catalog/Model/Resource/Category.php @@ -89,10 +89,7 @@ public function setStoreId($storeId) */ public function getStoreId() { - if ($this->_storeId === null) { - return Mage::app()->getStore()->getId(); - } - return $this->_storeId; + return $this->_storeId ?? Mage::app()->getStore()->getId(); } /** diff --git a/app/code/core/Mage/Catalog/Model/Resource/Collection/Abstract.php b/app/code/core/Mage/Catalog/Model/Resource/Collection/Abstract.php index 11f9bb4b2b9..70c6f740bb5 100644 --- a/app/code/core/Mage/Catalog/Model/Resource/Collection/Abstract.php +++ b/app/code/core/Mage/Catalog/Model/Resource/Collection/Abstract.php @@ -170,11 +170,7 @@ protected function _addLoadAttributesSelectValues($select, $table, $type) */ protected function _joinAttributeToSelect($method, $attribute, $tableAlias, $condition, $fieldCode, $fieldAlias) { - if (isset($this->_joinAttributes[$fieldCode]['store_id'])) { - $store_id = $this->_joinAttributes[$fieldCode]['store_id']; - } else { - $store_id = $this->getStoreId(); - } + $store_id = $this->_joinAttributes[$fieldCode]['store_id'] ?? $this->getStoreId(); $adapter = $this->getConnection(); diff --git a/app/code/core/Mage/Catalog/Model/Resource/Config.php b/app/code/core/Mage/Catalog/Model/Resource/Config.php index 3e14ad2ae84..1d084a887b6 100644 --- a/app/code/core/Mage/Catalog/Model/Resource/Config.php +++ b/app/code/core/Mage/Catalog/Model/Resource/Config.php @@ -66,10 +66,7 @@ public function setStoreId($storeId) */ public function getStoreId() { - if ($this->_storeId === null) { - return Mage::app()->getStore()->getId(); - } - return $this->_storeId; + return $this->_storeId ?? Mage::app()->getStore()->getId(); } /** diff --git a/app/code/core/Mage/Catalog/Model/Resource/Product/Attribute/Backend/Media.php b/app/code/core/Mage/Catalog/Model/Resource/Product/Attribute/Backend/Media.php index db546c4aa1e..a882160497c 100644 --- a/app/code/core/Mage/Catalog/Model/Resource/Product/Attribute/Backend/Media.php +++ b/app/code/core/Mage/Catalog/Model/Resource/Product/Attribute/Backend/Media.php @@ -188,7 +188,7 @@ public function duplicate($object, $newFiles, $originalProductId, $newProductId) $data = [ 'attribute_id' => $object->getAttribute()->getId(), 'entity_id' => $newProductId, - 'value' => (isset($newFiles[$row['value_id']]) ? $newFiles[$row['value_id']] : $row['value']) + 'value' => $newFiles[$row['value_id']] ?? $row['value'] ]; $valueIdMap[$row['value_id']] = $this->insertGallery($data); diff --git a/app/code/core/Mage/Catalog/Model/Resource/Product/Collection.php b/app/code/core/Mage/Catalog/Model/Resource/Product/Collection.php index 764deeaa908..8e64bbcebc0 100644 --- a/app/code/core/Mage/Catalog/Model/Resource/Product/Collection.php +++ b/app/code/core/Mage/Catalog/Model/Resource/Product/Collection.php @@ -753,11 +753,7 @@ public function getMaxAttributeValue($attribute) ->group('e.entity_type_id'); $data = $this->getConnection()->fetchRow($select); - if (isset($data[$fieldAlias])) { - return $data[$fieldAlias]; - } - - return null; + return $data[$fieldAlias] ?? null; } /** @@ -1056,10 +1052,7 @@ public function addCountToCategories($categoryCollection) } foreach ($categoryCollection as $category) { - $_count = 0; - if (isset($productCounts[$category->getId()])) { - $_count = $productCounts[$category->getId()]; - } + $_count = $productCounts[$category->getId()] ?? 0; $category->setProductCount($_count); } @@ -1827,9 +1820,7 @@ protected function _applyProductLimitations() { Mage::dispatchEvent('catalog_product_collection_apply_limitations_before', [ 'collection' => $this, - 'category_id' => isset($this->_productLimitationFilters['category_id']) - ? $this->_productLimitationFilters['category_id'] - : null, + 'category_id' => $this->_productLimitationFilters['category_id'] ?? null, ]); $this->_prepareProductLimitationFilters(); $this->_productLimitationJoinWebsite(); diff --git a/app/code/core/Mage/Catalog/Model/Resource/Product/Indexer/Price.php b/app/code/core/Mage/Catalog/Model/Resource/Product/Indexer/Price.php index a483f6e4738..c15467b50ee 100644 --- a/app/code/core/Mage/Catalog/Model/Resource/Product/Indexer/Price.php +++ b/app/code/core/Mage/Catalog/Model/Resource/Product/Indexer/Price.php @@ -341,11 +341,7 @@ public function getTypeIndexers() $this->_indexers = []; $types = Mage::getSingleton('catalog/product_type')->getTypesByPriority(); foreach ($types as $typeId => $typeInfo) { - if (isset($typeInfo['price_indexer'])) { - $modelName = $typeInfo['price_indexer']; - } else { - $modelName = $this->_defaultPriceIndexer; - } + $modelName = $typeInfo['price_indexer'] ?? $this->_defaultPriceIndexer; $isComposite = !empty($typeInfo['composite']); $indexer = Mage::getResourceModel($modelName) ->setTypeId($typeId) diff --git a/app/code/core/Mage/Catalog/Model/Resource/Url.php b/app/code/core/Mage/Catalog/Model/Resource/Url.php index 41d229f053b..b91600a2b42 100644 --- a/app/code/core/Mage/Catalog/Model/Resource/Url.php +++ b/app/code/core/Mage/Catalog/Model/Resource/Url.php @@ -793,10 +793,7 @@ public function getCategory($categoryId, $storeId) } $categories = $this->_getCategories($categoryId, $storeId); - if (isset($categories[$categoryId])) { - return $categories[$categoryId]; - } - return false; + return $categories[$categoryId] ?? false; } /** @@ -1015,10 +1012,7 @@ public function getProduct($productId, $storeId) { $entityId = 0; $products = $this->_getProducts($productId, $storeId, 0, $entityId); - if (isset($products[$productId])) { - return $products[$productId]; - } - return false; + return $products[$productId] ?? false; } /** diff --git a/app/code/core/Mage/Catalog/Model/Template/Filter.php b/app/code/core/Mage/Catalog/Model/Template/Filter.php index 67b91b0d2e6..be3891c200f 100644 --- a/app/code/core/Mage/Catalog/Model/Template/Filter.php +++ b/app/code/core/Mage/Catalog/Model/Template/Filter.php @@ -126,7 +126,7 @@ public function storeDirective($construction) $params['_direct'] = $params['direct_url']; unset($params['direct_url']); } else { - $path = isset($params['url']) ? $params['url'] : ''; + $path = $params['url'] ?? ''; unset($params['url']); } diff --git a/app/code/core/Mage/Catalog/Model/Url.php b/app/code/core/Mage/Catalog/Model/Url.php index 0287894df3c..eb318dac6a2 100644 --- a/app/code/core/Mage/Catalog/Model/Url.php +++ b/app/code/core/Mage/Catalog/Model/Url.php @@ -222,10 +222,7 @@ public function setShouldSaveRewritesHistory($flag) */ public function getShouldSaveRewritesHistory($storeId = null) { - if ($this->_saveRewritesHistory !== null) { - return $this->_saveRewritesHistory; - } - return Mage::helper('catalog')->shouldSaveUrlRewritesHistory($storeId); + return $this->_saveRewritesHistory ?? Mage::helper('catalog')->shouldSaveUrlRewritesHistory($storeId); } /** @@ -658,7 +655,7 @@ public function getUnusedPathByUrlKey($storeId, $requestPath, $idPath, $urlKey) return $this->getUnusedPathByUrlKey($storeId, '-', $idPath, $urlKey); } $match['prefix'] = $match['prefix'] . '-'; - $match['suffix'] = isset($match['suffix']) ? $match['suffix'] : ''; + $match['suffix'] = $match['suffix'] ?? ''; $lastRequestPath = $this->getResource() ->getLastUsedRewriteRequestIncrement($match['prefix'], $match['suffix'], $storeId); diff --git a/app/code/core/Mage/CatalogInventory/Block/Adminhtml/Form/Field/Customergroup.php b/app/code/core/Mage/CatalogInventory/Block/Adminhtml/Form/Field/Customergroup.php index d2c8a9f8bdd..4d6c74fa2dd 100644 --- a/app/code/core/Mage/CatalogInventory/Block/Adminhtml/Form/Field/Customergroup.php +++ b/app/code/core/Mage/CatalogInventory/Block/Adminhtml/Form/Field/Customergroup.php @@ -58,7 +58,7 @@ protected function _getCustomerGroups($groupId = null) } } if (!is_null($groupId)) { - return isset($this->_customerGroups[$groupId]) ? $this->_customerGroups[$groupId] : null; + return $this->_customerGroups[$groupId] ?? null; } return $this->_customerGroups; } diff --git a/app/code/core/Mage/CatalogInventory/Helper/Data.php b/app/code/core/Mage/CatalogInventory/Helper/Data.php index 3f8e8e60507..d4d6a41b2d0 100644 --- a/app/code/core/Mage/CatalogInventory/Helper/Data.php +++ b/app/code/core/Mage/CatalogInventory/Helper/Data.php @@ -54,10 +54,7 @@ class Mage_CatalogInventory_Helper_Data extends Mage_Core_Helper_Abstract public function isQty($productTypeId) { $this->getIsQtyTypeIds(); - if (!isset(self::$_isQtyTypeIds[$productTypeId])) { - return false; - } - return self::$_isQtyTypeIds[$productTypeId]; + return self::$_isQtyTypeIds[$productTypeId] ?? false; } /** diff --git a/app/code/core/Mage/CatalogInventory/Model/Api2/Stock/Item/Rest.php b/app/code/core/Mage/CatalogInventory/Model/Api2/Stock/Item/Rest.php index b02d3125b70..90048d12284 100644 --- a/app/code/core/Mage/CatalogInventory/Model/Api2/Stock/Item/Rest.php +++ b/app/code/core/Mage/CatalogInventory/Model/Api2/Stock/Item/Rest.php @@ -47,7 +47,7 @@ protected function _retrieve() protected function _retrieveCollection() { $data = $this->_getCollectionForRetrieve()->load()->toArray(); - return isset($data['items']) ? $data['items'] : $data; + return $data['items'] ?? $data; } /** @@ -117,7 +117,7 @@ protected function _multiUpdate(array $data) if (!$validator->isValidSingleItemDataForMultiUpdate($itemData)) { foreach ($validator->getErrors() as $error) { $this->_errorMessage($error, Mage_Api2_Model_Server::HTTP_BAD_REQUEST, [ - 'item_id' => isset($itemData['item_id']) ? $itemData['item_id'] : null + 'item_id' => $itemData['item_id'] ?? null ]); } $this->_critical(self::RESOURCE_DATA_PRE_VALIDATION_ERROR); @@ -137,7 +137,7 @@ protected function _multiUpdate(array $data) // pre-validation errors are already added if ($e->getMessage() != self::RESOURCE_DATA_PRE_VALIDATION_ERROR) { $this->_errorMessage($e->getMessage(), $e->getCode(), [ - 'item_id' => isset($itemData['item_id']) ? $itemData['item_id'] : null + 'item_id' => $itemData['item_id'] ?? null ]); } } catch (Exception $e) { @@ -145,7 +145,7 @@ protected function _multiUpdate(array $data) Mage_Api2_Model_Resource::RESOURCE_INTERNAL_ERROR, Mage_Api2_Model_Server::HTTP_INTERNAL_ERROR, [ - 'item_id' => isset($itemData['item_id']) ? $itemData['item_id'] : null + 'item_id' => $itemData['item_id'] ?? null ] ); } diff --git a/app/code/core/Mage/CatalogInventory/Model/Resource/Indexer/Stock.php b/app/code/core/Mage/CatalogInventory/Model/Resource/Indexer/Stock.php index f9111c441fa..b7a19870212 100644 --- a/app/code/core/Mage/CatalogInventory/Model/Resource/Indexer/Stock.php +++ b/app/code/core/Mage/CatalogInventory/Model/Resource/Indexer/Stock.php @@ -255,11 +255,7 @@ protected function _getTypeIndexers() $this->_indexers = []; $types = Mage::getSingleton('catalog/product_type')->getTypesByPriority(); foreach ($types as $typeId => $typeInfo) { - if (isset($typeInfo['stock_indexer'])) { - $modelName = $typeInfo['stock_indexer']; - } else { - $modelName = $this->_defaultIndexer; - } + $modelName = $typeInfo['stock_indexer'] ?? $this->_defaultIndexer; $isComposite = !empty($typeInfo['composite']); $indexer = Mage::getResourceModel($modelName) ->setTypeId($typeId) diff --git a/app/code/core/Mage/CatalogInventory/Model/Stock/Status.php b/app/code/core/Mage/CatalogInventory/Model/Stock/Status.php index 5a14e960396..2d8d8a7547d 100644 --- a/app/code/core/Mage/CatalogInventory/Model/Stock/Status.php +++ b/app/code/core/Mage/CatalogInventory/Model/Stock/Status.php @@ -96,10 +96,7 @@ public function getProductTypeInstances() public function getProductTypeInstance($productType) { $types = $this->getProductTypeInstances(); - if (isset($types[$productType])) { - return $types[$productType]; - } - return false; + return $types[$productType] ?? false; } /** @@ -131,10 +128,7 @@ public function getWebsites($websiteId = null) public function getWebsiteDefaultStoreId($websiteId) { $websites = $this->getWebsites(); - if (isset($websites[$websiteId])) { - return $websites[$websiteId]; - } - return 0; + return $websites[$websiteId] ?? 0; } /** @@ -202,7 +196,7 @@ public function assignProduct(Mage_Catalog_Model_Product $product, $stockId = 1, if (is_null($stockStatus)) { $websiteId = $product->getStore()->getWebsiteId(); $status = $this->getProductStatus($product->getId(), $websiteId, $stockId); - $stockStatus = isset($status[$product->getId()]) ? $status[$product->getId()] : null; + $stockStatus = $status[$product->getId()] ?? null; } $product->setIsSalable($stockStatus); @@ -363,7 +357,7 @@ protected function _processParents($productId, $stockId = 1, $websiteId = null) $item = $this->getStockItemModel(); foreach ($parentIds as $parentId) { - $parentType = isset($productTypes[$parentId]) ? $productTypes[$parentId] : null; + $parentType = $productTypes[$parentId] ?? null; $item->setData(['stock_id' => $stockId]) ->setOrigData() ->loadByProduct($parentId); @@ -432,10 +426,7 @@ public function getProductData($productIds, $websiteId, $stockId = 1) public function getProductType($productId) { $types = $this->getResource()->getProductsType($productId); - if (isset($types[$productId])) { - return $types[$productId]; - } - return false; + return $types[$productId] ?? false; } /** diff --git a/app/code/core/Mage/CatalogRule/Model/Observer.php b/app/code/core/Mage/CatalogRule/Model/Observer.php index 870ce7d6c64..29f72e1e56d 100644 --- a/app/code/core/Mage/CatalogRule/Model/Observer.php +++ b/app/code/core/Mage/CatalogRule/Model/Observer.php @@ -441,7 +441,7 @@ public function prepareCatalogProductCollectionPrices(Varien_Event_Observer $obs ->getRulePrices($date, $websiteId, $groupId, $productIds); foreach ($productIds as $productId) { $key = $this->_getRulePricesKey([$date, $websiteId, $groupId, $productId]); - $this->_rulePrices[$key] = isset($rulePrices[$productId]) ? $rulePrices[$productId] : false; + $this->_rulePrices[$key] = $rulePrices[$productId] ?? false; } } diff --git a/app/code/core/Mage/CatalogRule/Model/Resource/Rule.php b/app/code/core/Mage/CatalogRule/Model/Resource/Rule.php index 5d56cf52d76..3965f7ef1c6 100644 --- a/app/code/core/Mage/CatalogRule/Model/Resource/Rule.php +++ b/app/code/core/Mage/CatalogRule/Model/Resource/Rule.php @@ -609,11 +609,7 @@ protected function _calcRuleProductPrice($ruleData, $productData = null) $productPrice = $productData['rule_price']; } else { $websiteId = $ruleData['website_id']; - if (isset($ruleData['website_'.$websiteId.'_price'])) { - $productPrice = $ruleData['website_'.$websiteId.'_price']; - } else { - $productPrice = $ruleData['default_price']; - } + $productPrice = $ruleData['website_' . $websiteId . '_price'] ?? $ruleData['default_price']; } $productPrice = Mage::helper('catalogrule')->calcPriceRule( @@ -674,11 +670,7 @@ protected function _saveRuleProductPrices($arrData) public function getRulePrice($date, $wId, $gId, $pId) { $data = $this->getRulePrices($date, $wId, $gId, [$pId]); - if (isset($data[$pId])) { - return $data[$pId]; - } - - return false; + return $data[$pId] ?? false; } /** diff --git a/app/code/core/Mage/CatalogRule/Model/Rule/Condition/Product.php b/app/code/core/Mage/CatalogRule/Model/Rule/Condition/Product.php index ec9d9666588..4233cf1027e 100644 --- a/app/code/core/Mage/CatalogRule/Model/Rule/Condition/Product.php +++ b/app/code/core/Mage/CatalogRule/Model/Rule/Condition/Product.php @@ -89,11 +89,9 @@ protected function _getAttributeValue($object) $attrCode = $this->getAttribute(); $storeId = $object->getStoreId(); $defaultStoreId = Mage_Core_Model_App::ADMIN_STORE_ID; - $productValues = isset($this->_entityAttributeValues[$object->getId()]) - ? $this->_entityAttributeValues[$object->getId()] : []; - $defaultValue = isset($productValues[$defaultStoreId]) - ? $productValues[$defaultStoreId] : $object->getData($attrCode); - $value = isset($productValues[$storeId]) ? $productValues[$storeId] : $defaultValue; + $productValues = $this->_entityAttributeValues[$object->getId()] ?? []; + $defaultValue = $productValues[$defaultStoreId] ?? $object->getData($attrCode); + $value = $productValues[$storeId] ?? $defaultValue; $value = $this->_prepareDatetimeValue($value, $object); $value = $this->_prepareMultiselectValue($value, $object); diff --git a/app/code/core/Mage/CatalogSearch/Block/Advanced/Form.php b/app/code/core/Mage/CatalogSearch/Block/Advanced/Form.php index df1eee82b34..2cf7a7d29fb 100644 --- a/app/code/core/Mage/CatalogSearch/Block/Advanced/Form.php +++ b/app/code/core/Mage/CatalogSearch/Block/Advanced/Form.php @@ -90,11 +90,7 @@ public function getAttributeValue($attribute, $part = null) { $value = $this->getRequest()->getQuery($attribute->getAttributeCode()); if ($part && $value) { - if (isset($value[$part])) { - $value = $value[$part]; - } else { - $value = ''; - } + $value = $value[$part] ?? ''; } return $value; diff --git a/app/code/core/Mage/Centinel/Model/Api.php b/app/code/core/Mage/Centinel/Model/Api.php index d6f3c380fe4..6acca510ebd 100644 --- a/app/code/core/Mage/Centinel/Model/Api.php +++ b/app/code/core/Mage/Centinel/Model/Api.php @@ -191,7 +191,7 @@ public function callLookup($data) $month = strlen($data->getCardExpMonth()) == 1 ? '0' . $data->getCardExpMonth() : $data->getCardExpMonth(); $currencyCode = $data->getCurrencyCode(); - $currencyNumber = isset(self::$_iso4217Currencies[$currencyCode]) ? self::$_iso4217Currencies[$currencyCode] : ''; + $currencyNumber = self::$_iso4217Currencies[$currencyCode] ?? ''; if (!$currencyNumber) { return $result->setErrorNo(1)->setErrorDesc( Mage::helper('payment')->__('Unsupported currency code: %s.', $currencyCode) diff --git a/app/code/core/Mage/Checkout/Block/Cart/Abstract.php b/app/code/core/Mage/Checkout/Block/Cart/Abstract.php index 1120fd62668..54069ffb09c 100644 --- a/app/code/core/Mage/Checkout/Block/Cart/Abstract.php +++ b/app/code/core/Mage/Checkout/Block/Cart/Abstract.php @@ -79,10 +79,7 @@ public function getItemRender($type) */ public function getItemRendererInfo($type) { - if (isset($this->_itemRenders[$type])) { - return $this->_itemRenders[$type]; - } - return $this->_itemRenders['default']; + return $this->_itemRenders[$type] ?? $this->_itemRenders['default']; } /** diff --git a/app/code/core/Mage/Checkout/Model/Cart/Payment/Api.php b/app/code/core/Mage/Checkout/Model/Cart/Payment/Api.php index 866e60fc8ad..dfa287238ed 100644 --- a/app/code/core/Mage/Checkout/Model/Cart/Payment/Api.php +++ b/app/code/core/Mage/Checkout/Model/Cart/Payment/Api.php @@ -151,7 +151,7 @@ public function setPaymentMethod($quoteId, $paymentData, $store = null) $this->_fault('billing_address_is_not_set'); } $quote->getBillingAddress()->setPaymentMethod( - isset($paymentData['method']) ? $paymentData['method'] : null + $paymentData['method'] ?? null ); } else { // check if shipping address is set @@ -159,7 +159,7 @@ public function setPaymentMethod($quoteId, $paymentData, $store = null) $this->_fault('shipping_address_is_not_set'); } $quote->getShippingAddress()->setPaymentMethod( - isset($paymentData['method']) ? $paymentData['method'] : null + $paymentData['method'] ?? null ); } diff --git a/app/code/core/Mage/Checkout/Model/Type/Multishipping.php b/app/code/core/Mage/Checkout/Model/Type/Multishipping.php index df911648ac1..cd2d36b46dc 100644 --- a/app/code/core/Mage/Checkout/Model/Type/Multishipping.php +++ b/app/code/core/Mage/Checkout/Model/Type/Multishipping.php @@ -286,7 +286,7 @@ protected function _addShippingItem($quoteItemId, $data) { $qty = isset($data['qty']) ? (int) $data['qty'] : 1; //$qty = $qty > 0 ? $qty : 1; - $addressId = isset($data['address']) ? $data['address'] : false; + $addressId = $data['address'] ?? false; $quoteItem = $this->getQuote()->getItemById($quoteItemId); if ($addressId && $quoteItem) { diff --git a/app/code/core/Mage/Checkout/Model/Type/Onepage.php b/app/code/core/Mage/Checkout/Model/Type/Onepage.php index fc1969bfb69..2d1f7af7bc6 100644 --- a/app/code/core/Mage/Checkout/Model/Type/Onepage.php +++ b/app/code/core/Mage/Checkout/Model/Type/Onepage.php @@ -90,10 +90,7 @@ public function getCheckout() */ public function getQuote() { - if ($this->_quote === null) { - return $this->_checkoutSession->getQuote(); - } - return $this->_quote; + return $this->_quote ?? $this->_checkoutSession->getQuote(); } /** @@ -641,9 +638,9 @@ public function savePayment($data) } $quote = $this->getQuote(); if ($quote->isVirtual()) { - $quote->getBillingAddress()->setPaymentMethod(isset($data['method']) ? $data['method'] : null); + $quote->getBillingAddress()->setPaymentMethod($data['method'] ?? null); } else { - $quote->getShippingAddress()->setPaymentMethod(isset($data['method']) ? $data['method'] : null); + $quote->getShippingAddress()->setPaymentMethod($data['method'] ?? null); } // shipping totals may be affected by payment method diff --git a/app/code/core/Mage/ConfigurableSwatches/Helper/Mediafallback.php b/app/code/core/Mage/ConfigurableSwatches/Helper/Mediafallback.php index 574e90e0713..2f4cf3f9d33 100644 --- a/app/code/core/Mage/ConfigurableSwatches/Helper/Mediafallback.php +++ b/app/code/core/Mage/ConfigurableSwatches/Helper/Mediafallback.php @@ -117,10 +117,7 @@ public function attachProductChildrenAttributeMapping(array $parentProducts, $st } // using default value as key unless store-specific label is present - $optionLabel = $optionLabels[$optionId][0]; - if (isset($optionLabels[$optionId][$storeId])) { - $optionLabel = $optionLabels[$optionId][$storeId]; - } + $optionLabel = $optionLabels[$optionId][$storeId] ?? $optionLabels[$optionId][0]; // initialize arrays if not present if (!isset($mapping[$optionLabel])) { diff --git a/app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php b/app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php index 3e03e6cc408..bbf81c63c30 100644 --- a/app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php +++ b/app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php @@ -71,9 +71,8 @@ public function getProductImgByLabel($text, $product, $type = null) $text = Mage_ConfigurableSwatches_Helper_Data::normalizeKey($text); $resultImages = [ - 'standard' => isset($images[$text]) ? $images[$text] : null, - 'swatch' => isset($images[$text . self::SWATCH_LABEL_SUFFIX]) ? $images[$text . self::SWATCH_LABEL_SUFFIX] - : null, + 'standard' => $images[$text] ?? null, + 'swatch' => $images[$text . self::SWATCH_LABEL_SUFFIX] ?? null, ]; if (!is_null($type) && array_key_exists($type, $resultImages)) { diff --git a/app/code/core/Mage/Core/Controller/Request/Http.php b/app/code/core/Mage/Core/Controller/Request/Http.php index 1e2fd0fa407..a167789b40a 100644 --- a/app/code/core/Mage/Core/Controller/Request/Http.php +++ b/app/code/core/Mage/Core/Controller/Request/Http.php @@ -162,7 +162,7 @@ public function setPathInfo($pathInfo = null) $stores = Mage::app()->getStores(true, true); if ($storeCode!=='' && isset($stores[$storeCode])) { Mage::app()->setCurrentStore($storeCode); - $pathInfo = '/'.(isset($pathParts[1]) ? $pathParts[1] : ''); + $pathInfo = '/'.($pathParts[1] ?? ''); } elseif ($storeCode !== '') { $this->setActionName('noRoute'); } @@ -424,10 +424,7 @@ public function getActionName() public function getAlias($name) { $aliases = $this->getAliases(); - if (isset($aliases[$name])) { - return $aliases[$name]; - } - return null; + return $aliases[$name] ?? null; } /** @@ -437,10 +434,7 @@ public function getAlias($name) */ public function getAliases() { - if (isset($this->_routingInfo['aliases'])) { - return $this->_routingInfo['aliases']; - } - return parent::getAliases(); + return $this->_routingInfo['aliases'] ?? parent::getAliases(); } /** diff --git a/app/code/core/Mage/Core/Controller/Varien/Front.php b/app/code/core/Mage/Core/Controller/Varien/Front.php index 28bf4bc4d09..19f21c5808f 100644 --- a/app/code/core/Mage/Core/Controller/Varien/Front.php +++ b/app/code/core/Mage/Core/Controller/Varien/Front.php @@ -113,10 +113,7 @@ public function addRouter($name, Mage_Core_Controller_Varien_Router_Abstract $ro */ public function getRouter($name) { - if (isset($this->_routers[$name])) { - return $this->_routers[$name]; - } - return false; + return $this->_routers[$name] ?? false; } /** diff --git a/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php b/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php index e3df2775e5b..c2fb0e7331b 100644 --- a/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php +++ b/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php @@ -376,10 +376,7 @@ public function addModule($frontName, $moduleNames, $routeName) */ public function getModuleByFrontName($frontName) { - if (isset($this->_modules[$frontName])) { - return $this->_modules[$frontName]; - } - return false; + return $this->_modules[$frontName] ?? false; } /** @@ -404,10 +401,7 @@ public function getModuleByName($moduleName, $modules) */ public function getFrontNameByRoute($routeName) { - if (isset($this->_routes[$routeName])) { - return $this->_routes[$routeName]; - } - return false; + return $this->_routes[$routeName] ?? false; } /** diff --git a/app/code/core/Mage/Core/Exception.php b/app/code/core/Mage/Core/Exception.php index 34d40c62c69..0bc73cb6cca 100644 --- a/app/code/core/Mage/Core/Exception.php +++ b/app/code/core/Mage/Core/Exception.php @@ -57,7 +57,7 @@ public function getMessages($type = '') } return $arrRes; } - return isset($this->_messages[$type]) ? $this->_messages[$type] : []; + return $this->_messages[$type] ?? []; } /** diff --git a/app/code/core/Mage/Core/Helper/Cookie.php b/app/code/core/Mage/Core/Helper/Cookie.php index 5b9d6b73721..c859935629d 100644 --- a/app/code/core/Mage/Core/Helper/Cookie.php +++ b/app/code/core/Mage/Core/Helper/Cookie.php @@ -76,20 +76,19 @@ class Mage_Core_Helper_Cookie extends Mage_Core_Helper_Abstract */ public function __construct(array $data = []) { - $this->_currentStore = isset($data['current_store']) ? $data['current_store'] : Mage::app()->getStore(); + $this->_currentStore = $data['current_store'] ?? Mage::app()->getStore(); if (!$this->_currentStore instanceof Mage_Core_Model_Store) { throw new InvalidArgumentException('Required store object is invalid'); } - $this->_cookieModel = isset($data['cookie_model']) - ? $data['cookie_model'] : Mage::getSingleton('core/cookie'); + $this->_cookieModel = $data['cookie_model'] ?? Mage::getSingleton('core/cookie'); if (!$this->_cookieModel instanceof Mage_Core_Model_Cookie) { throw new InvalidArgumentException('Required cookie object is invalid'); } - $this->_website = isset($data['website']) ? $data['website'] : Mage::app()->getWebsite(); + $this->_website = $data['website'] ?? Mage::app()->getWebsite(); if (!$this->_website instanceof Mage_Core_Model_Website) { throw new InvalidArgumentException('Required website object is invalid'); diff --git a/app/code/core/Mage/Core/Helper/Data.php b/app/code/core/Mage/Core/Helper/Data.php index 2f0e88689a0..3b6f3a3b0d2 100644 --- a/app/code/core/Mage/Core/Helper/Data.php +++ b/app/code/core/Mage/Core/Helper/Data.php @@ -473,7 +473,7 @@ public function copyFieldset($fieldset, $aspect, $source, $target, $root = 'glob } if ($sourceIsArray) { - $value = isset($source[$code]) ? $source[$code] : null; + $value = $source[$code] ?? null; } else { $value = $source->getDataUsingMethod($code); } diff --git a/app/code/core/Mage/Core/Model/Abstract.php b/app/code/core/Mage/Core/Model/Abstract.php index 8611cc3c28d..ecaf56c7039 100644 --- a/app/code/core/Mage/Core/Model/Abstract.php +++ b/app/code/core/Mage/Core/Model/Abstract.php @@ -387,10 +387,7 @@ public function isObjectNew($flag = null) if ($flag !== null) { $this->_isObjectNew = $flag; } - if ($this->_isObjectNew !== null) { - return $this->_isObjectNew; - } - return !(bool)$this->getId(); + return $this->_isObjectNew ?? !(bool)$this->getId(); } /** diff --git a/app/code/core/Mage/Core/Model/App.php b/app/code/core/Mage/Core/Model/App.php index 11b934a333c..4bf1d1ea070 100644 --- a/app/code/core/Mage/Core/Model/App.php +++ b/app/code/core/Mage/Core/Model/App.php @@ -349,7 +349,7 @@ public function initSpecified($scopeCode, $scopeType = null, $options = [], $mod */ public function run($params) { - $options = isset($params['options']) ? $params['options'] : []; + $options = $params['options'] ?? []; $this->baseInit($options); Mage::register('application_params', $params); @@ -360,8 +360,8 @@ public function run($params) $this->loadAreaPart(Mage_Core_Model_App_Area::AREA_GLOBAL, Mage_Core_Model_App_Area::PART_EVENTS); if ($this->_config->isLocalConfigLoaded()) { - $scopeCode = isset($params['scope_code']) ? $params['scope_code'] : ''; - $scopeType = isset($params['scope_type']) ? $params['scope_type'] : 'store'; + $scopeCode = $params['scope_code'] ?? ''; + $scopeType = $params['scope_type'] ?? 'store'; $this->_initCurrentStore($scopeCode, $scopeType); $this->_initRequest(); Mage_Core_Model_Resource_Setup::applyAllDataUpdates(); diff --git a/app/code/core/Mage/Core/Model/Cache.php b/app/code/core/Mage/Core/Model/Cache.php index 14fbef27651..e5b70643b1f 100644 --- a/app/code/core/Mage/Core/Model/Cache.php +++ b/app/code/core/Mage/Core/Model/Cache.php @@ -113,12 +113,11 @@ class Mage_Core_Model_Cache */ public function __construct(array $options = []) { - $this->_defaultBackendOptions['cache_dir'] = isset($options['cache_dir']) ? $options['cache_dir'] : - Mage::getBaseDir('cache'); + $this->_defaultBackendOptions['cache_dir'] = $options['cache_dir'] ?? Mage::getBaseDir('cache'); /** * Initialize id prefix */ - $this->_idPrefix = isset($options['id_prefix']) ? $options['id_prefix'] : ''; + $this->_idPrefix = $options['id_prefix'] ?? ''; if (!$this->_idPrefix && isset($options['prefix'])) { $this->_idPrefix = $options['prefix']; } @@ -157,7 +156,7 @@ public function __construct(array $options = []) protected function _getBackendOptions(array $cacheOptions) { $enable2levels = false; - $type = isset($cacheOptions['backend']) ? $cacheOptions['backend'] : $this->_defaultBackend; + $type = $cacheOptions['backend'] ?? $this->_defaultBackend; if (isset($cacheOptions['backend_options']) && is_array($cacheOptions['backend_options'])) { $options = $cacheOptions['backend_options']; } else { @@ -317,13 +316,12 @@ protected function _getTwoLevelsBackendOptions($fastOptions, $cacheOptions) */ protected function _getFrontendOptions(array $cacheOptions) { - $options = isset($cacheOptions['frontend_options']) ? $cacheOptions['frontend_options'] : []; + $options = $cacheOptions['frontend_options'] ?? []; if (!array_key_exists('caching', $options)) { $options['caching'] = true; } if (!array_key_exists('lifetime', $options)) { - $options['lifetime'] = isset($cacheOptions['lifetime']) ? $cacheOptions['lifetime'] - : self::DEFAULT_LIFETIME; + $options['lifetime'] = $cacheOptions['lifetime'] ?? self::DEFAULT_LIFETIME; } if (!array_key_exists('automatic_cleaning_factor', $options)) { $options['automatic_cleaning_factor'] = 0; diff --git a/app/code/core/Mage/Core/Model/Config/Options.php b/app/code/core/Mage/Core/Model/Config/Options.php index 072c7ecc267..e5557ec8544 100644 --- a/app/code/core/Mage/Core/Model/Config/Options.php +++ b/app/code/core/Mage/Core/Model/Config/Options.php @@ -177,8 +177,7 @@ public function getSysTmpDir() public function getVarDir() { //$dir = $this->getDataSetDefault('var_dir', $this->getBaseDir().DS.'var'); - $dir = isset($this->_data['var_dir']) ? $this->_data['var_dir'] - : $this->_data['base_dir'] . DS . self::VAR_DIRECTORY; + $dir = $this->_data['var_dir'] ?? ($this->_data['base_dir'] . DS . self::VAR_DIRECTORY); if (!$this->createDirIfNotExists($dir)) { $dir = $this->getSysTmpDir().DS.'magento'.DS.'var'; if (!$this->createDirIfNotExists($dir)) { diff --git a/app/code/core/Mage/Core/Model/Design/Fallback.php b/app/code/core/Mage/Core/Model/Design/Fallback.php index 97aca02d3ea..113fc06a3ef 100644 --- a/app/code/core/Mage/Core/Model/Design/Fallback.php +++ b/app/code/core/Mage/Core/Model/Design/Fallback.php @@ -56,7 +56,7 @@ class Mage_Core_Model_Design_Fallback */ public function __construct(array $params = []) { - $this->_config = isset($params['config']) ? $params['config'] : Mage::getModel('core/design_config'); + $this->_config = $params['config'] ?? Mage::getModel('core/design_config'); } /** @@ -66,10 +66,7 @@ public function __construct(array $params = []) */ public function getStore() { - if ($this->_store === null) { - return Mage::app()->getStore(); - } - return $this->_store; + return $this->_store ?? Mage::app()->getStore(); } /** diff --git a/app/code/core/Mage/Core/Model/Design/Package.php b/app/code/core/Mage/Core/Model/Design/Package.php index 55531961777..3c90e8558d5 100644 --- a/app/code/core/Mage/Core/Model/Design/Package.php +++ b/app/code/core/Mage/Core/Model/Design/Package.php @@ -131,10 +131,7 @@ public function setStore($store) */ public function getStore() { - if ($this->_store === null) { - return Mage::app()->getStore(); - } - return $this->_store; + return $this->_store ?? Mage::app()->getStore(); } /** @@ -317,7 +314,7 @@ public function updateParamDefaults(array &$params) $params['_package'] = $this->getPackageName(); } if (empty($params['_theme'])) { - $params['_theme'] = $this->getTheme((isset($params['_type'])) ? $params['_type'] : ''); + $params['_theme'] = $this->getTheme($params['_type'] ?? ''); } if (empty($params['_default'])) { $params['_default'] = false; diff --git a/app/code/core/Mage/Core/Model/Domainpolicy.php b/app/code/core/Mage/Core/Model/Domainpolicy.php index f781f53d39c..0853c883423 100644 --- a/app/code/core/Mage/Core/Model/Domainpolicy.php +++ b/app/code/core/Mage/Core/Model/Domainpolicy.php @@ -59,7 +59,7 @@ class Mage_Core_Model_Domainpolicy */ public function __construct($options = []) { - $this->_store = isset($options['store']) ? $options['store'] : Mage::app()->getStore(); + $this->_store = $options['store'] ?? Mage::app()->getStore(); } /** diff --git a/app/code/core/Mage/Core/Model/Email/Template/Filter.php b/app/code/core/Mage/Core/Model/Email/Template/Filter.php index c9254666080..b40858caa58 100644 --- a/app/code/core/Mage/Core/Model/Email/Template/Filter.php +++ b/app/code/core/Mage/Core/Model/Email/Template/Filter.php @@ -324,7 +324,7 @@ public function storeDirective($construction) $params['_direct'] = $params['direct_url']; unset($params['direct_url']); } else { - $path = isset($params['url']) ? $params['url'] : ''; + $path = $params['url'] ?? ''; unset($params['url']); } diff --git a/app/code/core/Mage/Core/Model/File/Storage.php b/app/code/core/Mage/Core/Model/File/Storage.php index 69d096bf752..96732676de9 100644 --- a/app/code/core/Mage/Core/Model/File/Storage.php +++ b/app/code/core/Mage/Core/Model/File/Storage.php @@ -102,7 +102,7 @@ public function getStorageModel($storage = null, $params = []) $model = Mage::getModel('core/file_storage_file'); break; case self::STORAGE_MEDIA_DATABASE: - $connection = (isset($params['connection'])) ? $params['connection'] : null; + $connection = $params['connection'] ?? null; $model = Mage::getModel('core/file_storage_database', ['connection' => $connection]); break; default: @@ -130,7 +130,7 @@ public function synchronize($storage) { if (is_array($storage) && isset($storage['type'])) { $storageDest = (int) $storage['type']; - $connection = (isset($storage['connection'])) ? $storage['connection'] : null; + $connection = $storage['connection'] ?? null; $helper = Mage::helper('core/file_storage'); // if unable to sync to internal storage from itself diff --git a/app/code/core/Mage/Core/Model/File/Storage/Database/Abstract.php b/app/code/core/Mage/Core/Model/File/Storage/Database/Abstract.php index 0c4f7e2dfc7..186bdfae446 100644 --- a/app/code/core/Mage/Core/Model/File/Storage/Database/Abstract.php +++ b/app/code/core/Mage/Core/Model/File/Storage/Database/Abstract.php @@ -36,7 +36,7 @@ abstract class Mage_Core_Model_File_Storage_Database_Abstract extends Mage_Core_ */ public function __construct($params = []) { - $connectionName = (isset($params['connection'])) ? $params['connection'] : null; + $connectionName = $params['connection'] ?? null; if (empty($connectionName)) { $connectionName = $this->getConfigConnectionName(); } diff --git a/app/code/core/Mage/Core/Model/File/Uploader.php b/app/code/core/Mage/Core/Model/File/Uploader.php index f6e3b340395..44635743fba 100644 --- a/app/code/core/Mage/Core/Model/File/Uploader.php +++ b/app/code/core/Mage/Core/Model/File/Uploader.php @@ -112,7 +112,7 @@ public function checkAllowedExtension($extension) */ public function save($destinationFolder, $newFileName = null) { - $fileName = isset($newFileName) ? $newFileName : $this->_file['name']; + $fileName = $newFileName ?? $this->_file['name']; if (strlen($fileName) > $this->_fileNameMaxLength) { throw new Exception( Mage::helper('core')->__("File name is too long. Maximum length is %s.", $this->_fileNameMaxLength) diff --git a/app/code/core/Mage/Core/Model/Input/Filter.php b/app/code/core/Mage/Core/Model/Input/Filter.php index 7fe6dc6fb7d..5c15088d26f 100644 --- a/app/code/core/Mage/Core/Model/Input/Filter.php +++ b/app/code/core/Mage/Core/Model/Input/Filter.php @@ -189,7 +189,7 @@ public function getFilters($name = null) if ($name === null) { return $this->_filters; } else { - return isset($this->_filters[$name]) ? $this->_filters[$name] : null; + return $this->_filters[$name] ?? null; } } diff --git a/app/code/core/Mage/Core/Model/Layout.php b/app/code/core/Mage/Core/Model/Layout.php index 17bfbd048c2..a062e16aa98 100644 --- a/app/code/core/Mage/Core/Model/Layout.php +++ b/app/code/core/Mage/Core/Model/Layout.php @@ -539,11 +539,7 @@ public function getAllBlocks() */ public function getBlock($name) { - if (isset($this->_blocks[$name])) { - return $this->_blocks[$name]; - } else { - return false; - } + return $this->_blocks[$name] ?? false; } /** diff --git a/app/code/core/Mage/Core/Model/Layout/Update.php b/app/code/core/Mage/Core/Model/Layout/Update.php index 63b597a30a9..ea5be7799e1 100644 --- a/app/code/core/Mage/Core/Model/Layout/Update.php +++ b/app/code/core/Mage/Core/Model/Layout/Update.php @@ -442,7 +442,7 @@ public function getFileLayoutUpdatesXml($area, $package, $theme, $storeId = null $updateFiles = []; foreach ($updates as $updateNode) { if (!empty($updateNode['file'])) { - $module = isset($updateNode['@']['module']) ? $updateNode['@']['module'] : false; + $module = $updateNode['@']['module'] ?? false; if ($module && Mage::getStoreConfigFlag('advanced/modules_disable_output/' . $module, $storeId)) { continue; } diff --git a/app/code/core/Mage/Core/Model/Message/Collection.php b/app/code/core/Mage/Core/Model/Message/Collection.php index d669ccbaccc..7606a96667a 100644 --- a/app/code/core/Mage/Core/Model/Message/Collection.php +++ b/app/code/core/Mage/Core/Model/Message/Collection.php @@ -135,7 +135,7 @@ public function deleteMessageByIdentifier($identifier) public function getItems($type = null) { if ($type) { - return isset($this->_messages[$type]) ? $this->_messages[$type] : []; + return $this->_messages[$type] ?? []; } $arrRes = []; @@ -154,7 +154,7 @@ public function getItems($type = null) */ public function getItemsByType($type) { - return isset($this->_messages[$type]) ? $this->_messages[$type] : []; + return $this->_messages[$type] ?? []; } /** diff --git a/app/code/core/Mage/Core/Model/Resource.php b/app/code/core/Mage/Core/Model/Resource.php index fc39301de3e..439b253cff4 100644 --- a/app/code/core/Mage/Core/Model/Resource.php +++ b/app/code/core/Mage/Core/Model/Resource.php @@ -324,11 +324,7 @@ public function setMappedTableName($tableName, $mappedName) */ public function getMappedTableName($tableName) { - if (isset($this->_mappedTableNames[$tableName])) { - return $this->_mappedTableNames[$tableName]; - } else { - return false; - } + return $this->_mappedTableNames[$tableName] ?? false; } /** diff --git a/app/code/core/Mage/Core/Model/Resource/Db/Collection/Abstract.php b/app/code/core/Mage/Core/Model/Resource/Db/Collection/Abstract.php index 3d42aa95bb4..1c2574e90f2 100644 --- a/app/code/core/Mage/Core/Model/Resource/Db/Collection/Abstract.php +++ b/app/code/core/Mage/Core/Model/Resource/Db/Collection/Abstract.php @@ -214,7 +214,7 @@ protected function _initSelectFields() if ($column instanceof Zend_Db_Expr) { $column = $column->__toString(); } - $key = ($alias !== null ? $alias : $column); + $key = $alias ?? $column; $columnsToSelect[$key] = $columnEntry; } } diff --git a/app/code/core/Mage/Core/Model/Resource/Resource.php b/app/code/core/Mage/Core/Model/Resource/Resource.php index c3145f9b14c..ae8ded2cff8 100644 --- a/app/code/core/Mage/Core/Model/Resource/Resource.php +++ b/app/code/core/Mage/Core/Model/Resource/Resource.php @@ -94,7 +94,7 @@ public function getDbVersion($resName) return false; } $this->_loadVersionData('db'); - return isset(self::$_versions[$resName]) ? self::$_versions[$resName] : false; + return self::$_versions[$resName] ?? false; } /** @@ -138,7 +138,7 @@ public function getDataVersion($resName) $this->_loadVersionData('data'); - return isset(self::$_dataVersions[$resName]) ? self::$_dataVersions[$resName] : false; + return self::$_dataVersions[$resName] ?? false; } /** diff --git a/app/code/core/Mage/Core/Model/Resource/Setup.php b/app/code/core/Mage/Core/Model/Resource/Setup.php index f1a1ee2f8b6..f2cd60c8fdd 100644 --- a/app/code/core/Mage/Core/Model/Resource/Setup.php +++ b/app/code/core/Mage/Core/Model/Resource/Setup.php @@ -733,9 +733,7 @@ public function getTableRow($table, $idField, $id, $field = null, $parentField = if (is_null($field)) { return $this->_setupCache[$table][$parentId][$id]; } - return isset($this->_setupCache[$table][$parentId][$id][$field]) - ? $this->_setupCache[$table][$parentId][$id][$field] - : false; + return $this->_setupCache[$table][$parentId][$id][$field] ?? false; } /** diff --git a/app/code/core/Mage/Core/Model/Session.php b/app/code/core/Mage/Core/Model/Session.php index 67f15279585..cd664e1b658 100644 --- a/app/code/core/Mage/Core/Model/Session.php +++ b/app/code/core/Mage/Core/Model/Session.php @@ -45,7 +45,7 @@ class Mage_Core_Model_Session extends Mage_Core_Model_Session_Abstract */ public function __construct($data = []) { - $name = isset($data['name']) ? $data['name'] : null; + $name = $data['name'] ?? null; $this->init('core', $name); } diff --git a/app/code/core/Mage/Core/Model/Translate.php b/app/code/core/Mage/Core/Model/Translate.php index 6406fcd12e6..44acd427c73 100644 --- a/app/code/core/Mage/Core/Model/Translate.php +++ b/app/code/core/Mage/Core/Model/Translate.php @@ -195,10 +195,7 @@ public function setConfig($config) */ public function getConfig($key) { - if (isset($this->_config[$key])) { - return $this->_config[$key]; - } - return null; + return $this->_config[$key] ?? null; } /** diff --git a/app/code/core/Mage/Core/Model/Translate/Inline.php b/app/code/core/Mage/Core/Model/Translate/Inline.php index e34609ef15e..1f1088b3a1a 100644 --- a/app/code/core/Mage/Core/Model/Translate/Inline.php +++ b/app/code/core/Mage/Core/Model/Translate/Inline.php @@ -310,11 +310,7 @@ protected function _getTagLocation($matches, $options) { $tagName = strtolower($options['tagName']); - if (isset($options['tagList'][$tagName])) { - return $options['tagList'][$tagName]; - } - - return ucfirst($tagName) . ' Text'; + return $options['tagList'][$tagName] ?? (ucfirst($tagName) . ' Text'); } /** diff --git a/app/code/core/Mage/Core/Model/Url.php b/app/code/core/Mage/Core/Model/Url.php index 9584f49f211..876f2518350 100644 --- a/app/code/core/Mage/Core/Model/Url.php +++ b/app/code/core/Mage/Core/Model/Url.php @@ -1193,7 +1193,7 @@ public function sessionVarCallback($match) return $match[1] . $session->getSessionIdQueryParam() . '=' . $session->getEncryptedSessionId() - . (isset($match[3]) ? $match[3] : ''); + . ($match[3] ?? ''); } else { if ($match[1] == '?' && isset($match[3])) { return '?'; diff --git a/app/code/core/Mage/Core/Model/Url/Rewrite/Request.php b/app/code/core/Mage/Core/Model/Url/Rewrite/Request.php index 694946338c7..ddc70957885 100644 --- a/app/code/core/Mage/Core/Model/Url/Rewrite/Request.php +++ b/app/code/core/Mage/Core/Model/Url/Rewrite/Request.php @@ -356,10 +356,7 @@ protected function _processRewriteUrl($url) */ protected function _getRouter($name) { - if (isset($this->_routers[$name])) { - return $this->_routers[$name]; - } - return false; + return $this->_routers[$name] ?? false; } /** diff --git a/app/code/core/Mage/Customer/Helper/Address.php b/app/code/core/Mage/Customer/Helper/Address.php index 54245170ae9..a5472d43a15 100644 --- a/app/code/core/Mage/Customer/Helper/Address.php +++ b/app/code/core/Mage/Customer/Helper/Address.php @@ -177,8 +177,7 @@ public function getAttributes() public function getAttributeValidationClass($attributeCode) { /** @var Mage_Customer_Model_Attribute $attribute */ - $attribute = isset($this->_attributes[$attributeCode]) ? $this->_attributes[$attributeCode] - : Mage::getSingleton('eav/config')->getAttribute('customer_address', $attributeCode); + $attribute = $this->_attributes[$attributeCode] ?? Mage::getSingleton('eav/config')->getAttribute('customer_address', $attributeCode); $class = $attribute ? $attribute->getFrontend()->getClass() : ''; if (in_array($attributeCode, ['firstname', 'middlename', 'lastname', 'prefix', 'suffix', 'taxvat'])) { diff --git a/app/code/core/Mage/Customer/Model/Address/Api.php b/app/code/core/Mage/Customer/Model/Address/Api.php index d9d432bec81..f3853c2f3cb 100644 --- a/app/code/core/Mage/Customer/Model/Address/Api.php +++ b/app/code/core/Mage/Customer/Model/Address/Api.php @@ -58,7 +58,7 @@ public function items($customerId) $row = []; foreach ($this->_mapAttributes as $attributeAlias => $attributeCode) { - $row[$attributeAlias] = isset($data[$attributeCode]) ? $data[$attributeCode] : null; + $row[$attributeAlias] = $data[$attributeCode] ?? null; } foreach ($this->getAllowedAttributes($address) as $attributeCode => $attribute) { diff --git a/app/code/core/Mage/Customer/Model/Api2/Customer/Address/Rest.php b/app/code/core/Mage/Customer/Model/Api2/Customer/Address/Rest.php index dffa0cc3034..5c738c07bc4 100644 --- a/app/code/core/Mage/Customer/Model/Api2/Customer/Address/Rest.php +++ b/app/code/core/Mage/Customer/Model/Api2/Customer/Address/Rest.php @@ -150,7 +150,7 @@ protected function _update(array $data) if (isset($data['region'])) { $data['region'] = $this->_getRegionIdByNameOrCode( $data['region'], - isset($data['country_id']) ? $data['country_id'] : $address->getCountryId() + $data['country_id'] ?? $address->getCountryId() ); $data['region_id'] = null; // to avoid overwrite region during update in address model _beforeSave() } diff --git a/app/code/core/Mage/Customer/Model/Api2/Customer/Rest.php b/app/code/core/Mage/Customer/Model/Api2/Customer/Rest.php index faf492375c6..9ec99c4fcd4 100644 --- a/app/code/core/Mage/Customer/Model/Api2/Customer/Rest.php +++ b/app/code/core/Mage/Customer/Model/Api2/Customer/Rest.php @@ -82,7 +82,7 @@ protected function _retrieve() protected function _retrieveCollection() { $data = $this->_getCollectionForRetrieve()->load()->toArray(); - return isset($data['items']) ? $data['items'] : $data; + return $data['items'] ?? $data; } /** diff --git a/app/code/core/Mage/Customer/Model/Convert/Adapter/Customer.php b/app/code/core/Mage/Customer/Model/Convert/Adapter/Customer.php index 75871b57184..ece86fd4b5a 100644 --- a/app/code/core/Mage/Customer/Model/Convert/Adapter/Customer.php +++ b/app/code/core/Mage/Customer/Model/Convert/Adapter/Customer.php @@ -184,11 +184,7 @@ public function getRegionId($country, $regionName) } } - if (isset($this->_regions[$country][$regionName])) { - return $this->_regions[$country][$regionName]; - } - - return 0; + return $this->_regions[$country][$regionName] ?? 0; } /** @@ -460,7 +456,7 @@ public function saveRow($importData) * Check customer group */ if (empty($importData['group']) || !isset($customerGroups[$importData['group']])) { - $value = isset($importData['group']) ? $importData['group'] : ''; + $value = $importData['group'] ?? ''; $message = Mage::helper('catalog')->__('Skipping import row, the value "%s" is not valid for the "%s" field.', $value, 'group'); Mage::throwException($message); } @@ -628,7 +624,7 @@ public function saveRow($importData) } $billingAddress->setCountryId($importData['billing_country']); - $regionName = isset($importData['billing_region']) ? $importData['billing_region'] : ''; + $regionName = $importData['billing_region'] ?? ''; if ($regionName) { $regionId = $this->getRegionId($importData['billing_country'], $regionName); $billingAddress->setRegionId($regionId); @@ -681,7 +677,7 @@ public function saveRow($importData) } $shippingAddress->setCountryId($importData['shipping_country']); - $regionName = isset($importData['shipping_region']) ? $importData['shipping_region'] : ''; + $regionName = $importData['shipping_region'] ?? ''; if ($regionName) { $regionId = $this->getRegionId($importData['shipping_country'], $regionName); $shippingAddress->setRegionId($regionId); diff --git a/app/code/core/Mage/Customer/Model/Convert/Parser/Customer.php b/app/code/core/Mage/Customer/Model/Convert/Parser/Customer.php index 9c47587994e..02a215cd0bf 100644 --- a/app/code/core/Mage/Customer/Model/Convert/Parser/Customer.php +++ b/app/code/core/Mage/Customer/Model/Convert/Parser/Customer.php @@ -442,11 +442,7 @@ protected function _getCustomerGroupCode($customer) } } - if (isset($this->_customerGroups[$customer->getGroupId()])) { - return $this->_customerGroups[$customer->getGroupId()]; - } else { - return null; - } + return $this->_customerGroups[$customer->getGroupId()] ?? null; } /** @@ -495,7 +491,7 @@ public function parse() } // get store ids - $storeIds = $this->getStoreIds(isset($row['store']) ? $row['store'] : $this->getVar('store')); + $storeIds = $this->getStoreIds($row['store'] ?? $this->getVar('store')); if (!$storeIds) { $this->addException(Mage::helper('customer')->__("Invalid store specified, skipping the record."), Varien_Convert_Exception::ERROR); continue; diff --git a/app/code/core/Mage/Customer/Model/Customer.php b/app/code/core/Mage/Customer/Model/Customer.php index c295d1921a7..0aac700f8e4 100644 --- a/app/code/core/Mage/Customer/Model/Customer.php +++ b/app/code/core/Mage/Customer/Model/Customer.php @@ -468,10 +468,7 @@ public function getAttributes() public function getAttribute($attributeCode) { $this->getAttributes(); - if (isset($this->_attributes[$attributeCode])) { - return $this->_attributes[$attributeCode]; - } - return null; + return $this->_attributes[$attributeCode] ?? null; } /** diff --git a/app/code/core/Mage/Customer/Model/Customer/Api.php b/app/code/core/Mage/Customer/Model/Customer/Api.php index d973763a8bd..00de5b2c813 100644 --- a/app/code/core/Mage/Customer/Model/Customer/Api.php +++ b/app/code/core/Mage/Customer/Model/Customer/Api.php @@ -125,7 +125,7 @@ public function items($filters) $data = $customer->toArray(); $row = []; foreach ($this->_mapAttributes as $attributeAlias => $attributeCode) { - $row[$attributeAlias] = (isset($data[$attributeCode]) ? $data[$attributeCode] : null); + $row[$attributeAlias] = $data[$attributeCode] ?? null; } foreach ($this->getAllowedAttributes($customer) as $attributeCode => $attribute) { if (isset($data[$attributeCode])) { diff --git a/app/code/core/Mage/Customer/Model/Resource/Setup.php b/app/code/core/Mage/Customer/Model/Resource/Setup.php index 88aa7a41779..f637db9372d 100644 --- a/app/code/core/Mage/Customer/Model/Resource/Setup.php +++ b/app/code/core/Mage/Customer/Model/Resource/Setup.php @@ -73,8 +73,8 @@ public function installCustomerForms() $attributes = $entities['customer']['attributes']; foreach ($attributes as $attributeCode => $attribute) { $attributeId = $attributeIds[$customer][$attributeCode]; - $attribute['system'] = isset($attribute['system']) ? $attribute['system'] : true; - $attribute['visible'] = isset($attribute['visible']) ? $attribute['visible'] : true; + $attribute['system'] = $attribute['system'] ?? true; + $attribute['visible'] = $attribute['visible'] ?? true; if ($attribute['system'] != true || $attribute['visible'] != false) { $usedInForms = [ 'customer_account_create', @@ -101,8 +101,8 @@ public function installCustomerForms() $attributes = $entities['customer_address']['attributes']; foreach ($attributes as $attributeCode => $attribute) { $attributeId = $attributeIds[$customerAddress][$attributeCode]; - $attribute['system'] = isset($attribute['system']) ? $attribute['system'] : true; - $attribute['visible'] = isset($attribute['visible']) ? $attribute['visible'] : true; + $attribute['system'] = $attribute['system'] ?? true; + $attribute['visible'] = $attribute['visible'] ?? true; if (($attribute['system'] == true && $attribute['visible'] == false) === false) { $usedInForms = [ 'adminhtml_customer_address', diff --git a/app/code/core/Mage/Dataflow/Model/Convert/Action/Abstract.php b/app/code/core/Mage/Dataflow/Model/Convert/Action/Abstract.php index f5d60ffbda5..6979fa57863 100644 --- a/app/code/core/Mage/Dataflow/Model/Convert/Action/Abstract.php +++ b/app/code/core/Mage/Dataflow/Model/Convert/Action/Abstract.php @@ -66,10 +66,7 @@ abstract class Mage_Dataflow_Model_Convert_Action_Abstract */ public function getParam($key, $default=null) { - if (!isset($this->_params[$key])) { - return $default; - } - return $this->_params[$key]; + return $this->_params[$key] ?? $default; } /** diff --git a/app/code/core/Mage/Dataflow/Model/Convert/Container/Abstract.php b/app/code/core/Mage/Dataflow/Model/Convert/Container/Abstract.php index cfe47b08062..9c86d74d8a3 100644 --- a/app/code/core/Mage/Dataflow/Model/Convert/Container/Abstract.php +++ b/app/code/core/Mage/Dataflow/Model/Convert/Container/Abstract.php @@ -233,7 +233,7 @@ public function setBatchParams($data) public function getBatchParams($key = null) { if (!empty($key)) { - return isset($this->_batchParams[$key]) ? $this->_batchParams[$key] : null; + return $this->_batchParams[$key] ?? null; } return $this->_batchParams; } diff --git a/app/code/core/Mage/Dataflow/Model/Convert/Mapper/Column.php b/app/code/core/Mage/Dataflow/Model/Convert/Mapper/Column.php index 4e692ff141a..440fd8b1a32 100644 --- a/app/code/core/Mage/Dataflow/Model/Convert/Mapper/Column.php +++ b/app/code/core/Mage/Dataflow/Model/Convert/Mapper/Column.php @@ -130,7 +130,7 @@ public function map() $newRow = []; foreach ($attributesToSelect as $field => $mapField) { - $newRow[$mapField] = isset($row[$field]) ? $row[$field] : null; + $newRow[$mapField] = $row[$field] ?? null; } $batchExport->setBatchData($newRow) diff --git a/app/code/core/Mage/Dataflow/Model/Convert/Parser/Csv.php b/app/code/core/Mage/Dataflow/Model/Convert/Parser/Csv.php index 29333b9b3da..a80cb44d102 100644 --- a/app/code/core/Mage/Dataflow/Model/Convert/Parser/Csv.php +++ b/app/code/core/Mage/Dataflow/Model/Convert/Parser/Csv.php @@ -100,7 +100,7 @@ public function parse() $itemData = []; $countRows ++; $i = 0; foreach ($fieldNames as $field) { - $itemData[$field] = isset($csvData[$i]) ? $csvData[$i] : null; + $itemData[$field] = $csvData[$i] ?? null; $i ++; } @@ -142,7 +142,7 @@ public function parseRow($i, $line) $resultRow = []; foreach ($this->_fields as $j=>$f) { - $resultRow[$f] = isset($line[$j]) ? $line[$j] : ''; + $resultRow[$f] = $line[$j] ?? ''; } return $resultRow; } @@ -179,7 +179,7 @@ public function unparse() $row = $batchExport->getBatchData(); foreach ($fieldList as $field) { - $csvData[] = isset($row[$field]) ? $row[$field] : ''; + $csvData[] = $row[$field] ?? ''; } $csvData = $this->getCsvString($csvData); $io->write($csvData); diff --git a/app/code/core/Mage/Dataflow/Model/Convert/Parser/Xml/Excel.php b/app/code/core/Mage/Dataflow/Model/Convert/Parser/Xml/Excel.php index 7a122b4f87c..19f8312c9d3 100644 --- a/app/code/core/Mage/Dataflow/Model/Convert/Parser/Xml/Excel.php +++ b/app/code/core/Mage/Dataflow/Model/Convert/Parser/Xml/Excel.php @@ -314,7 +314,7 @@ protected function _saveParsedRow($xmlString) $i = 0; foreach ($this->_parseFieldNames as $field) { - $itemData[$field] = isset($xmlData[$i]) ? $xmlData[$i] : null; + $itemData[$field] = $xmlData[$i] ?? null; $i ++; } @@ -375,7 +375,7 @@ public function unparse() $row = $batchExport->getBatchData(); foreach ($fieldList as $field) { - $xmlData[] = isset($row[$field]) ? $row[$field] : ''; + $xmlData[] = $row[$field] ?? ''; } $xmlData = $this->_getXmlString($xmlData); $io->write($xmlData); diff --git a/app/code/core/Mage/Dataflow/Model/Mysql4/Catalogold.php b/app/code/core/Mage/Dataflow/Model/Mysql4/Catalogold.php index d59f3e6a0c9..aa1f6ec9c53 100644 --- a/app/code/core/Mage/Dataflow/Model/Mysql4/Catalogold.php +++ b/app/code/core/Mage/Dataflow/Model/Mysql4/Catalogold.php @@ -74,7 +74,7 @@ public function getProductIdBySku($sku) $this->_productsBySku[$p['sku']] = $p['entity_id']; } } - return isset($this->_productsBySku[$sku]) ? $this->_productsBySku[$sku] : false; + return $this->_productsBySku[$sku] ?? false; } public function addProductToStore($productId, $storeId) diff --git a/app/code/core/Mage/Dataflow/Model/Profile.php b/app/code/core/Mage/Dataflow/Model/Profile.php index 9044f0c54c9..d7738c2307b 100644 --- a/app/code/core/Mage/Dataflow/Model/Profile.php +++ b/app/code/core/Mage/Dataflow/Model/Profile.php @@ -454,8 +454,8 @@ public function _parseGuiData() // Need to rewrite the whole xml action format if ($import) { - $numberOfRecords = isset($p['import']['number_of_records']) ? $p['import']['number_of_records'] : 1; - $decimalSeparator = isset($p['import']['decimal_separator']) ? $p['import']['decimal_separator'] : ' . '; + $numberOfRecords = $p['import']['number_of_records'] ?? 1; + $decimalSeparator = $p['import']['decimal_separator'] ?? ' . '; $parseFileXmlInter .= ' ' . $numberOfRecords . '' . $nl; $parseFileXmlInter .= ' __('One or more invalid symbols have been specified.'), ]; - $this->_messages[] = isset($errorCodes[$response['error']['code']]) - ? $errorCodes[$response['error']['code']] - : Mage::helper('directory')->__('Currency rates can\'t be retrieved.'); + $this->_messages[] = $errorCodes[$response['error']['code']] ?? Mage::helper('directory')->__('Currency rates can\'t be retrieved.'); return false; } diff --git a/app/code/core/Mage/Downloadable/Helper/Download.php b/app/code/core/Mage/Downloadable/Helper/Download.php index 83a75c765a9..3fa9cfd249d 100644 --- a/app/code/core/Mage/Downloadable/Helper/Download.php +++ b/app/code/core/Mage/Downloadable/Helper/Download.php @@ -115,10 +115,7 @@ protected function _getHandle() $port = (int)$urlProp['port']; } - $path = '/'; - if (isset($urlProp['path'])) { - $path = $urlProp['path']; - } + $path = $urlProp['path'] ?? '/'; $query = ''; if (isset($urlProp['query'])) { $query = '?' . $urlProp['query']; diff --git a/app/code/core/Mage/Downloadable/Model/Link/Api/Uploader.php b/app/code/core/Mage/Downloadable/Model/Link/Api/Uploader.php index d4c74905afd..8632d43f6c8 100644 --- a/app/code/core/Mage/Downloadable/Model/Link/Api/Uploader.php +++ b/app/code/core/Mage/Downloadable/Model/Link/Api/Uploader.php @@ -89,7 +89,7 @@ private function _decodeFile($fileInfo) return [ 'name' => $fileInfo['name'], - 'type' => isset($fileInfo['type'])? $fileInfo['type'] : self::DEFAULT_FILE_TYPE, + 'type' => $fileInfo['type'] ?? self::DEFAULT_FILE_TYPE, 'tmp_name' => $tmpFileName, 'error' => 0, 'size' => filesize($tmpFileName) diff --git a/app/code/core/Mage/Downloadable/Model/Sales/Order/Pdf/Items/Creditmemo.php b/app/code/core/Mage/Downloadable/Model/Sales/Order/Pdf/Items/Creditmemo.php index e4bffe28aa8..2925c5d0028 100644 --- a/app/code/core/Mage/Downloadable/Model/Sales/Order/Pdf/Items/Creditmemo.php +++ b/app/code/core/Mage/Downloadable/Model/Sales/Order/Pdf/Items/Creditmemo.php @@ -106,7 +106,7 @@ public function draw() ]; // draw options value - $_printValue = isset($option['print_value']) ? $option['print_value'] : strip_tags($option['value']); + $_printValue = $option['print_value'] ?? strip_tags($option['value']); $lines[][] = [ 'text' => Mage::helper('core/string')->str_split($_printValue, 30, true, true), 'feed' => 40 diff --git a/app/code/core/Mage/Downloadable/Model/Sales/Order/Pdf/Items/Invoice.php b/app/code/core/Mage/Downloadable/Model/Sales/Order/Pdf/Items/Invoice.php index db01ecae20b..7dc27909da1 100644 --- a/app/code/core/Mage/Downloadable/Model/Sales/Order/Pdf/Items/Invoice.php +++ b/app/code/core/Mage/Downloadable/Model/Sales/Order/Pdf/Items/Invoice.php @@ -117,11 +117,7 @@ public function draw() ]; if ($option['value']) { - if (isset($option['print_value'])) { - $_printValue = $option['print_value']; - } else { - $_printValue = strip_tags($option['value']); - } + $_printValue = $option['print_value'] ?? strip_tags($option['value']); $values = explode(', ', $_printValue); foreach ($values as $value) { $lines[][] = [ diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Main/Abstract.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Main/Abstract.php index 7b7e7ae8d86..19bb9882bf9 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Main/Abstract.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Main/Abstract.php @@ -44,10 +44,7 @@ public function setAttributeObject($attribute) */ public function getAttributeObject() { - if ($this->_attribute === null) { - return Mage::registry('entity_attribute'); - } - return $this->_attribute; + return $this->_attribute ?? Mage::registry('entity_attribute'); } /** diff --git a/app/code/core/Mage/Eav/Model/Attribute.php b/app/code/core/Mage/Eav/Model/Attribute.php index ed866a84fce..728969c1add 100644 --- a/app/code/core/Mage/Eav/Model/Attribute.php +++ b/app/code/core/Mage/Eav/Model/Attribute.php @@ -142,10 +142,7 @@ public function setValidateRules($rules) protected function _getScopeValue($key) { $scopeKey = sprintf('scope_%s', $key); - if ($this->getData($scopeKey) !== null) { - return $this->getData($scopeKey); - } - return $this->getData($key); + return $this->getData($scopeKey) ?? $this->getData($key); } /** diff --git a/app/code/core/Mage/Eav/Model/Attribute/Data/Abstract.php b/app/code/core/Mage/Eav/Model/Attribute/Data/Abstract.php index aef46e84bd4..5264ead3b77 100644 --- a/app/code/core/Mage/Eav/Model/Attribute/Data/Abstract.php +++ b/app/code/core/Mage/Eav/Model/Attribute/Data/Abstract.php @@ -174,10 +174,7 @@ public function setExtractedData(array $data) public function getExtractedData($index = null) { if (!is_null($index)) { - if (isset($this->_extractedData[$index])) { - return $this->_extractedData[$index]; - } - return null; + return $this->_extractedData[$index] ?? null; } return $this->_extractedData; } @@ -491,21 +488,13 @@ protected function _getRequestValue(Zend_Controller_Request_Http $request) $params = $request->getParams(); $parts = explode('/', $this->_requestScope); foreach ($parts as $part) { - if (isset($params[$part])) { - $params = $params[$part]; - } else { - $params = []; - } + $params = $params[$part] ?? []; } } else { $params = $request->getParam($this->_requestScope); } - if (isset($params[$attrCode])) { - $value = $params[$attrCode]; - } else { - $value = false; - } + $value = $params[$attrCode] ?? false; if (!$this->_requestScopeOnly && $value === false) { $value = $request->getParam($attrCode, false); diff --git a/app/code/core/Mage/Eav/Model/Config.php b/app/code/core/Mage/Eav/Model/Config.php index daa979cb4a3..f8905def827 100644 --- a/app/code/core/Mage/Eav/Model/Config.php +++ b/app/code/core/Mage/Eav/Model/Config.php @@ -125,7 +125,7 @@ public function clear() */ protected function _load($id) { - return isset($this->_objects[$id]) ? $this->_objects[$id] : null; + return $this->_objects[$id] ?? null; } /** @@ -162,7 +162,7 @@ protected function _addEntityTypeReference($id, $code) */ protected function _getEntityTypeReference($id) { - return isset($this->_references['entity'][$id]) ? $this->_references['entity'][$id] : null; + return $this->_references['entity'][$id] ?? null; } /** @@ -188,10 +188,7 @@ protected function _addAttributeReference($id, $code, $entityTypeCode) */ protected function _getAttributeReference($id, $entityTypeCode) { - if (isset($this->_references['attribute'][$entityTypeCode][$id])) { - return $this->_references['attribute'][$entityTypeCode][$id]; - } - return null; + return $this->_references['attribute'][$entityTypeCode][$id] ?? null; } /** diff --git a/app/code/core/Mage/Eav/Model/Convert/Adapter/Entity.php b/app/code/core/Mage/Eav/Model/Convert/Adapter/Entity.php index c782dbc9fff..5306d75b2b9 100644 --- a/app/code/core/Mage/Eav/Model/Convert/Adapter/Entity.php +++ b/app/code/core/Mage/Eav/Model/Convert/Adapter/Entity.php @@ -95,11 +95,7 @@ public function setFilter($attrFilterArray, $attrToDb = null, $bind = null, $joi foreach ($attrFilterArray as $key => $type) { if (is_array($type)) { - if (isset($type['bind'])) { - $bind = $type['bind']; - } else { - $bind = $defBind; - } + $bind = $type['bind'] ?? $defBind; $type = $type['type']; } @@ -112,7 +108,7 @@ public function setFilter($attrFilterArray, $attrToDb = null, $bind = null, $joi } } - $keyDB = (isset($this->_attrToDb[$key])) ? $this->_attrToDb[$key] : $key; + $keyDB = $this->_attrToDb[$key] ?? $key; $exp = explode('/', $key); @@ -129,7 +125,7 @@ public function setFilter($attrFilterArray, $attrToDb = null, $bind = null, $joi } $keyDB = str_replace('/', '_', $keyDB); } else { - $val = isset($filters[$key]) ? $filters[$key] : null; + $val = $filters[$key] ?? null; } if (is_null($val)) { continue; @@ -172,8 +168,8 @@ public function setFilter($attrFilterArray, $attrToDb = null, $bind = null, $joi case 'datetimeFromTo': $attr = [ 'attribute' => $keyDB, - 'from' => isset($val['from']) ? $val['from'] : null, - 'to' => isset($val['to']) ? $val['to'] : null, + 'from' => $val['from'] ?? null, + 'to' => $val['to'] ?? null, 'datetime' => true ]; break; @@ -224,11 +220,11 @@ public function setJoinAttr($joinAttr) { if (is_array($joinAttr)) { $joinArrAttr = []; - $joinArrAttr['attribute'] = isset($joinAttr['attribute']) ? $joinAttr['attribute'] : null; + $joinArrAttr['attribute'] = $joinAttr['attribute'] ?? null; $joinArrAttr['alias'] = isset($joinAttr['attribute']) ? str_replace('/', '_', $joinAttr['attribute']):null; - $joinArrAttr['bind'] = isset($joinAttr['bind']) ? $joinAttr['bind'] : null; - $joinArrAttr['joinType'] = isset($joinAttr['joinType']) ? $joinAttr['joinType'] : null; - $joinArrAttr['storeId'] = isset($joinAttr['storeId']) ? $joinAttr['storeId'] : $this->getStoreId(); + $joinArrAttr['bind'] = $joinAttr['bind'] ?? null; + $joinArrAttr['joinType'] = $joinAttr['joinType'] ?? null; + $joinArrAttr['storeId'] = $joinAttr['storeId'] ?? $this->getStoreId(); $this->_joinAttr[] = $joinArrAttr; } } diff --git a/app/code/core/Mage/Eav/Model/Convert/Parser/Abstract.php b/app/code/core/Mage/Eav/Model/Convert/Parser/Abstract.php index 4cf45658af9..19b7dbdf580 100644 --- a/app/code/core/Mage/Eav/Model/Convert/Parser/Abstract.php +++ b/app/code/core/Mage/Eav/Model/Convert/Parser/Abstract.php @@ -97,7 +97,7 @@ public function getAttributeSetName($entityTypeId, $id) if (!$this->_attributeSetsById) { $this->loadAttributeSets($entityTypeId); } - return isset($this->_attributeSetsById[$id]) ? $this->_attributeSetsById[$id] : false; + return $this->_attributeSetsById[$id] ?? false; } /** @@ -110,7 +110,7 @@ public function getAttributeSetId($entityTypeId, $name) if (!$this->_attributeSetsByName) { $this->loadAttributeSets($entityTypeId); } - return isset($this->_attributeSetsByName[$name]) ? $this->_attributeSetsByName[$name] : false; + return $this->_attributeSetsByName[$name] ?? false; } /** diff --git a/app/code/core/Mage/Eav/Model/Entity/Abstract.php b/app/code/core/Mage/Eav/Model/Entity/Abstract.php index 9a6827850fd..7b7b76e4479 100644 --- a/app/code/core/Mage/Eav/Model/Entity/Abstract.php +++ b/app/code/core/Mage/Eav/Model/Entity/Abstract.php @@ -1237,11 +1237,7 @@ protected function _getStaticFieldProperties($field) ->describeTable($this->getEntityTable()); } - if (isset($this->_describeTable[$this->getEntityTable()][$field])) { - return $this->_describeTable[$this->getEntityTable()][$field]; - } - - return false; + return $this->_describeTable[$this->getEntityTable()][$field] ?? false; } /** diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute/Source/Abstract.php b/app/code/core/Mage/Eav/Model/Entity/Attribute/Source/Abstract.php index ad21db26ce1..8cb7146e8ab 100644 --- a/app/code/core/Mage/Eav/Model/Entity/Attribute/Source/Abstract.php +++ b/app/code/core/Mage/Eav/Model/Entity/Attribute/Source/Abstract.php @@ -76,14 +76,11 @@ public function getOptionText($value) if (count($options)) { foreach ($options as $option) { if (isset($option['value']) && $option['value'] == $value) { - return isset($option['label']) ? $option['label'] : $option['value']; + return $option['label'] ?? $option['value']; } } // End } - if (isset($options[$value])) { - return $options[$value]; - } - return false; + return $options[$value] ?? false; } /** diff --git a/app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php b/app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php index b8b406d0374..4c361808ac1 100644 --- a/app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php +++ b/app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php @@ -630,11 +630,7 @@ public function joinAttribute($alias, $attribute, $bind, $filter = null, $joinTy $entity = $attribute->getEntity(); } elseif (is_string($entity)) { // retrieve cached entity if possible - if (isset($this->_joinEntities[$entity])) { - $entity = $this->_joinEntities[$entity]; - } else { - $entity = Mage::getModel('eav/entity')->setType($attrArr[0]); - } + $entity = $this->_joinEntities[$entity] ?? Mage::getModel('eav/entity')->setType($attrArr[0]); } if (!$entity || !$entity->getTypeId()) { throw Mage::exception('Mage_Eav', Mage::helper('eav')->__('Invalid entity type')); @@ -1404,12 +1400,7 @@ protected function _getAttributeConditionSql($attribute, $condition, $joinType = ); } else { $this->_addAttributeJoin($attribute, $joinType); - if (isset($this->_joinAttributes[$attribute]['condition_alias'])) { - $field = $this->_joinAttributes[$attribute]['condition_alias']; - } else { - $field = $this->_getAttributeTableAlias($attribute) . '.value'; - } - + $field = $this->_joinAttributes[$attribute]['condition_alias'] ?? ($this->_getAttributeTableAlias($attribute) . '.value'); $conditionSql = $this->_getConditionSql($field, $condition); } diff --git a/app/code/core/Mage/Eav/Model/Entity/Setup.php b/app/code/core/Mage/Eav/Model/Entity/Setup.php index de0543b39a3..a6928739a62 100644 --- a/app/code/core/Mage/Eav/Model/Entity/Setup.php +++ b/app/code/core/Mage/Eav/Model/Entity/Setup.php @@ -613,7 +613,7 @@ protected function _getValue($array, $key, $default = null) if (isset($array[$key]) && is_bool($array[$key])) { $array[$key] = (int) $array[$key]; } - return isset($array[$key]) ? $array[$key] : $default; + return $array[$key] ?? $default; } /** @@ -687,7 +687,7 @@ public function addAttribute($entityTypeId, $code, array $attr) $this->_validateAttributeData($data); - $sortOrder = isset($attr['sort_order']) ? $attr['sort_order'] : null; + $sortOrder = $attr['sort_order'] ?? null; $attributeId = $this->getAttribute($entityTypeId, $code, 'attribute_id'); if ($attributeId) { $this->updateAttribute($entityTypeId, $attributeId, $data, null, $sortOrder); @@ -759,13 +759,13 @@ public function addAttributeOption($option) if (!$intOptionId) { $data = [ 'attribute_id' => $option['attribute_id'], - 'sort_order' => isset($option['order'][$optionId]) ? $option['order'][$optionId] : 0, + 'sort_order' => $option['order'][$optionId] ?? 0, ]; $this->_conn->insert($optionTable, $data); $intOptionId = $this->_conn->lastInsertId($optionTable); } else { $data = [ - 'sort_order' => isset($option['order'][$optionId]) ? $option['order'][$optionId] : 0, + 'sort_order' => $option['order'][$optionId] ?? 0, ]; $this->_conn->update($optionTable, $data, ['option_id=?' => $intOptionId]); } @@ -965,7 +965,7 @@ public function getAttribute($entityTypeId, $id, $field = null) $row = $this->_setupCache[$mainTable][$entityTypeId][$id]; if ($field !== null) { - return isset($row[$field]) ? $row[$field] : false; + return $row[$field] ?? false; } return $row; @@ -1206,9 +1206,9 @@ public function installEntities($entities = null) foreach ($entities as $entityName => $entity) { $this->addEntityType($entityName, $entity); - $frontendPrefix = isset($entity['frontend_prefix']) ? $entity['frontend_prefix'] : ''; - $backendPrefix = isset($entity['backend_prefix']) ? $entity['backend_prefix'] : ''; - $sourcePrefix = isset($entity['source_prefix']) ? $entity['source_prefix'] : ''; + $frontendPrefix = $entity['frontend_prefix'] ?? ''; + $backendPrefix = $entity['backend_prefix'] ?? ''; + $sourcePrefix = $entity['source_prefix'] ?? ''; foreach ($entity['attributes'] as $attrCode => $attr) { if (!empty($attr['backend'])) { diff --git a/app/code/core/Mage/Eav/Model/Resource/Config.php b/app/code/core/Mage/Eav/Model/Resource/Config.php index 01b99bf43f8..a06c52e820d 100644 --- a/app/code/core/Mage/Eav/Model/Resource/Config.php +++ b/app/code/core/Mage/Eav/Model/Resource/Config.php @@ -101,11 +101,9 @@ public function fetchEntityTypeData($entityType) $this->_loadTypes(); if (is_numeric($entityType)) { - $info = isset(self::$_entityTypes['by_id'][$entityType]) - ? self::$_entityTypes['by_id'][$entityType] : null; + $info = self::$_entityTypes['by_id'][$entityType] ?? null; } else { - $info = isset(self::$_entityTypes['by_code'][$entityType]) - ? self::$_entityTypes['by_code'][$entityType] : null; + $info = self::$_entityTypes['by_code'][$entityType] ?? null; } $data = []; diff --git a/app/code/core/Mage/Eav/Model/Resource/Entity/Attribute/Collection.php b/app/code/core/Mage/Eav/Model/Resource/Entity/Attribute/Collection.php index 8e1ddabbd08..9b5e12f4913 100644 --- a/app/code/core/Mage/Eav/Model/Resource/Entity/Attribute/Collection.php +++ b/app/code/core/Mage/Eav/Model/Resource/Entity/Attribute/Collection.php @@ -358,11 +358,7 @@ protected function _addSetInfo() } foreach ($this->_data as &$attributeData) { - $setInfo = []; - if (isset($attributeToSetInfo[$attributeData['attribute_id']])) { - $setInfo = $attributeToSetInfo[$attributeData['attribute_id']]; - } - + $setInfo = $attributeToSetInfo[$attributeData['attribute_id']] ?? []; $attributeData['attribute_set_info'] = $setInfo; } diff --git a/app/code/core/Mage/Eav/Model/Resource/Entity/Attribute/Set.php b/app/code/core/Mage/Eav/Model/Resource/Entity/Attribute/Set.php index 3e9de4fde60..994d1dafa01 100644 --- a/app/code/core/Mage/Eav/Model/Resource/Entity/Attribute/Set.php +++ b/app/code/core/Mage/Eav/Model/Resource/Entity/Attribute/Set.php @@ -135,9 +135,7 @@ public function getSetInfo(array $attributeIds, $setId = null) } foreach ($attributeIds as $atttibuteId) { - $setInfo[$atttibuteId] = isset($attributeToSetInfo[$atttibuteId]) - ? $attributeToSetInfo[$atttibuteId] - : []; + $setInfo[$atttibuteId] = $attributeToSetInfo[$atttibuteId] ?? []; } return $setInfo; diff --git a/app/code/core/Mage/ImportExport/Model/Export/Entity/Customer.php b/app/code/core/Mage/ImportExport/Model/Export/Entity/Customer.php index e75fe77e853..49fcc387231 100644 --- a/app/code/core/Mage/ImportExport/Model/Export/Entity/Customer.php +++ b/app/code/core/Mage/ImportExport/Model/Export/Entity/Customer.php @@ -210,14 +210,8 @@ protected function _prepareExport() array_keys($defaultAddrMap) )); foreach ($collection as $customerId => $customer) { - $customerAddress = []; - if (isset($customerAddrs[$customerId])) { - $customerAddress = $customerAddrs[$customerId]; - } - $addressMultiselect= []; - if (isset($addrAttributeMultiSelect[$customerId])) { - $addressMultiselect = $addrAttributeMultiSelect[$customerId]; - } + $customerAddress = $customerAddrs[$customerId] ?? []; + $addressMultiselect = $addrAttributeMultiSelect[$customerId] ?? []; $row = $this->_prepareExportRow($customer, $customerAttributeMultiSelect); $defaultAddrs = $this->_prepareDefaultAddress($customer); @@ -414,9 +408,7 @@ protected function _prepareExportRow($customer, &$attributeMultiSelect) $row[$attrCode] = $attrValue; } } - $row[self::COL_WEBSITE] = $this->_websiteIdToCode[ - $customer['website_id'] === null ? 0 : $customer['website_id'] - ]; + $row[self::COL_WEBSITE] = $this->_websiteIdToCode[$customer['website_id'] ?? 0]; $row[self::COL_STORE] = $this->_storeIdToCode[$customer['store_id']]; return $row; diff --git a/app/code/core/Mage/ImportExport/Model/Export/Entity/Product.php b/app/code/core/Mage/ImportExport/Model/Export/Entity/Product.php index c60d6637934..f0a4122cc77 100644 --- a/app/code/core/Mage/ImportExport/Model/Export/Entity/Product.php +++ b/app/code/core/Mage/ImportExport/Model/Export/Entity/Product.php @@ -806,9 +806,7 @@ protected function _prepareExport() $row = []; $productId = $option['product_id']; $optionId = $option['option_id']; - $customOptions = isset($customOptionsDataPre[$productId][$optionId]) - ? $customOptionsDataPre[$productId][$optionId] - : []; + $customOptions = $customOptionsDataPre[$productId][$optionId] ?? []; if ($defaultStoreId == $storeId) { $row['_custom_option_type'] = $option['type']; diff --git a/app/code/core/Mage/ImportExport/Model/Import/Entity/Product/Type/Configurable.php b/app/code/core/Mage/ImportExport/Model/Import/Entity/Product/Type/Configurable.php index 789492c3034..ace38b56fd8 100644 --- a/app/code/core/Mage/ImportExport/Model/Import/Entity/Product/Type/Configurable.php +++ b/app/code/core/Mage/ImportExport/Model/Import/Entity/Product/Type/Configurable.php @@ -146,11 +146,7 @@ protected function _addAttributeParams($attrSetName, array $attrParams) */ protected function _getSuperAttributeId($productId, $attributeId) { - if (isset($this->_productSuperAttrs["{$productId}_{$attributeId}"])) { - return $this->_productSuperAttrs["{$productId}_{$attributeId}"]; - } else { - return null; - } + return $this->_productSuperAttrs["{$productId}_{$attributeId}"] ?? null; } /** diff --git a/app/code/core/Mage/Index/Model/Event.php b/app/code/core/Mage/Index/Model/Event.php index 325b825075a..2ff5e6f77c3 100644 --- a/app/code/core/Mage/Index/Model/Event.php +++ b/app/code/core/Mage/Index/Model/Event.php @@ -257,7 +257,7 @@ public function getNewData($useNamespace = true) $data = []; } if ($useNamespace && $this->_dataNamespace) { - return isset($data[$this->_dataNamespace]) ? $data[$this->_dataNamespace] : []; + return $data[$this->_dataNamespace] ?? []; } return $data; } diff --git a/app/code/core/Mage/Install/Model/Installer/Console.php b/app/code/core/Mage/Install/Model/Installer/Console.php index bf9e4805d8c..1e558ac9233 100644 --- a/app/code/core/Mage/Install/Model/Installer/Console.php +++ b/app/code/core/Mage/Install/Model/Installer/Console.php @@ -162,7 +162,7 @@ public function setArgs($args = null) * Set args values */ foreach ($this->_getOptions() as $name => $option) { - $this->_args[$name] = isset($args[$name]) ? $args[$name] : ''; + $this->_args[$name] = $args[$name] ?? ''; } return true; diff --git a/app/code/core/Mage/Log/Helper/Data.php b/app/code/core/Mage/Log/Helper/Data.php index 58e3b0fe36e..4f128757f9a 100644 --- a/app/code/core/Mage/Log/Helper/Data.php +++ b/app/code/core/Mage/Log/Helper/Data.php @@ -45,8 +45,7 @@ class Mage_Log_Helper_Data extends Mage_Core_Helper_Abstract */ public function __construct(array $data = []) { - $this->_logLevel = isset($data['log_level']) ? $data['log_level'] - : intval(Mage::getStoreConfig(self::XML_PATH_LOG_ENABLED)); + $this->_logLevel = $data['log_level'] ?? intval(Mage::getStoreConfig(self::XML_PATH_LOG_ENABLED)); } /** diff --git a/app/code/core/Mage/Log/Model/Resource/Visitor.php b/app/code/core/Mage/Log/Model/Resource/Visitor.php index bb25e5ff8df..c3e72e255c2 100644 --- a/app/code/core/Mage/Log/Model/Resource/Visitor.php +++ b/app/code/core/Mage/Log/Model/Resource/Visitor.php @@ -41,8 +41,7 @@ class Mage_Log_Model_Resource_Visitor extends Mage_Core_Model_Resource_Db_Abstra public function __construct(array $data = []) { parent::__construct(); - $this->_urlLoggingCondition = isset($data['log_condition']) - ? $data['log_condition'] : Mage::helper('log'); + $this->_urlLoggingCondition = $data['log_condition'] ?? Mage::helper('log'); } protected function _construct() diff --git a/app/code/core/Mage/Log/Model/Resource/Visitor/Collection.php b/app/code/core/Mage/Log/Model/Resource/Visitor/Collection.php index 34ba3fe22d3..6139748a058 100644 --- a/app/code/core/Mage/Log/Model/Resource/Visitor/Collection.php +++ b/app/code/core/Mage/Log/Model/Resource/Visitor/Collection.php @@ -207,11 +207,7 @@ public function addFieldToFilter($fieldName, $condition = null) */ protected function _getFieldMap($fieldName) { - if (isset($this->_fieldMap[$fieldName])) { - return $this->_fieldMap[$fieldName]; - } else { - return 'main_table.' . $fieldName; - } + return $this->_fieldMap[$fieldName] ?? ('main_table.' . $fieldName); } /** diff --git a/app/code/core/Mage/Media/Model/Image.php b/app/code/core/Mage/Media/Model/Image.php index 91ca628052e..53c15503036 100644 --- a/app/code/core/Mage/Media/Model/Image.php +++ b/app/code/core/Mage/Media/Model/Image.php @@ -216,11 +216,7 @@ public function setParam($param, $value = null) */ public function getParam($param) { - if (isset($this->_params[$param])) { - return $this->_params[$param]; - } - - return null; + return $this->_params[$param] ?? null; } /** diff --git a/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizeController.php b/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizeController.php index 6919d0b5e19..43d3e901fc5 100644 --- a/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizeController.php +++ b/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizeController.php @@ -252,8 +252,8 @@ protected function _checkLoginIsEmpty() $action = $this->getRequest()->getActionName(); if (($action == 'index' || $action == 'simple') && $this->getRequest()->getPost('login')) { $postLogin = $this->getRequest()->getPost('login'); - $username = isset($postLogin['username']) ? $postLogin['username'] : ''; - $password = isset($postLogin['password']) ? $postLogin['password'] : ''; + $username = $postLogin['username'] ?? ''; + $password = $postLogin['password'] ?? ''; if (empty($username) || empty($password)) { $error = true; } diff --git a/app/code/core/Mage/Page/Model/Config.php b/app/code/core/Mage/Page/Model/Config.php index cda98c2849b..6681cbd2002 100644 --- a/app/code/core/Mage/Page/Model/Config.php +++ b/app/code/core/Mage/Page/Model/Config.php @@ -99,11 +99,7 @@ public function getPageLayout($layoutCode) { $this->_initPageLayouts(); - if (isset($this->_pageLayouts[$layoutCode])) { - return $this->_pageLayouts[$layoutCode]; - } - - return false; + return $this->_pageLayouts[$layoutCode] ?? false; } /** diff --git a/app/code/core/Mage/Paygate/Model/Authorizenet.php b/app/code/core/Mage/Paygate/Model/Authorizenet.php index 2bcad56333d..d78754af74e 100644 --- a/app/code/core/Mage/Paygate/Model/Authorizenet.php +++ b/app/code/core/Mage/Paygate/Model/Authorizenet.php @@ -1315,7 +1315,7 @@ protected function _postRequest(Varien_Object $request) ->setCustomerId($r[12]) ->setMd5Hash($r[37]) ->setCardCodeResponseCode($r[38]) - ->setCAVVResponseCode( (isset($r[39])) ? $r[39] : null) + ->setCAVVResponseCode($r[39] ?? null) ->setSplitTenderId($r[52]) ->setAccNumber($r[50]) ->setCardType($r[51]) diff --git a/app/code/core/Mage/Payment/Block/Info/Cc.php b/app/code/core/Mage/Payment/Block/Info/Cc.php index ee9d7bfe947..6a22be26d68 100644 --- a/app/code/core/Mage/Payment/Block/Info/Cc.php +++ b/app/code/core/Mage/Payment/Block/Info/Cc.php @@ -36,10 +36,7 @@ public function getCcTypeName() { $types = Mage::getSingleton('payment/config')->getCcTypes(); $ccType = $this->getInfo()->getCcType(); - if (isset($types[$ccType])) { - return $types[$ccType]; - } - return (empty($ccType)) ? Mage::helper('payment')->__('N/A') : $ccType; + return $types[$ccType] ?? (empty($ccType) ? Mage::helper('payment')->__('N/A') : $ccType); } /** diff --git a/app/code/core/Mage/Payment/Model/Info.php b/app/code/core/Mage/Payment/Model/Info.php index 66ed4d9e3b6..c4fac4571ea 100644 --- a/app/code/core/Mage/Payment/Model/Info.php +++ b/app/code/core/Mage/Payment/Model/Info.php @@ -174,7 +174,7 @@ public function getAdditionalInformation($key = null) if ($key === null) { return $this->_additionalInformation; } - return isset($this->_additionalInformation[$key]) ? $this->_additionalInformation[$key] : null; + return $this->_additionalInformation[$key] ?? null; } /** diff --git a/app/code/core/Mage/Payment/Model/Method/Cc.php b/app/code/core/Mage/Payment/Model/Method/Cc.php index b45bf2d68be..44c01ff3d25 100644 --- a/app/code/core/Mage/Payment/Model/Method/Cc.php +++ b/app/code/core/Mage/Payment/Model/Method/Cc.php @@ -149,7 +149,7 @@ public function validate() //validate credit card verification number if ($errorMsg === false && $this->hasVerification()) { $verifcationRegEx = $this->getVerificationRegEx(); - $regExp = isset($verifcationRegEx[$info->getCcType()]) ? $verifcationRegEx[$info->getCcType()] : ''; + $regExp = $verifcationRegEx[$info->getCcType()] ?? ''; if (!$info->getCcCid() || !$regExp || !preg_match($regExp, $info->getCcCid())) { $errorMsg = Mage::helper('payment')->__('Please enter a valid credit card verification number.'); } diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Deprecated.php b/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Deprecated.php index 2feb21c8823..d70e9be777c 100644 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Deprecated.php +++ b/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Deprecated.php @@ -37,7 +37,7 @@ class Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Deprecated protected function _getWasActiveConfigPath(Varien_Data_Form_Element_Abstract $element) { $groupConfig = $this->getGroup($element)->asArray(); - return isset($groupConfig['was_enabled_path']) ? $groupConfig['was_enabled_path'] : ''; + return $groupConfig['was_enabled_path'] ?? ''; } /** diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Expanded.php b/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Expanded.php index 483b642e8ab..33063df7c19 100644 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Expanded.php +++ b/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Expanded.php @@ -37,10 +37,6 @@ class Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Expanded protected function _getCollapseState($element) { $extra = Mage::getSingleton('admin/session')->getUser()->getExtra(); - if (isset($extra['configState'][$element->getId()])) { - return $extra['configState'][$element->getId()]; - } - - return true; + return $extra['configState'][$element->getId()] ?? true; } } diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Global.php b/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Global.php index bbb50bd3898..04cfd13c3d5 100644 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Global.php +++ b/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Global.php @@ -59,7 +59,7 @@ public function render(Varien_Data_Form_Element_Abstract $fieldset) $originalData = $fieldset->getOriginalData(); $this->addData([ 'fieldset_label' => $fieldset->getLegend(), - 'fieldset_help_url' => isset($originalData['help_url']) ? $originalData['help_url'] : '', + 'fieldset_help_url' => $originalData['help_url'] ?? '', ]); return $this->toHtml(); } @@ -82,10 +82,7 @@ public function getElements() */ public function getElement($elementId) { - if (isset($this->_elements[$elementId])) { - return $this->_elements[$elementId]; - } - return false; + return $this->_elements[$elementId] ?? false; } /** @@ -158,7 +155,7 @@ public function getElementComment(Varien_Data_Form_Element_Abstract $element) public function getElementOriginalData(Varien_Data_Form_Element_Abstract $element, $key) { $data = $element->getOriginalData(); - return isset($data[$key]) ? $data[$key] : ''; + return $data[$key] ?? ''; } /** diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/PathDependent.php b/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/PathDependent.php index a8ba264d33a..5c2484fa539 100644 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/PathDependent.php +++ b/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/PathDependent.php @@ -36,7 +36,7 @@ class Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_PathDependent */ public function hasActivePathDependencies($groupConfig) { - $activityPath = isset($groupConfig['hide_case_path']) ? $groupConfig['hide_case_path'] : ''; + $activityPath = $groupConfig['hide_case_path'] ?? ''; return !empty($activityPath) && (bool)(string)$this->_getConfigDataModel()->getConfigDataValue($activityPath); } diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Payment.php b/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Payment.php index 5e6525891a8..c694096931d 100644 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Payment.php +++ b/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Payment.php @@ -50,7 +50,7 @@ protected function _getFrontendClass($element) protected function _isPaymentEnabled($element, $configCallback = null) { $groupConfig = $this->getGroup($element)->asArray(); - $activityPath = isset($groupConfig['activity_path']) ? $groupConfig['activity_path'] : ''; + $activityPath = $groupConfig['activity_path'] ?? ''; if (empty($activityPath)) { return false; diff --git a/app/code/core/Mage/Paypal/Model/Api/Abstract.php b/app/code/core/Mage/Paypal/Model/Api/Abstract.php index d8ee4d35654..bae8a98519c 100644 --- a/app/code/core/Mage/Paypal/Model/Api/Abstract.php +++ b/app/code/core/Mage/Paypal/Model/Api/Abstract.php @@ -537,7 +537,7 @@ protected function _importStreetFromAddress(Varien_Object $address, array &$to) $i = 0; foreach ($keys as $key) { - $to[$key] = isset($street[$i]) ? $street[$i]: ''; + $to[$key] = $street[$i] ?? ''; $i++; } } diff --git a/app/code/core/Mage/Paypal/Model/Api/Nvp.php b/app/code/core/Mage/Paypal/Model/Api/Nvp.php index 39def2e5146..1d262165444 100644 --- a/app/code/core/Mage/Paypal/Model/Api/Nvp.php +++ b/app/code/core/Mage/Paypal/Model/Api/Nvp.php @@ -1052,8 +1052,8 @@ protected function _handleCallErrors($response) $errorMessages = implode(' ', array_values($errorMessages)); $exceptionLogMessage = sprintf('PayPal NVP gateway errors: %s Correlation ID: %s. Version: %s.', $errorMessages, - isset($response['CORRELATIONID']) ? $response['CORRELATIONID'] : '', - isset($response['VERSION']) ? $response['VERSION'] : '' + $response['CORRELATIONID'] ?? '', + $response['VERSION'] ?? '' ); $exception = new $exceptionClass($exceptionLogMessage, $exceptionCode); @@ -1329,10 +1329,7 @@ protected function _importAddresses(array $to) */ protected function _filterCcType($value) { - if (isset($this->_supportedCcTypes[$value])) { - return $this->_supportedCcTypes[$value]; - } - return ''; + return $this->_supportedCcTypes[$value] ?? ''; } /** diff --git a/app/code/core/Mage/Paypal/Model/Config.php b/app/code/core/Mage/Paypal/Model/Config.php index 42d0c15b3e6..658b4012b17 100644 --- a/app/code/core/Mage/Paypal/Model/Config.php +++ b/app/code/core/Mage/Paypal/Model/Config.php @@ -924,7 +924,7 @@ public function getCountryMethods($countryCode = null) if ($countryCode === null) { return $countryMethods; } - return isset($countryMethods[$countryCode]) ? $countryMethods[$countryCode] : $countryMethods['other']; + return $countryMethods[$countryCode] ?? $countryMethods['other']; } /** diff --git a/app/code/core/Mage/Paypal/Model/Express.php b/app/code/core/Mage/Paypal/Model/Express.php index 65a14b3c82a..579b35a36b9 100644 --- a/app/code/core/Mage/Paypal/Model/Express.php +++ b/app/code/core/Mage/Paypal/Model/Express.php @@ -540,7 +540,7 @@ public function assignData($data) $result = parent::assignData($data); $key = Mage_Paypal_Model_Express_Checkout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT; if (is_array($data)) { - $this->getInfoInstance()->setAdditionalInformation($key, isset($data[$key]) ? $data[$key] : null); + $this->getInfoInstance()->setAdditionalInformation($key, $data[$key] ?? null); } elseif ($data instanceof Varien_Object) { $this->getInfoInstance()->setAdditionalInformation($key, $data->getData($key)); diff --git a/app/code/core/Mage/Paypal/Model/Hostedpro.php b/app/code/core/Mage/Paypal/Model/Hostedpro.php index c13819470f5..bd556d6155e 100644 --- a/app/code/core/Mage/Paypal/Model/Hostedpro.php +++ b/app/code/core/Mage/Paypal/Model/Hostedpro.php @@ -188,10 +188,7 @@ protected function _sendFormUrlRequest(Mage_Paypal_Model_Hostedpro_Request $requ $api = $this->_pro->getApi(); $response = $api->call(self::BM_BUTTON_METHOD, $request->getRequestData()); - if (!isset($response['EMAILLINK'])) { - return false; - } - return $response['EMAILLINK']; + return $response['EMAILLINK'] ?? false; } /** diff --git a/app/code/core/Mage/Paypal/Model/Hostedpro/Request.php b/app/code/core/Mage/Paypal/Model/Hostedpro/Request.php index c2c078c8ded..7ade9f0e309 100644 --- a/app/code/core/Mage/Paypal/Model/Hostedpro/Request.php +++ b/app/code/core/Mage/Paypal/Model/Hostedpro/Request.php @@ -195,8 +195,8 @@ protected function _getShippingAddress(Varien_Object $address) $street = Mage::helper('customer/address') ->convertStreetLines($address->getStreet(), 2); - $request['address1'] = isset($street[0]) ? $street[0]: ''; - $request['address2'] = isset($street[1]) ? $street[1]: ''; + $request['address1'] = $street[0] ?? ''; + $request['address2'] = $street[1] ?? ''; return $request; } @@ -222,8 +222,8 @@ protected function _getBillingAddress(Varien_Object $address) $street = Mage::helper('customer/address') ->convertStreetLines($address->getStreet(), 2); - $request['billing_address1'] = isset($street[0]) ? $street[0]: ''; - $request['billing_address2'] = isset($street[1]) ? $street[1]: ''; + $request['billing_address1'] = $street[0] ?? ''; + $request['billing_address2'] = $street[1] ?? ''; return $request; } diff --git a/app/code/core/Mage/Paypal/Model/Ipn.php b/app/code/core/Mage/Paypal/Model/Ipn.php index a2293c181b4..25a658fbe4e 100644 --- a/app/code/core/Mage/Paypal/Model/Ipn.php +++ b/app/code/core/Mage/Paypal/Model/Ipn.php @@ -85,7 +85,7 @@ public function getRequestData($key = null) if ($key === null) { return $this->_request; } - return isset($this->_request[$key]) ? $this->_request[$key] : null; + return $this->_request[$key] ?? null; } /** @@ -275,7 +275,7 @@ protected function _processOrder() $this->_info = Mage::getSingleton('paypal/info'); try { // Handle payment_status - $transactionType = isset($this->_request['txn_type']) ? $this->_request['txn_type'] : null; + $transactionType = $this->_request['txn_type'] ?? null; switch ($transactionType) { // handle new case created case Mage_Paypal_Model_Info::TXN_TYPE_NEW_CASE: @@ -303,7 +303,7 @@ protected function _processOrder() */ protected function _registerAdjustment() { - $reasonCode = isset($this->_request['reason_code']) ? $this->_request['reason_code'] : null; + $reasonCode = $this->_request['reason_code'] ?? null; $reasonComment = $this->_info::explainReasonCode($reasonCode); $notificationAmount = $this->_order->getBaseCurrency()->formatTxt($this->_request['mc_gross']); /** @@ -320,11 +320,11 @@ protected function _registerAdjustment() */ protected function _registerDispute() { - $reasonCode = isset($this->_request['reason_code']) ? $this->_request['reason_code'] : null; + $reasonCode = $this->_request['reason_code'] ?? null; $reasonComment = $this->_info::explainReasonCode($reasonCode); - $caseType = isset($this->_request['case_type']) ? $this->_request['case_type'] : null; + $caseType = $this->_request['case_type'] ?? null; $caseTypeLabel = $this->_info::getCaseTypeLabel($caseType); - $caseId = isset($this->_request['case_id']) ? $this->_request['case_id'] : null; + $caseId = $this->_request['case_id'] ?? null; /** * Add IPN comment about registered dispute */ @@ -583,15 +583,12 @@ protected function _registerPaymentRefund() */ protected function _registerPaymentReversal() { - $reasonCode = isset($this->_request['reason_code']) ? $this->_request['reason_code'] : null; + $reasonCode = $this->_request['reason_code'] ?? null; $reasonComment = $this->_info::explainReasonCode($reasonCode); $notificationAmount = $this->_order ->getBaseCurrency() ->formatTxt($this->_request['mc_gross'] + $this->_request['mc_fee']); - $paymentStatus = $this->_filterPaymentStatus(isset($this->_request['payment_status']) - ? $this->_request['payment_status'] - : null - ); + $paymentStatus = $this->_filterPaymentStatus($this->_request['payment_status'] ?? null); $orderStatus = ($paymentStatus == Mage_Paypal_Model_Info::PAYMENTSTATUS_REVERSED) ? Mage_Paypal_Model_Info::ORDER_STATUS_REVERSED : Mage_Paypal_Model_Info::ORDER_STATUS_CANCELED_REVERSAL; diff --git a/app/code/core/Mage/Paypal/Model/Payflow/Request.php b/app/code/core/Mage/Paypal/Model/Payflow/Request.php index 2ab9484c28a..b830f4668e9 100644 --- a/app/code/core/Mage/Paypal/Model/Payflow/Request.php +++ b/app/code/core/Mage/Paypal/Model/Payflow/Request.php @@ -43,10 +43,10 @@ public function __call($method, $args) } switch (substr($method, 0, 3)) { case 'get' : - return $this->getData($key, isset($args[0]) ? $args[0] : null); + return $this->getData($key, $args[0] ?? null); case 'set' : - return $this->setData($key, isset($args[0]) ? $args[0] : null); + return $this->setData($key, $args[0] ?? null); case 'uns' : return $this->unsetData($key); diff --git a/app/code/core/Mage/Paypal/Model/Payment/Transaction.php b/app/code/core/Mage/Paypal/Model/Payment/Transaction.php index e936d4a474c..e704e34b53f 100644 --- a/app/code/core/Mage/Paypal/Model/Payment/Transaction.php +++ b/app/code/core/Mage/Paypal/Model/Payment/Transaction.php @@ -155,7 +155,7 @@ public function getAdditionalInformation($key = null) $info = []; } if ($key) { - return (isset($info[$key]) ? $info[$key] : null); + return $info[$key] ?? null; } return $info; } diff --git a/app/code/core/Mage/Paypal/Model/Report/Settlement/Row.php b/app/code/core/Mage/Paypal/Model/Report/Settlement/Row.php index 104577561c6..dd6a2d6eca8 100644 --- a/app/code/core/Mage/Paypal/Model/Report/Settlement/Row.php +++ b/app/code/core/Mage/Paypal/Model/Report/Settlement/Row.php @@ -100,10 +100,7 @@ public function getReferenceType($code = null) asort($types); return $types; } - if (isset($types[$code])) { - return $types[$code]; - } - return $code; + return $types[$code] ?? $code; } /** @@ -115,10 +112,7 @@ public function getReferenceType($code = null) public function getTransactionEvent($code) { $this->_generateEventLabels(); - if (isset(self::$_eventList[$code])) { - return self::$_eventList[$code]; - } - return $code; + return self::$_eventList[$code] ?? $code; } /** @@ -148,10 +142,7 @@ public function getDebitCreditText($code = null) if($code === null) { return $options; } - if (isset($options[$code])) { - return $options[$code]; - } - return $code; + return $options[$code] ?? $code; } /** diff --git a/app/code/core/Mage/Reports/Model/Totals.php b/app/code/core/Mage/Reports/Model/Totals.php index 002f06ca0b1..c7ddc5a647d 100644 --- a/app/code/core/Mage/Reports/Model/Totals.php +++ b/app/code/core/Mage/Reports/Model/Totals.php @@ -55,7 +55,7 @@ public function countTotals($grid, $from, $to) foreach ($columns as $field => $a) { if ($field !== '') { - $columns[$field]['value'] = $columns[$field]['value'] + (isset($data[$field]) ? $data[$field] : 0); + $columns[$field]['value'] += $data[$field] ?? 0; } } $count++; diff --git a/app/code/core/Mage/Review/Model/Resource/Review/Collection.php b/app/code/core/Mage/Review/Model/Resource/Review/Collection.php index 248feca6c6d..ef3fcdac117 100644 --- a/app/code/core/Mage/Review/Model/Resource/Review/Collection.php +++ b/app/code/core/Mage/Review/Model/Resource/Review/Collection.php @@ -192,7 +192,7 @@ public function addStatusFilter($status) { if (is_string($status)) { $statuses = array_flip(Mage::helper('review')->getReviewStatuses()); - $status = isset($statuses[$status]) ? $statuses[$status] : 0; + $status = $statuses[$status] ?? 0; } if (is_numeric($status)) { $this->addFilter( diff --git a/app/code/core/Mage/Rss/Helper/Data.php b/app/code/core/Mage/Rss/Helper/Data.php index d8a076218e1..21595e27a67 100644 --- a/app/code/core/Mage/Rss/Helper/Data.php +++ b/app/code/core/Mage/Rss/Helper/Data.php @@ -38,9 +38,8 @@ class Mage_Rss_Helper_Data extends Mage_Core_Helper_Abstract public function __construct(array $params = []) { - $this->_rssSession = isset($params['rss_session']) ? $params['rss_session'] : Mage::getSingleton('rss/session'); - $this->_adminSession = isset($params['admin_session']) - ? $params['admin_session'] : Mage::getSingleton('admin/session'); + $this->_rssSession = $params['rss_session'] ?? Mage::getSingleton('rss/session'); + $this->_adminSession = $params['admin_session'] ?? Mage::getSingleton('admin/session'); } /** diff --git a/app/code/core/Mage/Rule/Model/Condition/Abstract.php b/app/code/core/Mage/Rule/Model/Condition/Abstract.php index 97d5e21040b..df9b22208d6 100644 --- a/app/code/core/Mage/Rule/Model/Condition/Abstract.php +++ b/app/code/core/Mage/Rule/Model/Condition/Abstract.php @@ -200,10 +200,10 @@ public function asXml() public function loadArray($arr) { $this->setType($arr['type']); - $this->setAttribute(isset($arr['attribute']) ? $arr['attribute'] : false); - $this->setOperator(isset($arr['operator']) ? $arr['operator'] : false); - $this->setValue(isset($arr['value']) ? $arr['value'] : false); - $this->setIsValueParsed(isset($arr['is_value_parsed']) ? $arr['is_value_parsed'] : false); + $this->setAttribute($arr['attribute'] ?? false); + $this->setOperator($arr['operator'] ?? false); + $this->setValue($arr['value'] ?? false); + $this->setIsValueParsed($arr['is_value_parsed'] ?? false); return $this; } @@ -277,10 +277,7 @@ public function loadOperatorOptions() */ public function getInputType() { - if ($this->_inputType === null) { - return 'string'; - } - return $this->_inputType; + return $this->_inputType ?? 'string'; } /** diff --git a/app/code/core/Mage/Rule/Model/Condition/Combine.php b/app/code/core/Mage/Rule/Model/Condition/Combine.php index 29d12a9517b..2efc0fbc042 100644 --- a/app/code/core/Mage/Rule/Model/Condition/Combine.php +++ b/app/code/core/Mage/Rule/Model/Condition/Combine.php @@ -255,10 +255,8 @@ public function asXml($containerKey = 'conditions', $itemKey = 'condition') */ public function loadArray($arr, $key = 'conditions') { - $this->setAggregator(isset($arr['aggregator']) ? $arr['aggregator'] - : (isset($arr['attribute']) ? $arr['attribute'] : null)) - ->setValue(isset($arr['value']) ? $arr['value'] - : (isset($arr['operator']) ? $arr['operator'] : null)); + $this->setAggregator($arr['aggregator'] ?? $arr['attribute'] ?? null) + ->setValue($arr['value'] ?? $arr['operator'] ?? null); if (!empty($arr[$key]) && is_array($arr[$key])) { foreach ($arr[$key] as $condArr) { diff --git a/app/code/core/Mage/Rule/Model/Condition/Product/Abstract.php b/app/code/core/Mage/Rule/Model/Condition/Product/Abstract.php index 83d48e12e3f..871e0df35cb 100644 --- a/app/code/core/Mage/Rule/Model/Condition/Product/Abstract.php +++ b/app/code/core/Mage/Rule/Model/Condition/Product/Abstract.php @@ -476,7 +476,7 @@ public function getExplicitApply() */ public function loadArray($arr) { - $this->setAttribute(isset($arr['attribute']) ? $arr['attribute'] : false); + $this->setAttribute($arr['attribute'] ?? false); $attribute = $this->getAttributeObject(); $isContainsOperator = !empty($arr['operator']) && in_array($arr['operator'], ['{}', '!{}']); diff --git a/app/code/core/Mage/Rule/Model/Resource/Rule/Collection/Abstract.php b/app/code/core/Mage/Rule/Model/Resource/Rule/Collection/Abstract.php index 46bdb129fcf..f4405b3755b 100644 --- a/app/code/core/Mage/Rule/Model/Resource/Rule/Collection/Abstract.php +++ b/app/code/core/Mage/Rule/Model/Resource/Rule/Collection/Abstract.php @@ -85,7 +85,7 @@ protected function _afterLoad() */ public function addWebsitesToResult($flag = null) { - $flag = ($flag === null) ? true : $flag; + $flag = $flag ?? true; $this->setFlag('add_websites_to_result', $flag); return $this; } diff --git a/app/code/core/Mage/Rule/Model/Resource/Rule/Condition/SqlBuilder.php b/app/code/core/Mage/Rule/Model/Resource/Rule/Condition/SqlBuilder.php index 343608af991..c23fc7f86b3 100644 --- a/app/code/core/Mage/Rule/Model/Resource/Rule/Condition/SqlBuilder.php +++ b/app/code/core/Mage/Rule/Model/Resource/Rule/Condition/SqlBuilder.php @@ -36,9 +36,7 @@ class Mage_Rule_Model_Resource_Rule_Condition_SqlBuilder */ public function __construct(array $config = []) { - $this->_adapter = isset($config['adapter']) - ? $config['adapter'] - : Mage::getSingleton('core/resource')->getConnection(Mage_Core_Model_Resource::DEFAULT_READ_RESOURCE); + $this->_adapter = $config['adapter'] ?? Mage::getSingleton('core/resource')->getConnection(Mage_Core_Model_Resource::DEFAULT_READ_RESOURCE); } /** diff --git a/app/code/core/Mage/Sales/Block/Order/Totals.php b/app/code/core/Mage/Sales/Block/Order/Totals.php index c7742fc2970..4c2f7078f99 100644 --- a/app/code/core/Mage/Sales/Block/Order/Totals.php +++ b/app/code/core/Mage/Sales/Block/Order/Totals.php @@ -242,10 +242,7 @@ public function addTotalBefore(Varien_Object $total, $before = null) */ public function getTotal($code) { - if (isset($this->_totals[$code])) { - return $this->_totals[$code]; - } - return false; + return $this->_totals[$code] ?? false; } /** diff --git a/app/code/core/Mage/Sales/Helper/Guest.php b/app/code/core/Mage/Sales/Helper/Guest.php index 6f4c4dc0e7c..2d7368cd321 100644 --- a/app/code/core/Mage/Sales/Helper/Guest.php +++ b/app/code/core/Mage/Sales/Helper/Guest.php @@ -158,8 +158,8 @@ protected function _loadOrderByCookie($cookie = null) { if (!is_null($cookie)) { $cookieData = explode(':', base64_decode($cookie)); - $protectCode = isset($cookieData[0]) ? $cookieData[0] : null; - $incrementId = isset($cookieData[1]) ? $cookieData[1] : null; + $protectCode = $cookieData[0] ?? null; + $incrementId = $cookieData[1] ?? null; if (!empty($protectCode) && !empty($incrementId)) { /** @var Mage_Sales_Model_Order $order */ diff --git a/app/code/core/Mage/Sales/Model/Api2/Order/Comment/Rest.php b/app/code/core/Mage/Sales/Model/Api2/Order/Comment/Rest.php index b90469cad3a..0a48f54d361 100644 --- a/app/code/core/Mage/Sales/Model/Api2/Order/Comment/Rest.php +++ b/app/code/core/Mage/Sales/Model/Api2/Order/Comment/Rest.php @@ -46,7 +46,7 @@ protected function _retrieveCollection() $this->_applyCollectionModifiers($collection); $data = $collection->load()->toArray(); - return isset($data['items']) ? $data['items'] : $data; + return $data['items'] ?? $data; } /** diff --git a/app/code/core/Mage/Sales/Model/Entity/Sale/Collection.php b/app/code/core/Mage/Sales/Model/Entity/Sale/Collection.php index 1dc503250a1..b3d20dd44f1 100644 --- a/app/code/core/Mage/Sales/Model/Entity/Sale/Collection.php +++ b/app/code/core/Mage/Sales/Model/Entity/Sale/Collection.php @@ -112,7 +112,7 @@ public function load($printQuery = false, $logQuery = false) if (! empty($values)) { foreach ($values as $v) { $obj = new Varien_Object($v); - $storeName = isset($stores[$obj->getStoreId()]) ? $stores[$obj->getStoreId()] : null; + $storeName = $stores[$obj->getStoreId()] ?? null; $this->_items[ $v['store_id'] ] = $obj; $this->_items[ $v['store_id'] ]->setStoreName($storeName); diff --git a/app/code/core/Mage/Sales/Model/Order.php b/app/code/core/Mage/Sales/Model/Order.php index 085174a9fe3..aadc27276fa 100644 --- a/app/code/core/Mage/Sales/Model/Order.php +++ b/app/code/core/Mage/Sales/Model/Order.php @@ -544,10 +544,7 @@ public function unsetData($key = null) */ public function getActionFlag($action) { - if (isset($this->_actionFlag[$action])) { - return $this->_actionFlag[$action]; - } - return null; + return $this->_actionFlag[$action] ?? null; } /** diff --git a/app/code/core/Mage/Sales/Model/Order/Creditmemo/Api.php b/app/code/core/Mage/Sales/Model/Order/Creditmemo/Api.php index 5388dc917ef..76c7dc2ecec 100644 --- a/app/code/core/Mage/Sales/Model/Order/Creditmemo/Api.php +++ b/app/code/core/Mage/Sales/Model/Order/Creditmemo/Api.php @@ -233,12 +233,12 @@ public function cancel($creditmemoIncrementId) /** * Hook method, could be replaced in derived classes * - * @param array $data + * @param array|null $data * @return array */ protected function _prepareCreateData($data) { - $data = isset($data) ? $data : []; + $data = $data ?? []; if (isset($data['qtys']) && count($data['qtys'])) { $qtysArray = []; diff --git a/app/code/core/Mage/Sales/Model/Order/Invoice.php b/app/code/core/Mage/Sales/Model/Order/Invoice.php index e97ade45cdc..b1c27c7a0fb 100644 --- a/app/code/core/Mage/Sales/Model/Order/Invoice.php +++ b/app/code/core/Mage/Sales/Model/Order/Invoice.php @@ -631,10 +631,7 @@ public function getStateName($stateId = null) if (is_null(self::$_states)) { self::getStates(); } - if (isset(self::$_states[$stateId])) { - return self::$_states[$stateId]; - } - return Mage::helper('sales')->__('Unknown State'); + return self::$_states[$stateId] ?? Mage::helper('sales')->__('Unknown State'); } /** diff --git a/app/code/core/Mage/Sales/Model/Order/Item.php b/app/code/core/Mage/Sales/Model/Order/Item.php index 793c58b55fc..9f787d91612 100644 --- a/app/code/core/Mage/Sales/Model/Order/Item.php +++ b/app/code/core/Mage/Sales/Model/Order/Item.php @@ -537,10 +537,7 @@ public static function getStatusName($statusId) if (is_null(self::$_statuses)) { self::getStatuses(); } - if (isset(self::$_statuses[$statusId])) { - return self::$_statuses[$statusId]; - } - return Mage::helper('sales')->__('Unknown Status'); + return self::$_statuses[$statusId] ?? Mage::helper('sales')->__('Unknown Status'); } /** @@ -640,10 +637,7 @@ public function getProductOptionByCode($code = null) if (is_null($code)) { return $options; } - if (isset($options[$code])) { - return $options[$code]; - } - return null; + return $options[$code] ?? null; } /** @@ -834,8 +828,7 @@ public function getBaseDiscountAppliedForWeeeTax() if (isset($weeeTaxAppliedAmount['total_base_weee_discount'])) { return $weeeTaxAppliedAmount['total_base_weee_discount']; } else { - $totalDiscount += isset($weeeTaxAppliedAmount['base_weee_discount']) - ? $weeeTaxAppliedAmount['base_weee_discount'] : 0; + $totalDiscount += $weeeTaxAppliedAmount['base_weee_discount'] ?? 0; } } return $totalDiscount; @@ -857,8 +850,7 @@ public function getDiscountAppliedForWeeeTax() if (isset($weeeTaxAppliedAmount['total_weee_discount'])) { return $weeeTaxAppliedAmount['total_weee_discount']; } else { - $totalDiscount += isset($weeeTaxAppliedAmount['weee_discount']) - ? $weeeTaxAppliedAmount['weee_discount'] : 0; + $totalDiscount += $weeeTaxAppliedAmount['weee_discount'] ?? 0; } } return $totalDiscount; diff --git a/app/code/core/Mage/Sales/Model/Order/Payment.php b/app/code/core/Mage/Sales/Model/Order/Payment.php index 61a0daeece9..31b46be9240 100644 --- a/app/code/core/Mage/Sales/Model/Order/Payment.php +++ b/app/code/core/Mage/Sales/Model/Order/Payment.php @@ -411,7 +411,7 @@ public function place() } } } - $isCustomerNotified = ($orderIsNotified !== null) ? $orderIsNotified : $order->getCustomerNoteNotify(); + $isCustomerNotified = $orderIsNotified ?? $order->getCustomerNoteNotify(); $message = $order->getCustomerNote(); // add message if order was put into review during authorization or capture @@ -1674,7 +1674,7 @@ public function getTransactionAdditionalInfo($key = null) if (is_null($key)) { return $this->_transactionAdditionalInfo; } - return isset($this->_transactionAdditionalInfo[$key]) ? $this->_transactionAdditionalInfo[$key] : null; + return $this->_transactionAdditionalInfo[$key] ?? null; } /** diff --git a/app/code/core/Mage/Sales/Model/Order/Pdf/Abstract.php b/app/code/core/Mage/Sales/Model/Order/Pdf/Abstract.php index 9c28ca2f10a..2f391c4a28c 100644 --- a/app/code/core/Mage/Sales/Model/Order/Pdf/Abstract.php +++ b/app/code/core/Mage/Sales/Model/Order/Pdf/Abstract.php @@ -896,7 +896,7 @@ public function drawLineBlocks(Zend_Pdf_Page $page, array $draw, array $pageSett Mage::throwException(Mage::helper('sales')->__('Invalid draw line data. Please define "lines" array.')); } $lines = $itemsProp['lines']; - $height = isset($itemsProp['height']) ? $itemsProp['height'] : 10; + $height = $itemsProp['height'] ?? 10; if (empty($itemsProp['shift'])) { $shift = 0; diff --git a/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Creditmemo/Default.php b/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Creditmemo/Default.php index a3a177f27dd..5406ca76ec8 100644 --- a/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Creditmemo/Default.php +++ b/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Creditmemo/Default.php @@ -105,7 +105,7 @@ public function draw() ]; // draw options value - $_printValue = isset($option['print_value']) ? $option['print_value'] : strip_tags($option['value']); + $_printValue = $option['print_value'] ?? strip_tags($option['value']); $lines[][] = [ 'text' => Mage::helper('core/string')->str_split($_printValue, 30, true, true), 'feed' => 40 diff --git a/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Invoice/Default.php b/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Invoice/Default.php index f0f67137397..156c0135fba 100644 --- a/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Invoice/Default.php +++ b/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Invoice/Default.php @@ -116,11 +116,7 @@ public function draw() ]; if ($option['value']) { - if (isset($option['print_value'])) { - $_printValue = $option['print_value']; - } else { - $_printValue = strip_tags($option['value']); - } + $_printValue = $option['print_value'] ?? strip_tags($option['value']); $values = explode(', ', $_printValue); foreach ($values as $value) { $lines[][] = [ diff --git a/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Shipment/Default.php b/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Shipment/Default.php index 513bef89df0..621299f782c 100644 --- a/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Shipment/Default.php +++ b/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Shipment/Default.php @@ -69,9 +69,7 @@ public function draw() // draw options value if ($option['value']) { - $_printValue = isset($option['print_value']) - ? $option['print_value'] - : strip_tags($option['value']); + $_printValue = $option['print_value'] ?? strip_tags($option['value']); $values = explode(', ', $_printValue); foreach ($values as $value) { $lines[][] = [ diff --git a/app/code/core/Mage/Sales/Model/Quote/Address.php b/app/code/core/Mage/Sales/Model/Quote/Address.php index fa2d94a621a..1c18c1a83e2 100644 --- a/app/code/core/Mage/Sales/Model/Quote/Address.php +++ b/app/code/core/Mage/Sales/Model/Quote/Address.php @@ -1286,10 +1286,7 @@ public function addBaseTotalAmount($code, $amount) */ public function getTotalAmount($code) { - if (isset($this->_totalAmounts[$code])) { - return $this->_totalAmounts[$code]; - } - return 0; + return $this->_totalAmounts[$code] ?? 0; } /** @@ -1300,10 +1297,7 @@ public function getTotalAmount($code) */ public function getBaseTotalAmount($code) { - if (isset($this->_baseTotalAmounts[$code])) { - return $this->_baseTotalAmounts[$code]; - } - return 0; + return $this->_baseTotalAmounts[$code] ?? 0; } /** diff --git a/app/code/core/Mage/Sales/Model/Resource/Sale/Collection.php b/app/code/core/Mage/Sales/Model/Resource/Sale/Collection.php index fa6f33c9314..ea4216fd77f 100644 --- a/app/code/core/Mage/Sales/Model/Resource/Sale/Collection.php +++ b/app/code/core/Mage/Sales/Model/Resource/Sale/Collection.php @@ -178,7 +178,7 @@ public function load($printQuery = false, $logQuery = false) foreach ($data as $v) { $storeObject = new Varien_Object($v); $storeId = $v['store_id']; - $storeName = isset($stores[$storeId]) ? $stores[$storeId] : null; + $storeName = $stores[$storeId] ?? null; $storeObject->setStoreName($storeName) ->setWebsiteId(Mage::app()->getStore($storeId)->getWebsiteId()) ->setAvgNormalized($v['avgsale'] * $v['num_orders']); diff --git a/app/code/core/Mage/Sales/Model/Resource/Setup.php b/app/code/core/Mage/Sales/Model/Resource/Setup.php index 2f400f48013..b36c7a0c887 100644 --- a/app/code/core/Mage/Sales/Model/Resource/Setup.php +++ b/app/code/core/Mage/Sales/Model/Resource/Setup.php @@ -147,7 +147,7 @@ protected function _addGridAttribute($table, $attribute, $attr, $entityTypeId) protected function _getAttributeColumnDefinition($code, $data) { // Convert attribute type to column info - $data['type'] = isset($data['type']) ? $data['type'] : 'varchar'; + $data['type'] = $data['type'] ?? 'varchar'; $type = null; $length = null; switch ($data['type']) { @@ -180,7 +180,7 @@ protected function _getAttributeColumnDefinition($code, $data) } $data['nullable'] = isset($data['required']) ? !$data['required'] : true; - $data['comment'] = isset($data['comment']) ? $data['comment'] : ucwords(str_replace('_', ' ', $code)); + $data['comment'] = $data['comment'] ?? ucwords(str_replace('_', ' ', $code)); return $data; } diff --git a/app/code/core/Mage/Sales/Model/Service/Order.php b/app/code/core/Mage/Sales/Model/Service/Order.php index e2982c44b5f..0ca7be4a895 100644 --- a/app/code/core/Mage/Sales/Model/Service/Order.php +++ b/app/code/core/Mage/Sales/Model/Service/Order.php @@ -213,7 +213,7 @@ public function prepareCreditmemo($data = []) { $totalQty = 0; $creditmemo = $this->_convertor->toCreditmemo($this->_order); - $qtys = isset($data['qtys']) ? $data['qtys'] : []; + $qtys = $data['qtys'] ?? []; $this->updateLocaleNumbers($qtys); foreach ($this->_order->getAllItems() as $orderItem) { @@ -256,7 +256,7 @@ public function prepareCreditmemo($data = []) public function prepareInvoiceCreditmemo($invoice, $data = []) { $totalQty = 0; - $qtys = isset($data['qtys']) ? $data['qtys'] : []; + $qtys = $data['qtys'] ?? []; $this->updateLocaleNumbers($qtys); $creditmemo = $this->_convertor->toCreditmemo($this->_order); diff --git a/app/code/core/Mage/SalesRule/Model/Rule.php b/app/code/core/Mage/SalesRule/Model/Rule.php index 0db4f3be631..f4fcbf5eaef 100644 --- a/app/code/core/Mage/SalesRule/Model/Rule.php +++ b/app/code/core/Mage/SalesRule/Model/Rule.php @@ -482,7 +482,7 @@ public function setIsValidForAddress($address, $validationResult) public function getIsValidForAddress($address) { $addressId = $this->_getAddressId($address); - return isset($this->_validatedAddresses[$addressId]) ? $this->_validatedAddresses[$addressId] : false; + return $this->_validatedAddresses[$addressId] ?? false; } /** diff --git a/app/code/core/Mage/SalesRule/Model/Validator.php b/app/code/core/Mage/SalesRule/Model/Validator.php index d7441bc33e9..4eac4d97ac4 100644 --- a/app/code/core/Mage/SalesRule/Model/Validator.php +++ b/app/code/core/Mage/SalesRule/Model/Validator.php @@ -871,10 +871,7 @@ public function setCartFixedRuleUsedForAddress($ruleId, $itemId) */ public function getCartFixedRuleUsedForAddress($ruleId) { - if (isset($this->_cartFixedRuleUsedForAddress[$ruleId])) { - return $this->_cartFixedRuleUsedForAddress[$ruleId]; - } - return null; + return $this->_cartFixedRuleUsedForAddress[$ruleId] ?? null; } /** @@ -983,7 +980,7 @@ protected function _getItemPrice($item) { $price = $item->getDiscountCalculationPrice(); $calcPrice = $item->getCalculationPrice(); - return ($price !== null) ? $price : $calcPrice; + return $price ?? $calcPrice; } /** diff --git a/app/code/core/Mage/Sendfriend/Model/Sendfriend.php b/app/code/core/Mage/Sendfriend/Model/Sendfriend.php index 69bf651e864..ae12f9787a2 100644 --- a/app/code/core/Mage/Sendfriend/Model/Sendfriend.php +++ b/app/code/core/Mage/Sendfriend/Model/Sendfriend.php @@ -510,11 +510,7 @@ protected function _sentCountByCookies($increment = false) $time = time(); $newTimes = []; - if (isset($this->_lastCookieValue[$cookie])) { - $oldTimes = $this->_lastCookieValue[$cookie]; - } else { - $oldTimes = $this->getCookie()->get($cookie); - } + $oldTimes = $this->_lastCookieValue[$cookie] ?? $this->getCookie()->get($cookie); if ($oldTimes) { $oldTimes = explode(',', $oldTimes); diff --git a/app/code/core/Mage/Shipping/Model/Rate/Result.php b/app/code/core/Mage/Shipping/Model/Rate/Result.php index b6989607e53..cf4ed49956c 100644 --- a/app/code/core/Mage/Shipping/Model/Rate/Result.php +++ b/app/code/core/Mage/Shipping/Model/Rate/Result.php @@ -110,7 +110,7 @@ public function getAllRates() */ public function getRateById($id) { - return isset($this->_rates[$id]) ? $this->_rates[$id] : null; + return $this->_rates[$id] ?? null; } /** diff --git a/app/code/core/Mage/Tax/Helper/Data.php b/app/code/core/Mage/Tax/Helper/Data.php index 2b6b83ed441..ece3a175f5e 100644 --- a/app/code/core/Mage/Tax/Helper/Data.php +++ b/app/code/core/Mage/Tax/Helper/Data.php @@ -1151,11 +1151,11 @@ public function getAllWeee($source = null) if (!$helper->includeInSubtotal($store)) { foreach ($source->getAllItems() as $item) { foreach ($helper->getApplied($item) as $tax) { - $weeeDiscount = isset($tax['weee_discount']) ? $tax['weee_discount'] : 0; + $weeeDiscount = $tax['weee_discount'] ?? 0; $title = $tax['title']; - $rowAmount = isset($tax['row_amount']) ? $tax['row_amount'] : 0; - $rowAmountInclTax = isset($tax['row_amount_incl_tax']) ? $tax['row_amount_incl_tax'] : 0; + $rowAmount = $tax['row_amount'] ?? 0; + $rowAmountInclTax = $tax['row_amount_incl_tax'] ?? 0; $amountDisplayed = ($helper->isTaxIncluded()) ? $rowAmountInclTax : $rowAmount; if (array_key_exists($title, $allWeee)) { diff --git a/app/code/core/Mage/Tax/Model/Observer.php b/app/code/core/Mage/Tax/Model/Observer.php index b74e2aae0fd..c4652afb71d 100644 --- a/app/code/core/Mage/Tax/Model/Observer.php +++ b/app/code/core/Mage/Tax/Model/Observer.php @@ -113,7 +113,7 @@ public function salesEventOrderAfterSave(Varien_Event_Observer $observer) } $baseRealAmount = $row['base_amount'] / $row['percent'] * $tax['percent']; } - $hidden = (isset($row['hidden']) ? $row['hidden'] : 0); + $hidden = $row['hidden'] ?? 0; $data = [ 'order_id' => $order->getId(), 'code' => $tax['code'], diff --git a/app/code/core/Mage/Tax/Model/Resource/Calculation.php b/app/code/core/Mage/Tax/Model/Resource/Calculation.php index 48d4927eb2f..211529d813e 100644 --- a/app/code/core/Mage/Tax/Model/Resource/Calculation.php +++ b/app/code/core/Mage/Tax/Model/Resource/Calculation.php @@ -124,7 +124,7 @@ public function getCalculationProcess($request, $rates = null) $countedRates = count($rates); for ($i = 0; $i < $countedRates; $i++) { $rate = $rates[$i]; - $value = (isset($rate['value']) ? $rate['value'] : $rate['percent']) * 1; + $value = ($rate['value'] ?? $rate['percent']) * 1; $oneRate = [ 'code' => $rate['code'], diff --git a/app/code/core/Mage/Tax/Model/Sales/Total/Quote/Shipping.php b/app/code/core/Mage/Tax/Model/Sales/Total/Quote/Shipping.php index 44cffa248ba..742f21caab3 100644 --- a/app/code/core/Mage/Tax/Model/Sales/Total/Quote/Shipping.php +++ b/app/code/core/Mage/Tax/Model/Sales/Total/Quote/Shipping.php @@ -204,7 +204,7 @@ protected function _round($price, $rate, $direction, $type = 'regular') $deltas = $this->_address->getRoundingDeltas(); $key = $type.$direction; $rate = (string) $rate; - $delta = isset($deltas[$key][$rate]) ? $deltas[$key][$rate] : 0; + $delta = $deltas[$key][$rate] ?? 0; return $this->_calculator->round($price+$delta); } diff --git a/app/code/core/Mage/Tax/Model/Sales/Total/Quote/Subtotal.php b/app/code/core/Mage/Tax/Model/Sales/Total/Quote/Subtotal.php index df4c5e662ed..5f6220944c5 100644 --- a/app/code/core/Mage/Tax/Model/Sales/Total/Quote/Subtotal.php +++ b/app/code/core/Mage/Tax/Model/Sales/Total/Quote/Subtotal.php @@ -712,7 +712,7 @@ protected function _deltaRound($price, $rate, $direction, $type = 'regular') $rate = (string)$rate; $type = $type . $direction; // initialize the delta to a small number to avoid non-deterministic behavior with rounding of 0.5 - $delta = isset($this->_roundingDeltas[$type][$rate]) ? $this->_roundingDeltas[$type][$rate] :0.000001; + $delta = $this->_roundingDeltas[$type][$rate] ?? 0.000001; $price += $delta; $this->_roundingDeltas[$type][$rate] = $price - $this->_calculator->round($price); $price = $this->_calculator->round($price); diff --git a/app/code/core/Mage/Tax/Model/Sales/Total/Quote/Tax.php b/app/code/core/Mage/Tax/Model/Sales/Total/Quote/Tax.php index 2069e1d225d..a5ef7a7b027 100644 --- a/app/code/core/Mage/Tax/Model/Sales/Total/Quote/Tax.php +++ b/app/code/core/Mage/Tax/Model/Sales/Total/Quote/Tax.php @@ -1279,15 +1279,15 @@ protected function _calculateWeeeAmountInclTax($item, $appliedRates, $base = tru $weeeAmountExclTax = 0; if ($base) { - $weeeAmountInclTax = isset($tax['base_amount_incl_tax']) ? $tax['base_amount_incl_tax'] : 0; - $weeeAmountExclTax = isset($tax['base_amount']) ? $tax['base_amount'] : 0; - $weeeRowAmountInclTax = isset($tax['base_row_amount_incl_tax']) ? $tax['base_row_amount_incl_tax'] : 0; - $weeeRowAmountExclTax = isset($tax['base_row_amount']) ? $tax['base_row_amount'] : 0; + $weeeAmountInclTax = $tax['base_amount_incl_tax'] ?? 0; + $weeeAmountExclTax = $tax['base_amount'] ?? 0; + $weeeRowAmountInclTax = $tax['base_row_amount_incl_tax'] ?? 0; + $weeeRowAmountExclTax = $tax['base_row_amount'] ?? 0; } else { - $weeeAmountInclTax = isset($tax['amount_incl_tax']) ? $tax['amount_incl_tax'] : 0; - $weeeAmountExclTax = isset($tax['amount']) ? $tax['amount'] : 0; - $weeeRowAmountInclTax = isset($tax['row_amount_incl_tax']) ? $tax['row_amount_incl_tax'] : 0; - $weeeRowAmountExclTax = isset($tax['row_amount']) ? $tax['row_amount'] : 0; + $weeeAmountInclTax = $tax['amount_incl_tax'] ?? 0; + $weeeAmountExclTax = $tax['amount'] ?? 0; + $weeeRowAmountInclTax = $tax['row_amount_incl_tax'] ?? 0; + $weeeRowAmountExclTax = $tax['row_amount'] ?? 0; } $weeeTax = []; @@ -1356,11 +1356,11 @@ protected function _calculateWeeeTax($discountAmount, $item, $rate, $base = true $weeeAmountExclTax = 0; if ($base) { - $weeeAmountInclTax = isset($tax['base_amount_incl_tax']) ? $tax['base_amount_incl_tax'] : 0; - $weeeAmountExclTax = isset($tax['base_amount']) ? $tax['base_amount'] : 0; + $weeeAmountInclTax = $tax['base_amount_incl_tax'] ?? 0; + $weeeAmountExclTax = $tax['base_amount'] ?? 0; } else { - $weeeAmountInclTax = isset($tax['amount_incl_tax']) ? $tax['amount_incl_tax'] : 0; - $weeeAmountExclTax = isset($tax['amount']) ? $tax['amount'] : 0; + $weeeAmountInclTax = $tax['amount_incl_tax'] ?? 0; + $weeeAmountExclTax = $tax['amount'] ?? 0; } $weeeTaxWithOutDiscount = $this->_getWeeeTax($rate, $item, 0, $weeeAmountInclTax, $weeeAmountExclTax); @@ -1412,11 +1412,11 @@ protected function _calculateRowWeeeTax($discountAmount, $item, $rate, $base = t $weeeAmountExclTax = 0; if ($base) { - $weeeAmountInclTax = isset($tax['base_row_amount_incl_tax']) ? $tax['base_row_amount_incl_tax'] : 0; - $weeeAmountExclTax = isset($tax['base_row_amount']) ? $tax['base_row_amount'] : 0; + $weeeAmountInclTax = $tax['base_row_amount_incl_tax'] ?? 0; + $weeeAmountExclTax = $tax['base_row_amount'] ?? 0; } else { - $weeeAmountInclTax = isset($tax['row_amount_incl_tax']) ? $tax['row_amount_incl_tax'] : 0; - $weeeAmountExclTax = isset($tax['row_amount']) ? $tax['row_amount'] : 0; + $weeeAmountInclTax = $tax['row_amount_incl_tax'] ?? 0; + $weeeAmountExclTax = $tax['row_amount'] ?? 0; } $weeeTaxWithOutDiscount = $this->_getWeeeTax($rate, $item, 0, $weeeAmountInclTax, $weeeAmountExclTax); @@ -1490,7 +1490,7 @@ protected function _deltaRound($price, $rate, $direction, $type = 'regular') $rate = (string)$rate; $type = $type . $direction; // initialize the delta to a small number to avoid non-deterministic behavior with rounding of 0.5 - $delta = isset($this->_roundingDeltas[$type][$rate]) ? $this->_roundingDeltas[$type][$rate] : 0.000001; + $delta = $this->_roundingDeltas[$type][$rate] ?? 0.000001; $price += $delta; $this->_roundingDeltas[$type][$rate] = $price - $this->_calculator->round($price); $price = $this->_calculator->round($price); diff --git a/app/code/core/Mage/Uploader/Helper/File.php b/app/code/core/Mage/Uploader/Helper/File.php index c35dce2f8fc..88c15e6b808 100644 --- a/app/code/core/Mage/Uploader/Helper/File.php +++ b/app/code/core/Mage/Uploader/Helper/File.php @@ -655,10 +655,7 @@ public function __construct() public function getMimeTypeByExtension($ext) { $type = 'x' . $ext; - if (isset($this->_mimeTypes[$type])) { - return $this->_mimeTypes[$type]; - } - return 'application/octet-stream'; + return $this->_mimeTypes[$type] ?? 'application/octet-stream'; } /** diff --git a/app/code/core/Mage/Uploader/Model/Config/Abstract.php b/app/code/core/Mage/Uploader/Model/Config/Abstract.php index 5e528dc828a..55c0170e6f3 100644 --- a/app/code/core/Mage/Uploader/Model/Config/Abstract.php +++ b/app/code/core/Mage/Uploader/Model/Config/Abstract.php @@ -51,10 +51,10 @@ public function __call($method, $args) $key = lcfirst($this->_camelize(substr($method,3))); switch (substr($method, 0, 3)) { case 'get' : - return $this->getData($key, isset($args[0]) ? $args[0] : null); + return $this->getData($key, $args[0] ?? null); case 'set' : - return $this->setData($key, isset($args[0]) ? $args[0] : null); + return $this->setData($key, $args[0] ?? null); case 'uns' : return $this->unsetData($key); diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Abstract.php b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Abstract.php index c1314b4378f..7e04ea16fe2 100644 --- a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Abstract.php +++ b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Abstract.php @@ -60,7 +60,7 @@ public function setActiveFlag($code = 'active') */ public function getCarrierCode() { - return isset($this->_code) ? $this->_code : null; + return $this->_code ?? null; } public function getTrackingInfo($tracking) @@ -248,7 +248,7 @@ protected function _getQuotesCacheKey($requestParams) protected function _getCachedQuotes($requestParams) { $key = $this->_getQuotesCacheKey($requestParams); - return isset(self::$_quotesCache[$key]) ? self::$_quotesCache[$key] : null; + return self::$_quotesCache[$key] ?? null; } /** diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl.php b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl.php index c6caa637898..468599ba5cc 100644 --- a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl.php +++ b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl.php @@ -905,11 +905,7 @@ public function getCode($type, $code = '') return $codes[$type]; } - if (!isset($codes[$type][$code])) { - return false; - } else { - return $codes[$type][$code]; - } + return $codes[$type][$code] ?? false; } /** @@ -942,7 +938,7 @@ protected function _addRate($shipXml) } } - $data['term'] = (isset($services[$service]) ? $services[$service] : $desc); + $data['term'] = $services[$service] ?? $desc; $data['price_total'] = $this->getMethodPrice($totalEstimate, $service); $this->_dhlRates[] = ['service' => $service, 'data' => $data]; } diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International.php b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International.php index 33e39f5e81b..b3a765f97d3 100644 --- a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International.php +++ b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International.php @@ -452,11 +452,7 @@ public function getCode($type, $code = '') } $code = strtoupper($code); - if (!isset($codes[$type][$code])) { - return false; - } else { - return $codes[$type][$code]; - } + return $codes[$type][$code] ?? false; } /** @@ -528,7 +524,7 @@ public function getDhlProductTitle($code) { $contentType = $this->getConfigData('content_type'); $dhlProducts = $this->getDhlProducts($contentType); - return isset($dhlProducts[$code]) ? $dhlProducts[$code] : false; + return $dhlProducts[$code] ?? false; } /** @@ -926,11 +922,7 @@ protected function _parseResponse($response) ) { $code = null; $data = null; - if (isset($xml->Response->Status->Condition)) { - $nodeCondition = $xml->Response->Status->Condition; - } else { - $nodeCondition = $xml->GetQuoteResponse->Note->Condition; - } + $nodeCondition = $xml->Response->Status->Condition ?? $xml->GetQuoteResponse->Note->Condition; if ($this->_isShippingLabelFlag) { foreach ($nodeCondition as $condition) { @@ -1110,7 +1102,7 @@ protected function getCountryParams($countryCode) if (isset($this->_countryParams->$countryCode)) { $countryParams = new Varien_Object($this->_countryParams->$countryCode->asArray()); } - return isset($countryParams) ? $countryParams : new Varien_Object(); + return $countryParams ?? new Varien_Object(); } /** diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex.php b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex.php index 662d3212488..6ca26348c15 100644 --- a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex.php +++ b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex.php @@ -924,11 +924,7 @@ public function getCode($type, $code='') return $codes[$type]; } - if (!isset($codes[$type][$code])) { - return false; - } else { - return $codes[$type][$code]; - } + return $codes[$type][$code] ?? false; } /** @@ -956,7 +952,7 @@ public function getCurrencyCode () 'TWD' => 'NTD', // New Taiwan Dollars ]; $currencyCode = Mage::app()->getStore()->getBaseCurrencyCode(); - return isset($codes[$currencyCode]) ? $codes[$currencyCode] : $currencyCode; + return $codes[$currencyCode] ?? $currencyCode; } /** @@ -1064,16 +1060,14 @@ protected function _parseTrackingResponse($trackingValue, $response) $trackInfo = $response->TrackDetails; $resultArray['status'] = (string)$trackInfo->StatusDescription; $resultArray['service'] = (string)$trackInfo->ServiceInfo; - $timestamp = isset($trackInfo->EstimatedDeliveryTimestamp) ? - $trackInfo->EstimatedDeliveryTimestamp : $trackInfo->ActualDeliveryTimestamp; + $timestamp = $trackInfo->EstimatedDeliveryTimestamp ?? $trackInfo->ActualDeliveryTimestamp; $timestamp = strtotime((string)$timestamp); if ($timestamp) { $resultArray['deliverydate'] = date('Y-m-d', $timestamp); $resultArray['deliverytime'] = date('H:i:s', $timestamp); } - $deliveryLocation = isset($trackInfo->EstimatedDeliveryAddress) ? - $trackInfo->EstimatedDeliveryAddress : $trackInfo->ActualDeliveryAddress; + $deliveryLocation = $trackInfo->EstimatedDeliveryAddress ?? $trackInfo->ActualDeliveryAddress; $deliveryLocationArray = []; if (isset($deliveryLocation->City)) { $deliveryLocationArray[] = (string)$deliveryLocation->City; diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups.php b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups.php index 367f369a76f..353ebb007dc 100644 --- a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups.php +++ b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups.php @@ -768,11 +768,7 @@ public function getCode($type, $code='') return $codes[$type]; } - if (!isset($codes[$type][$code])) { - return false; - } else { - return $codes[$type][$code]; - } + return $codes[$type][$code] ?? false; } /** diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps.php b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps.php index e2dc6d5d0c3..b39b882a5cd 100644 --- a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps.php +++ b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps.php @@ -512,11 +512,7 @@ protected function _parseXmlResponse($response) $rate->setCarrier('usps'); $rate->setCarrierTitle($this->getConfigData('title')); $rate->setMethod($method); - $rate->setMethodTitle( - isset($serviceCodeToActualNameMap[$method]) - ? $serviceCodeToActualNameMap[$method] - : $this->getCode('method', $method) - ); + $rate->setMethodTitle($serviceCodeToActualNameMap[$method] ?? $this->getCode('method', $method)); $rate->setCost($costArr[$method]); $rate->setPrice($price); $result->append($rate); @@ -895,11 +891,7 @@ public function getCode($type, $code = '') return $codes[$type]; } - if (!isset($codes[$type][$code])) { - return false; - } else { - return $codes[$type][$code]; - } + return $codes[$type][$code] ?? false; } /** * Get tracking diff --git a/app/code/core/Mage/Weee/Helper/Data.php b/app/code/core/Mage/Weee/Helper/Data.php index 9bc5d00ba32..2e48f71fd87 100644 --- a/app/code/core/Mage/Weee/Helper/Data.php +++ b/app/code/core/Mage/Weee/Helper/Data.php @@ -656,8 +656,7 @@ public function getRowWeeeAmountAfterDiscount($item) foreach ($weeeTaxAppliedAmounts as $weeeTaxAppliedAmount) { $weeeAmountInclDiscount += $weeeTaxAppliedAmount['row_amount']; if (!$this->includeInSubtotal()) { - $weeeAmountInclDiscount -= isset($weeeTaxAppliedAmount['weee_discount']) - ? $weeeTaxAppliedAmount['weee_discount'] : 0; + $weeeAmountInclDiscount -= $weeeTaxAppliedAmount['weee_discount'] ?? 0; } } return $weeeAmountInclDiscount; @@ -678,8 +677,7 @@ public function getBaseRowWeeeAmountAfterDiscount($item) foreach ($weeeTaxAppliedAmounts as $weeeTaxAppliedAmount) { $baseWeeeAmountInclDiscount += $weeeTaxAppliedAmount['base_row_amount']; if (!$this->includeInSubtotal()) { - $baseWeeeAmountInclDiscount -= isset($weeeTaxAppliedAmount['base_weee_discount']) - ? $weeeTaxAppliedAmount['base_weee_discount'] : 0; + $baseWeeeAmountInclDiscount -= $weeeTaxAppliedAmount['base_weee_discount'] ?? 0; } } return $baseWeeeAmountInclDiscount; diff --git a/app/code/core/Mage/Weee/Model/Attribute/Backend/Weee/Tax.php b/app/code/core/Mage/Weee/Model/Attribute/Backend/Weee/Tax.php index ac8fd28e129..c0844938f23 100644 --- a/app/code/core/Mage/Weee/Model/Attribute/Backend/Weee/Tax.php +++ b/app/code/core/Mage/Weee/Model/Attribute/Backend/Weee/Tax.php @@ -56,7 +56,7 @@ public function validate($object) continue; } - $state = isset($tax['state']) ? $tax['state'] : '*'; + $state = $tax['state'] ?? '*'; $key1 = implode('-', [$tax['website_id'], $tax['country'], $state]); if (!empty($dup[$key1])) { diff --git a/app/code/core/Mage/Widget/Block/Adminhtml/Widget/Options.php b/app/code/core/Mage/Widget/Block/Adminhtml/Widget/Options.php index 2a0ab21ea2e..a1919d4ca86 100644 --- a/app/code/core/Mage/Widget/Block/Adminhtml/Widget/Options.php +++ b/app/code/core/Mage/Widget/Block/Adminhtml/Widget/Options.php @@ -145,7 +145,7 @@ protected function _addField($parameter) ]; if ($values = $this->getWidgetValues()) { - $data['value'] = (isset($values[$fieldName]) ? $values[$fieldName] : ''); + $data['value'] = $values[$fieldName] ?? ''; } else { $data['value'] = $parameter->getValue(); //prepare unique id value diff --git a/app/code/core/Mage/Widget/Model/Template/Filter.php b/app/code/core/Mage/Widget/Model/Template/Filter.php index b4456c37821..0c1c0c54205 100644 --- a/app/code/core/Mage/Widget/Model/Template/Filter.php +++ b/app/code/core/Mage/Widget/Model/Template/Filter.php @@ -38,10 +38,7 @@ public function widgetDirective($construction) $params = $this->_getIncludeParameters($construction[2]); // Determine what name block should have in layout - $name = null; - if (isset($params['name'])) { - $name = $params['name']; - } + $name = $params['name'] ?? null; // validate required parameter type or id if (!empty($params['type'])) { diff --git a/app/code/core/Mage/Wishlist/controllers/IndexController.php b/app/code/core/Mage/Wishlist/controllers/IndexController.php index 00060e88f26..b8f56955e9b 100644 --- a/app/code/core/Mage/Wishlist/controllers/IndexController.php +++ b/app/code/core/Mage/Wishlist/controllers/IndexController.php @@ -495,11 +495,7 @@ public function cartAction() // Set qty $qty = $this->getRequest()->getParam('qty'); if (is_array($qty)) { - if (isset($qty[$itemId])) { - $qty = $qty[$itemId]; - } else { - $qty = 1; - } + $qty = $qty[$itemId] ?? 1; } $qty = (float)$qty; if ($qty && $qty>0) {