We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
If use array_merge with list arguments return type should be list https://psalm.dev/r/937292dfcd
<?php /** * @param list<int> $foo */ function foo(array $foo) : void { var_export($foo); } $foo1 = [1, 2, 3]; $foo2 = [1, 4, 5]; $fooMerged = array_merge($foo1, $foo2); foo($foo1); foo($foo2); foo($fooMerged);
Actual: ERROR: InvalidArgument - 15:5 - Argument 1 of foo expects list, array{0: int(1), 1: int(2), 2: int(3), 3: int(1), 4: int(4), 5: int(5)} provided Expected: no errors
The text was updated successfully, but these errors were encountered:
I found these snippets:
Psalm output (using commit 26bf183): ERROR: InvalidArgument - 15:5 - Argument 1 of foo expects list<int>, array{0: int(1), 1: int(2), 2: int(3), 3: int(1), 4: int(4), 5: int(5)} provided
Sorry, something went wrong.
works if manually declared as list<int>: https://psalm.dev/r/d5c0079603
list<int>
<?php /** * @param list<int> $foo */ function foo(array $foo) : void { var_export($foo); } /** @var list<int> */ $foo1 = [1, 2, 3]; /** @var list<int> */ $foo2 = [1, 4, 5]; $fooMerged = array_merge($foo1, $foo2); foo($foo1); foo($foo2); foo($fooMerged);
Psalm output (using commit 619ced1): No issues!
24e1d54
No branches or pull requests
If use array_merge with list arguments return type should be list
https://psalm.dev/r/937292dfcd
Actual: ERROR: InvalidArgument - 15:5 - Argument 1 of foo expects list, array{0: int(1), 1: int(2), 2: int(3), 3: int(1), 4: int(4), 5: int(5)} provided
Expected: no errors
The text was updated successfully, but these errors were encountered: