The problem was about my missing * character in annotations as @LazyOne said in his comment. @property tag is working perfect now.
It should read:
/**
* @property Entity\SubClassRepository $repository
*/
Вопрос
I have a problem with Phpstorm's code completion for inherited properties. There is an example from my code below.
class ParentClass
{
public $repository;
}
/*
* @property Entity\SubClassRepository $repository
*/
class SubClass extends ParentClass
{
public function __construct()
{
$this->repository= $this->em->getRepository('Entity\Subclass');
}
public function ExampleFunction()
{
$this->repository-> !Here i need the code completion!
}
}
The getRepository function returns SubClassRepository for param = Entity\SubClass or returns OtherClassRepository for param = Entity\OtherClass. Btw there is no exact type that it returns. Thus; i need to say Phpstorm what type $repository object of parent class is.
I know that Phpstorm uses Phpdoc notation for code completion. Thus i tried to use @property notation and added the lines below to SubClass.
/*
* @property Entity\SubClassRepository $repository
*/
It doesn't work. Do you have any idea? Thanks much.
Решение
The problem was about my missing * character in annotations as @LazyOne said in his comment. @property tag is working perfect now.
It should read:
/**
* @property Entity\SubClassRepository $repository
*/