Skip to content

Commit 9918ba2

Browse files
committed
rector: ChangeIfElseValueAssignToEarlyReturnRector
- see https://getrector.com/rule-detail/change-if-else-value-assign-to-early-return-rector
1 parent 533b2a7 commit 9918ba2

File tree

56 files changed

+197
-310
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+197
-310
lines changed

.rector.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@
9999
DeadCode\Ternary\TernaryToBooleanOrFalseToBooleanAndRector::class, # todo: TMP
100100
DeadCode\TryCatch\RemoveDeadTryCatchRector::class, # todo: TMP (!?!)
101101
EarlyReturn\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector::class, # todo: TMP
102-
EarlyReturn\If_\ChangeIfElseValueAssignToEarlyReturnRector::class, # todo: TMP
103102
EarlyReturn\If_\ChangeNestedIfsToEarlyReturnRector::class, # todo: TMP
104103
EarlyReturn\If_\ChangeOrIfContinueToMultiContinueRector::class, # todo: TMP
105104
EarlyReturn\Return_\ReturnBinaryOrToEarlyReturnRector::class, # todo: TMP

app/code/core/Mage/Adminhtml/Block/Catalog/Category/Widget/Chooser.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,25 +123,24 @@ public function getNodeClickListener()
123123
}
124124

125125
if ($this->getUseMassaction()) {
126-
$js = '
126+
return '
127127
function (node, e) {
128128
if (node.ui.toggleCheck) {
129129
node.ui.toggleCheck(true);
130130
}
131131
}
132132
';
133-
} else {
134-
$chooserJsObject = $this->getId();
135-
$js = '
133+
}
134+
135+
$chooserJsObject = $this->getId();
136+
137+
return '
136138
function (node, e) {
137139
' . $chooserJsObject . '.setElementValue("category/" + node.attributes.id);
138140
' . $chooserJsObject . '.setElementLabel(node.text);
139141
' . $chooserJsObject . '.close();
140142
}
141143
';
142-
}
143-
144-
return $js;
145144
}
146145

147146
/**

app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,10 @@ public function getBillingAddressHtml()
183183
{
184184
$html = '';
185185
if ($address = $this->getCustomer()->getPrimaryBillingAddress()) {
186-
$html = $address->format('html');
187-
} else {
188-
$html = Mage::helper('customer')->__('The customer does not have default billing address.');
186+
return $address->format('html');
189187
}
190188

191-
return $html;
189+
return Mage::helper('customer')->__('The customer does not have default billing address.');
192190
}
193191

194192
/**

app/code/core/Mage/Adminhtml/Block/Dashboard/Searches/Renderer/Searchquery.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,10 @@ public function render(Varien_Object $row)
1818
{
1919
$value = $row->getData($this->getColumn()->getIndex());
2020
if (Mage::helper('core/string')->strlen($value) > 30) {
21-
$value = '<span title="' . $this->escapeHtml($value) . '">'
21+
return '<span title="' . $this->escapeHtml($value) . '">'
2222
. $this->escapeHtml(Mage::helper('core/string')->truncate($value, 30)) . '</span>';
23-
} else {
24-
$value = $this->escapeHtml($value);
2523
}
2624

27-
return $value;
25+
return $this->escapeHtml($value);
2826
}
2927
}

app/code/core/Mage/Adminhtml/Block/Sales/Order/Create.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,12 @@ protected function _getSession()
115115
public function getCancelUrl()
116116
{
117117
if ($this->_getSession()->getOrder()->getId()) {
118-
$url = $this->getUrl('*/sales_order/view', [
118+
return $this->getUrl('*/sales_order/view', [
119119
'order_id' => Mage::getSingleton('adminhtml/session_quote')->getOrder()->getId(),
120120
]);
121-
} else {
122-
$url = $this->getUrl('*/*/cancel');
123121
}
124122

125-
return $url;
123+
return $this->getUrl('*/*/cancel');
126124
}
127125

128126
/**

app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Shipping/Address.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,10 @@ public function getAddressId()
109109
public function getAddress()
110110
{
111111
if ($this->getIsAsBilling()) {
112-
$address = $this->getCreateOrderModel()->getBillingAddress();
113-
} else {
114-
$address = $this->getCreateOrderModel()->getShippingAddress();
112+
return $this->getCreateOrderModel()->getBillingAddress();
115113
}
116114

117-
return $address;
115+
return $this->getCreateOrderModel()->getShippingAddress();
118116
}
119117

120118
/**

app/code/core/Mage/Adminhtml/Block/Sales/Order/Creditmemo/Create.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,16 @@ public function getCreditmemo()
4242
public function getHeaderText()
4343
{
4444
if ($this->getCreditmemo()->getInvoice()) {
45-
$header = Mage::helper('sales')->__(
45+
return Mage::helper('sales')->__(
4646
'New Credit Memo for Invoice #%s',
4747
$this->escapeHtml($this->getCreditmemo()->getInvoice()->getIncrementId()),
4848
);
49-
} else {
50-
$header = Mage::helper('sales')->__(
51-
'New Credit Memo for Order #%s',
52-
$this->escapeHtml($this->getCreditmemo()->getOrder()->getRealOrderId()),
53-
);
5449
}
5550

56-
return $header;
51+
return Mage::helper('sales')->__(
52+
'New Credit Memo for Order #%s',
53+
$this->escapeHtml($this->getCreditmemo()->getOrder()->getRealOrderId()),
54+
);
5755
}
5856

5957
/**

app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Packaging.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,12 +193,10 @@ public function getPackages()
193193
{
194194
$packages = $this->getShipment()->getPackages();
195195
if ($packages) {
196-
$packages = unserialize($packages, ['allowed_classes' => false]);
197-
} else {
198-
$packages = [];
196+
return unserialize($packages, ['allowed_classes' => false]);
199197
}
200198

201-
return $packages;
199+
return [];
202200
}
203201

204202
/**

app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Packaging/Grid.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,11 @@ public function __construct()
2828
public function getCollection()
2929
{
3030
if ($this->getShipment()->getId()) {
31-
$collection = Mage::getModel('sales/order_shipment_item')->getCollection()
31+
return Mage::getModel('sales/order_shipment_item')->getCollection()
3232
->setShipmentFilter($this->getShipment()->getId());
33-
} else {
34-
$collection = $this->getShipment()->getAllItems();
3533
}
3634

37-
return $collection;
35+
return $this->getShipment()->getAllItems();
3836
}
3937

4038
/**

app/code/core/Mage/Adminhtml/Block/Sales/Order/Status/Grid.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,10 @@ protected function _prepareColumns()
8686
public function decorateState($value, $row, $column, $isExport)
8787
{
8888
if ($value) {
89-
$cell = $value . ' [' . Mage::getSingleton('sales/order_config')->getStateLabel($value) . ']';
90-
} else {
91-
$cell = $value;
89+
return $value . ' [' . Mage::getSingleton('sales/order_config')->getStateLabel($value) . ']';
9290
}
9391

94-
return $cell;
92+
return $value;
9593
}
9694

9795
public function decorateAction($value, $row, $column, $isExport)

0 commit comments

Comments
 (0)