Make param/env use in #[Attribute] more precise
namespace App\Service;
use Symfony\Component\DependencyInjection\Attribute\Autowire;
class MessageGenerator
{
public function __construct(
- #[Autowire('%kernel.debug%')]
+ #[Autowire(param: 'kernel.debug')]
bool $debugMode,
- #[Autowire('%env(SOME_ENV_VAR)%')]
+ #[Autowire(env: 'SOME_ENV_VAR')]
string $senderName,
) {
}
}
Configure your rector.php
:
<?php
use Rector\Config\RectorConfig;
use Rector\Symfony\Symfony63\Rector\Class_\ParamAndEnvAttributeRector;
return RectorConfig::configure()
->withRules([
ParamAndEnvAttributeRector::class,
]);