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

[TypeDeclaration] Skip Type modified between Assign and Return_ on ReturnTypeFromReturnNewRector #2650

Merged
merged 8 commits into from Jul 10, 2022

Conversation

samsonasik
Copy link
Member

@samsonasik samsonasik commented Jul 10, 2022

The following code should be skipped:

final class SkipTypeModifiedBetweenAssignAndReturn
{
    public function action()
    {
        $response = new SomeResponse();

        $this->verify($response);

        return $response;
    }

    private function verify(SomeResponse &$someResponse): void
    {
        if (is_cli()) {
            $someResponse = new CLIResponse();
        }
    }
}

@samsonasik samsonasik changed the title [TypeDeclaration] SKip has other Stmt between assign and Return on ReturnTypeFromReturnNewRector [TypeDeclaration] Skip has other Stmt between assign and Return on ReturnTypeFromReturnNewRector Jul 10, 2022
@samsonasik
Copy link
Member Author

Fixed 🎉

@samsonasik
Copy link
Member Author

All checks have passed 🎉 @TomasVotruba it is ready for review.

@samsonasik
Copy link
Member Author

I updated to verify with type change on next Stmt on pass by reference use case.

@samsonasik samsonasik changed the title [TypeDeclaration] Skip has other Stmt between assign and Return on ReturnTypeFromReturnNewRector [TypeDeclaration] Skip Type modified between Assign and Return_ on ReturnTypeFromReturnNewRector Jul 10, 2022
@samsonasik
Copy link
Member Author

samsonasik commented Jul 10, 2022

I found another use case to be skipped:

final class SkipTypeModifiedBetweenAssignAndReturnWithIf
{
    public function action()
    {
        $response = new SomeResponse();

        if (is_cli()) {
            $response = new CLIResponse();
        }

        return $response;
    }
}

@samsonasik
Copy link
Member Author

Fixed 🎉

@samsonasik
Copy link
Member Author

All checks have passed 🎉 @TomasVotruba I think it is ready.

@TomasVotruba
Copy link
Member

Thank you 👍

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