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] Handle inner Closure on ReturnTypeFromReturnNewRector #1467

Merged
merged 5 commits into from
Dec 11, 2021

Conversation

samsonasik
Copy link
Member

@samsonasik samsonasik commented Dec 11, 2021

Given the following code:

final class InnerClosure
{
    public function __construct()
    {
        $a = function () {
            return new \stdClass;
        };
    }
}

It currently produce parent classmethod,

-    public function __construct()
+    public function __construct(): \stdClass
     {
         $a = function () {

which invalid. This PR try to fix it.

Fixes rectorphp/rector#6858

@samsonasik samsonasik changed the title [TypeDeclaration] Handle inner function on ReturnTypeFromReturnNewRector [TypeDeclaration] Handle inner Closure on ReturnTypeFromReturnNewRector Dec 11, 2021
@samsonasik
Copy link
Member Author

Fixed 🎉

@samsonasik
Copy link
Member Author

/cc @javaDeveloperKid

@samsonasik
Copy link
Member Author

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

@TomasVotruba TomasVotruba merged commit 86394ab into main Dec 11, 2021
@TomasVotruba TomasVotruba deleted the handle-inner-funciton-return-new branch December 11, 2021 16:02
@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
Development

Successfully merging this pull request may close these issues.

Incorrect behavior of ReturnTypeFromReturnNewRector, AddClosureReturnTypeRector
2 participants