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
Wrong type for $_FILES
when uploading multiple files
#8760
Comments
I found these snippets: https://psalm.dev/r/be6a290e56<?php
$x = $_FILES;
/** @psalm-trace $_FILES */;
|
Even worse, The only way to fix this properly is to introduced specialized logic in the ArrayFetchAnalyzer. |
As a hotfix, I'd recommend creating a wrapper function with a set of variadic parameters that returns a properly typed array, psalm-suppressing issues just for that function. I gave a go at implementing the ArrayFetch logic when I removed your types, but it's messier than I thought it would be: I'll try to give it a go later, you can also try digging in that direction if you want. |
@danog any further thoughts on this yet? I'm not really sure what/how you intend to resolve this issue for all possibilities which are:
Which actually isn't correct too, since you can have a mix of them too if 1 input has multiple attribute but others do not, like e.g.
|
There is no way of solving this with a specific type, the only way is with a "hack" that directly modifies the array key resolution logic to always return a |
As per last change in #8621 the type of
$_FILES
is wrong when using "multiple" attribute.https://psalm.dev/r/be6a290e56
$_FILES
will contain an array of strings for each key, not a string in that case.@danog
The text was updated successfully, but these errors were encountered: