Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array is not reconciled to iterable #1240

Closed
sserbin opened this issue Jan 25, 2019 · 0 comments
Closed

Array is not reconciled to iterable #1240

sserbin opened this issue Jan 25, 2019 · 0 comments
Labels

Comments

@sserbin
Copy link

sserbin commented Jan 25, 2019

Test case:

<?php
/**
 * @template K
 * @template V
 * @param iterable<K,V> $collection
 * @return V
 * @psalm-suppress InvalidReturnType
 */
function first($collection) {}

$one = first([1,2,3]);
strlen($one);

https://getpsalm.org/r/124a8a4417

Expected: $one is int
Actual: $one is mixed
If $collection is documented as iterable<K,V>|array<K,V> result type is inferred properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants