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_map() destroys generic part of shape+generic array #6038

Closed
weirdan opened this issue Jul 2, 2021 · 1 comment · Fixed by #6039
Closed

array_map() destroys generic part of shape+generic array #6038

weirdan opened this issue Jul 2, 2021 · 1 comment · Fixed by #6039

Comments

@weirdan
Copy link
Collaborator

weirdan commented Jul 2, 2021

https://psalm.dev/r/0c83024b48

Expected: array{0: string}<array-key,string>

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/0c83024b48
<?php
/** 
 * @param string[] $line
 */
function f(array $line): void {
    if (empty($line[0])) {
        throw new InvalidArgumentException;
    }
    
    /** @psalm-trace $line */;
    
    $_line = array_map(
        function($val) { return $val; },
        $line
    );
    
    /** @psalm-trace $_line */;
}
Psalm output (using commit 2111916):

INFO: Trace - 10:30 - $line: array{0: non-falsy-string}<array-key, string>

INFO: Trace - 17:31 - $_line: array{0: string}

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

Successfully merging a pull request may close this issue.

1 participant