Bug Report
| Subject |
Details |
| Rector version |
Rector v0.7.22 |
| Installed as |
composer dependency |
Complex if-else if block is reduced to something too simple.
'else if' could be handled similar to 'elseif'
Minimal PHP Code Causing Issue
https://getrector.org/demo/e02bb6b3-6008-4554-927e-695821918b6c
Notice how $anotherObject is missing from the result
Notice how if you write else if as elseif it does the correct thing.
Expected Behaviour
Code should be processed while keeping this view of it in mind:
if ($someName && $someObject->someName == $someName) {
return true;
}
if (!$someName && !$funnel->someName) {
return true;
}
if (!$someName && $anotherObject->someName == $funnel->someName) {
return true;
}
return false;
I guess another way is to merge the if (!$someName):
if ($someName && $someObject->someName == $someName) {
return true;
}
if(!$someName) {
if (!$funnel->someName) {
return true;
}
if ($anotherObject->someName == $funnel->someName) {
return true;
}
}
return false;
Bug Report
Complex
if-else ifblock is reduced to something too simple.'else if' could be handled similar to 'elseif'
Minimal PHP Code Causing Issue
https://getrector.org/demo/e02bb6b3-6008-4554-927e-695821918b6c
Notice how $anotherObject is missing from the result
Notice how if you write
else ifaselseifit does the correct thing.Expected Behaviour
Code should be processed while keeping this view of it in mind:
I guess another way is to merge the
if (!$someName):