Preserving auto-completion abilities with Symfony2 Dependency Injection
It is more involving, but you can still do this with eclipse PDT:
$myThingy = $this->get('some_cool_service');/* @var $myThingy \MyNamespace\CoolService */
UPDATE:The example on this page shows you may also use the other way round with phpStorm:
$myThingy = $this->get('some_cool_service');/* @var \MyNamespace\CoolService $myThingy */
You could define private properties in your controllers
class MyController extends Controller{ /** * @var \Namespace\To\SomeCoolService; */ private $my_service; public function myAction() { $this->my_service = $this->get('some_cool_service'); /** * enjoy your autocompletion :) */ }}
I use base Controller class for bundle. You need to annotate the return in method. At least that works on Eclipse.
/** * Gets SomeCoolService * * @return \Namespace\To\SomeCoolService */protected function getSomeCoolService(){ return $this->get('some_cool_service');}
I don't like /*var ... */, because it gets too much into code.I don't like private properties, because you can wrongly assume that services are already loaded.