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

Accept derived template types #999

Merged
merged 1 commit into from Feb 5, 2022
Merged

Conversation

arnaud-lb
Copy link
Contributor

@arnaud-lb arnaud-lb commented Feb 5, 2022

Template types in non-parameter locations are extra strict about what they accept, as they will only accept a type strictly equal to themselves (same name, scope, bound, and implementation).

This PR relaxes this a bit so that template types recognizes that they can be derived. They will now accept an other template type with equal name+scope and whose bound is a sub-type of the accepting type's bound.

I believe that this is still correct because as long as two template types have the same name+scope, they are in fact the same type.

This fixes phpstan/phpstan#5844 and phpstan/phpstan#5706.

@ondrejmirtes
Copy link
Member

Awesome! Hold on, I'm looking into the failures.

@ondrejmirtes
Copy link
Member

Oh yes, the fact these errors move to level 7 is actually nice.

@arnaud-lb
Copy link
Contributor Author

arnaud-lb commented Feb 5, 2022

I'm not 100% sure about this PR, though. There may be some scenarios where the type will not be correct.

@ondrejmirtes
Copy link
Member

It's fine, it's better than before and users will let us know if we missed something sooner or later :)

@ondrejmirtes
Copy link
Member

phpstan-symfony still failing, I'm looking into it, otherwise it's good!

@ondrejmirtes ondrejmirtes merged commit ccffbc3 into phpstan:master Feb 5, 2022
@ondrejmirtes
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