You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<?phpnamespaceApp\Foo;
useSymfony\Component\DependencyInjection\Attribute\Autoconfigure;
#[Autoconfigure(autowiring: disabled)]
class Foo
{
// ...
}
because the services MUST not be injected automatically and the class must be instantiated manually. To do so, I decided to instantiate the class only through a static function and to use a private constructor.
Problem
When I add a Symfony\Component\HttpFoundation\Request in a private constructor, I do have the following warning :
Symfony: You probably dont want to inject a "Request" here
I think this warning should be disabled when a private constructor is used.
Workaround I found
Put the service in a folder that is excluded from autowiring in config/services.yml (this make the warning disappear but I think the PHP attribute should be processed too.
The text was updated successfully, but these errors were encountered:
Context
I have a service where autowiring is disabled:
because the services MUST not be injected automatically and the class must be instantiated manually. To do so, I decided to instantiate the class only through a static function and to use a private constructor.
Problem
When I add a
Symfony\Component\HttpFoundation\Request
in a private constructor, I do have the following warning :Symfony: You probably dont want to inject a "Request" here
I think this warning should be disabled when a private constructor is used.
Workaround I found
Put the service in a folder that is excluded from autowiring in
config/services.yml
(this make the warning disappear but I think the PHP attribute should be processed too.The text was updated successfully, but these errors were encountered: