vimeo/psalm

array_walk_recursive changes variable type to incorrect

Open

#5,767 opened on 2021年5月14日

GitHub で見る
 (2 comments) (1 reaction) (0 assignees)PHP (668 forks)batch import
good first issuetype providers

Repository metrics

Stars
 (5,369 stars)
PR merge metrics
 (平均マージ 3d 12h) (30d で 5 merged PRs)

説明

I have an array array<int, array<int, int>>, that I pass to array_walk_recursive.

The first parameter in the callback function int &$id I take by reference, then I change the value to a different type. (e.g.: string) Though I define the @param-out string $id annotation, the inferred type is not what it expected.

Expected: array<int, array<int, string>> Inferred: array<array-key, mixed>

https://psalm.dev/r/097021124e

コントリビューターガイド