Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug with NewlineBeforeNewAssignSetRector #8991

Closed
guideloince opened this issue Jan 29, 2025 · 1 comment
Closed

Bug with NewlineBeforeNewAssignSetRector #8991

guideloince opened this issue Jan 29, 2025 · 1 comment
Labels

Comments

@guideloince
Copy link

guideloince commented Jan 29, 2025

Bug Report

Subject Details
Rector version 2.0.6

Hi People,

I discovered a problem during my development.

Indeed, on the rule "NewlineBeforeNewAssignSetRector", I had a very strange case, and I only reproduced it within a class. Here is the initial code:

class Foo
{
    public function bar(): void
    {
        $bar         = new \stdClass();
        $bar->barFoo = false;

        $barFoo           = new \stdClass();
        $barFoo->tokenize = false;
    }
}

Rector tries to add a line after the second class declaration.

class Foo
{
    public function bar(): void
    {
        $bar         = new \stdClass();
        $bar->barFoo = false;

        $barFoo           = new \stdClass();
        $barFoo->tokenize = false;
    }
}

By trying several different cases it turns out that my property must have the same name as my next variable. In my case ->barFoo and $barFoo.

Minimal PHP Code Causing Issue

demo

Expected Behaviour

For me is a bug in rector but i'm not sure !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants