Skip to content

[Backport] Eliminate usage of "else" statements #14696

New issue

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

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

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ public function getCondition()
{
if ($this->getValue()) {
return $this->getColumn()->getValue();
} else {
return [['neq' => $this->getColumn()->getValue()], ['is' => new \Zend_Db_Expr('NULL')]];
}
return [['neq' => $this->getColumn()->getValue()], ['is' => new \Zend_Db_Expr('NULL')]];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,8 @@ public function getSelectedJson()
if ($selected = $this->getRequest()->getParam($this->getFormFieldNameInternal())) {
$selected = explode(',', $selected);
return join(',', $selected);
} else {
return '';
}
return '';
}

/**
Expand All @@ -237,9 +236,8 @@ public function getSelected()
if ($selected = $this->getRequest()->getParam($this->getFormFieldNameInternal())) {
$selected = explode(',', $selected);
return $selected;
} else {
return [];
}
return [];
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,8 @@ public function getSelectedJson()
if ($selected = $this->getRequest()->getParam($this->getFormFieldNameInternal())) {
$selected = explode(',', $selected);
return join(',', $selected);
} else {
return '';
}
return '';
}

/**
Expand All @@ -233,9 +232,8 @@ public function getSelected()
if ($selected = $this->getRequest()->getParam($this->getFormFieldNameInternal())) {
$selected = explode(',', $selected);
return $selected;
} else {
return [];
}
return [];
}

/**
Expand Down
3 changes: 1 addition & 2 deletions app/code/Magento/Backend/Controller/Adminhtml/Auth/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ public function execute()
// redirect according to rewrite rule
if ($requestUrl != $backendUrl) {
return $this->getRedirect($backendUrl);
} else {
return $this->resultPageFactory->create();
}
return $this->resultPageFactory->create();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ private function getSecurityCookie()
{
if (!($this->securityCookie instanceof SecurityCookie)) {
return \Magento\Framework\App\ObjectManager::getInstance()->get(SecurityCookie::class);
} else {
return $this->securityCookie;
}
return $this->securityCookie;
}

/**
Expand Down
3 changes: 1 addition & 2 deletions app/code/Magento/Backend/Model/Menu/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -503,12 +503,11 @@ public function populateFromArray(array $data)
$this->_tooltip = $this->_getArgument($data, 'toolTip');
$this->_title = $this->_getArgument($data, 'title');
$this->target = $this->_getArgument($data, 'target');
$this->_submenu = null;
if (isset($data['sub_menu'])) {
$menu = $this->_menuFactory->create();
$menu->populateFromArray($data['sub_menu']);
$this->_submenu = $menu;
} else {
$this->_submenu = null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ public function __get($name)
{
if (array_key_exists($name, $this->_attributes)) {
return $this->_attributes[$name];
} else {
trigger_error('Undefined property on ' . get_class($this) . ': ' . $name, E_USER_NOTICE);
return null;
}
trigger_error('Undefined property on ' . get_class($this) . ': ' . $name, E_USER_NOTICE);
return null;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,8 @@ public function getChildren($item)

if (isset($itemsArray[$item->getOrderItem()->getId()])) {
return $itemsArray[$item->getOrderItem()->getId()];
} else {
return null;
}
return null;
}

/**
Expand Down Expand Up @@ -219,9 +218,8 @@ public function getOrderItem()
{
if ($this->getItem() instanceof \Magento\Sales\Model\Order\Item) {
return $this->getItem();
} else {
return $this->getItem()->getOrderItem();
}
return $this->getItem()->getOrderItem();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,8 @@ public function isSelected($selection)
return in_array($selection->getSelectionId(), $selectedOptions);
} elseif ($selectedOptions == 'None') {
return false;
} else {
return $selection->getIsDefault() && $selection->isSaleable();
}
return $selection->getIsDefault() && $selection->isSaleable();
}

/**
Expand Down
6 changes: 2 additions & 4 deletions app/code/Magento/Bundle/Block/Sales/Order/Items/Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,8 @@ public function getValueHtml($item)
if ($attributes = $this->getSelectionAttributes($item)) {
return sprintf('%d', $attributes['qty']) . ' x ' . $this->escapeHtml($item->getName()) . " "
. $this->getOrder()->formatPrice($attributes['price']);
} else {
return $this->escapeHtml($item->getName());
}
return $this->escapeHtml($item->getName());
}

/**
Expand Down Expand Up @@ -179,9 +178,8 @@ public function getChildren($item)

if (isset($itemsArray[$item->getOrderItem()->getId()])) {
return $itemsArray[$item->getOrderItem()->getId()];
} else {
return null;
}
return null;
}

/**
Expand Down
3 changes: 1 addition & 2 deletions app/code/Magento/Bundle/Model/Plugin/PriceBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ public function aroundValidate(
&& $object->getPriceType() == \Magento\Bundle\Model\Product\Price::PRICE_TYPE_DYNAMIC
) {
return true;
} else {
return $proceed($object);
}
return $proceed($object);
}
}
3 changes: 1 addition & 2 deletions app/code/Magento/Bundle/Model/Product/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -1015,9 +1015,8 @@ public function shakeSelections($firstItem, $secondItem)
];
if ($aPosition == $bPosition) {
return 0;
} else {
return $aPosition < $bPosition ? -1 : 1;
}
return $aPosition < $bPosition ? -1 : 1;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,8 @@ public function getChildren($item)

if (isset($itemsArray[$item->getOrderItem()->getId()])) {
return $itemsArray[$item->getOrderItem()->getId()];
} else {
return null;
}
return null;
}

/**
Expand Down Expand Up @@ -244,9 +243,8 @@ public function getOrderItem()
{
if ($this->getItem() instanceof \Magento\Sales\Model\Order\Item) {
return $this->getItem();
} else {
return $this->getItem()->getOrderItem();
}
return $this->getItem()->getOrderItem();
}

/**
Expand Down
3 changes: 1 addition & 2 deletions app/code/Magento/Bundle/Pricing/Adjustment/Calculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,8 @@ public function calculateBundleAmount($basePriceValue, $bundleProduct, $selectio
{
if ($bundleProduct->getPriceType() == Price::PRICE_TYPE_FIXED) {
return $this->calculateFixedBundleAmount($basePriceValue, $bundleProduct, $selectionPriceList, $exclude);
} else {
return $this->calculateDynamicBundleAmount($basePriceValue, $bundleProduct, $selectionPriceList, $exclude);
}
return $this->calculateDynamicBundleAmount($basePriceValue, $bundleProduct, $selectionPriceList, $exclude);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,7 @@ public function getProduct()
{
if ($this->bundleProduct->getPriceType() == Price::PRICE_TYPE_DYNAMIC) {
return parent::getProduct();
} else {
return $this->bundleProduct;
}
return $this->bundleProduct;
}
}
3 changes: 1 addition & 2 deletions app/code/Magento/Bundle/Pricing/Price/ConfiguredPrice.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,8 @@ public function getValue()
$this->priceInfo
->getPrice(BundleDiscountPrice::PRICE_CODE)
->calculateDiscount($configuredOptionsAmount);
} else {
return parent::getValue();
}
return parent::getValue();
}

/**
Expand Down