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

fix position variance of static method parameters #2313

Merged

Conversation

jiripudil
Copy link
Contributor

As a follow-up on #2311, I think the $isStatic condition was originally meant as an exception for constructors, and was widened to static methods by mistake, because it produces false negatives (https://phpstan.org/r/1bb14b3f-5dc5-4417-9e27-8c0e4c886987).

Now that variance in constructors is ignored entirely, we can just remove the conditional and treat parameters in static methods as contravariant.

I’m not sure about the BC impact of this change though. It’s technically a bug fix, but it might disrupt some existing builds. I’m curious to see if any integration tests fail.

@ondrejmirtes
Copy link
Member

There aren't many heavy-generics projects in the integration test suite so that's why we might not see any failures here. But I feel like this should be behind bleedingEdge config because it detects NEW situations in the code.

@jiripudil jiripudil force-pushed the fix-static-method-position-variance branch from 9ac499d to 96c6421 Compare April 2, 2023 14:43
@ondrejmirtes ondrejmirtes merged commit d107613 into phpstan:1.10.x Apr 2, 2023
@ondrejmirtes
Copy link
Member

Thank you!

@jiripudil jiripudil deleted the fix-static-method-position-variance branch April 2, 2023 17:20
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.

2 participants