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 anonymous class and other object on ReturnUnionTypeRector #4670

Merged
merged 13 commits into from
Aug 6, 2023

Conversation

samsonasik
Copy link
Member

The following code should be skipped:

final class SkipAnonymousClassAndOtherObject
{
    public function run()
    {
        if (rand(0,1)) {
            return new SkipAnonymousClassAndOtherObject();
        }

        return new class {};
    }
}

as it will cause fatal error even with object|SkipAnonymousClassAndOtherObject see https://3v4l.org/TFnZj

@samsonasik
Copy link
Member Author

Fixed 🎉 , I reverted ReturnTypeInferer native usage as seems already cover docblock already

@samsonasik
Copy link
Member Author

Ok, reverting ReturnTypeInferer to use getType() instead of getNativeType() cause invalid result on docblock

https://github.com/rectorphp/rector-src/actions/runs/5775375225/job/15653289866?pr=4670#step:5:39

I will check if it can be tweaked for special New_ usage

@samsonasik samsonasik marked this pull request as draft August 6, 2023 07:49
@samsonasik
Copy link
Member Author

Fixed 🎉 with class name anonymous detection 69e2b41 in ClassAnalyzer

@samsonasik samsonasik marked this pull request as ready for review August 6, 2023 08:10
@samsonasik
Copy link
Member Author

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

@samsonasik
Copy link
Member Author

Also handled anonymous class with parent e16b762 that covered by NewTypeResolver

@TomasVotruba
Copy link
Member

Thank you 👍

@TomasVotruba TomasVotruba merged commit 6110a50 into main Aug 6, 2023
44 checks passed
@TomasVotruba TomasVotruba deleted the skip-ano-other-object branch August 6, 2023 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants