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 ExplicitBoolCompareRector - double variable assignment in condition #8741

Open
etshy opened this issue Jul 16, 2024 · 1 comment

Comments

@etshy
Copy link

etshy commented Jul 16, 2024

Bug Report

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

Minimal PHP Code Causing Issue

See https://getrector.com/demo/df4a4011-49f2-4fd2-96e7-a1627ebb4eaa

<?php

declare(strict_types=1);

final class DemoFile
{
    public function run(): int|string
    {
        if ($base64 = base64_encode('')) {
            return 5;
        }

        return '10';
    }
}

Responsible rules

  • ExplicitBoolCompareRector

Expected Behavior

Not doubling the variable assignment.
Or make the variable assignment before the condition and then using the variable.

@etshy etshy added the bug label Jul 16, 2024
@samsonasik
Copy link
Member

we are aware of it, just not a priority right now #8663 (comment)

@samsonasik samsonasik removed the bug label Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants