Open michel-cetina opened 1 year ago
Hey @michel-cetina, can you reproduce the issue on https://psalm.dev ?
Unfortunately I wouldn't know how to do it in Pslam's playground tool, because of the addition of the special stub. I've provided a repo sample where the issue can be reproduced.
Can you post the result of psalm with --debug-by-line added to the command?
Hi @orklah, thanks a lot for the quick response!
Please find the ouput of the command in the following link: https://github.com/michel-cetina/psalm-stubs-issue/blob/main/error.github
Well, the good news is that the stub is correctly parsed and Psalm do use it.
We can see in the debug by line that the file is visited and parsed, and then the error you posted says:
Argument 3 of MichelCetina\PsalmSubIssue\TestProcessor::process has wrong type 'array<array-key, mixed>', expecting 'array<string, string>' as defined by ApiPlatform\State\ProcessorInterface::process
So Psalm seems to enforce array<string, string>
as it is said in the interface. This is good.
What's not good is that your implementation (TestProcessor) should fit nicely with this interface because it declares @param array<string, string> $uriVariables
. However, Psalm does not see that, see the highlighted part of the error:
Argument 3 of MichelCetina\PsalmSubIssue\TestProcessor::process has wrong type 'array<array-key, mixed>', expecting 'array<string, string>' as defined by ApiPlatform\State\ProcessorInterface::process
I'm not sure what's going on here... Could you try to add --debug-emitted-issues at the end please?
Thanks for the detailed explanation, it kind of aligns with my line of thought. Please find here the output with the desired argument: https://github.com/michel-cetina/psalm-stubs-issue/blob/main/error-emitted-issues.github
Hi,
Our project uses api-platform and we're trying to improve the arrays types signatures using annotations but we are facing some issues as Api-Platform's code does not integrate the correct PhPDoc blocks.
Reading Psalm's documentation we found out that stubs could be used, adding the missing annotations to the desired interfaces.
The error that we face is that Psalm is ignoring the method's annotations and it's taking the raw value from the function signature.
::error file=src/TestProcessor.php,line=16,col=70,title=MethodSignatureMismatch::src/TestProcessor.php:16:70: MethodSignatureMismatch: Argument 3 of MichelCetina\PsalmSubIssue\TestProcessor::process has wrong type 'array<array-key, mixed>', expecting 'array<string, string>' as defined by ApiPlatform\State\ProcessorInterface::process (see https://psalm.dev/042)
I've created a repository where the error can be duplicated and analyzed: https://github.com/michel-cetina/psalm-stubs-issue
Thank you for your time and keep the great work going!
PD: Please let me know if these kind of questions should use a different kind of channel and I'll forward it.