Skip to content

Incorrect behavior of RemoveAlwaysTrueIfConditionRector #9336

@mityu

Description

@mityu

Bug Report

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

Minimal PHP Code Causing Issue

See https://getrector.com/demo/56b9957e-d1d5-442b-8458-2a54346c2724

<?php

// toplevel
if (true) {
    // first innner
    f();
    // second inner
}

Responsible rules

  • RemoveAlwaysTrueIfConditionRector

Expected Behavior

The refactored php code should keep these both comments:

  • // toplevel comment, which is on the above of the if statement.
  • // first inner comment, which is the first statement of if-then block.

In other words, the refactored php code should be like this:

<?php

// toplevel
// first innner
f();
// second inner

Actual Behavior

The // first inner comment is thrown away.

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