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

T doesn't accept T&DateTimeInterface #6418

Closed
arnaud-lb opened this issue Jan 19, 2022 · 4 comments
Closed

T doesn't accept T&DateTimeInterface #6418

arnaud-lb opened this issue Jan 19, 2022 · 4 comments
Labels
Milestone

Comments

@arnaud-lb
Copy link
Contributor

Bug report

Code snippet that reproduces the problem

https://phpstan.org/r/d4a4ee11-f3e6-44e4-b9a9-88d4310d2c40

Expected output

No error

Did PHPStan help you today? Did it make you happy in any way?

PHPStan is awesome

@arnaud-lb
Copy link
Contributor Author

arnaud-lb commented Jan 19, 2022

Seems to be caused by https://github.com/phpstan/phpstan-src/blob/875f156d386fa789cf543b701d8a719284574fa4/src/Rules/RuleLevelHelper.php#L55. T&DateTimeInterface becomes a NeverType after T is replaced by a TemplateStrictMixedType

@arnaud-lb arnaud-lb changed the title Template type should be considered a super type of an intersection containing it T doesn't accept T&DateTimeInterface Jan 19, 2022
@ondrejmirtes ondrejmirtes added this to the Generics milestone Jan 20, 2022
@phpstan-bot
Copy link
Contributor

@arnaud-lb After the latest commit in dev-master, PHPStan now reports different result with your code snippet:

@@ @@
-11: Function test() should return T but returns DateTimeInterface&T.
+No errors

@ondrejmirtes
Copy link
Member

Fixed: phpstan/phpstan-src@9f12f0f

@github-actions
Copy link

github-actions bot commented Mar 6, 2022

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants