Skip to content

Reproduce generics union bound issue#953

Closed
ondrejmirtes wants to merge 1 commit intomasterfrom
reproduce-5591
Closed

Reproduce generics union bound issue#953
ondrejmirtes wants to merge 1 commit intomasterfrom
reproduce-5591

Conversation

@ondrejmirtes
Copy link
Copy Markdown
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

Development

Successfully merging this pull request may close these issues.

1 participant