PHPStorm can't find declaration to go to

I'm editing a file in our main folder that instantiates a class in a lateral folder (that's I've attached to "External Libraries" since my project is inside our main folder for various reasons), and if I Ctrl+click the class that's being instantiated, PHPStorm will take me to that class' __construct method (which is empty), but if I Ctrl+click a method call the object makes, it says it can't find the declaration even though I can copy the function, Ctrl+click the class (in the instantiation line which creates the object), paste it into text search and it finds the exact method.

Instantiation: $nerp = new Nerpy(); // Ctrl+click goes to the class' __construct method
Object method call: $nerp->getJerps() // Ctrl+click pops up a red box saying "Cannot find declaration to go to"

2 comments
Comment actions Permalink

Hi there,

Please try "File | Invalidate Caches..." and restart IDE. This usually helps in such cases (especially if you have recently updated IDE or when IDE suddenly marks previously found methods as unknown).

If still no changes -- please show what IDE thinks about $nerp on that $nerp->getJerps() line (View | Quick Documentation). Will it work any better if you use "Navigate | Declaration" or "Navigate | Implementation(s)" instead of Ctrl+Click?

It's also possible (heard it few times from other users) that some misbehaving plugin may cause such stuff. You may test it with all 3rd party (not bundled by default) plugins disabled.

It may also be that this project is somehow corrupted (which means -- the same code copied into another empty project works just fine). This is a completely different case .. but just to illustrate such possibility.

3
Comment actions Permalink

Discovered a die() statement prevented the interpreter from finding the function, though a better error message would have helped.

0

Please sign in to leave a comment.