-
-
Notifications
You must be signed in to change notification settings - Fork 738
Closed
rectorphp/rector-src
#7659Labels
Description
Bug Report
| Subject | Details |
|---|---|
| Rector version | 2.2.8 |
RemoveAlwaysElseRector is not formatting code correctly or completing what I would expect it to refactor.
Minimal PHP Code Causing Issue
https://getrector.com/demo/6b25de4e-f818-4e12-95c4-62620da5445d
- if ($value == 0) {
- return $value;
- } elseif ($formatForEmail) {
- $value .= '|' . 1;
-
- return $time_context . ' // ' . $direction . $value . ' minute(s)';
- } else {
+ if ($value == 0) {
+ return $value;
+ }
+ if ($formatForEmail) {
+ $value .= '|' . 1;
+ return $time_context . ' // ' . $direction . $value . ' minute(s)';
+ }
+ else {
return $value;
}Expected Behaviour
Highlights
- Final
elsebranch can be refactored further - A newline should be inserted between
ifconditions - The newline present in the original code should be maintained after the refactor (i.e. the one that comes after
$value .= '|' . 1;)
- if ($value == 0) {
- return $value;
- } elseif ($formatForEmail) {
- $value .= '|' . 1;
-
- return $time_context . ' // ' . $direction . $value . ' minute(s)';
- } else {
- return $value;
- }
+ if ($value == 0) {
+ return $value;
+ }
+
+ if ($formatForEmail) {
+ $value .= '|' . 1;
+
+ return $time_context . ' // ' . $direction . $value . ' minute(s)';
+ }
+
+ return $value;