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

Incorrect behavior of IfIssetToCoalescingRector #8933

Open
yguedidi opened this issue Dec 13, 2024 · 1 comment
Open

Incorrect behavior of IfIssetToCoalescingRector #8933

yguedidi opened this issue Dec 13, 2024 · 1 comment
Labels

Comments

@yguedidi
Copy link

Bug Report

Subject Details
Rector version 1.2.10
Installed as composer dependency

Minimal PHP Code Causing Issue

See https://getrector.com/demo/b74a1b1b-f13c-4f65-a7a1-a23c36ca40c7

<?php

final class DemoFile
{
    private string|null $value;
    
    public function run(string $param)
    {
        if (isset($this->value)) {
            return $this->value;
        }

        return $this->value = $param;
    }
}

Responsible rules

  • IfIssetToCoalescingRector

Expected Behavior

This gives return $this->value ?? $this->value = $param;
Would have expected return $this->value ??= $param; directly, seems not catch even after additional runs of Rector

@yguedidi yguedidi added the bug label Dec 13, 2024
@samsonasik
Copy link
Member

is the result equals? if yes, then it is a feature, not a bug, as that's possible improvement.

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