Search code examples
idecode-completionphpstorm

How to tell IDE to type hint a class/instance property correctly?


When declaring a class/instance property, I am accustomed to doing something like this:

class MyClass
{
  protected
    /** @var SplDoublyLinkedList */
    $_nodes;
}

In the example above, I would expect my IDE (PhpStorm in my case) to show me code completion for the SplDoublyLinkedList class any time I typed $this->_nodes-> anywhere inside the class declaration.

This doesn't appear to be occurring, though. Is this a a problem with PhpStorm, or am I just not doing it right?

EDIT: I've submitted a feature request on YouTrack.


Solution

  • try

     class MyClass
    {
       /** @var SplDoublyLinkedList */
       protected
       $_nodes;
    }