Skip to content

RemoveDeadIfBlockRector changes behaviour with elseif #9884

Description

@raphaelincert

Bug Report

Subject Details
Rector version 2.6.6

Removing empty if block changes behaviour with elseif.
if the expression of the empty if block is true
before: nothing is executed
after: the else block is executed

Minimal PHP Code Causing Issue

<?php
$a = 1;
$b = [1];
$c = [];

if (in_array($a, $b)) {
	
} elseif (in_array($a, $c)) {
	echo "elseif";
} else {
	echo "else";
}

https://getrector.com/demo/5bd04d06-85d8-4cba-be99-f83465e58ef2

Expected Behaviour

No change.
After the rector change the else block is executed instead of nothing.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions