Type mismatch between array and iterable when key is passed to a callable #5622
-
|
Hi there, I'm not sure if I'm doing something wrong in my types or if PHPStan shouldn't report what it reports. I have 3 functions that are "functional" helpers. They are called "collect", and do a mix of both "map" and (optionally) "filter". Simple example: Anyway.. The code and error reporting will be easier for you to read than for me to explain, I think : https://phpstan.org/r/b40e5ab9-6c91-4f94-ac7a-8ddfb08b5a9f Is there something I should be typing differently ? I've tried writing the typing a bit differently between gnutix |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
|
If you use a template type as an array key, you need to use the |
Beta Was this translation helpful? Give feedback.
-
|
OK, I managed to type the functions themselves properly. However, I have another bug now when I call them and use a short/arrow function If I change the code above to a standard anonymous function like |
Beta Was this translation helpful? Give feedback.
If you use a template type as an array key, you need to use the
array-keybound: https://phpstan.org/r/244bd5dc-0294-468d-abdf-700705bbc697