CookieSameSiteConstantRector
Replace the "same site" magic string of Cookie with a Cookie constant
use Symfony\Component\HttpFoundation\Cookie;
-$cookie = Cookie::create('name', 'value', 0, '/', null, false, true, false, 'lax');
+$cookie = Cookie::create('name', 'value', 0, '/', null, false, true, false, Cookie::SAMESITE_LAX);
Configure your rector.php:
<?php
use Rector\Config\RectorConfig;
use Rector\Symfony\HttpFoundation\Rector\New_\CookieSameSiteConstantRector;
return RectorConfig::configure()
->withRules([
CookieSameSiteConstantRector::class,
]);
PACKAGE:
symfony/http-foundation >=4.2