vimeo/psalm

array_walk_recursive changes variable type to incorrect

Ouverte

#5 767 ouverte le 14 mai 2021

 (2 commentaires) (1 réaction) (0 personne assignée)PHP (668 forks)batch import
good first issuetype providers

Métriques du dépôt

Stars
 (5 369 étoiles)
Métriques de merge PR
 (Métriques PR en attente)

Description

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

Guide contributeur