Hast Hast - 3 months ago 14
PHP Question

Static class vars type definition in PhpStorm

I have some class named myClass, and following structure in there:

class myClass
{
static $foo;

public static function init()
{
self::$foo = new bar();
}
}


How can I make phpstorm define myClass::$foo as bar's object in the rest of my code?

Answer

Use a PHPDoc.

class myClass
{
    /**
     * @var bar $foo - Holds a bar object.
     */
    static $foo;
}
Comments