Skip to content

RemoveDeadIfBlockRector removes else condition #9776

Description

@BenMorel

Bug Report

Subject Details
Rector version 2.4.5

Minimal PHP Code Causing Issue

final class DemoFile
{
    public function calculatePrice($qty, $cond, $price, $price2)
    {
        if ($qty < 1) {
        } elseif (!$cond) {
            $total = $qty * $price1;
        } else {
            $total = $qty * $price2;
        }

        return $total;
    }
}

https://getrector.com/demo/700bb8f8-3477-4c0c-aa93-0588334e0f0e

Expected Behaviour

        if ($qty >= 1 && !$cond) {
            $total = $qty * $price1;
        } else {
            $total = $qty * $price2;
        }

Actual Behaviour

        if ($qty >= 1 && !$cond) {
            $total = $qty * $price1;
        }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions