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

Reproduce generics union bound issue #953

Closed
wants to merge 1 commit into from
Closed

Conversation

ondrejmirtes
Copy link
Member

See phpstan/phpstan#5591

/cc @arnaud-lb Looks like you're digging through some older issues, I've got one that you're more equipped to fix rather than me :) The problem here is that the type is rejected although it's exactly the same one: https://phpstan.org/r/cc421f16-0749-407d-80ac-e05e7624d3f7

Parameter #1 $record of method App\TestClass<TEntity of App\EntityA|App\EntityB>::innerMethod() expects (TEntity of App\EntityA|App\EntityB)|null, (TEntity of App\EntityA|App\EntityB)|null given.

The problem is that we're representing TEntity|null as a UnionType(new TemplateUnionType(EntityA, EntityB), null). Union inside union might not be ideal but I don't know how differently it could work.

The problem is that UnionType::accepts() does not accept the same type it's itself. Can you please look into it and figure out what's the root cause and how it could be fixed?

Thank you :)

@ondrejmirtes ondrejmirtes deleted the reproduce-5591 branch February 7, 2022 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant