-
Notifications
You must be signed in to change notification settings - Fork 185
Introduce support for various dependency injection containers #271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Usually you shouldn't interact with a container directly. You should typehint your functions and let the container autowire the dependencies. |
The phpstorm IDE supports some extended metadata in which one can describe additional types for autocompletion purposes... Maybe the language server can also interpret this file format and make use of it? https://confluence.jetbrains.com/plugins/servlet/mobile#content/view/51186876 |
Usually, yes. However, consider something like Drupal. Large parts of the CMS were rewritten for D8, but there is still some procedural code present. This procedural code has mostly evolved into being wrappers around OO code that's accessed through the DI container though, and for the time being, module authors occasionally have to write some procedural code of their own. If it's not worth doing this, it's cool. Just thought I'd float the idea. |
@staabm I am against adding language-server specific metadata files. Everything should go through type inference and docblock annotations. |
There are various DI container libraries available right now. Ideally, this language server would be able to look at something like this:
and be able to resolve
service.name
to a class in the container and provide completions for that class.To further complicate this, there are multiple ways that some containers can be configured. The symfony container can be configured via an XML file, a YAML file, or directly wiring things up in PHP - or any combination of these things! Perhaps a reasonable MVP for this functionality would be to support one container configured in one way + lay the groundwork for supporting other containers?
What do you think about this? Is it worthwhile? Or is it better to just rely on developers to do something like this:
and parse the
@var
docblocks?The text was updated successfully, but these errors were encountered: