Change explicit configuration parameter pass into #[Autowire] attributes
-use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
+use Symfony\Component\DependencyInjection\Attribute\Autowire;
final class CertificateFactory
{
private ?string $certName;
public function __construct(
- ParameterBagInterface $parameterBag
+ #[Autowire(param: 'certificate_name')]
+ $certName,
) {
- $this->certName = $parameterBag->get('certificate_name');
+ $this->certName = $certName;
}
}
Configure your rector.php
:
<?php
use Rector\Config\RectorConfig;
use Rector\Symfony\Configs\Rector\Class_\ParameterBagToAutowireAttributeRector;
return RectorConfig::configure()
->withRules([
ParameterBagToAutowireAttributeRector::class,
]);