Skip to content

Incorrect behavior of RemoveAlwaysTrueIfConditionRector #7757

@Naugrimm

Description

@Naugrimm

Bug Report

Subject Details
Rector version last dev-main
Installed as composer dependency

Minimal PHP Code Causing Issue

See https://getrector.com/demo/e8d55b28-49e1-46ff-81df-2866f17b85f3

<?php

final class DemoFile
{
    public function run()
    {
        if (($value = "foo") !== null) {
        	echo $value;
        }
    }
}

Responsible rules

  • RemoveAlwaysTrueIfConditionRector

Expected Behavior

The Rector should either not touch the code or extract the assignment before removing the if-statement.

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