Linq5
1 week ago

Code completion after app(Class::class) in PHPStorm

Posted 1 week ago by Linq5

Hi,

We use PHPStorm at work. We have a difference in functionality between colleagues, whereas the environments look the same (same plugins, for instance). Consider the following code:

$migrator = app(ModuleMigrator::class);
$migrator->up();

A colleague of mine can ctrl+click on the up() method to navigate to the ModuleMigrator class. I however can't; the IDE does not recognize the $migrator variable as such. I have to add a type hint, /** App\Migrators\ModuleMigrator $migrator */ to it before the IDE recognizes it.

Can anyone explain the difference in behaviour? It's very annoying, as renaming a method does not work well if the IDE does not recognize all uses of the method.

Kind regards,

Eelco

Please sign in or create an account to participate in this conversation.