Search code examples
phpstormphpdoc

PHPDoc for PhpStorm hint suggestion on class in array


Is there any correct PHPDoc to recognize the PhpStorm for autocomplete/suggest on this source?

class someClass
{
    public $foo;

    const BAR = 1;

    public function doSomething()
    {
        return 2;
    }
}

/** @var $arrayClass[] someClass */ $arrayClass = [];
for($i = 0; $i < 5; $i++)
{
    $arrayClass[$i] = new someClass();
    $arrayClass[$i]->             # <---here says No suggestions when (ctrl+space)
}

enter image description here


Solution

  • Found the solution for PhpStorm (if anyone search for this)

    I was change the bracets position and works

    from

    /** @var $arrayClass[] someClass */ $arrayClass = [];
    

    to

    /** @var $arrayClass someClass[] */ $arrayClass = [];