Haehnchen / idea-php-symfony2-plugin

IntelliJ IDEA / PhpStorm Symfony Plugin
https://plugins.jetbrains.com/plugin/7219
MIT License
910 stars 137 forks source link

Add autocomplete for classes in YAML services definition #1054

Open King2500 opened 6 years ago

King2500 commented 6 years ago

(Couldn't find an existing issue for this..)

services:
    <caret>

Since Symfony 3.3 the recommended id for services is their FQCN:

services:
    _defaults:
        autowire: true

    AppBundle\Service\MessageGenerator: ~
$container->get(MessageGenerator::class)->foo();

... or when autoconfigure is set, a namespace prefix:

services:
    _defaults:
        autowire: true
        autoconfigure: true

    AppBundle\:
        resource: '../../src/AppBundle/*'
        # you can exclude directories or files
        # but if a service is unused, it's removed anyway
        exclude: '../../src/AppBundle/{Entity,Repository}'

Ideally _defaults is included at above caret position for completion.

King2500 commented 6 years ago

Theoretically you could exclude classes for already defined services from the autocomplete list. (Not sure if that makes sense)

@stof what do you think?

stof commented 6 years ago

technically, it could be fine to load a batch of services without autoconfiguring them (loading them without autowiring them is much harder, because it would require to have only services without dependencies).

I would not exclude classes already used (except in the same file, as YAML cannot have duplicate keys), as you might want to override a service.