Skip to content

Fix MixedType->equals(ErrorType) #3934

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

Open
wants to merge 7 commits into
base: 2.1.x
Choose a base branch
from
Open

Fix MixedType->equals(ErrorType) #3934

wants to merge 7 commits into from

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Apr 13, 2025

@staabm
Copy link
Contributor Author

staabm commented Apr 13, 2025

I was not sure whether TemplateMixedType should be considered equal to MixedType or not

@staabm staabm marked this pull request as draft April 13, 2025 20:37
@staabm staabm marked this pull request as ready for review April 14, 2025 07:45
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

@@ -314,6 +314,10 @@ public function equals(Type $type): bool
return false;
}

if ($type instanceof ErrorType) {
Copy link
Member

Choose a reason for hiding this comment

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

MixedType isn't equal to TemplateMixedType.

A bunch of types use !$type instanceof static, maybe we should do it in more cases.

Copy link
Contributor Author

@staabm staabm Apr 14, 2025

Choose a reason for hiding this comment

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

changing MixedType->equals() to return false for TemplateMixedType makes this test fail.

1) PHPStan\Generics\TemplateTypeFactoryTest::testCreate with data set #6 (PHPStan\Type\Generic\TemplateMixedType Object (...), PHPStan\Type\MixedType Object (...))
mixed -> equals(U (function a(), parameter))
Failed asserting that false is true.

I am not into generics enough to oversee how this should work

@herndlm
Copy link
Contributor

herndlm commented Apr 14, 2025

👍 I suppose this improves the weird cases I had before too, where error is accepted as a mixed or at least something like that 😊

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.

4 participants