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

Support contravariant template types #2051

merged 6 commits into from Dec 5, 2022


Copy link

Closes phpstan/phpstan#3960.

Basically, I'm picking up where #1492 left off, with a couple more tests.

Once this lands, I'd like to follow up with a fix to the bug mentioned in the original PR (#1492 (comment)). The logs are no longer available for the relevant builds, but I understand it caused some turmoil, and should therefore be discussed separately.

Copy link

@ondrejmirtes ondrejmirtes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like some "accepts" tests, meaning "does this parameter accept this argument"? For example in CallMethodsRuleTest, to see that the objects behave correctly :)

Copy link
Contributor Author

I'm assuming you have something like this in mind? Otherwise, apart from a detail irrelevant to this case, GenericObjectType::accepts() shares the implementation with isSuperTypeOf() which is already covered by tests. But can't hurt to have an integration test on top of that :)

Copy link

Yes, thank you :)

@ondrejmirtes ondrejmirtes merged commit 024e98e into phpstan:1.9.x Dec 5, 2022
375 of 376 checks passed
@jiripudil jiripudil deleted the template-contravariant branch December 5, 2022 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

Contravariant bounds in generics
2 participants