rector-symfony icon indicating copy to clipboard operation
rector-symfony copied to clipboard

Symfony 6 Rules about ContainerInterface

Open etshy opened this issue 7 months ago • 6 comments

I'm upgrading a few project from Symfony 5.4 to 6.4. I first try to upgrade to Symfony 6.0 and I don't quite understand the rules about ContainerInterface.

    $rectorConfig->ruleWithConfiguration(ReplaceServiceArgumentRector::class, [
        new ReplaceServiceArgument('Psr\Container\ContainerInterface', new String_('service_container')),
        new ReplaceServiceArgument(
            'Symfony\Component\DependencyInjection\ContainerInterface',
            new String_('service_container')
        ),
    ]);

What's is this supposed to change ?

If we use the interface directly it doesn't change anything so shouldn't it be a class rename from ContainerInterface (both PSR and Symfony) into Symfony\Contracts\Service\ServiceProviderInterface? (not sure about that as ServiceLocator are not the only use for injecting ContainerInterface) Or at least add the following definitions ?

services:
  Symfony\Component\DependencyInjection\ContainerInterface: '@service_container'
  Psr\Container\ContainerInterface: '@service_container'

etshy avatar Jul 04 '24 09:07 etshy