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

Object implementing mixed type of a generic interface is not considered as a sub type of the interface. #8322

Open
JoyceBabu opened this issue Nov 8, 2022 · 5 comments
Labels
Milestone

Comments

@JoyceBabu
Copy link

JoyceBabu commented Nov 8, 2022

Bug report

PHPStan does not correctly detect Objects implementing generic type mixed of an interface, as a super type of the interface.

If I use any other type, say array<string,string> or list<string>, it works.

Code snippet that reproduces the problem

https://phpstan.org/r/f317cce1-39d8-47a4-a397-5e8c79c69c96

Expected output

The code to pass validation as Object<mixed> is a super type of Interface<mixed>.

@rajyan
Copy link
Contributor

rajyan commented Nov 9, 2022

This looks like an error from strict mixed, because changing the level to 8 can suppress the error. Although, not sure this is an intended behavior or not.

@ondrejmirtes
Copy link
Member

@mad-briller
Copy link
Contributor

mad-briller commented Nov 9, 2022

this gets posted once a day on here it feels like @ondrejmirtes , is it maybe worth adding a link to that article in the tip of related errors at all?

@ondrejmirtes
Copy link
Member

It's planned, I'll have to add something like acceptsWithReason(): AcceptsResult to Type interface.

@github-actions
Copy link

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 Dec 11, 2022
@ondrejmirtes ondrejmirtes reopened this Mar 27, 2023
@ondrejmirtes ondrejmirtes added this to the Generics milestone Mar 27, 2023
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

4 participants