-
Notifications
You must be signed in to change notification settings - Fork 651
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 spread operator false negative #5431
Comments
I found these snippets: https://psalm.dev/r/ef5d2a6084<?php
/** @return array<array-key, int> */
function getArray(): array {
return ['test' => 0];
}
function test(): array {
$a = getArray();
$b = [...$a];
return $b;
}
test();
|
AndrolGenhald
added a commit
to AndrolGenhald/psalm
that referenced
this issue
Mar 19, 2021
Note that spread with string keys will become valid in 8.1: https://3v4l.org/DSLic/rfc#git.master, https://wiki.php.net/rfc/array_unpacking_string_keys |
Cool! Maybe I'll work on adding support sometime since I've already familiarized myself with ArrayAnalyzer. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Caused by fix to #2852. It might be slightly annoying to have to annotate with
list<mixed>
orarray<int, mixed>
instead of justfunction test(): array {}
, but this is definitely a false negative considering that this code crashes: https://psalm.dev/r/ef5d2a6084 https://3v4l.org/9q0EqThe text was updated successfully, but these errors were encountered: