-
Notifications
You must be signed in to change notification settings - Fork 659
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
Inconsistent MethodSignatureMismatch reporting: it yields randomly and poiting to the wrong class #6773
Inconsistent MethodSignatureMismatch reporting: it yields randomly and poiting to the wrong class #6773
Comments
I found these snippets: https://psalm.dev/r/dd7372a1bf<?php
class Foo
{
/** @param array<string, mixed> $array */
public function foo(array $array): void {}
}
/** @psalm-method void foo(array $array) */
class Bar extends Foo
{
}
|
Can you perhaps create a reproducer in a separate repo then? |
Can you make sure you don't have your cache folder in your config. Did you install the plugin for doctrine? Do you sometimes use psalm with only one file in in command line? |
I tried to make a new repo with Doctrine and Symfony in order to reproduce this inconsistent error, but Psalm doesn't yield MethodSignatureMismatch in a brand new repo.
My config is <?xml version="1.0"?>
<psalm
errorLevel="1"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src"/>
<ignoreFiles>
<directory name="vendor"/>
<file name="src/Kernel.php"/>
</ignoreFiles>
</projectFiles>
<forbiddenFunctions>
<function name="dd"/>
<function name="dump"/>
</forbiddenFunctions>
<plugins>
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
<pluginClass class="Weirdan\DoctrinePsalmPlugin\Plugin"/>
</plugins>
</psalm>
Yes. Sorry, forgot to mention it.
In CLI I use Psalm only as |
I found these snippets: https://psalm.dev/r/dd7372a1bf<?php
class Foo
{
/** @param array<string, mixed> $array */
public function foo(array $array): void {}
}
/** @psalm-method void foo(array $array) */
class Bar extends Foo
{
}
|
I think I already observed this bug but not through PHPStorm. It looked like this:
It may be more subtle than that but I was at work and couldn't spend a long time on this |
psalm 4.11.2
Sometimes Psalm yields MethodSignatureMismatch errors on some of my project's Repositories classes extended from the Doctrine one.
If I do
psalm --clear-cache
then this kind of errors disappears for some time. (?!)One more interesting thing is that Doctrine's code is perfectly correct, the first argument is typed array<string, mixed> in both cases (it's a recent change, it was just an array). But! There are
@psalm-method
stubs in the FooRepository itself that actually causes the issue:So there are two bound issues:
@method
annotation causes Psalm to blame wrong class.Also I don't know how to fix my
@psalm-method
annotation, because I can't specify array<string, mixed> inside a@method
, it's a phpDoc syntax error, as I understand. At least looks like psalm doesn't understand this syntax, but doesn't yield a syntax error either. So any advice will be appreciated.So, as I can't reproduce the issue(s) on psalm.dev properly as it tightly bound to the Doctrine library code, and I failed to find a minimal reproducible case, feel free to ask any debug info or point the place in the psalm's source code where I can investigate the issue(s).
The text was updated successfully, but these errors were encountered: