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

query re: (array) list resetting type to array<array-key, mixed> #2577

Closed
SignpostMarv opened this issue Jan 9, 2020 · 2 comments
Closed
Labels

Comments

@SignpostMarv
Copy link
Contributor

https://psalm.dev/r/9b1c535513

Should typecasting reset list to mixed[] ?

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/9b1c535513
<?php
/**
* @param list<int>|null $bar
*/
function foo(array $bar = null) : void { bar($bar ?: (array) $bar); }

/**
* @param list<int> $_baz
*/
function bar(array $_baz) : void {}

/**
* @param list<empty> $_bat
*/
function baz(array $_bat) : void { bar((array) $_bat); }

bar([]);
baz([]);
baz((array) null);
Psalm output (using commit bd7f342):

INFO: MixedArgumentTypeCoercion - 15:40 - Argument 1 of bar expects list<int>, parent type array<array-key, mixed> provided

@muglug muglug added the bug label Jan 9, 2020
@muglug
Copy link
Collaborator

muglug commented Jan 9, 2020

No

@muglug muglug closed this as completed in 85966d8 Jan 11, 2020
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