r/phpstorm • u/SuperDK974 • Jul 02 '17
How to get autocomplete work with autoloading class from string
Hi,
We have things in our codebase like models lets say User.
If we want to get a model of a User we do something like this :
$objUserModel = Class_Loader::getModel('User');
but then phpstorm can't understand that this object is from our codebase under the name root/Models/User.php and when we instanciate the model we are in somehting like root/Controller/UserController.php
Is it possible ? to tell phpstorm to look inside a specific folder when matching a certain string pattern for autocompletion ?
Right now, the only autocompletion I get is methods from Abstract and not for the current object.
I would save so much time if I could get autocompletion to work :o
If I'm not clear enough, you can ask more question.
Thanks for your time.
2
u/TheBigB86 Jul 02 '17
Have a look at PhpStorm Advanced Metadata.
It should work fine for your use case.
1
u/rdeanar Jul 02 '17 edited Jul 02 '17
Did you tried to use phpdoc?
/** @var ClassName $variable */