Skip to content

Incorrect behavior of SplitDoubleAssignRector #9749

Description

@franck-paul

Bug Report

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

Minimal PHP Code Causing Issue

See https://getrector.com/demo/88709536-50ef-4cc6-842a-75409b778fbe

<?php

final class DemoFile
{
    public function run(bool $param)
    {
        if ($this->isTrue($param)) {
            return 5;
        }

        return '10';
    }

    private function isTrue($value)
    {
        $a = $b = 42;
        
        // Test with comment just before double assignment
        $c = $d = 13;
        
        return $value === true;
    }
}

Responsible rules

  • SplitDoubleAssignRector

Expected Behavior

The // Test with comment just before double assignment comment line disappear, it should not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions