Search code examples
dependency-injectionphpstormcode-completionsilexservice-locator

PHPStorm, Silex DI indices code completion


I'm trying PHPStorm and have trouble with its code completion. I write project with Silex framework and faced PHPStorm's lack of code completion for Silex dependency injection container. For example, it doesnt codecomplete $app['twig']-> or $app['db']-> or any other service. The only way solution I've found is to do smth like this

$db = $app['db'];
/** @var $db \Doctrine\DBAL\Connection */
$db->....

And then PHPStorm will do code completion. Services are registered using ServiceProvider interface. Is there a way to make PHPStorm do code completion in such cases without additional vars and comments?


Solution

  • As far as I'm aware, this is currently not possible, however, there is currently work going on to add support for generic factory patterns, see this issue on their issue-tracker:

    http://youtrack.jetbrains.com/issue/WI-6027

    The PhpStorm developers welcome new feature requests on their issue tracker and are quite responsive. So you may file a feature request

    Also, this may be related to your question: http://youtrack.jetbrains.com/issue/WI-5304