Open jameslkingsley opened 1 week ago
Thank you for pointing this out.
Internally, we know how confident the reference is (it's used during rename refactoring for example). When finding all the references, we wanted to highlight all the potential ones, so we don't miss any (most PHP code is not annotated well so users would miss a lot of references). Sadly there is no way in VSCode to distinguish between potential and solid reference.
We can add a setting, or maybe change the default behavior.
Yeah a setting would be ideal I think. Depends on the maturity of the codebase, which in my case I'm happy for that tradeoff of potentially missing some older code
If I lookup the references to a function, PHP tools will show me false-positives in cases where no types could be determined.
Example of this is where you have mocks in a test that are testing a completely unrelated class:
So I have a trait such as:
And then somewhere completely unrelated in a test:
Even though it's using a method named
getAttribute
, it has nothing to do with the trait, it doesn't use it at all. Yet PHP tools tries to be clever and assumes this test is making use of it.There needs to be a setting to only consider references to things when there is absolute confidence in the types being used.