Skip to content

Commit

Permalink
Applied first rule "SwitchNegatedTernaryRector"
Browse files Browse the repository at this point in the history
  • Loading branch information
sreichel committed Nov 23, 2023
1 parent eba1ba7 commit 368047c
Show file tree
Hide file tree
Showing 91 changed files with 152 additions and 152 deletions.
2 changes: 1 addition & 1 deletion app/Mage.php
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,7 @@ public static function printException(Throwable $e, $extra = '')
print '</pre>';
} else {
$reportData = [
(!empty($extra) ? $extra . "\n\n" : '') . $e->getMessage(),
(empty($extra) ? '' : $extra . "\n\n") . $e->getMessage(),
$e->getTraceAsString()
];

Expand Down
4 changes: 2 additions & 2 deletions app/code/core/Mage/Admin/Model/Redirectpolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class Mage_Admin_Model_Redirectpolicy
*/
public function __construct($parameters = [])
{
$this->_urlModel = (!empty($parameters['urlModel'])) ?
$parameters['urlModel'] : Mage::getModel('adminhtml/url');
$this->_urlModel = (empty($parameters['urlModel'])) ?
Mage::getModel('adminhtml/url') : $parameters['urlModel'];
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Admin/Model/Resource/Acl.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function loadRules(Mage_Admin_Model_Acl $acl, array $rulesArr)
foreach ($rulesArr as $rule) {
$role = $rule['role_type'] . $rule['role_id'];
$resource = $rule['resource_id'];
$privileges = !empty($rule['privileges']) ? explode(',', $rule['privileges']) : null;
$privileges = empty($rule['privileges']) ? null : explode(',', $rule['privileges']);

$assert = null;
if ($rule['assert_id'] != 0) {
Expand Down
12 changes: 6 additions & 6 deletions app/code/core/Mage/Admin/Model/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ class Mage_Admin_Model_Session extends Mage_Core_Model_Session_Abstract
*/
public function __construct($parameters = [])
{
$this->_urlPolicy = (!empty($parameters['redirectPolicy'])) ?
$parameters['redirectPolicy'] : Mage::getModel('admin/redirectpolicy');
$this->_urlPolicy = (empty($parameters['redirectPolicy'])) ?
Mage::getModel('admin/redirectpolicy') : $parameters['redirectPolicy'];

$this->_response = (!empty($parameters['response'])) ?
$parameters['response'] : new Mage_Core_Controller_Response_Http();
$this->_response = (empty($parameters['response'])) ?
new Mage_Core_Controller_Response_Http() : $parameters['response'];

$this->_factory = (!empty($parameters['factory'])) ?
$parameters['factory'] : Mage::getModel('core/factory');
$this->_factory = (empty($parameters['factory'])) ?
Mage::getModel('core/factory') : $parameters['factory'];

$this->init('admin');
$this->logoutIndirect();
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Adminhtml/Block/Api/Tab/Userroles.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __construct()
parent::__construct();

$uid = $this->getRequest()->getParam('id', false);
$uid = !empty($uid) ? $uid : 0;
$uid = empty($uid) ? 0 : $uid;
$roles = Mage::getModel("api/roles")
->getCollection()
->load();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public function getGroupTreeJson()
$attr = [
'text' => $child->getAttributeCode(),
'id' => $child->getAttributeId(),
'cls' => (!$child->getIsUserDefined()) ? 'system-leaf' : 'leaf',
'cls' => ($child->getIsUserDefined()) ? 'leaf' : 'system-leaf',
'allowDrop' => false,
'allowDrag' => true,
'leaf' => true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Mage_Adminhtml_Block_Customer_Edit_Renderer_Region extends Mage_Adminhtml_
*/
public function __construct(array $args = [])
{
$this->_factory = !empty($args['factory']) ? $args['factory'] : Mage::getSingleton('core/factory');
$this->_factory = empty($args['factory']) ? Mage::getSingleton('core/factory') : $args['factory'];
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ public function render(Varien_Object $row)
Mage::helper('adminnotification')->__('Read Details') . '</a> | '
: '';

$markAsReadHtml = (!$row->getIsRead())
? '<a href="' . $this->getUrl('*/*/markAsRead/', ['_current' => true, 'id' => $row->getId()]) . '">' .
Mage::helper('adminnotification')->__('Mark as Read') . '</a> | '
: '';
$markAsReadHtml = ($row->getIsRead())
? ''
: '<a href="' . $this->getUrl('*/*/markAsRead/', ['_current' => true, 'id' => $row->getId()]) . '">' .
Mage::helper('adminnotification')->__('Mark as Read') . '</a> | ';

/** @var Mage_Core_Helper_Url $helper */
$helper = $this->helper('core/url');
Expand Down
16 changes: 8 additions & 8 deletions app/code/core/Mage/Adminhtml/Block/Page/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,21 +264,21 @@ protected function _callbackSecretKey($match)
*/
public function getMenuLevel($menu, $level = 0)
{
$html = '<ul ' . (!$level ? 'id="nav"' : '') . '>' . PHP_EOL;
$html = '<ul ' . ($level ? '' : 'id="nav"') . '>' . PHP_EOL;
foreach ($menu as $item) {
if ((empty($item['url']) || ($item['url'] == '#')) && empty($item['children'])) {
continue; // for example hide System/Tools when empty
}
$html .= '<li ' . (!empty($item['children']) ? 'onmouseover="Element.addClassName(this,\'over\')" '
. 'onmouseout="Element.removeClassName(this,\'over\')"' : '') . ' class="'
$html .= '<li ' . (empty($item['children']) ? '' : 'onmouseover="Element.addClassName(this,\'over\')" '
. 'onmouseout="Element.removeClassName(this,\'over\')"') . ' class="'
. (!$level && !empty($item['active']) ? ' active' : '') . ' '
. (!empty($item['children']) ? ' parent' : '')
. (empty($item['children']) ? '' : ' parent')
. (!empty($level) && !empty($item['last']) ? ' last' : '')
. ' level' . $level . '"> <a href="' . $item['url'] . '" '
. (!empty($item['title']) ? 'title="' . $item['title'] . '"' : '') . ' '
. (!empty($item['target']) ? 'target="' . $item['target'] . '"' : '') . ' '
. (!empty($item['click']) ? 'onclick="' . $item['click'] . '"' : '') . ' class="'
. (!empty($item['active']) ? 'active' : '') . '"><span>'
. (empty($item['title']) ? '' : 'title="' . $item['title'] . '"') . ' '
. (empty($item['target']) ? '' : 'target="' . $item['target'] . '"') . ' '
. (empty($item['click']) ? '' : 'onclick="' . $item['click'] . '"') . ' class="'
. (empty($item['active']) ? '' : 'active') . '"><span>'
. $this->escapeHtml($item['label']) . '</span></a>' . PHP_EOL;
if (!empty($item['children'])) {
$html .= $this->getMenuLevel($item['children'], $level + 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __construct()
parent::__construct();

$uid = $this->getRequest()->getParam('id', false);
$uid = !empty($uid) ? $uid : 0;
$uid = empty($uid) ? 0 : $uid;
$roles = Mage::getModel("admin/roles")
->getCollection()
->load();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public function getContainerTypeByCode($code)
$carrier = $this->getShipment()->getOrder()->getShippingCarrier();
if ($carrier) {
$containerTypes = $carrier->getContainerTypes();
return !empty($containerTypes[$code]) ? $containerTypes[$code] : '';
return empty($containerTypes[$code]) ? '' : $containerTypes[$code];
}
return '';
}
Expand All @@ -160,7 +160,7 @@ public function getDeliveryConfirmationTypeByCode($code)
if ($carrier) {
$params = new Varien_Object(['country_recipient' => $countryId]);
$confirmationTypes = $carrier->getDeliveryConfirmationTypes($params);
return !empty($confirmationTypes[$code]) ? $confirmationTypes[$code] : '';
return empty($confirmationTypes[$code]) ? '' : $confirmationTypes[$code];
}
return '';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ protected function _prepareForm()
'container_id' => 'used_currently_for',
'after_element_html' =>
'<script type="text/javascript">' .
(!$this->getEmailTemplate()->getSystemConfigPathsWhereUsedCurrently()
? '$(\'' . 'used_currently_for' . '\').hide(); ' : '') .
($this->getEmailTemplate()->getSystemConfigPathsWhereUsedCurrently()
? '' : '$(\'' . 'used_currently_for' . '\').hide(); ') .
'</script>',
]);
}
Expand All @@ -73,8 +73,8 @@ protected function _prepareForm()
'container_id' => 'used_default_for',
'after_element_html' =>
'<script type="text/javascript">' .
(!(bool)$this->getEmailTemplate()->getOrigTemplateCode()
? '$(\'' . 'used_default_for' . '\').hide(); ' : '') .
((bool)$this->getEmailTemplate()->getOrigTemplateCode()
? '' : '$(\'' . 'used_default_for' . '\').hide(); ') .
'</script>',
]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function getHtml()
$html .= '<option value="0"' . ($value == 0 ? ' selected="selected"' : '') . '>'
. Mage::helper('adminhtml')->__('All Store Views') . '</option>';
} else {
$html .= '<option value=""' . (!$value ? ' selected="selected"' : '') . '></option>';
$html .= '<option value=""' . ($value ? '' : ' selected="selected"') . '></option>';
}
foreach ($websiteCollection as $website) {
$websiteShow = false;
Expand Down
4 changes: 2 additions & 2 deletions app/code/core/Mage/Adminhtml/Model/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ public function getSecretKey($controller = null, $action = null)

$p = explode('/', trim($this->getRequest()->getOriginalPathInfo(), '/'));
if (!$controller) {
$controller = !empty($p[1]) ? $p[1] : $this->getRequest()->getControllerName();
$controller = empty($p[1]) ? $this->getRequest()->getControllerName() : $p[1];
}
if (!$action) {
$action = !empty($p[2]) ? $p[2] : $this->getRequest()->getActionName();
$action = empty($p[2]) ? $this->getRequest()->getActionName() : $p[2];
}

$secret = $controller . $action . $salt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function saveAction()
$id = $this->getRequest()->getParam('user_id');
$model = Mage::getModel('admin/user')->load($id);
// @var $isNew flag for detecting new admin user creation.
$isNew = !$model->getId() ? true : false;
$isNew = $model->getId() ? false : true;
if (!$model->getId() && $id) {
Mage::getSingleton('adminhtml/session')->addError($this->__('This user no longer exists.'));
$this->_redirect('*/*/');
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Api/Model/Resource/Acl.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function loadRules(Mage_Api_Model_Acl $acl, array $rulesArr)
foreach ($rulesArr as $rule) {
$role = $rule['role_type'] . $rule['role_id'];
$resource = $rule['resource_id'];
$privileges = !empty($rule['api_privileges']) ? explode(',', $rule['api_privileges']) : null;
$privileges = empty($rule['api_privileges']) ? null : explode(',', $rule['api_privileges']);

$assert = null;
if ($rule['assert_id'] != 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ protected function _buildValidatorsChain(array $validationConfig)
}
$validator = $this->_getValidatorInstance(
$validatorConfig['type'],
!empty($validatorConfig['options']) ? $validatorConfig['options'] : []
empty($validatorConfig['options']) ? [] : $validatorConfig['options']
);
// set custom message
if (isset($validatorConfig['message'])) {
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Authorizenet/Model/Directpost.php
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ public function validateResponse()
{
$response = $this->getResponse();
$xSHA2Hash = $response->getData('x_SHA2_Hash');
$hashConfigKey = !empty($xSHA2Hash) ? 'signature_key' : 'trans_md5';
$hashConfigKey = empty($xSHA2Hash) ? 'trans_md5' : 'signature_key';

//hash check
if (!$this->getConfigData($hashConfigKey)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function placeAction()
$orderData = $this->getRequest()->getPost('order');
$sendConfirmationFlag = 0;
if ($orderData) {
$sendConfirmationFlag = (!empty($orderData['send_confirmation'])) ? 1 : 0;
$sendConfirmationFlag = (empty($orderData['send_confirmation'])) ? 0 : 1;
} else {
$orderData = [];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public function getJsonConfig()
$taxHelper = Mage::helper('tax');
foreach ($_option->getSelections() as $_selection) {
$selectionId = $_selection->getSelectionId();
$_qty = !($_selection->getSelectionQty() * 1) ? '1' : $_selection->getSelectionQty() * 1;
$_qty = $_selection->getSelectionQty() * 1 ? $_selection->getSelectionQty() * 1 : '1';
// recalculate currency
$tierPrices = $_selection->getTierPrice();
foreach ($tierPrices as &$tierPriceInfo) {
Expand Down
4 changes: 2 additions & 2 deletions app/code/core/Mage/Catalog/Helper/Category/Url/Rewrite.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ class Mage_Catalog_Helper_Category_Url_Rewrite implements Mage_Catalog_Helper_Ca
public function __construct(array $args = [])
{
$this->_resource = Mage::getSingleton('core/resource');
$this->_connection = !empty($args['connection']) ? $args['connection'] : $this->_resource
->getConnection(Mage_Core_Model_Resource::DEFAULT_READ_RESOURCE);
$this->_connection = empty($args['connection']) ? $this->_resource
->getConnection(Mage_Core_Model_Resource::DEFAULT_READ_RESOURCE) : $args['connection'];
}

/**
Expand Down
4 changes: 2 additions & 2 deletions app/code/core/Mage/Catalog/Helper/Product/Url/Rewrite.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ class Mage_Catalog_Helper_Product_Url_Rewrite implements Mage_Catalog_Helper_Pro
public function __construct(array $args = [])
{
$this->_resource = Mage::getSingleton('core/resource');
$this->_connection = !empty($args['connection']) ? $args['connection'] : $this->_resource
->getConnection(Mage_Core_Model_Resource::DEFAULT_READ_RESOURCE);
$this->_connection = empty($args['connection']) ? $this->_resource
->getConnection(Mage_Core_Model_Resource::DEFAULT_READ_RESOURCE) : $args['connection'];
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ public function validate($object)
if (!is_array($available)) {
$available = explode(',', $available);
}
$data = (!in_array('default_sort_by', $postDataConfig)) ? $object->getData($attributeCode) :
Mage::getStoreConfig("catalog/frontend/default_sort_by");
$data = (in_array('default_sort_by', $postDataConfig)) ? Mage::getStoreConfig("catalog/frontend/default_sort_by") :
$object->getData($attributeCode);
if (!in_array($data, $available)) {
Mage::throwException(Mage::helper('eav')->__('Default Product Listing Sort by does not exist in Available Product Listing Sort By.'));
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Catalog/Model/Category/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class Mage_Catalog_Model_Category_Url
*/
public function __construct(array $args = [])
{
$this->_factory = !empty($args['factory']) ? $args['factory'] : Mage::getSingleton('catalog/factory');
$this->_factory = empty($args['factory']) ? Mage::getSingleton('catalog/factory') : $args['factory'];
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ public function afterSave($object)
));

$useForAllGroups = $data['cust_group'] == Mage_Customer_Model_Group::CUST_GROUP_ALL;
$customerGroupId = !$useForAllGroups ? $data['cust_group'] : 0;
$customerGroupId = $useForAllGroups ? 0 : $data['cust_group'];

$new[$key] = array_merge([
'website_id' => $data['website_id'],
Expand Down
6 changes: 3 additions & 3 deletions app/code/core/Mage/Catalog/Model/Product/Option/Type/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -504,9 +504,9 @@ protected function _getOptionHtml($optionValue)
$sizes = '';
}

$urlRoute = !empty($value['url']['route']) ? $value['url']['route'] : '';
$urlParams = !empty($value['url']['params']) ? $value['url']['params'] : '';
$title = !empty($value['title']) ? $value['title'] : '';
$urlRoute = empty($value['url']['route']) ? '' : $value['url']['route'];
$urlParams = empty($value['url']['params']) ? '' : $value['url']['params'];
$title = empty($value['title']) ? '' : $value['title'];

return sprintf(
'<a href="%s" target="_blank">%s</a> %s',
Expand Down
4 changes: 2 additions & 2 deletions app/code/core/Mage/Catalog/Model/Product/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ class Mage_Catalog_Model_Product_Url extends Varien_Object
*/
public function __construct(array $args = [])
{
$this->_factory = !empty($args['factory']) ? $args['factory'] : Mage::getSingleton('catalog/factory');
$this->_store = !empty($args['store']) ? $args['store'] : Mage::app()->getStore();
$this->_factory = empty($args['factory']) ? Mage::getSingleton('catalog/factory') : $args['factory'];
$this->_store = empty($args['store']) ? Mage::app()->getStore() : $args['store'];
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class Mage_Catalog_Model_Resource_Category_Collection extends Mage_Catalog_Model
public function __construct($resource = null, array $args = [])
{
parent::__construct($resource);
$this->_factory = !empty($args['factory']) ? $args['factory'] : Mage::getSingleton('catalog/factory');
$this->_factory = empty($args['factory']) ? Mage::getSingleton('catalog/factory') : $args['factory'];
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class Mage_Catalog_Model_Resource_Category_Flat extends Mage_Index_Model_Resourc
*/
public function __construct(array $args = [])
{
$this->_factory = !empty($args['factory']) ? $args['factory'] : Mage::getSingleton('catalog/factory');
$this->_factory = empty($args['factory']) ? Mage::getSingleton('catalog/factory') : $args['factory'];
parent::__construct();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Mage_Catalog_Model_Resource_Category_Flat_Collection extends Mage_Core_Mod
public function __construct($resource = null, array $args = [])
{
parent::__construct($resource);
$this->_factory = !empty($args['factory']) ? $args['factory'] : Mage::getSingleton('catalog/factory');
$this->_factory = empty($args['factory']) ? Mage::getSingleton('catalog/factory') : $args['factory'];
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class Mage_Catalog_Model_Resource_Product_Collection extends Mage_Catalog_Model_
public function __construct($resource = null, array $args = [])
{
parent::__construct($resource);
$this->_factory = !empty($args['factory']) ? $args['factory'] : Mage::getSingleton('catalog/factory');
$this->_factory = empty($args['factory']) ? Mage::getSingleton('catalog/factory') : $args['factory'];
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public function savePrices($attribute)
'pricing_value' => $v['pricing_value'],
'is_percent' => $v['is_percent'],
'website_id' => $websiteId,
'use_default' => !empty($v['use_default_value']) ? true : false
'use_default' => empty($v['use_default_value']) ? false : true
];
}

Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Catalog/Model/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ public function getUnusedPathByUrlKey($storeId, $requestPath, $idPath, $urlKey)
$match['increment'] = $lastRequestPath;
}
return $match['prefix']
. (!empty($match['increment']) ? ((int)$match['increment'] + 1) : '1')
. (empty($match['increment']) ? ('1') : (int)$match['increment'] + 1)
. $match['suffix'];
} else {
return $requestPath;
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/CatalogInventory/Helper/Minsaleqty.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Mage_CatalogInventory_Helper_Minsaleqty
*/
protected function _fixQty($qty)
{
return (!empty($qty) ? (float)$qty : null);
return (empty($qty) ? null : (float)$qty);
}

/**
Expand Down
Loading

0 comments on commit 368047c

Please sign in to comment.