Skip to content

Commit e59605b

Browse files
author
Stanislav Idolov
authored
ENGCOM-1263: Eliminate usage of "else" statements #14652
2 parents 8107096 + 4a7bffd commit e59605b

File tree

16 files changed

+22
-43
lines changed

16 files changed

+22
-43
lines changed

app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Radio.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ public function getCondition()
3131
{
3232
if ($this->getValue()) {
3333
return $this->getColumn()->getValue();
34-
} else {
35-
return [['neq' => $this->getColumn()->getValue()], ['is' => new \Zend_Db_Expr('NULL')]];
3634
}
35+
return [['neq' => $this->getColumn()->getValue()], ['is' => new \Zend_Db_Expr('NULL')]];
3736
}
3837
}

app/code/Magento/Backend/Block/Widget/Grid/Massaction/AbstractMassaction.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,8 @@ public function getSelectedJson()
223223
if ($selected = $this->getRequest()->getParam($this->getFormFieldNameInternal())) {
224224
$selected = explode(',', $selected);
225225
return join(',', $selected);
226-
} else {
227-
return '';
228226
}
227+
return '';
229228
}
230229

231230
/**
@@ -238,9 +237,8 @@ public function getSelected()
238237
if ($selected = $this->getRequest()->getParam($this->getFormFieldNameInternal())) {
239238
$selected = explode(',', $selected);
240239
return $selected;
241-
} else {
242-
return [];
243240
}
241+
return [];
244242
}
245243

246244
/**

app/code/Magento/Backend/Block/Widget/Grid/Massaction/Extended.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,8 @@ public function getSelectedJson()
219219
if ($selected = $this->getRequest()->getParam($this->getFormFieldNameInternal())) {
220220
$selected = explode(',', $selected);
221221
return join(',', $selected);
222-
} else {
223-
return '';
224222
}
223+
return '';
225224
}
226225

227226
/**
@@ -234,9 +233,8 @@ public function getSelected()
234233
if ($selected = $this->getRequest()->getParam($this->getFormFieldNameInternal())) {
235234
$selected = explode(',', $selected);
236235
return $selected;
237-
} else {
238-
return [];
239236
}
237+
return [];
240238
}
241239

242240
/**

app/code/Magento/Backend/Controller/Adminhtml/Auth/Login.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,8 @@ public function execute()
5050
// redirect according to rewrite rule
5151
if ($requestUrl != $backendUrl) {
5252
return $this->getRedirect($backendUrl);
53-
} else {
54-
return $this->resultPageFactory->create();
5553
}
54+
return $this->resultPageFactory->create();
5655
}
5756

5857
/**

app/code/Magento/Backend/Controller/Adminhtml/System/Account/Save.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@ private function getSecurityCookie()
3232
{
3333
if (!($this->securityCookie instanceof SecurityCookie)) {
3434
return \Magento\Framework\App\ObjectManager::getInstance()->get(SecurityCookie::class);
35-
} else {
36-
return $this->securityCookie;
3735
}
36+
return $this->securityCookie;
3837
}
3938

4039
/**

app/code/Magento/Backend/Model/Menu/Item.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,12 +503,11 @@ public function populateFromArray(array $data)
503503
$this->_tooltip = $this->_getArgument($data, 'toolTip');
504504
$this->_title = $this->_getArgument($data, 'title');
505505
$this->target = $this->_getArgument($data, 'target');
506+
$this->_submenu = null;
506507
if (isset($data['sub_menu'])) {
507508
$menu = $this->_menuFactory->create();
508509
$menu->populateFromArray($data['sub_menu']);
509510
$this->_submenu = $menu;
510-
} else {
511-
$this->_submenu = null;
512511
}
513512
}
514513
}

app/code/Magento/Braintree/Test/Unit/Model/Report/BraintreeTransactionStub.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,9 @@ public function __get($name)
3434
{
3535
if (array_key_exists($name, $this->_attributes)) {
3636
return $this->_attributes[$name];
37-
} else {
38-
trigger_error('Undefined property on ' . get_class($this) . ': ' . $name, E_USER_NOTICE);
39-
return null;
4037
}
38+
trigger_error('Undefined property on ' . get_class($this) . ': ' . $name, E_USER_NOTICE);
39+
return null;
4140
}
4241

4342
/**

app/code/Magento/Bundle/Block/Adminhtml/Sales/Order/Items/Renderer.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,8 @@ public function getChildren($item)
9595

9696
if (isset($itemsArray[$item->getOrderItem()->getId()])) {
9797
return $itemsArray[$item->getOrderItem()->getId()];
98-
} else {
99-
return null;
10098
}
99+
return null;
101100
}
102101

103102
/**
@@ -219,9 +218,8 @@ public function getOrderItem()
219218
{
220219
if ($this->getItem() instanceof \Magento\Sales\Model\Order\Item) {
221220
return $this->getItem();
222-
} else {
223-
return $this->getItem()->getOrderItem();
224221
}
222+
return $this->getItem()->getOrderItem();
225223
}
226224

227225
/**

app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle/Option.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,8 @@ public function isSelected($selection)
189189
return in_array($selection->getSelectionId(), $selectedOptions);
190190
} elseif ($selectedOptions == 'None') {
191191
return false;
192-
} else {
193-
return $selection->getIsDefault() && $selection->isSaleable();
194192
}
193+
return $selection->getIsDefault() && $selection->isSaleable();
195194
}
196195

197196
/**

app/code/Magento/Bundle/Block/Sales/Order/Items/Renderer.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,8 @@ public function getValueHtml($item)
142142
if ($attributes = $this->getSelectionAttributes($item)) {
143143
return sprintf('%d', $attributes['qty']) . ' x ' . $this->escapeHtml($item->getName()) . " "
144144
. $this->getOrder()->formatPrice($attributes['price']);
145-
} else {
146-
return $this->escapeHtml($item->getName());
147145
}
146+
return $this->escapeHtml($item->getName());
148147
}
149148

150149
/**
@@ -179,9 +178,8 @@ public function getChildren($item)
179178

180179
if (isset($itemsArray[$item->getOrderItem()->getId()])) {
181180
return $itemsArray[$item->getOrderItem()->getId()];
182-
} else {
183-
return null;
184181
}
182+
return null;
185183
}
186184

187185
/**

app/code/Magento/Bundle/Model/Plugin/PriceBackend.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ public function aroundValidate(
2929
&& $object->getPriceType() == \Magento\Bundle\Model\Product\Price::PRICE_TYPE_DYNAMIC
3030
) {
3131
return true;
32-
} else {
33-
return $proceed($object);
3432
}
33+
return $proceed($object);
3534
}
3635
}

app/code/Magento/Bundle/Model/Product/Type.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,9 +1007,8 @@ public function shakeSelections($firstItem, $secondItem)
10071007
];
10081008
if ($aPosition == $bPosition) {
10091009
return 0;
1010-
} else {
1011-
return $aPosition < $bPosition ? -1 : 1;
10121010
}
1011+
return $aPosition < $bPosition ? -1 : 1;
10131012
}
10141013

10151014
/**

app/code/Magento/Bundle/Model/Sales/Order/Pdf/Items/AbstractItems.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,8 @@ public function getChildren($item)
9292

9393
if (isset($itemsArray[$item->getOrderItem()->getId()])) {
9494
return $itemsArray[$item->getOrderItem()->getId()];
95-
} else {
96-
return null;
9795
}
96+
return null;
9897
}
9998

10099
/**
@@ -244,9 +243,8 @@ public function getOrderItem()
244243
{
245244
if ($this->getItem() instanceof \Magento\Sales\Model\Order\Item) {
246245
return $this->getItem();
247-
} else {
248-
return $this->getItem()->getOrderItem();
249246
}
247+
return $this->getItem()->getOrderItem();
250248
}
251249

252250
/**

app/code/Magento/Bundle/Pricing/Adjustment/Calculator.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,8 @@ public function calculateBundleAmount($basePriceValue, $bundleProduct, $selectio
271271
{
272272
if ($bundleProduct->getPriceType() == Price::PRICE_TYPE_FIXED) {
273273
return $this->calculateFixedBundleAmount($basePriceValue, $bundleProduct, $selectionPriceList, $exclude);
274-
} else {
275-
return $this->calculateDynamicBundleAmount($basePriceValue, $bundleProduct, $selectionPriceList, $exclude);
276274
}
275+
return $this->calculateDynamicBundleAmount($basePriceValue, $bundleProduct, $selectionPriceList, $exclude);
277276
}
278277

279278
/**

app/code/Magento/Bundle/Pricing/Price/BundleSelectionPrice.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,7 @@ public function getProduct()
178178
{
179179
if ($this->bundleProduct->getPriceType() == Price::PRICE_TYPE_DYNAMIC) {
180180
return parent::getProduct();
181-
} else {
182-
return $this->bundleProduct;
183181
}
182+
return $this->bundleProduct;
184183
}
185184
}

app/code/Magento/Bundle/Pricing/Price/ConfiguredPrice.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,8 @@ public function getValue()
140140
$this->priceInfo
141141
->getPrice(BundleDiscountPrice::PRICE_CODE)
142142
->calculateDiscount($configuredOptionsAmount);
143-
} else {
144-
return parent::getValue();
145143
}
144+
return parent::getValue();
146145
}
147146

148147
/**

0 commit comments

Comments
 (0)