array_map doesn't infer an array type #5292
-
I'm running PHP 7.4 on Linux. I have the following code to reproduce my issue: https://phpstan.org/r/8e3982eb-725f-4511-840d-42ab718eecf1 I had expected that since Is it a wrong expectation on my end, wrong annotations, or something else? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hi, this is expected since we don' know how the arrow function in If you move the declaration directly into the |
Beta Was this translation helpful? Give feedback.
Hi, this is expected since we don' know how the arrow function in
$rowToString
will be used.If you move the declaration directly into the
array_map
call it works as you want it to: https://phpstan.org/r/4a331a70-2f73-4396-9f14-71fc0f2ac2e9 (I also had to modify the $data PHPDoc as the arrays weren' exactly the same)