How to tell PhpStorm which class my variable is in?
I've got very dynamic code that is impossible to analyze statically. So I'd like to tell PhpStorm about the types of my variables, so that autocompletion works correctly. Example code:
$article = $this->object;
I'd like to tell PhpStorm that $a is actually an instance of the Article class, so that things like $article->title can be auto-completed.
How would I go about this?
Please sign in to leave a comment.
Well, I could do this:
function cast_Article(Article $x) { return $x; }
$article = cast_Article($this->object);
But this seems a bit much PHP code just to tell PhpStorm what is going on...
You can use phpdoc:
Very nice! Thanks a lot! It works really well. Just what the doctor ordered :-)