My question is almost identical to this one, however it is regarding a different IDE.
When using a service in Zend Framework 2, I use code similar to the following:
$myService = $this->getServiceLocator()->get('MyService');
However, I have to manually add in type-hinting for the service for autocomplete to work:
/** @var \Module\Service\MyService $myService */
This is useful as it means you get the information on what parameters to give to functions, for example, without having to open the class and find the function. But when there are many services it starts to get clunky having multiple type-hints, especially for larger projects that have 7 or 8 services being used. Of course, these type-hints must be added to each individual controller and action as well; a time-consuming task.
So, my question - is there a way in Zend Studio (13.5) to automatically type-hint all services in the project?
Edit
I declare services in the Module.php file with code similar to the following:
public function getServiceConfig() {
return array(
'factories' => array(
'MyService' => function ($sm) {
$dbAdapter = $sm->get('db');
$sql = new Sql($dbAdapter);
return new MyService($sql);
}
)
);
}