Skip to content

[config] Add RemoveConstructorAutowireServiceRector#855

Merged
TomasVotruba merged 2 commits intomainfrom
tv-remove-arg-service
Oct 25, 2025
Merged

[config] Add RemoveConstructorAutowireServiceRector#855
TomasVotruba merged 2 commits intomainfrom
tv-remove-arg-service

Conversation

@TomasVotruba
Copy link
Copy Markdown
Member

@TomasVotruba TomasVotruba commented Oct 25, 2025

Why passing a service that is already autowired? 😉


use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
    $services = $containerConfigurator->services();

    $services->defaults()
        ->autowire();

-   $services->set(\App\SomeClass::class)
+   $services->set(\App\SomeClass::class);
-       ->arg('$someService', ref(\App\SomeService::class));
};

final class SomeClass
{
    public function __construct(private SomeService $someService)
    {
    }
}

@TomasVotruba TomasVotruba force-pushed the tv-remove-arg-service branch 2 times, most recently from e9741dc to cda0ade Compare October 25, 2025 14:27
@TomasVotruba TomasVotruba force-pushed the tv-remove-arg-service branch from cda0ade to 3587b7c Compare October 25, 2025 14:38
@TomasVotruba TomasVotruba merged commit a9dfc5d into main Oct 25, 2025
5 checks passed
@TomasVotruba TomasVotruba deleted the tv-remove-arg-service branch October 25, 2025 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant