Find the best Rector rule to solve your problem
Converts order-dependent arguments args() to named arg() call
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(SomeClass::class)
- ->args(['some_value']);
+ ->arg('$someCtorParameter', 'some_value');
};
Merge name === type service registration, $services->set(SomeType::class, SomeType::class)
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
- $services->set(\App\SomeClass::class, \App\SomeClass::class);
+ $services->set(\App\SomeClass::class);
};
Change $services->set(..., ...)->tag(...) to $services->defaults()->autodiscovery() where meaningful
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use App\Command\SomeCommand;
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
+ $services->defaults()
+ ->autoconfigure();
- $services->set(SomeCommand::class)
- ->tag('console.command');
+ $services->set(SomeCommand::class);
};
Change $service->set() string names to class-type-based names, to allow $container->get() by types in Symfony 2.8. Provide XML config via $rectorConfig->symfonyContainerXml(...);
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
- $services->set('some_name', App\SomeClass::class);
+ $services->set('app\\someclass', App\SomeClass::class);
};
Change $services->set(..., ...) to $services->load(..., ...) where meaningful
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
-use App\Services\FistService;
-use App\Services\SecondService;
-
return static function (ContainerConfigurator $containerConfigurator): void {
$parameters = $containerConfigurator->parameters();
$services = $containerConfigurator->services();
- $services->set(FistService::class);
- $services->set(SecondService::class);
+ $services->load('App\\Services\\', '../src/Services/*');
};