Psalm type inference mixes values and types, leading to wrong behaviors as this snipped shows : https://psalm.dev/r/6bc69067cf Could it be fixed ? When juggling with types, the issue occurs quite often, always requiring work-arounds. It lead me to write additional tools such as the class hereafter for the sole purpose of deceiving Psalm type system. ``` class CollectionUtils { /** * Casts anything that extends a possibly-empty list of elements into a possibly-empty list of elements. * * @param array $array Original collection of elements * @return array Possibly empty list of elements * * @psalm-template T * @psalm-template C of list<T> * @psalm-param C $array * @psalm-return list<T> * @psalm-pure */ public static function list(array $array): array { return $array; } /** * Casts an array into a list * * @param array $array Original array of elements * @return array List of elements * * @psalm-template T * @psalm-template C of array<array-key, T> * @psalm-param C $array * @psalm-return list<T> * @psalm-pure */ public static function arrayToList(array $array): array { /** @var list<T> $array */ return $array; } } ```