Replies: 2 comments 7 replies
-
Here I see too differences between how keys are inferred in different ways: https://phpstan.org/r/8e09ae8b-69c8-4dc2-8e59-4a8a61568efb |
Beta Was this translation helpful? Give feedback.
0 replies
-
With In fact, I don't see why any of them should fail, can you explain please? See also: https://phpstan.org/blog/whats-up-with-template-covariant |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Following the conversation I started in #5518 I provide the following example:
https://phpstan.org/r/1695407d-224f-4e63-8976-e0b48f4de2f4
Besides I think I understand covariance, contravariance and invariance, I'm not fully understanding the problem here. I'm not sure that I want
QueryInterface
to be covariant, and looks like my specific problem is solved by typing a non-mixed key and value in theiterable
, so now I want to try to understand what can be happening with iterables.The two main things I don't understand is this difference between
array
anditerable
:and why I have errors like
Parameter #1 $query of method QueryBus::handle() expects QueryInterface<array<int, mixed>>, ShouldFailArrayMixedValueQuery given.
if I'm passingShouldFailArrayMixedValueQuery
, which is exactly aQueryInterface<array<int, mixed>>
.This triggers in me a cognitive dissonance. Probably it is right and I'm just missing the point, but right now from my POV it feels like some kind of inconsistency.
Beta Was this translation helpful? Give feedback.
All reactions