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
Raise RedundantCast when using array_values on a list (fixes #6988) #6997
Conversation
Interesting, it found a few cases in psalm itself. Can you remove them and see if anything breaks? |
//we remove the key for display
unset($type_params[0]);
/** @psalm-trace $type_params */;
$type_params = array_values($type_params); Psalm output:
|
This may be a bug in Psalm, I'll look at that this evening |
Ok, the issue is in Psalm. we have a I'll see how I can fix that |
Can you rebase? It should be better |
73e5e54
to
00ab986
Compare
test with real project fails with strange error
I'm also unsure what to think about adding polyfills into Psalm. We have to keep in mind that Psalm make use of global namespace for a lot of things and things like polyfill could introduce new weird bugs |
Interesting. Locally, the crash happens with PHP 8.0 only (neither 7.4 nor 8.1 are affected). |
I believe this is caused by Rather than investigating and fixing it upstream (we can't use current php-scoper version on PHP 7.1 anyway) it's probably easier to snatch the function in its entirety and put it somewhere under It'll also make sure we don't load global symbols (functions and classes) into Psalm runtime - that could cause false negatives analyzing the code on PHP 8 due to reflection fallback we have. |
This should work nicely! |
@weirdan I think we can merge this, but we'll need to update baseline on phpunit |
Thanks! |
Done. |
Fixes #6988