Open Spea opened 5 months ago
I found these snippets:
I can confirm, that this also leads to psalm not detecting issues in classes extending Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository
of doctrine/doctrine-bundle
, which has a backwards-compatible Definition: https://github.com/doctrine/DoctrineBundle/blob/2.12.x/src/Repository/ServiceEntityRepository.php that is detected as duplicate.
Seems like this is the same issue (or related) as #9216
Whenever a
DuplicateClass
error is detected, psalm will stop analysing any child classes which leads to potential undetected issues.This can be replicated via the following snippet: https://psalm.dev/r/5506f97530 (
new Foo()
should also raise aUndefinedClass
error)When looking at the code in the ClassLikeNodeScanner, stopping analysis for any potential child classes seems to be intentional whenever a
DuplicateClass
error was detected.However, while this might not necessarily be an issue when you have complete control over the code, it becomes quite critical when the
DuplicateClass
error is coming from a vendor directory, as this leads to psalm not detecting any issues in your own files.I also created a test that replicates this behaviour: https://github.com/vimeo/psalm/compare/master...rebuy-de:psalm:issues-ignored-on-duplicate-class
Side note: In our case we extended the AbstractFOSRestController from the FOSRestBundle and our class had some minor issues but psalm did not raise any errors.