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 PreparedValueToEarlyReturnRector #8390

Closed
staabm opened this issue Jan 5, 2024 · 0 comments · Fixed by rectorphp/rector-src#5545
Closed

Incorrect behavior of PreparedValueToEarlyReturnRector #8390

staabm opened this issue Jan 5, 2024 · 0 comments · Fixed by rectorphp/rector-src#5545
Labels

Comments

@staabm
Copy link
Contributor

staabm commented Jan 5, 2024

Bug Report

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

Minimal PHP Code Causing Issue

See https://getrector.com/demo/776ea60b-3f0c-4c6f-94b6-ffa54ce1005b

<?php

function articelnameWithFootnotes(clxArtikel $artikel, $showZusatz = true): string
    {
        $return = HtmlHelper::escape_htmlspecial($artikel->getName());
        if ($showZusatz) {
            $return = HtmlHelper::escape_htmlspecial($artikel->getName().' '.$artikel->getZusatz());
        }

        if ('' != $artikel->rechtstext) {
            $footnote = Cmsfootnote::fetchOrCreate($artikel->rechtstext, '**');
            $return .= $footnote->renderReference();
        }

        return $return;
    }

Responsible rules

  • PreparedValueToEarlyReturnRector

Expected Behavior

after transformation phpstan reports

Undefined variable: $return

because the code after rector processed it, is not euqivalent to the initial logic

my guess is that rector does not realize, that there is a .= assignment

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

Successfully merging a pull request may close this issue.

1 participant