Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to auto complete methods from Symfony 2 DI in netbeans

I am starting to develop with symfony 2 and it uses a lot dependency injection. I would like to know if is there any way that makes netbeans detect the type of object based on the string and auto complete with their methods?

For example, $this->container->get('doctrine') returns a Doctrine\Bundle\DoctrineBundle\Registry instance. In the container, the key doctrine corresponds to Doctrine\Bundle\DoctrineBundle\Registry.

Something like it, could be useful for zendframework 2 also.

I don't want to create new methods in the controller and nor use /* @var $var Symfony...*/, I would automatic detection.

like image 572
dextervip Avatar asked Feb 26 '13 14:02

dextervip


1 Answers

As far as I know, there's no way for an IDE to detect the type of the object your container returns. My solution is to wrap those calls to the container into private getter functions. IMHO this improves code readability as well – especially, if you do this call more than once per class.

/**
 * @return \Doctrine\Bundle\DoctrineBundle\Registry
 */
private function getDoctrine()
{
    return $this->container->get('doctrine');
}
like image 53
Alexander M. Turek Avatar answered Nov 06 '22 06:11

Alexander M. Turek